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 <kw...@redhat.com> > --- > 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
signature.asc
Description: OpenPGP digital signature