mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Enter monitor within qemuProcessSetLinkStates
Move {Enter,Exit}Monitor calls inside qemuProcessSetLinkStates to simplify qemuProcessStart. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
dd79eb8b77
commit
f78d070d68
@ -2233,19 +2233,25 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
|
||||
|
||||
/* set link states to down on interfaces at qemu start */
|
||||
static int
|
||||
qemuProcessSetLinkStates(virDomainObjPtr vm)
|
||||
qemuProcessSetLinkStates(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
qemuDomainAsyncJob asyncJob)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
virDomainDefPtr def = vm->def;
|
||||
size_t i;
|
||||
int ret = 0;
|
||||
int ret = -1;
|
||||
int rv;
|
||||
|
||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < def->nnets; i++) {
|
||||
if (def->nets[i]->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) {
|
||||
if (!def->nets[i]->info.alias) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("missing alias for network device"));
|
||||
return -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
VIR_DEBUG("Setting link state: %s", def->nets[i]->info.alias);
|
||||
@ -2253,20 +2259,26 @@ qemuProcessSetLinkStates(virDomainObjPtr vm)
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
|
||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||
_("Setting of link state is not supported by this qemu"));
|
||||
return -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = qemuMonitorSetLink(priv->mon,
|
||||
def->nets[i]->info.alias,
|
||||
VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN);
|
||||
if (ret != 0) {
|
||||
rv = qemuMonitorSetLink(priv->mon,
|
||||
def->nets[i]->info.alias,
|
||||
VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN);
|
||||
if (rv < 0) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
_("Couldn't set link state on interface: %s"), def->nets[i]->info.alias);
|
||||
break;
|
||||
_("Couldn't set link state on interface: %s"),
|
||||
def->nets[i]->info.alias);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -4937,11 +4949,7 @@ int qemuProcessStart(virConnectPtr conn,
|
||||
/* qemu doesn't support setting this on the command line, so
|
||||
* enter the monitor */
|
||||
VIR_DEBUG("Setting network link states");
|
||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||
goto error;
|
||||
if (qemuProcessSetLinkStates(vm) < 0)
|
||||
goto exit_monitor;
|
||||
if (qemuDomainObjExitMonitor(driver, vm))
|
||||
if (qemuProcessSetLinkStates(driver, vm, asyncJob) < 0)
|
||||
goto error;
|
||||
|
||||
VIR_DEBUG("Fetching list of active devices");
|
||||
|
Loading…
x
Reference in New Issue
Block a user