qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH 06/10] qemu-img: Prepare for locked images


From: Eric Blake
Subject: Re: [Qemu-block] [PATCH 06/10] qemu-img: Prepare for locked images
Date: Tue, 22 Dec 2015 14:41:16 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 12/22/2015 09:46 AM, Kevin Wolf wrote:
> This patch extends qemu-img for working with locked images. It prints a
> helpful error message when trying to access a locked image read-write,
> and adds a 'qemu-img force-unlock' command as well as a 'qemu-img check
> -r all --force' option in order to override a lock left behind after a
> qemu crash.
> 
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
>  include/block/block.h |  1 +
>  include/qapi/error.h  |  1 +
>  qapi/common.json      |  3 +-
>  qemu-img-cmds.hx      | 10 ++++--
>  qemu-img.c            | 96 
> +++++++++++++++++++++++++++++++++++++++++++--------
>  qemu-img.texi         | 20 ++++++++++-
>  6 files changed, 113 insertions(+), 18 deletions(-)
> 
> diff --git a/include/block/block.h b/include/block/block.h
> index 0d00ac1..1ae655c 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -101,6 +101,7 @@ typedef struct HDGeometry {
>  #define BDRV_OPT_CACHE_DIRECT   "cache.direct"
>  #define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush"
>  
> +#define BDRV_OPT_OVERRIDE_LOCK  "override-lock"

New dict key here...

>  
>      blk = blk_new_open(id, filename, NULL, options, flags, &local_err);
> +    if (!blk && error_get_class(local_err) == ERROR_CLASS_IMAGE_FILE_LOCKED) 
> {
> +        if (force) {
> +            qdict_put(options, BDRV_OPT_OVERRIDE_LOCK, 
> qstring_from_str("on"));

...but not supported by any of the block drivers until 10/10 adds it for
qcow2.  I guess what happens is that...

> +            blk = blk_new_open(id, filename, NULL, options, flags, NULL);

...the second blk_new_open() fails if the option is unrecognized, but we
ignore the second failure; and therefore the option makes a difference
only if the block driver understands the option.

-- 
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

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