[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v1 2/3] qemu_hotplug: use qemu_driver->unplugTimeout in device removal



qemuDomainResetDeviceRemoval() uses a global variable called
'qemuDomainRemoveDeviceWaitTime', hardcoded to 5000, to use
as timeout value for virDomainObjWaitUntil().

This timeout value can now be set by the user, via 'unplug_timeout'
in qemu.conf,  and it is stored in the QEMUDriver object.

Signed-off-by: Daniel Henrique Barboza <danielhb413 gmail com>
---
 src/qemu/qemu_hotplug.c | 10 +++++-----
 tests/qemuhotplugtest.c |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index d8be63b71c..04a888863c 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -5135,7 +5135,7 @@ qemuDomainResetDeviceRemoval(virDomainObjPtr vm)
  *      - we failed to reliably wait for the event and thus use fallback behavior
  */
 static int
-qemuDomainWaitForDeviceRemoval(virDomainObjPtr vm)
+qemuDomainWaitForDeviceRemoval(virQEMUDriverPtr driver, virDomainObjPtr vm)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
     unsigned long long until;
@@ -5143,7 +5143,7 @@ qemuDomainWaitForDeviceRemoval(virDomainObjPtr vm)
 
     if (virTimeMillisNow(&until) < 0)
         return 1;
-    until += qemuDomainRemoveDeviceWaitTime;
+    until += driver->unplugTimeout;
 
     while (priv->unplug.alias) {
         if ((rc = virDomainObjWaitUntil(vm, until)) == 1)
@@ -5599,7 +5599,7 @@ qemuDomainDetachDeviceChr(virQEMUDriverPtr driver,
     } else if (async) {
         ret = 0;
     } else {
-        if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
+        if ((ret = qemuDomainWaitForDeviceRemoval(driver, vm)) == 1)
             ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr, true);
     }
 
@@ -5899,7 +5899,7 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
     if (async) {
         ret = 0;
     } else {
-        if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
+        if ((ret = qemuDomainWaitForDeviceRemoval(driver, vm)) == 1)
             ret = qemuDomainRemoveDevice(driver, vm, &detach);
     }
 
@@ -6005,7 +6005,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
         goto cleanup;
     }
 
-    if ((rc = qemuDomainWaitForDeviceRemoval(vm)) <= 0) {
+    if ((rc = qemuDomainWaitForDeviceRemoval(driver, vm)) <= 0) {
         if (rc == 0)
             virReportError(VIR_ERR_OPERATION_FAILED, "%s",
                            _("vcpu unplug request timed out"));
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 6ad67c8902..5e9fc48975 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -622,7 +622,7 @@ mymain(void)
         return EXIT_FAILURE;
 
     /* wait only 100ms for DEVICE_DELETED event */
-    qemuDomainRemoveDeviceWaitTime = 100;
+    driver.unplugTimeout = 100;
 
 #define DO_TEST(file, ACTION, dev, fial, kep, ...) \
     do { \
-- 
2.21.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]