[libvirt] [PATCH v4 05/14] qemu: Store pr runtime data in status XML

John Ferlan jferlan at redhat.com
Fri Apr 13 20:57:33 UTC 2018



On 04/10/2018 10:58 AM, Michal Privoznik wrote:
> Now that we generate pr-manager alias and socket path store them
> in status XML so that they are preserved across daemon restarts.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/qemu/qemu_domain.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
> 

So if we were to save this information (and at this point I don't think
we need to), then this is where we should be allocating and filling in
the private data (e.g. not in the previous patch).

Again as I noted previously, save the alias when printing the domain
active information and I think you're good.

AFAICT the only thing printed now (@relPath) is something generated via
qemu_driver calls (I didn't dig deep); whereas, this data is easily
regeneratable from existing domain definition data.

John


> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 361a80be84..0856f04406 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -1961,13 +1961,74 @@ qemuDomainObjPrivateFree(void *data)
>  }
>  
>  
> +static int
> +qemuStorageSourcePrivateDataParsePR(xmlXPathContextPtr ctxt,
> +                                    virStorageSourcePtr src)
> +{
> +    qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
> +    qemuDomainDiskPRDPtr prd = NULL;
> +    int rc;
> +    int ret = -1;
> +
> +    if ((rc = virXPathBoolean("boolean(./prd)", ctxt)) == 0) {
> +        return 0;
> +    } else if (rc < 0) {
> +        return ret;
> +    }
> +
> +    if (VIR_ALLOC(prd) < 0)
> +        return ret;
> +
> +    if (!(prd->alias = virXPathString("string(./prd/alias)", ctxt)) ||
> +        !(prd->path = virXPathString("string(./prd/path)", ctxt))) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("malformed <prd/>"));
> +        goto cleanup;
> +    }
> +
> +    VIR_STEAL_PTR(srcPriv->prd, prd);
> +    ret = 0;
> + cleanup:
> +    qemuDomainDiskPRDFree(prd);
> +    return ret;
> +}
> +
> +
> +static int
> +qemuStorageSourcePrivateDataFormatPR(virStorageSourcePtr src,
> +                                     virBufferPtr buf)
> +{
> +    qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
> +    qemuDomainDiskPRDPtr prd;
> +
> +    if (!srcPriv || !srcPriv->prd)
> +        return 0;
> +
> +    prd = srcPriv->prd;
> +
> +    virBufferAddLit(buf, "<prd>\n");
> +    virBufferAdjustIndent(buf, 2);
> +    virBufferAsprintf(buf, "<alias>%s</alias>\n", prd->alias);
> +    virBufferEscapeString(buf, "<path>%s</path>\n", prd->path);
> +    virBufferAdjustIndent(buf, -2);
> +    virBufferAddLit(buf, "</prd>\n");
> +    return 0;
> +}
> +
> +
>  static int
>  qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
>                                    virStorageSourcePtr src)
>  {
> +    if (!(src->privateData = qemuDomainStorageSourcePrivateNew()))
> +        return -1;
> +
>      if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0)
>          return -1;
>  
> +    if (qemuStorageSourcePrivateDataParsePR(ctxt, src) < 0)
> +        return -1;
> +
>      return 0;
>  }
>  
> @@ -1979,6 +2040,9 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
>      if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0)
>          return -1;
>  
> +    if (qemuStorageSourcePrivateDataFormatPR(src, buf) < 0)
> +        return -1;
> +
>      return 0;
>  }
>  
> 




More information about the libvir-list mailing list