The 'timeout' argument is used by 'qemuMonitorOpenUnix' only when the
'retry' argument is true. The callers of 'qemuMonitorOpen' only pass
'0'
for timeout when they call it with 'retry' true and use other values
when 'retry' is false and thus ignored.
This means we can remove the argument and simply have it set to the
default value of QEMU_DEFAULT_MONITOR_WAIT.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_monitor.c | 21 +++++----------------
src/qemu/qemu_monitor.h | 3 +--
src/qemu/qemu_process.c | 10 +---------
tests/qemumonitortestutils.c | 1 -
4 files changed, 7 insertions(+), 28 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 6ebdeb46f3..91e9f76944 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -223,12 +223,12 @@ qemuMonitorDispose(void *obj)
g_free(mon->domainName);
}
+#define QEMU_DEFAULT_MONITOR_WAIT 30
static int
qemuMonitorOpenUnix(const char *monitor,
pid_t cpid,
- bool retry,
- unsigned long long timeout)
+ bool retry)
{
struct sockaddr_un addr;
VIR_AUTOCLOSE monfd = -1;
@@ -250,7 +250,7 @@ qemuMonitorOpenUnix(const char *monitor,
}
if (retry) {
- if (virTimeBackOffStart(&timebackoff, 1, timeout * 1000) < 0)
+ if (virTimeBackOffStart(&timebackoff, 1, QEMU_DEFAULT_MONITOR_WAIT * 1000)
< 0)
return -1;
while (virTimeBackOffWait(&timebackoff)) {
ret = connect(monfd, (struct sockaddr *)&addr, sizeof(addr));
@@ -694,20 +694,13 @@ qemuMonitorOpenInternal(virDomainObj *vm,
}
-#define QEMU_DEFAULT_MONITOR_WAIT 30
-
/**
* qemuMonitorOpen:
* @vm: domain object
* @config: monitor configuration
- * @timeout: number of seconds to add to default timeout
* @cb: monitor event handles
*
- * Opens the monitor for running qemu. It may happen that it
- * takes some time for qemu to create the monitor socket (e.g.
- * because kernel is zeroing configured hugepages), therefore we
- * wait up to default + timeout seconds for the monitor to show
- * up after which a failure is claimed.
+ * Opens the monitor for running qemu.
*
* Returns monitor object, NULL on error.
*/
@@ -715,15 +708,12 @@ qemuMonitor *
qemuMonitorOpen(virDomainObj *vm,
virDomainChrSourceDef *config,
bool retry,
- unsigned long long timeout,
GMainContext *context,
qemuMonitorCallbacks *cb)
{
VIR_AUTOCLOSE fd = -1;
qemuMonitor *ret = NULL;
- timeout += QEMU_DEFAULT_MONITOR_WAIT;
-
if (config->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to handle monitor type: %s"),
@@ -732,8 +722,7 @@ qemuMonitorOpen(virDomainObj *vm,
}
virObjectUnlock(vm);
- fd = qemuMonitorOpenUnix(config->data.nix.path,
- vm->pid, retry, timeout);
+ fd = qemuMonitorOpenUnix(config->data.nix.path, vm->pid, retry);
virObjectLock(vm);
if (fd < 0)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index b82f198285..2ef9118b84 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -409,10 +409,9 @@ struct _qemuMonitorCallbacks {
qemuMonitor *qemuMonitorOpen(virDomainObj *vm,
virDomainChrSourceDef *config,
bool retry,
- unsigned long long timeout,
GMainContext *context,
qemuMonitorCallbacks *cb)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
void qemuMonitorWatchDispose(void);
bool qemuMonitorWasDisposed(void);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 42a5b3f643..1cd55fe989 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1888,7 +1888,6 @@ qemuConnectMonitor(virQEMUDriver *driver,
{
qemuDomainObjPrivate *priv = vm->privateData;
qemuMonitor *mon = NULL;
- unsigned long long timeout = 0;
if (qemuSecuritySetDaemonSocketLabel(driver->securityManager, vm->def) < 0)
{
VIR_ERROR(_("Failed to set security context for monitor for %s"),
@@ -1896,18 +1895,11 @@ qemuConnectMonitor(virQEMUDriver *driver,
return -1;
}
- /* When using hugepages, kernel zeroes them out before
- * handing them over to qemu. This can be very time
- * consuming. Therefore, add a second to timeout for each
- * 1GiB of guest RAM. */
- timeout = virDomainDefGetMemoryTotal(vm->def) / (1024 * 1024);
-
ignore_value(virTimeMillisNow(&priv->monStart));
mon = qemuMonitorOpen(vm,
priv->monConfig,
false,
- timeout,
virEventThreadGetContext(priv->eventThread),
&monitorCallbacks);
@@ -9501,7 +9493,7 @@ qemuProcessQMPConnectMonitor(qemuProcessQMP *proc)
proc->vm->pid = proc->pid;
- if (!(proc->mon = qemuMonitorOpen(proc->vm, &monConfig, true, 0,
+ if (!(proc->mon = qemuMonitorOpen(proc->vm, &monConfig, true,
virEventThreadGetContext(proc->eventThread),
&callbacks)))
return -1;
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index a5d716deee..50808f1fb5 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -1110,7 +1110,6 @@ qemuMonitorTestNew(virDomainXMLOption *xmlopt,
if (!(test->mon = qemuMonitorOpen(test->vm,
&src,
true,
- 0,
virEventThreadGetContext(test->eventThread),
&qemuMonitorTestCallbacks)))
goto error;
--
2.36.1