[libvirt] [PATCH][RFC] enable modification of xml in case of a restore forthe combination of xen/libvirt

Jim Fehlig jfehlig at suse.com
Fri Sep 16 21:02:32 UTC 2016


On 09/12/2016 04:47 AM, Guido.Rossmueller at gdata.de wrote:
> Hello everybody,

Hi, thanks for the patch! But I'm sorry to report that your mailer has mangled
it. Please use 'git send-email' for sending patches. Refer to the contributors
guideline for more info

http://libvirt.org/hacking.html

>
> the modification of the xml-decription of an vm is disabled in libvirt for the
> combination of xen/libvirt.
> The following patches will enabled it.
>
> a possible use case is the restore of a vm , whose virtuell disk is on an LVM,
> and it should use for the restore a snapshot of this LVM
>
>
> all the best
> guido
>
> ---
>  src/libxl/libxl_domain.c | 14 +++++++++++---
>  src/libxl/libxl_domain.h |  3 ++-
>  src/libxl/libxl_driver.c |  9 +--------
>  3 files changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
> index 0e26b91..98992a5 100644
> --- a/src/libxl/libxl_domain.c
> +++ b/src/libxl/libxl_domain.c
> @@ -630,7 +630,8 @@ libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver,
>                           libxlDriverConfigPtr cfg,
>                           const char *from,
>                           virDomainDefPtr *ret_def,
> -                         libxlSavefileHeaderPtr ret_hdr)
> +                         libxlSavefileHeaderPtr ret_hdr,
> +                                                const char *xmlin )
>  {
>      int fd;
>      virDomainDefPtr def = NULL;
> @@ -675,10 +676,17 @@ libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver,
>          goto error;
>      }
>  
> -    if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
> +    if (xmlin != NULL) {
> +       if (!(def = virDomainDefParseString(xmlin, cfg->caps, driver->xmlopt,
> +                                               VIR_DOMAIN_DEF_PARSE_INACTIVE |
> +                                              
> VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
> +               goto error;
> +    } else {

We can't use the new XML wholesale. It should be checked for ABI compatibility.
I.e. we should ensure there are no changes to the new XML which prevent
restoring the saved image.  E.g. see qemuDomainSaveImageUpdateDef(), called by
qemuDomainRestoreFlags(), in src/qemu/qemu_driver.c.

> +       if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
>                                          VIR_DOMAIN_DEF_PARSE_INACTIVE |
>                                          VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
>          goto error;
> +    }
>  
>      VIR_FREE(xml);
>  
> @@ -1072,7 +1080,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
>  
>              managed_save_fd = libxlDomainSaveImageOpen(driver, cfg,
>                                                         managed_save_path,
> -                                                       &def, &hdr);
> +                                                       &def, &hdr, NULL);
>              if (managed_save_fd < 0)
>                  goto cleanup;
>  
> diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
> index af11a2c..863473d 100644
> --- a/src/libxl/libxl_domain.h
> +++ b/src/libxl/libxl_domain.h
> @@ -106,7 +106,8 @@ libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver,
>                           libxlDriverConfigPtr cfg,
>                           const char *from,
>                           virDomainDefPtr *ret_def,
> -                         libxlSavefileHeaderPtr ret_hdr)
> +                         libxlSavefileHeaderPtr ret_hdr,
> +                                                const char *xmlin)
>      ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
>  
>  int
> diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
> index cb501cf..4683fe7 100644
> --- a/src/libxl/libxl_driver.c
> +++ b/src/libxl/libxl_driver.c
> @@ -1828,14 +1828,7 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char
> *from,
>      return -1;
>  #endif
>  
> -    virCheckFlags(VIR_DOMAIN_SAVE_PAUSED, -1);

Inadvertent removal of the check for supported flags?

Regards,
Jim

> -    if (dxml) {
> -        virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
> -                       _("xml modification unsupported"));
> -        return -1;
> -    }
> -
> -    fd = libxlDomainSaveImageOpen(driver, cfg, from, &def, &hdr);
> +    fd = libxlDomainSaveImageOpen(driver, cfg, from, &def, &hdr, dxml);
>      if (fd < 0)
>          goto cleanup;
>  
> -- 
> 2.6.6




More information about the libvir-list mailing list