[libvirt] [PATCH 3/7] qemu: Use domain condition for device removal singalling
Cole Robinson
crobinso at redhat.com
Tue Apr 12 23:27:37 UTC 2016
s/singalling/signaling/
On 04/05/2016 11:09 AM, Peter Krempa wrote:
> No need to keep two separate conditions. A slight juggling of return
> values is needed to accomodate virDomainObjWaitUntil.
> ---
> src/qemu/qemu_domain.c | 4 ----
> src/qemu/qemu_domain.h | 1 -
> src/qemu/qemu_hotplug.c | 19 +++++++++----------
> 3 files changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index f38b0f3..8a673f8 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -586,9 +586,6 @@ qemuDomainObjPrivateAlloc(void)
> goto error;
> }
>
> - if (virCondInit(&priv->unplugFinished) < 0)
> - goto error;
> -
> if (!(priv->devs = virChrdevAlloc()))
> goto error;
>
> @@ -618,7 +615,6 @@ qemuDomainObjPrivateFree(void *data)
> VIR_FREE(priv->lockState);
> VIR_FREE(priv->origname);
>
> - virCondDestroy(&priv->unplugFinished);
> virStringFreeList(priv->qemuDevices);
> virChrdevFree(priv->devs);
>
> diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
> index 54d7bd7..2b92a90 100644
> --- a/src/qemu/qemu_domain.h
> +++ b/src/qemu/qemu_domain.h
> @@ -198,7 +198,6 @@ struct _qemuDomainObjPrivate {
>
> virPerfPtr perf;
>
> - virCond unplugFinished; /* signals that unpluggingDevice was unplugged */
> const char *unpluggingDevice; /* alias of the device that is being unplugged */
> char **qemuDevices; /* NULL-terminated list of devices aliases known to QEMU */
>
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 7317089..134f458 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -3364,6 +3364,7 @@ qemuDomainWaitForDeviceRemoval(virDomainObjPtr vm)
> {
> qemuDomainObjPrivatePtr priv = vm->privateData;
> unsigned long long until;
> + int rc;
>
> if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT))
> return 1;
> @@ -3373,15 +3374,13 @@ qemuDomainWaitForDeviceRemoval(virDomainObjPtr vm)
> until += qemuDomainRemoveDeviceWaitTime;
>
> while (priv->unpluggingDevice) {
> - if (virCondWaitUntil(&priv->unplugFinished,
> - &vm->parent.lock, until) < 0) {
> - if (errno == ETIMEDOUT) {
> - return 0;
> - } else {
> - VIR_WARN("Failed to wait on unplug condition for domain '%s' "
> - "device '%s'", vm->def->name, priv->unpluggingDevice);
> - return 1;
> - }
> + if ((rc = virDomainObjWaitUntil(vm, until)) == 1)
> + return 0;
> +
> + if (rc < 0) {
> + VIR_WARN("Failed to wait on unplug condition for domain '%s' "
> + "device '%s'", vm->def->name, priv->unpluggingDevice);
> + return 1;
> }
> }
>
> @@ -3402,7 +3401,7 @@ qemuDomainSignalDeviceRemoval(virDomainObjPtr vm,
>
> if (STREQ_NULLABLE(priv->unpluggingDevice, devAlias)) {
> qemuDomainResetDeviceRemoval(vm);
> - virCondSignal(&priv->unplugFinished);
> + virDomainObjBroadcast(vm);
> return true;
> }
> return false;
>
Neat, I didn't know about virDomainObjBroadcast etc. LGTM, ACK
- Cole
More information about the libvir-list
mailing list