From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCmbx-0001GE-SI for qemu-devel@nongnu.org; Mon, 10 Feb 2014 03:53:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCmbr-0003SH-Ls for qemu-devel@nongnu.org; Mon, 10 Feb 2014 03:53:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCmbr-0003Ru-5k for qemu-devel@nongnu.org; Mon, 10 Feb 2014 03:52:59 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1A8qwOi016512 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Feb 2014 03:52:58 -0500 Date: Mon, 10 Feb 2014 16:53:05 +0800 From: Fam Zheng Message-ID: <20140210085305.GV15707@T430.nay.redhat.com> References: <1391939335-31580-1-git-send-email-pbonzini@redhat.com> <1391939335-31580-21-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1391939335-31580-21-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH 20/20] vdi: say why an image is bad List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com On Sun, 02/09 10:48, Paolo Bonzini wrote: > Instead of just putting it in debugging output, we can now put the > value in an Error. > > Signed-off-by: Paolo Bonzini > --- > block/vdi.c | 25 ++++++++++++++++--------- > 1 file changed, 16 insertions(+), 9 deletions(-) > > diff --git a/block/vdi.c b/block/vdi.c > index 68e152c..3859e49 100644 > --- a/block/vdi.c > +++ b/block/vdi.c > @@ -399,39 +399,46 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, > ret = -EINVAL; > goto fail; > } else if (header.version != VDI_VERSION_1_1) { > - logout("unsupported version %u.%u\n", > - header.version >> 16, header.version & 0xffff); > + error_setg(errp, "unsupported VDI image (version %u.%u)\n", > + header.version >> 16, header.version & 0xffff); > ret = -ENOTSUP; > goto fail; > } else if (header.offset_bmap % SECTOR_SIZE != 0) { > /* We only support block maps which start on a sector boundary. */ > - logout("unsupported block map offset 0x%x B\n", header.offset_bmap); > + error_setg(errp, "unsupported VDI image (unaligned block map offset 0x%x)\n", > + header.offset_bmap); > ret = -ENOTSUP; > goto fail; > } else if (header.offset_data % SECTOR_SIZE != 0) { > /* We only support data blocks which start on a sector boundary. */ > - logout("unsupported data offset 0x%x B\n", header.offset_data); > + error_setg(errp, "unsupported VDI image (unaligned data offset 0x%x)\n", > + header.offset_data); > ret = -ENOTSUP; > goto fail; > } else if (header.sector_size != SECTOR_SIZE) { > - logout("unsupported sector size %u B\n", header.sector_size); > + error_setg(errp, "unsupported VDI image (sector size %u is not %u)\n", > + header.sector_size, SECTOR_SIZE); > ret = -ENOTSUP; > goto fail; > } else if (header.block_size != 1 * MiB) { > - logout("unsupported block size %u B\n", header.block_size); > + error_setg(errp, "unsupported VDI image (sector size %u is not %u)\n", s/sector size/block size/ > + header.block_size, 1 * MiB); > ret = -ENOTSUP; > goto fail; > } else if (header.disk_size > > (uint64_t)header.blocks_in_image * header.block_size) { > - logout("unsupported disk size %" PRIu64 " B\n", header.disk_size); > + error_setg(errp, "unsupported VDI image (disk size %" PRIu64 ", " > + "image bitmap has room for %" PRIu64 ")\n", > + header.disk_size, > + (uint64_t)header.blocks_in_image * header.block_size); Improved, good! > ret = -ENOTSUP; > goto fail; > } else if (!uuid_is_null(header.uuid_link)) { > - logout("link uuid != 0, unsupported\n"); > + error_setg(errp, "unsupported VDI image (non-NULL link UUID)\n"); > ret = -ENOTSUP; > goto fail; > } else if (!uuid_is_null(header.uuid_parent)) { > - logout("parent uuid != 0, unsupported\n"); > + error_setg(errp, "unsupported VDI image (non-NULL parent UUID)\n"); > ret = -ENOTSUP; > goto fail; > } There are also unnecessary ending "\n" in the messages. Fam