On Thu, Jan 18, 2018 at 17:04:39 +0100, Michal Privoznik wrote:
> This is the easier part. All we need to do here is put -object
> pr-manger-helper,id=$alias,path=$socketPath and then just
> reference the object in -drive file.pr-manger=$alias.
> 
> Signed-off-by: Michal Privoznik <mpriv...@redhat.com>
> ---
>  src/qemu/qemu_command.c                            | 59 
> ++++++++++++++++++++++
>  .../disk-virtio-scsi-reservations-not-managed.args | 28 ++++++++++
>  .../disk-virtio-scsi-reservations.args             | 29 +++++++++++
>  tests/qemuxml2argvtest.c                           |  8 +++
>  4 files changed, 124 insertions(+)
>  create mode 100644 
> tests/qemuxml2argvdata/disk-virtio-scsi-reservations-not-managed.args
>  create mode 100644 tests/qemuxml2argvdata/disk-virtio-scsi-reservations.args
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index b8aede32d..13f2e4fd0 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -1515,6 +1515,20 @@ qemuDiskSourceGetProps(virStorageSourcePtr src)
>  }
>  
>  
> +static void
> +qemuBuildDriveSourcePR(virBufferPtr buf,
> +                       virStorageSourcePtr src)
> +{
> +    qemuDomainStorageSourcePrivatePtr srcPriv = 
> QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
> +
> +    if (!src->pr ||
> +        src->pr->enabled != VIR_TRISTATE_BOOL_YES)

This code should really just look whether the alias is allocated rather
than duplicating the logic of when it's used.

> +        return;
> +
> +    virBufferAsprintf(buf, ",file.pr-manager=%s", srcPriv->prAlias);

According qemu.git/qapi/block-core.json, the pr-manager field is
supported only for '@BlockdevOptionsFile'. This means that you need to
check that it's used only for local paths which eventually translate to
BlockdevOptionsFile. Otherwise qemu will refuse this with any network
based disk. virStorageSourceIsLocalStorage is your friend.


> +
>  static int
>  qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
>                          virQEMUCapsPtr qemuCaps,
> @@ -1591,6 +1605,8 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
>  
>          if (disk->src->debug)
>              virBufferAsprintf(buf, ",file.debug=%d", disk->src->debugLevel);
> +
> +        qemuBuildDriveSourcePR(buf, disk->src);
>      } else {
>          if (!(source = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
>              goto cleanup;
> @@ -10033,6 +10049,46 @@ qemuBuildPanicCommandLine(virCommandPtr cmd,
>  }
>  
>  
> +struct qemuBuildMasterPRCommandLineData {
> +    virCommandPtr cmd;
> +};

Do you really need a single member struct for the void pointer?

> +
> +
> +static int
> +qemuBuildMasterPRCommandLineHelper(void *payload,
> +                                   const void *name,
> +                                   void *opaque)
> +{
> +    qemuDomainDiskPRObjectPtr obj = payload;
> +    struct qemuBuildMasterPRCommandLineData *data = opaque;
> +    virBuffer buf = VIR_BUFFER_INITIALIZER;
> +    const char *alias = name;
> +
> +    virBufferAsprintf(&buf, "pr-manager-helper,id=%s,path=%s", alias, 
> obj->path);
> +    virCommandAddArg(data->cmd, "-object");
> +    virCommandAddArgBuffer(data->cmd, &buf);
> +    return 0;
> +}
> +

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to