[libvirt] [PATCH v2 2/2] lxc: Rearrange order in lxcDomainUpdateDeviceFlags

Michal Prívozník mprivozn at redhat.com
Sun Jul 1 10:52:51 UTC 2018


On 06/30/2018 04:51 PM, John Ferlan wrote:
> Although commit e3497f3f noted that the LIVE option doesn't
> matter and removed the call to virDomainDefCompatibleDevice,
> it didn't go quite far enough and change the order of the checks
> and rework the code to just handle the config change causing
> a failure after virDomainObjUpdateModificationImpact updates
> the @flags. Since we only support config a lot of previously
> conditional code is now just inlined.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/lxc/lxc_driver.c | 63 ++++++++++++++++++----------------------------------
>  1 file changed, 21 insertions(+), 42 deletions(-)
> 
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index aea48e5e3d..72c6daa507 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -4827,7 +4827,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
>      virCapsPtr caps = NULL;
>      virDomainObjPtr vm = NULL;
>      virDomainDefPtr vmdef = NULL;
> -    virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
> +    virDomainDeviceDefPtr dev = NULL;
>      int ret = -1;
>      virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
>  

> -        }

> +    ret = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef);
> +    if (!ret) {
> +        virDomainObjAssignDef(vm, vmdef, false, NULL);
> +        vmdef = NULL;
>      }

Well, this can be written a bit nicer:

    if (virDomainSaveConfig(cfg->configDir, driver->caps, vmdef) < 0)
        goto endjob;

    virDomainObjAssignDef(vm, vmdef, false, NULL);
    vmdef = NULL;
    ret = 0;

Michal




More information about the libvir-list mailing list