提交 3f745ebe 编写于 作者: C Cole Robinson

qemu: Explicitly error if guest virtual network is inactive

Currently we just error with ex. 'virbr0: No such device'.

Since we are using public API calls here, we need to ensure that any
raised error is properly saved and restored, since API entry points
always reset messages.
上级 6d4bd59c
......@@ -1472,17 +1472,39 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
int template_ifname = 0;
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
int active, fail = 0;
virErrorPtr errobj;
virNetworkPtr network = virNetworkLookupByName(conn,
net->data.network.name);
net->data.network.name);
if (!network)
return -1;
brname = virNetworkGetBridgeName(network);
active = virNetworkIsActive(network);
if (active != 1) {
fail = 1;
if (active == 0)
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("Network '%s' is not active."),
net->data.network.name);
}
if (!fail) {
brname = virNetworkGetBridgeName(network);
if (brname == NULL)
fail = 1;
}
/* Make sure any above failure is preserved */
errobj = virSaveLastError();
virNetworkFree(network);
virSetError(errobj);
virFreeError(errobj);
if (brname == NULL)
errobj = virSaveLastError();
if (fail)
return -1;
} else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
if (!(brname = strdup(net->data.bridge.brname))) {
virReportOOMError();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册