[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 3/7] qemu: Implement qemuDomainManagedSaveGetXMLDesc



On Wed, Jun 21, 2017 at 05:07:48 +0530, Kothapally Madhu Pavan wrote:
> This commit adds qemu driver implementaion to get xml description
> for managed save state domain.
> 
> Signed-off-by: Kothapally Madhu Pavan <kmp linux vnet ibm com>
> ---
>  src/qemu/qemu_driver.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index e91663c..c9b3ef3 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6798,6 +6798,45 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
>      return ret;
>  }
>  
> +static char *
> +qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags)
> +{
> +    virQEMUDriverPtr driver = dom->conn->privateData;
> +    virDomainObjPtr vm;
> +    char *path = NULL;
> +    char *ret = NULL;
> +    virDomainDefPtr def = NULL;
> +    int fd = -1;
> +    virQEMUSaveDataPtr data = NULL;
> +
> +    /* We only take subset of virDomainDefFormat flags.  */
> +    virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
> +
> +    if (!(vm = qemuDomObjFromDomain(dom)))
> +        return ret;
> +
> +    path = qemuDomainManagedSavePath(driver, vm);
> +
> +    if (!path)
> +        goto cleanup;
> +
> +    fd = qemuDomainSaveImageOpen(driver, path, &def, &data,
> +                                 false, NULL, false, false);
> +    if (fd < 0)

This will report a horrible error message in case when the VM is not
manage-saved. You need to check whether the file exists and report a
better one. 

(error message will be reported by qemuOpenFileAs, thus will be
Failed to open file '%s')

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]