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. Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- src/qemu/qemu_conf.c | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c9fe55b..6c64deb 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1482,17 +1482,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(); -- 1.6.5.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list