[libvirt] [v2] qemu: Set domain def as updated and transient if changes

Daniel P. Berrange berrange at redhat.com
Fri Dec 10 10:58:24 UTC 2010


On Fri, Dec 10, 2010 at 01:06:55PM +0800, Osier Yang wrote:
> As qemu driver doesn't allow to make changes on persistent
> domain configuration via "attach/detach/update device",
> and all the changes made on the running domain configuration
> should not be persistent across next boot (without the need
> of restarting libvirtd), so:
>  1) Set the running domain def as transient, and restore
>     the domain configuration to original configuration when
>     shutdown.
>  2) Set the running domain def as updated, and reset it as
>     not updated when shutdown.
> 
> Also for "live VCPU set", it doesn't change the persistent
> domain configuration, so, we also set the running domain
> def as updated and transient, and restore the original def
> when shutdown.
> 
> * src/qemu/qemu_driver.c
> ---
>  src/qemu/qemu_driver.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 47 insertions(+), 0 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 19ce9a6..a3d87eb 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -4429,11 +4429,18 @@ retry:
>      VIR_FREE(priv->vcpupids);
>      priv->nvcpupids = 0;
> 
> +    /* Restore original domain def, so that changes on running domain def
> +     * will not be persistent across next boot.
> +     */
>      if (vm->newDef) {
>          virDomainDefFree(vm->def);
>          vm->def = vm->newDef;
>          vm->def->id = -1;
>          vm->newDef = NULL;
> +
> +        /* Now set domain def as not updated */
> +        if (vm->updated)
> +            vm->updated = 0;
>      }
> 
>      if (orig_err) {
> @@ -6473,7 +6480,17 @@ qemudDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
>          break;
> 
>      case VIR_DOMAIN_VCPU_LIVE:
> +        if (virDomainObjSetDefTransient(driver->caps, vm) < 0) {
> +            VIR_ERROR("Unable to set domain %s's running config as transient",
> +            vm->def->name);
> +
> +            goto endjob;
> +        }


Why do we need this, or any other of the calls to SetDefTransient ?
Since the VM is already running, we know this has already been
called in qemudStartVMDaemon().

Regards,
Daniel




More information about the libvir-list mailing list