we've experience cases where waiting 30 seconds for a qemu monitor to
finish was not enough (slow and busy server with slow storage). that was
with managing qemu processes directly, btw, not with libvirt. however
those case where not common. how about making the timeout configurable
on-site?
---
src/qemu/qemu.conf | 5 +++++
src/qemu/qemu_conf.c | 10 ++++++++++
src/qemu/qemu_conf.h | 2 ++
src/qemu/qemu_driver.c | 29 ++++++++++++++---------------
4 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 2129bae..bca858a 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -157,3 +157,8 @@
# This currently requires ebtables to be installed.
#
# mac_filter = 1
+
+# job_wait_time specifies how many seconds should a qemu monitor query wait for
+# the monitor mutex.
+#
+# job_wait_time = 30
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 225a760..bcbe80d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -340,6 +340,16 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
}
}
+ p = virConfGetValue (conf, "job_wait_time");
+ CHECK_TYPE ("job_wait_time", VIR_CONF_LONG);
+ if (p && p->l) {
+ driver->job_wait_time = 1000ull * p->l;
+ } else {
+ driver->job_wait_time = 1000ull * 30;
+ }
+ if (driver->job_wait_time <= 0)
+ driver->job_wait_time = 1;
+
virConfFree (conf);
return 0;
}
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 1931aef..0d816e2 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -134,6 +134,8 @@ struct qemud_driver {
char *saveImageFormat;
pciDeviceList *activePciHostdevs;
+
+ int job_wait_time;
};
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a4a87ac..2f273eb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -160,11 +160,10 @@ static void qemuDomainObjPrivateFree(void *data)
* successful calls must be followed by EndJob eventually
*/
-/* Give up waiting for mutex after 30 seconds */
-#define QEMU_JOB_WAIT_TIME (1000ull * 30)
-
-static int qemuDomainObjBeginJob(virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
-static int qemuDomainObjBeginJob(virDomainObjPtr obj)
+static int qemuDomainObjBeginJob(struct qemud_driver *driver,
+ virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
+static int qemuDomainObjBeginJob(struct qemud_driver *driver,
+ virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
struct timeval now;
@@ -176,7 +175,7 @@ static int qemuDomainObjBeginJob(virDomainObjPtr obj)
return -1;
}
then = (now.tv_sec * 1000ull) + (now.tv_usec / 1000);
- then += QEMU_JOB_WAIT_TIME;
+ then += driver->job_wait_time;
virDomainObjRef(obj);
@@ -218,7 +217,7 @@ static int qemuDomainObjBeginJobWithDriver(struct qemud_driver
*driver,
return -1;
}
then = (now.tv_sec * 1000ull) + (now.tv_usec / 1000);
- then += QEMU_JOB_WAIT_TIME;
+ then += driver->job_wait_time;
virDomainObjRef(obj);
qemuDriverUnlock(driver);
@@ -3022,7 +3021,7 @@ static int qemudDomainShutdown(virDomainPtr dom) {
goto cleanup;
}
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJob(driver, vm) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
@@ -3203,7 +3202,7 @@ static int qemudDomainSetMemory(virDomainPtr dom, unsigned long
newmem) {
goto cleanup;
}
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJob(driver, vm) < 0)
goto cleanup;
if (virDomainObjIsActive(vm)) {
@@ -3269,7 +3268,7 @@ static int qemudDomainGetInfo(virDomainPtr dom,
if (virDomainObjIsActive(vm)) {
qemuDomainObjPrivatePtr priv = vm->privateData;
if (!priv->jobActive) {
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJob(driver, vm) < 0)
goto cleanup;
qemuDomainObjEnterMonitor(vm);
@@ -3544,7 +3543,7 @@ static int qemudDomainCoreDump(virDomainPtr dom,
goto cleanup;
}
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJob(driver, vm) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
@@ -3618,7 +3617,7 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int
nvcpus) {
goto cleanup;
}
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJob(driver, vm) < 0)
goto cleanup;
if (virDomainObjIsActive(vm)) {
@@ -4145,7 +4144,7 @@ static char *qemudDomainDumpXML(virDomainPtr dom,
/* Don't delay if someone's using the monitor, just use
* existing most recent data instead */
if (!priv->jobActive) {
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJob(driver, vm) < 0)
goto cleanup;
qemuDomainObjEnterMonitor(vm);
@@ -5777,7 +5776,7 @@ qemudDomainBlockStats (virDomainPtr dom,
goto cleanup;
}
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJob(driver, vm) < 0)
goto cleanup;
if (!virDomainObjIsActive (vm)) {
@@ -5986,7 +5985,7 @@ qemudDomainMemoryPeek (virDomainPtr dom,
goto cleanup;
}
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJob(driver, vm) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
--
1.6.5.2