[libvirt] [PATCH 03/11] Fix vm usage after ExitMonitor in UpdateDeviceList

Michal Privoznik mprivozn at redhat.com
Wed Dec 17 12:18:43 UTC 2014


On 16.12.2014 17:41, Ján Tomko wrote:
> Error out if the domain has disappeared in the meantime.
> Explicitly check if the domain is alive
> in qemuDomain{Attach,Detach}Live, where the return value
> is ignored.
>
> This prevents writing the persistent definition as the domain
> status and calling qemuDomainRemoveDevice on devices
> that already have been dealt with in qemuProcessStop.
> ---
>   src/qemu/qemu_domain.c | 3 ++-
>   src/qemu/qemu_driver.c | 4 ++++
>   2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index d074429..d9c22da 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -2763,7 +2763,8 @@ qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
>           qemuDomainObjExitMonitor(driver, vm);
>           return -1;
>       }
> -    qemuDomainObjExitMonitor(driver, vm);
> +    if (qemuDomainObjExitMonitorAlive(driver, vm) < 0)
> +        return -1;

So from now on, qemuDomainUpdateDeviceList() checks domain status after 
returning from monitor.

>
>       virStringFreeList(priv->qemuDevices);
>       priv->qemuDevices = aliases;
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 7211d42..99eb7c3 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -7058,6 +7058,8 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
>
>       if (ret == 0)
>           qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE);
> +    if (!virDomainObjIsActive(vm))
> +        return -1;

Therefore this is not needed. Moreover, as seen in the context, the 
return value of qemuDomainUpdateDeviceList() is ignored. And don't even 
get me started on the qemuDomainAttachDeviceLive() layout.

>
>       return ret;
>   }
> @@ -7134,6 +7136,8 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
>
>       if (ret == 0)
>           qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE);
> +    if (!virDomainObjIsActive(vm))
> +        return -1;

Ditto.

>
>       return ret;
>   }
>

Michal




More information about the libvir-list mailing list