[libvirt] PATCH: 6/7: Persist live domain config across restarts

Jim Meyering jim at meyering.net
Wed Aug 6 12:06:45 UTC 2008


"Daniel P. Berrange" <berrange at redhat.com> wrote:
> Internally the drivers track the current live configuration, and the new
> inactive config for running domains. When the libvirtd process is restarted
> though, this data is lost for any active LXC domains. This patch makes the
> LXC driver persist the live config to /var/run/libvirt/lxc/NAME.xml so it
> can be tracked across restarts
>
> It required a small change to the domain XML APis to make the autostart
> symlink processing optional when deleting a config file
...

Looks fine to me.
ACK

> diff -r cf1cf3a1d4d6 src/lxc_driver.c
> --- a/src/lxc_driver.c	Tue Aug 05 16:50:51 2008 +0100
> +++ b/src/lxc_driver.c	Tue Aug 05 16:50:59 2008 +0100
...
> @@ -960,6 +973,8 @@
>
>      vm = lxc_driver->domains;
>      while (vm) {
> +        char *config = NULL;
> +        virDomainDefPtr tmp;

The initialization of config looks unnecessary.

The only other change I'd make would be to move both declarations "down"
to first use.  Then the context-challenged reader doesn't have to wonder
what, if anything, happens to those variables between declaration and
first use.

>          int rc;
>          if ((vm->monitor = lxcMonitorClient(NULL, lxc_driver, vm)) < 0) {
>              vm = vm->next;
> @@ -972,6 +987,18 @@
>              vm->monitor = -1;
>              vm = vm->next;
>              continue;
> +        }
> +

           char *config;

> +        if (asprintf(&config, "%s/%s.xml",
> +                     lxc_driver->stateDir, vm->def->name) < 0)
> +            continue;
> +
> +        /* Try and load the live config */
> +        tmp = virDomainDefParseFile(NULL, lxc_driver->caps, config);

           virDomainDefPtr tmp = virDomainDefParseFile(NULL, lxc_driver->caps,
                                                       config);

> +        VIR_FREE(config);
> +        if (tmp) {
> +            vm->newDef = vm->def;
> +            vm->def = tmp;
>          }
>
>          if (vm->pid != 0) {




More information about the libvir-list mailing list