[libvirt] [PATCH v4 4/7] qemu: Implement qemuDomainManagedSaveDefineXML

Peter Krempa pkrempa at redhat.com
Mon Aug 28 15:19:25 UTC 2017


On Tue, Aug 08, 2017 at 13:32:52 +0530, Kothapally Madhu Pavan wrote:
> This commit adds qemu driver implementation to edit xml
> configuration of managed save state file of a domain.
> 
> Signed-off-by: Kothapally Madhu Pavan <kmp at linux.vnet.ibm.com>
> ---
>  src/qemu/qemu_driver.c | 41 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index ec73dc1..b6db435 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6842,6 +6842,46 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags)
>      return ret;
>  }
>  
> +static int
> +qemuDomainManagedSaveDefineXML(virDomainPtr dom, const char *dxml,
> +                               unsigned int flags)
> +{
> +    virQEMUDriverPtr driver = dom->conn->privateData;
> +    virConnectPtr conn = dom->conn;
> +    virDomainObjPtr vm;
> +    char *path = NULL;
> +    int ret;
> +
> +    if (!(vm = qemuDomObjFromDomain(dom)))
> +        return -1;
> +
> +    path = qemuDomainManagedSavePath(driver, vm);
> +    virDomainObjEndAPI(&vm);
> +
> +    if (!path)
> +        goto error;
> +
> +    if (!virFileExists(path)) {
> +        virReportError(VIR_ERR_OPERATION_INVALID,
> +                       "%s",_("domain does not have managed save image"));
> +        goto error;
> +    }
> +
> +    ret = qemuDomainSaveImageDefineXML(conn, path, dxml, flags);
> +
> +    VIR_FREE(path);
> +
> +    if (ret < 0)
> +        goto error;
> +
> +    return ret;
> +
> + error:
> +    VIR_FREE(path);
> +    virDispatchError(conn);

Error dispatching is supposed to be done from the main API call where
you've added, so it does not need to be duplicated. Also it's possible
to just return ret, since it's set correctly in
qemuDomainSaveImageDefineXML.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170828/718a836a/attachment-0001.sig>


More information about the libvir-list mailing list