]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: monitor: Remove 'timeout' argument from qemuMonitorOpen
authorPeter Krempa <pkrempa@redhat.com>
Tue, 2 Aug 2022 11:45:49 +0000 (13:45 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 3 Aug 2022 12:26:56 +0000 (14:26 +0200)
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@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_process.c
tests/qemumonitortestutils.c

index 6ebdeb46f35594305c0679542e7ab25d7d84fcb8..91e9f769443edee7ff4795ac94972122b3f8ee79 100644 (file)
@@ -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)
index b82f198285cc6c57679c7d5a41f88fa944d5107e..2ef9118b84543429e510398b78ecc7a3c17f872b 100644 (file)
@@ -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);
index 42a5b3f6432a61842cc57405a7af214274b6ae88..1cd55fe989a92746cc5e0305f08f94102bb88434 100644 (file)
@@ -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;
index a5d716deeed4b66da2a0c040d8300c1142ea927a..50808f1fb5c5100cb4420470649f001cec70e779 100644 (file)
@@ -1110,7 +1110,6 @@ qemuMonitorTestNew(virDomainXMLOption *xmlopt,
     if (!(test->mon = qemuMonitorOpen(test->vm,
                                       &src,
                                       true,
-                                      0,
                                       virEventThreadGetContext(test->eventThread),
                                       &qemuMonitorTestCallbacks)))
         goto error;