qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 3/8] block: add drive-backup QMP command


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v4 3/8] block: add drive-backup QMP command
Date: Wed, 22 May 2013 16:33:50 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]