[libvirt] [PATCH 01/11] Introduce qemuDomainObjExitMonitorAlive
Michal Privoznik
mprivozn at redhat.com
Wed Dec 17 12:18:41 UTC 2014
On 16.12.2014 17:41, Ján Tomko wrote:
> The domain might disappear during the time in monitor when
> the virDomainObjPtr is unlocked, so the caller needs to check
> if it's still alive.
>
> Introduce a helper function for the callers that want to report
> an error in this case.
> ---
> src/qemu/qemu_domain.c | 17 +++++++++++++++++
> src/qemu/qemu_domain.h | 3 +++
> 2 files changed, 20 insertions(+)
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 8dd427a..d074429 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -1606,6 +1606,23 @@ void qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
> qemuDomainObjExitMonitorInternal(driver, obj);
> }
>
> +/* obj must NOT be locked before calling
> + *
> + * Same as qemuDomainObjExitMonitor, but reports an error and
> + * returns -1 if the domain is no longer alive after exiting the monitor
Can you state explicitly that this function needs to be called whenever
the domain object or vm->def, or privdata (any runtime info held within
vm in general) is used after ExitMonitor()?
> + */
> +int qemuDomainObjExitMonitorAlive(virQEMUDriverPtr driver,
> + virDomainObjPtr obj)
> +{
> + qemuDomainObjExitMonitorInternal(driver, obj);
> + if (!virDomainObjIsActive(obj)) {
> + virReportError(VIR_ERR_OPERATION_FAILED, "%s",
> + _("domain is no longer running"));
> + return -1;
> + }
> + return 0;
> +}
> +
> /*
> * obj must be locked before calling
> *
> diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
> index ce5eba3..b8fec34 100644
> --- a/src/qemu/qemu_domain.h
> +++ b/src/qemu/qemu_domain.h
> @@ -250,6 +250,9 @@ void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver,
> void qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
> virDomainObjPtr obj)
> ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
> +int qemuDomainObjExitMonitorAlive(virQEMUDriverPtr driver,
> + virDomainObjPtr obj)
> + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
> int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver,
> virDomainObjPtr obj,
> qemuDomainAsyncJob asyncJob)
>
ACK
Michal
More information about the libvir-list
mailing list