mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-31 05:57:16 +00:00
qemu: monitor: Remove 'timeout' argument from qemuMonitorOpen
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>
This commit is contained in:
parent
d79216188d
commit
dce9047496
@ -223,12 +223,12 @@ qemuMonitorDispose(void *obj)
|
|||||||
g_free(mon->domainName);
|
g_free(mon->domainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define QEMU_DEFAULT_MONITOR_WAIT 30
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuMonitorOpenUnix(const char *monitor,
|
qemuMonitorOpenUnix(const char *monitor,
|
||||||
pid_t cpid,
|
pid_t cpid,
|
||||||
bool retry,
|
bool retry)
|
||||||
unsigned long long timeout)
|
|
||||||
{
|
{
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
VIR_AUTOCLOSE monfd = -1;
|
VIR_AUTOCLOSE monfd = -1;
|
||||||
@ -250,7 +250,7 @@ qemuMonitorOpenUnix(const char *monitor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (retry) {
|
if (retry) {
|
||||||
if (virTimeBackOffStart(&timebackoff, 1, timeout * 1000) < 0)
|
if (virTimeBackOffStart(&timebackoff, 1, QEMU_DEFAULT_MONITOR_WAIT * 1000) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
while (virTimeBackOffWait(&timebackoff)) {
|
while (virTimeBackOffWait(&timebackoff)) {
|
||||||
ret = connect(monfd, (struct sockaddr *)&addr, sizeof(addr));
|
ret = connect(monfd, (struct sockaddr *)&addr, sizeof(addr));
|
||||||
@ -694,20 +694,13 @@ qemuMonitorOpenInternal(virDomainObj *vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define QEMU_DEFAULT_MONITOR_WAIT 30
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemuMonitorOpen:
|
* qemuMonitorOpen:
|
||||||
* @vm: domain object
|
* @vm: domain object
|
||||||
* @config: monitor configuration
|
* @config: monitor configuration
|
||||||
* @timeout: number of seconds to add to default timeout
|
|
||||||
* @cb: monitor event handles
|
* @cb: monitor event handles
|
||||||
*
|
*
|
||||||
* Opens the monitor for running qemu. It may happen that it
|
* Opens the monitor for running qemu.
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
* Returns monitor object, NULL on error.
|
* Returns monitor object, NULL on error.
|
||||||
*/
|
*/
|
||||||
@ -715,15 +708,12 @@ qemuMonitor *
|
|||||||
qemuMonitorOpen(virDomainObj *vm,
|
qemuMonitorOpen(virDomainObj *vm,
|
||||||
virDomainChrSourceDef *config,
|
virDomainChrSourceDef *config,
|
||||||
bool retry,
|
bool retry,
|
||||||
unsigned long long timeout,
|
|
||||||
GMainContext *context,
|
GMainContext *context,
|
||||||
qemuMonitorCallbacks *cb)
|
qemuMonitorCallbacks *cb)
|
||||||
{
|
{
|
||||||
VIR_AUTOCLOSE fd = -1;
|
VIR_AUTOCLOSE fd = -1;
|
||||||
qemuMonitor *ret = NULL;
|
qemuMonitor *ret = NULL;
|
||||||
|
|
||||||
timeout += QEMU_DEFAULT_MONITOR_WAIT;
|
|
||||||
|
|
||||||
if (config->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
|
if (config->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unable to handle monitor type: %s"),
|
_("unable to handle monitor type: %s"),
|
||||||
@ -732,8 +722,7 @@ qemuMonitorOpen(virDomainObj *vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
fd = qemuMonitorOpenUnix(config->data.nix.path,
|
fd = qemuMonitorOpenUnix(config->data.nix.path, vm->pid, retry);
|
||||||
vm->pid, retry, timeout);
|
|
||||||
virObjectLock(vm);
|
virObjectLock(vm);
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
@ -409,10 +409,9 @@ struct _qemuMonitorCallbacks {
|
|||||||
qemuMonitor *qemuMonitorOpen(virDomainObj *vm,
|
qemuMonitor *qemuMonitorOpen(virDomainObj *vm,
|
||||||
virDomainChrSourceDef *config,
|
virDomainChrSourceDef *config,
|
||||||
bool retry,
|
bool retry,
|
||||||
unsigned long long timeout,
|
|
||||||
GMainContext *context,
|
GMainContext *context,
|
||||||
qemuMonitorCallbacks *cb)
|
qemuMonitorCallbacks *cb)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
|
||||||
|
|
||||||
void qemuMonitorWatchDispose(void);
|
void qemuMonitorWatchDispose(void);
|
||||||
bool qemuMonitorWasDisposed(void);
|
bool qemuMonitorWasDisposed(void);
|
||||||
|
@ -1888,7 +1888,6 @@ qemuConnectMonitor(virQEMUDriver *driver,
|
|||||||
{
|
{
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
qemuMonitor *mon = NULL;
|
qemuMonitor *mon = NULL;
|
||||||
unsigned long long timeout = 0;
|
|
||||||
|
|
||||||
if (qemuSecuritySetDaemonSocketLabel(driver->securityManager, vm->def) < 0) {
|
if (qemuSecuritySetDaemonSocketLabel(driver->securityManager, vm->def) < 0) {
|
||||||
VIR_ERROR(_("Failed to set security context for monitor for %s"),
|
VIR_ERROR(_("Failed to set security context for monitor for %s"),
|
||||||
@ -1896,18 +1895,11 @@ qemuConnectMonitor(virQEMUDriver *driver,
|
|||||||
return -1;
|
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));
|
ignore_value(virTimeMillisNow(&priv->monStart));
|
||||||
|
|
||||||
mon = qemuMonitorOpen(vm,
|
mon = qemuMonitorOpen(vm,
|
||||||
priv->monConfig,
|
priv->monConfig,
|
||||||
false,
|
false,
|
||||||
timeout,
|
|
||||||
virEventThreadGetContext(priv->eventThread),
|
virEventThreadGetContext(priv->eventThread),
|
||||||
&monitorCallbacks);
|
&monitorCallbacks);
|
||||||
|
|
||||||
@ -9501,7 +9493,7 @@ qemuProcessQMPConnectMonitor(qemuProcessQMP *proc)
|
|||||||
|
|
||||||
proc->vm->pid = proc->pid;
|
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),
|
virEventThreadGetContext(proc->eventThread),
|
||||||
&callbacks)))
|
&callbacks)))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1110,7 +1110,6 @@ qemuMonitorTestNew(virDomainXMLOption *xmlopt,
|
|||||||
if (!(test->mon = qemuMonitorOpen(test->vm,
|
if (!(test->mon = qemuMonitorOpen(test->vm,
|
||||||
&src,
|
&src,
|
||||||
true,
|
true,
|
||||||
0,
|
|
||||||
virEventThreadGetContext(test->eventThread),
|
virEventThreadGetContext(test->eventThread),
|
||||||
&qemuMonitorTestCallbacks)))
|
&qemuMonitorTestCallbacks)))
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
Reference in New Issue
Block a user