mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: Use domain condition for device removal signaling
No need to keep two separate conditions. A slight juggling of return values is needed to accomodate virDomainObjWaitUntil.
This commit is contained in:
parent
986a016c5d
commit
0f621198a4
@ -839,9 +839,6 @@ qemuDomainObjPrivateAlloc(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (virCondInit(&priv->unplugFinished) < 0)
|
||||
goto error;
|
||||
|
||||
if (!(priv->devs = virChrdevAlloc()))
|
||||
goto error;
|
||||
|
||||
@ -871,7 +868,6 @@ qemuDomainObjPrivateFree(void *data)
|
||||
VIR_FREE(priv->lockState);
|
||||
VIR_FREE(priv->origname);
|
||||
|
||||
virCondDestroy(&priv->unplugFinished);
|
||||
virStringFreeList(priv->qemuDevices);
|
||||
virChrdevFree(priv->devs);
|
||||
|
||||
|
@ -199,7 +199,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 */
|
||||
|
||||
|
@ -3361,6 +3361,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;
|
||||
@ -3370,15 +3371,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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3399,7 +3398,7 @@ qemuDomainSignalDeviceRemoval(virDomainObjPtr vm,
|
||||
|
||||
if (STREQ_NULLABLE(priv->unpluggingDevice, devAlias)) {
|
||||
qemuDomainResetDeviceRemoval(vm);
|
||||
virCondSignal(&priv->unplugFinished);
|
||||
virDomainObjBroadcast(vm);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user