Received: from eggs.gnu.org ([208.118.235.92]:44023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfABx-0005EW-1d for qemu-devel@nongnu.org; Wed, 22 May 2013 10:39:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfABu-0003Jf-2g for qemu-devel@nongnu.org; Wed, 22 May 2013 10:39:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11862) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfABt-0003JX-P1 for qemu-devel@nongnu.org; Wed, 22 May 2013 10:38:57 -0400 Date: Wed, 22 May 2013 16:33:50 +0200 From: Stefan Hajnoczi Message-ID: <20130522143350.GD28600@stefanha-thinkpad.redhat.com> References: <1368693379-8434-1-git-send-email-stefanha@redhat.com> <1368693379-8434-4-git-send-email-stefanha@redhat.com> <20130522095344.GB2541@dhcp-200-207.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130522095344.GB2541@dhcp-200-207.str.redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 3/8] block: add drive-backup QMP command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Fam Zheng , qemu-devel@nongnu.org, dietmar@proxmox.com, imain@redhat.com, Paolo Bonzini , xiawenc@linux.vnet.ibm.com On Wed, May 22, 2013 at 11:53:44AM +0200, Kevin Wolf wrote: > Am 16.05.2013 um 10:36 hat Stefan Hajnoczi geschrieben: > > + proto_drv = bdrv_find_protocol(target); > > + if (!proto_drv) { > > + error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); > > + return; > > + } > > I see that other block job commands are doing the same, but there are > two things unclear for me about this: > > 1. Shouldn't bdrv_img_create() and/or bdrv_open() already return an error > if the protocol can't be found? The error check is the only thing > that proto_drv is used for. > > 2. Why do we complain about a wrong _format_ here? If I ask for a qcow2 > image called foo:bar.qcow2, qemu won't find the protocol "foo" and > complain that qcow2 is an invalid format. You are right. It doesn't seem necessary, we'll get an error message later from bdrv_open() or bdrv_img_create(). Will drop in the next revision. > > + > > + bdrv_get_geometry(bs, &size); > > + size *= 512; > > I was going to suggest BDRV_SECTOR_SIZE at first, but... > > Why not use bdrv_getlength() in the first place if you need it in bytes > anyway? As a nice bonus you would get -errno instead of size 0 on > failure. Yes. Will fix and update qmp_drive_mirror() too. > > + if (mode != NEW_IMAGE_MODE_EXISTING) { > > + assert(format && drv); > > + bdrv_img_create(target, format, > > + NULL, NULL, NULL, size, flags, &local_err, false); > > + } > > + > > + if (error_is_set(&local_err)) { > > + error_propagate(errp, local_err); > > + return; > > + } > > + > > + target_bs = bdrv_new(""); > > + ret = bdrv_open(target_bs, target, NULL, flags, drv); > > + > > + if (ret < 0) { > > Why the empty line between bdrv_open and checking its return value? A dramatic pause, to build up suspense :). Will drop in the next revision and update qmp_drive_mirror() too.