[Libguestfs] [PATCH] lib: direct: Disable qemu locking when opening drives readonly.

Roman Kagan rkagan at virtuozzo.com
Wed Sep 6 07:41:24 UTC 2017


On Tue, Sep 05, 2017 at 03:55:08PM +0100, Richard W.M. Jones wrote:
> Since qemu 2.10, qemu locks all drives even when they are opened
> readonly.  This disables this locking in this safe case.
> 
> Incomplete fix for
> https://bugzilla.redhat.com/show_bug.cgi?id=1417306
> ---
>  lib/launch-direct.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/launch-direct.c b/lib/launch-direct.c
> index 3b848165c..e5465539d 100644
> --- a/lib/launch-direct.c
> +++ b/lib/launch-direct.c
> @@ -221,8 +221,11 @@ add_drive_standard_params (guestfs_h *g, struct backend_direct_data *data,
>      file = guestfs_int_drive_source_qemu_param (g, &drv->src);
>      append_list_format ("file=%s", file);
>  
> -    if (drv->readonly)
> +    if (drv->readonly) {
>        append_list ("snapshot=on");
> +      if (guestfs_int_version_ge (&data->qemu_version, 2, 10, 0))
> +        append_list ("locking=off");

Don't we have a way to enumerate supported options?

Depending on QEMU version is not going to play nice with vendor-shipped
QEMU where features are often backported.

> +    }
>      append_list_format ("cache=%s",
>                          drv->cachemode ? drv->cachemode : "writeback");
>      if (drv->src.format)

Roman.




More information about the Libguestfs mailing list