From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LhTJ1-00069p-4R for qemu-devel@nongnu.org; Wed, 11 Mar 2009 14:37:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LhTJ0-00069O-AD for qemu-devel@nongnu.org; Wed, 11 Mar 2009 14:37:26 -0400 Received: from [199.232.76.173] (port=35599 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LhTJ0-00069K-7U for qemu-devel@nongnu.org; Wed, 11 Mar 2009 14:37:26 -0400 Received: from mx2.redhat.com ([66.187.237.31]:58189) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LhTIz-0003dA-La for qemu-devel@nongnu.org; Wed, 11 Mar 2009 14:37:26 -0400 Message-ID: <49B804DD.6010608@redhat.com> Date: Wed, 11 Mar 2009 20:37:17 +0200 From: Uri Lublin MIME-Version: 1.0 References: <49B79D50.4090300@redhat.com> <49B7C6BF.6030803@codemonkey.ws> In-Reply-To: <49B7C6BF.6030803@codemonkey.ws> Content-Type: multipart/mixed; boundary="------------050408050508060803080203" Subject: [Qemu-devel] Re: Problems KVM-84 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Jay Mann , Uri Lublin , Avi Kivity , kvm@vger.kernel.org, qemu-devel This is a multi-part message in MIME format. --------------050408050508060803080203 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx2.redhat.com id n2BIbKhO030271 Anthony Liguori wrote: > Avi Kivity wrote: >> Jay Mann wrote: >>> Hi, >>> >>> I just downloaded built and installed kvm-84 on ubuntu Hardy x64 =20 >>> 2.6.24-23- >>> server and I=E2=80=99m getting the following 2 problems that did not = exists=20 >>> in kvm-83. >>> >>> 1. The qemu emulater (bios screen) takes a long time to start (~10= =20 >>> seconds), and subsequently Libvirt times out when I try to start a=20 >>> guest VM from virsh. =20 >> >> This is caused by qemu r6404: >> >> commit 5d4cbd78aa33f6d034a62207c99ad0b64af44621 >> Author: aliguori >> Date: Thu Jan 22 18:57:22 2009 +0000 >> >> block-qcow2: keep highest allocated byte (Uri Lublin) >> We want to know the highest written offset for qcow2 images. >> This gives a pretty good (and easy to calculate) estimation to how >> much more allocation can be done for the block device. >> It can be usefull for allocating more diskspace for that image >> (if possible, e.g. lvm) before we run out-of-disk-space >> Signed-off-by: Uri Lublin >> Signed-off-by: Anthony Liguori >> >> Scanning the file at startup is slow. We need to find a better way. >=20 > Any quick ideas? Seems like this is broken by design. Unless we can=20 > find a quick fix, I'm going to revert this in the stable tree. >=20 > Regards, >=20 > Anthony Liguori >=20 We only need to scan the given filename (no backing files). We can pass a= flag=20 to qcow_open (bdrv_open of bs->backing_hd) specifying it's a backing file. (attached 2 patches). That makes things better for small images with big = backing=20 files. It does not fix the problem for very large images. A better solution may we to allocate a qcow2-extension to keep highest-al= loc and=20 num-free-bytes so we don't have to scan refcount table of the image upon = open. With that solution qcow_create initializes them, qcow_open reads them and= =20 bdrv_close updates them. We can also add a qemu-img command to scan and u= pdate=20 those values. Regards, Uri. --------------050408050508060803080203 Content-Type: text/x-patch; name="0001-block-pass-BDRV_BACKING-flag-to-backing-file-open.patch" Content-Disposition: inline; filename*0="0001-block-pass-BDRV_BACKING-flag-to-backing-file-open.patch" Content-Transfer-Encoding: 7bit >>From 1ccf1940e0b45a9001b916bc6160c03a098a5d1d Mon Sep 17 00:00:00 2001 From: Uri Lublin Date: Wed, 11 Mar 2009 20:16:23 +0200 Subject: [PATCH] block: pass BDRV_BACKING flag to backing-file open With this information, open can behave differently for the image filename and its backing files. Signed-off-by: Uri Lublin --- qemu/block.c | 3 ++- qemu/block.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/qemu/block.c b/qemu/block.c index 4c556ec..45fa5f4 100644 --- a/qemu/block.c +++ b/qemu/block.c @@ -397,7 +397,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, /* Note: for compatibility, we open disk image files as RDWR, and RDONLY as fallback */ if (!(flags & BDRV_O_FILE)) - open_flags = BDRV_O_RDWR | (flags & BDRV_O_CACHE_MASK); + open_flags = BDRV_O_RDWR | (flags & (BDRV_O_CACHE_MASK | BDRV_O_BACKING)); else open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); ret = drv->bdrv_open(bs, filename, open_flags); @@ -429,6 +429,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, } path_combine(backing_filename, sizeof(backing_filename), filename, bs->backing_file); + open_flags |= BDRV_O_BACKING; if (bdrv_open(bs->backing_hd, backing_filename, open_flags) < 0) goto fail; } diff --git a/qemu/block.h b/qemu/block.h index e1927dd..ff70d64 100644 --- a/qemu/block.h +++ b/qemu/block.h @@ -56,6 +56,8 @@ typedef struct QEMUSnapshotInfo { #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_CACHE_DEF) +#define BDRV_O_BACKING 0x0100 + void bdrv_info(void); void bdrv_info_stats(void); -- 1.6.0.6 --------------050408050508060803080203 Content-Type: text/x-patch; name="0002-block-qcow2-do-not-scan-refcounts-when-opening-a-ba.patch" Content-Disposition: inline; filename*0="0002-block-qcow2-do-not-scan-refcounts-when-opening-a-ba.pat"; filename*1="ch" Content-Transfer-Encoding: 7bit >>From c618b293a64d1690105505d7cb28ba1ca8dd33c7 Mon Sep 17 00:00:00 2001 From: Uri Lublin Date: Wed, 11 Mar 2009 20:18:23 +0200 Subject: [PATCH] block-qcow2: do not scan refcounts when opening a backing file It takes too long and is not needed. Signed-off-by: Uri Lublin --- qemu/block-qcow2.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c index 465dcd6..41cdbe9 100644 --- a/qemu/block-qcow2.c +++ b/qemu/block-qcow2.c @@ -276,7 +276,8 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) if (refcount_init(bs) < 0) goto fail; - scan_refcount(bs, &s->highest_alloc, &s->nc_free); + if ((flags & BDRV_O_BACKING) == 0) + scan_refcount(bs, &s->highest_alloc, &s->nc_free); /* read the backing file name */ if (header.backing_file_offset != 0) { -- 1.6.0.6 --------------050408050508060803080203--