mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 02:04:16 +03:00
qemuMonitorOpenUnix: Remove 'retry' argument
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@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
13320bf77e
commit
31699d3914
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -1109,7 +1109,6 @@ qemuMonitorTestNew(virDomainXMLOption *xmlopt,
|
||||
test->qapischema = schema;
|
||||
if (!(test->mon = qemuMonitorOpen(test->vm,
|
||||
&src,
|
||||
false,
|
||||
virEventThreadGetContext(test->eventThread),
|
||||
&qemuMonitorTestCallbacks)))
|
||||
goto error;
|
||||
|
Loading…
x
Reference in New Issue
Block a user