[libvirt] [PATCH 2/2] qemuPrepareNVRAM: Save domain conf only if domain's persistent

Peter Krempa pkrempa at redhat.com
Wed Nov 12 17:47:04 UTC 2014


On 11/12/14 18:26, Michal Privoznik wrote:
> In one of my previous patches (3a3c3780b) I've tried to fix the
> problem of nvram path disappearing on a domain that's been
> started and shut down again. I fixed this by explicitly saving
> domain's config file.  However, I did a bit of clumsy without
> realizing we have a transient domains for which we don't save the
> config file. Hence, any domain using UEFI became persistent.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/qemu/qemu_process.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index c0ab341..1f44683 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -3902,13 +3902,13 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver,
>  
>  static int
>  qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,

This function is called just before cloning vm->def into vm->newDef and
thus vm->def becoming the live definition.

> -                 virDomainDefPtr def,
> +                 virDomainObjPtr vm,
>                   bool migrated)
>  {
>      int ret = -1;
>      int srcFD = -1;
>      int dstFD = -1;
> -    virDomainLoaderDefPtr loader = def->os.loader;
> +    virDomainLoaderDefPtr loader = vm->def->os.loader;
>      bool created = false;
>  
>      /* Unless domain has RO loader of pflash type, we have
> @@ -3934,12 +3934,13 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
>      if (!loader->nvram) {
>          if (virAsprintf(&loader->nvram,
>                          "%s/lib/libvirt/qemu/nvram/%s_VARS.fd",
> -                        LOCALSTATEDIR, def->name) < 0)
> +                        LOCALSTATEDIR, vm->def->name) < 0)
>              goto cleanup;
>  
>          loader->generated = true;
>  
> -        if (virDomainSaveConfig(cfg->configDir, def) < 0)
> +        if (vm->persistent &&
> +            virDomainSaveConfig(cfg->configDir, vm->def) < 0)

So saving the vm->def here is okay. In other place you'd need to use the
helper to get the right pointer according to the vm->persistent flag.

>              goto cleanup;
>      }
>  
> @@ -4106,7 +4107,7 @@ int qemuProcessStart(virConnectPtr conn,
>       * Fill them in prior to setting the domain def as transient. */
>      VIR_DEBUG("Generating paths");
>  
> -    if (qemuPrepareNVRAM(cfg, vm->def, migrateFrom) < 0)
> +    if (qemuPrepareNVRAM(cfg, vm, migrateFrom) < 0)
>          goto cleanup;
>  
>      /* Do this upfront, so any part of the startup process can add
> 

ACK,

Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141112/393aa903/attachment-0001.sig>


More information about the libvir-list mailing list