提交 ac97c2ba 编写于 作者: D Daniel P. Berrange

Improve error message in LXC startup with network is not active

If an LXC container is using a virtual network and that network
is not active, currently the user gets a rather unhelpful
error message about tap device setup failure. Add an explicit
check for whether the network is active, in exactly the same
way as the QEMU driver
上级 92c5924a
...@@ -452,14 +452,37 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn, ...@@ -452,14 +452,37 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
case VIR_DOMAIN_NET_TYPE_NETWORK: { case VIR_DOMAIN_NET_TYPE_NETWORK: {
virNetworkPtr network; virNetworkPtr network;
char *brname = NULL; char *brname = NULL;
bool fail = false;
int active;
virErrorPtr errobj;
if (!(network = virNetworkLookupByName(conn, if (!(network = virNetworkLookupByName(conn,
def->nets[i]->data.network.name))) def->nets[i]->data.network.name)))
goto cleanup; goto cleanup;
brname = virNetworkGetBridgeName(network); active = virNetworkIsActive(network);
if (active != 1) {
fail = true;
if (active == 0)
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Network '%s' is not active."),
def->nets[i]->data.network.name);
goto cleanup;
}
if (!fail) {
brname = virNetworkGetBridgeName(network);
if (brname == NULL)
fail = true;
}
/* Make sure any above failure is preserved */
errobj = virSaveLastError();
virNetworkFree(network); virNetworkFree(network);
if (!brname) virSetError(errobj);
virFreeError(errobj);
if (fail)
goto cleanup; goto cleanup;
if (virLXCProcessSetupInterfaceBridged(conn, if (virLXCProcessSetupInterfaceBridged(conn,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册