On 01/27/2015 12:46 PM, Max Reitz wrote:
> Implement 'change' on block devices by calling blockdev-open-tray,
> blockdev-remove-medium, blockdev-insert-medium (a variation of that
> which does not need a node-name) and blockdev-close-tray.
> 
> Signed-off-by: Max Reitz <mre...@redhat.com>
> ---
>  blockdev.c | 191 
> +++++++++++++++++++++++--------------------------------------
>  1 file changed, 72 insertions(+), 119 deletions(-)
> 

> +
> +    qmp_blockdev_open_tray(device, false, false, &err);
> +    if (err) {
> +        error_propagate(errp, err);
> +        return;
> +    }
> +
> +    qmp_blockdev_remove_medium(device, &err);
> +    if (err) {
> +        error_propagate(errp, err);
> +        return;
> +    }
> +
> +    qmp_blockdev_insert_anon_medium(device, medium_bs, &err);
> +    if (err) {
> +        error_propagate(errp, err);
> +        return;
> +    }
> +
> +    qmp_blockdev_close_tray(device, errp);

So if we fail anywhere in the middle, the device is left in an
unspecified state, and a followup query-block would be needed to learn
where we failed.  I guess that's life when you use a high-level command
instead of chaining low-level ones yourself.  I can live with it.

Reviewed-by: Eric Blake <ebl...@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to