Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mt6iL-0005af-4A for qemu-devel@nongnu.org; Wed, 30 Sep 2009 17:27:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mt6iG-0005Sl-PF for qemu-devel@nongnu.org; Wed, 30 Sep 2009 17:27:56 -0400 Received: from [199.232.76.173] (port=37731 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mt6iG-0005SX-Kn for qemu-devel@nongnu.org; Wed, 30 Sep 2009 17:27:52 -0400 Received: from smop.co.uk ([81.5.177.201]:47468 helo=mail.smop.co.uk) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mt6iF-0003fG-Jw for qemu-devel@nongnu.org; Wed, 30 Sep 2009 17:27:51 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.smop.co.uk (Postfix) with ESMTP id B6FDC2078E for ; Wed, 30 Sep 2009 22:27:45 +0100 (BST) Received: from mail.smop.co.uk ([127.0.0.1]) by localhost (vasquez.smop.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HrWPZPr0bTEU for ; Wed, 30 Sep 2009 22:27:37 +0100 (BST) Received: from ash (ash.smop.co.uk [192.168.101.10]) by mail.smop.co.uk (Postfix) with ESMTP for ; Wed, 30 Sep 2009 22:27:37 +0100 (BST) Date: Wed, 30 Sep 2009 22:27:36 +0100 From: Adrian Bridgett Message-ID: <20090930212736.GA17077@ash.smop.co.uk> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="huq684BweRXVnRxX" Content-Disposition: inline Subject: [Qemu-devel] qemu-img needs "-O host_device" describing Reply-To: adrian@smop.co.uk List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I've been trying to convert some personal KVM qemu (raw) file images to raw LVs using kvm-img -O raw. There's a short version and long version of this tale. The short version is "here is a patch to add '-O host_device' to the manpage", perhaps we should also warn if "kvm-img convert -O raw" is used on a block device (or even just automatically use host_device?) The long version is that first of all I changed block/raw-posix.c so that it didn't try and ftruncat() block devices and then eventually tracked down why "kvm-img convert -O raw" fails to block devices (it seeks past holes effectively which is good on files, but not block devices). Digging a bit deeper I found reference to "host_device" type and it turns out that using that as an output format fixes both these issues - with only one buglet - a hopefully irrelevant error: kvm-img convert -O host_device /var/lib/vm/bishop-disk /dev/rootvg/bishop-disk Unknown option 'size' This on qemu-kvm 0.11. Thanks, Adrian -- bitcube.co.uk - Linux infrastructure consultancy Puppet, Debian, Red Hat, Ubuntu, CentOS, ... --huq684BweRXVnRxX Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="qemu-truncate.diff" --- qemu-kvm-0.11.0~rc2.orig/block/raw-posix.c +++ qemu-kvm-0.11.0~rc2/block/raw-posix.c @@ -867,7 +867,12 @@ if (fd < 0) { result = -errno; } else { - if (ftruncate(fd, total_size * 512) != 0) { + struct stat stat; + if (!fstat(fd,&stat)) { + result = -errno; + } + if ((stat.st_mode & S_IFREG) && + (ftruncate(fd, total_size * 512) != 0)) { result = -errno; } if (close(fd) != 0) { --huq684BweRXVnRxX Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="qemu-host_device.diff" --- qemu-kvm-0.11.0.orig/qemu-img.texi +++ qemu-kvm-0.11.0/qemu-img.texi @@ -37,6 +37,12 @@ space. Use @code{qemu-img info} to know the real size used by the image or @code{ls -ls} on Unix/Linux. +@item host_device + +Host device format. This format should be used instead of raw when +converting to block devices or other devices where "holes" are not +supported. + @item qcow2 QEMU image format, the most versatile format. Use it to have smaller images (useful if your filesystem does not supports holes, for example --huq684BweRXVnRxX--