aboutsummaryrefslogtreecommitdiff
path: root/src/lxc
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2012-07-30 11:26:51 +0100
committerDaniel P. Berrange <berrange@redhat.com>2012-07-30 13:09:57 +0100
commitac97c2ba4ce203662b5885e7c85bd704afdab54d (patch)
tree4180a0f07c4f43c0ed0f7995b585e508531e4b8f /src/lxc
parentRemove tabs from all perl files & enforce this (diff)
downloadlibvirt-ac97c2ba4ce203662b5885e7c85bd704afdab54d.tar.gz
libvirt-ac97c2ba4ce203662b5885e7c85bd704afdab54d.tar.bz2
libvirt-ac97c2ba4ce203662b5885e7c85bd704afdab54d.zip
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
Diffstat (limited to 'src/lxc')
-rw-r--r--src/lxc/lxc_process.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index b42f4a04d..65b463fc1 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -452,14 +452,37 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
case VIR_DOMAIN_NET_TYPE_NETWORK: {
virNetworkPtr network;
char *brname = NULL;
+ bool fail = false;
+ int active;
+ virErrorPtr errobj;
if (!(network = virNetworkLookupByName(conn,
def->nets[i]->data.network.name)))
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);
- if (!brname)
+ virSetError(errobj);
+ virFreeError(errobj);
+
+ if (fail)
goto cleanup;
if (virLXCProcessSetupInterfaceBridged(conn,