All callers now pass false for 'retry' we are guaranteed to have a monitor socket present. This means that the retry code can be removed. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_monitor.c | 47 ++++++------------------------------ src/qemu/qemu_monitor.h | 1 - src/qemu/qemu_process.c | 3 +-- tests/qemumonitortestutils.c | 1 - 4 files changed, 8 insertions(+), 44 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 91e9f76944..ad5e121359 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -223,16 +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) +qemuMonitorOpenUnix(const char *monitor) { struct sockaddr_un addr; VIR_AUTOCLOSE monfd = -1; - virTimeBackOffVar timebackoff; int ret = -1; if ((monfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { @@ -249,39 +245,11 @@ qemuMonitorOpenUnix(const char *monitor, return -1; } - if (retry) { - if (virTimeBackOffStart(&timebackoff, 1, QEMU_DEFAULT_MONITOR_WAIT * 1000) < 0) - return -1; - while (virTimeBackOffWait(&timebackoff)) { - ret = connect(monfd, (struct sockaddr *)&addr, sizeof(addr)); - - if (ret == 0) - break; - - if ((errno == ENOENT || errno == ECONNREFUSED) && - (!cpid || virProcessKill(cpid, 0) == 0)) { - /* ENOENT : Socket may not have shown up yet - * ECONNREFUSED : Leftover socket hasn't been removed yet */ - continue; - } - - virReportSystemError(errno, "%s", - _("failed to connect to monitor socket")); - return -1; - } - - if (ret != 0) { - virReportSystemError(errno, "%s", - _("monitor socket did not show up")); - return -1; - } - } else { - ret = connect(monfd, (struct sockaddr *) &addr, sizeof(addr)); - if (ret < 0) { - virReportSystemError(errno, "%s", - _("failed to connect to monitor socket")); - return -1; - } + ret = connect(monfd, (struct sockaddr *) &addr, sizeof(addr)); + if (ret < 0) { + virReportSystemError(errno, "%s", + _("failed to connect to monitor socket")); + return -1; } ret = monfd; @@ -707,7 +675,6 @@ qemuMonitorOpenInternal(virDomainObj *vm, qemuMonitor * qemuMonitorOpen(virDomainObj *vm, virDomainChrSourceDef *config, - bool retry, GMainContext *context, qemuMonitorCallbacks *cb) { @@ -722,7 +689,7 @@ qemuMonitorOpen(virDomainObj *vm, } virObjectUnlock(vm); - fd = qemuMonitorOpenUnix(config->data.nix.path, vm->pid, retry); + fd = qemuMonitorOpenUnix(config->data.nix.path); virObjectLock(vm); if (fd < 0) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 2ef9118b84..742bfd4cdc 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -408,7 +408,6 @@ struct _qemuMonitorCallbacks { qemuMonitor *qemuMonitorOpen(virDomainObj *vm, virDomainChrSourceDef *config, - bool retry, GMainContext *context, qemuMonitorCallbacks *cb) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c51d704af8..d29da63242 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1899,7 +1899,6 @@ qemuConnectMonitor(virQEMUDriver *driver, mon = qemuMonitorOpen(vm, priv->monConfig, - false, virEventThreadGetContext(priv->eventThread), &monitorCallbacks); @@ -9493,7 +9492,7 @@ qemuProcessQMPConnectMonitor(qemuProcessQMP *proc) proc->vm->pid = proc->pid; - if (!(proc->mon = qemuMonitorOpen(proc->vm, &monConfig, false, + if (!(proc->mon = qemuMonitorOpen(proc->vm, &monConfig, virEventThreadGetContext(proc->eventThread), &callbacks))) return -1; diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 1ea8d72711..db0f450e40 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -1109,7 +1109,6 @@ qemuMonitorTestNew(virDomainXMLOption *xmlopt, test->qapischema = schema; if (!(test->mon = qemuMonitorOpen(test->vm, &src, - false, virEventThreadGetContext(test->eventThread), &qemuMonitorTestCallbacks))) goto error; -- 2.36.1