diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index e7234c147926109322c6e2d5bb9d5fe10d784ae6..2b9c6f1866a41bcc05f05ae4f17dbe7e27513201 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3380,6 +3380,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver, int ret = -1; char mac[VIR_MAC_STRING_BUFLEN]; virConnectPtr conn = NULL; + virErrorPtr save_err = NULL; libxl_device_nic_init(&nic); @@ -3440,6 +3441,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver, ret = 0; cleanup: + virErrorPreserveLast(&save_err); libxl_device_nic_dispose(&nic); if (!ret) { vm->def->nets[vm->def->nnets++] = net; @@ -3450,6 +3452,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver, } virObjectUnref(conn); virObjectUnref(cfg); + virErrorRestore(&save_err); return ret; } @@ -3838,6 +3841,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver, libxl_device_nic nic; char mac[VIR_MAC_STRING_BUFLEN]; int ret = -1; + virErrorPtr save_err = NULL; libxl_device_nic_init(&nic); @@ -3868,6 +3872,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver, ret = 0; cleanup: + virErrorPreserveLast(&save_err); libxl_device_nic_dispose(&nic); if (!ret) { if (detach->type == VIR_DOMAIN_NET_TYPE_NETWORK) { @@ -3882,6 +3887,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver, virDomainNetRemove(vm->def, detachidx); } virObjectUnref(cfg); + virErrorRestore(&save_err); return ret; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 1980d0804ea6d8bd15529052ace18cb95006b248..9db2a02deed8a7c03a051fad785473fead6fba46 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4337,6 +4337,7 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm, virDomainNetType actualType; virDomainNetDefPtr detach = NULL; virNetDevVPortProfilePtr vport = NULL; + virErrorPtr save_err = NULL; if ((detachidx = virDomainNetFindIdx(vm->def, dev->data.net)) < 0) goto cleanup; @@ -4396,6 +4397,7 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm, ret = 0; cleanup: if (!ret) { + virErrorPreserveLast(&save_err); if (detach->type == VIR_DOMAIN_NET_TYPE_NETWORK) { virConnectPtr conn = virGetConnectNetwork(); if (conn) { @@ -4407,6 +4409,7 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm, } virDomainNetRemove(vm->def, detachidx); virDomainNetDefFree(detach); + virErrorRestore(&save_err); } return ret; } diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 3a33418acaee2a1bd00a0b9bc38d1b02766ff1c9..de4d7c73fbac9a29edf81f48adbbc97eb91d4e33 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -550,6 +550,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn, virDomainNetDefPtr net; virDomainNetType type; virConnectPtr netconn = NULL; + virErrorPtr save_err = NULL; if (VIR_ALLOC_N(*veths, def->nnets + 1) < 0) return -1; @@ -642,6 +643,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn, cleanup: if (ret < 0) { + virErrorPreserveLast(&save_err); for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr iface = def->nets[i]; virNetDevVPortProfilePtr vport = virDomainNetGetActualVirtPortProfile(iface); @@ -652,6 +654,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn, if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK && netconn) virDomainNetReleaseActualDevice(netconn, def, iface); } + virErrorRestore(&save_err); } virObjectUnref(netconn); return ret; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e199368e8a6df418ef06a5eb6d864b1086350d31..f3c5f44a23cba839e723e89d4ce5010241506180 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1383,6 +1383,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, bool netdevPlugged = false; char *netdev_name; virConnectPtr conn = NULL; + virErrorPtr save_err = NULL; /* preallocate new slot for device */ if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0) @@ -1678,6 +1679,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, if (!ret) { vm->def->nets[vm->def->nnets++] = net; } else { + virErrorPreserveLast(&save_err); if (releaseaddr) qemuDomainReleaseDeviceAddress(vm, &net->info); @@ -1706,6 +1708,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, else VIR_WARN("Unable to release network device '%s'", NULLSTR(net->ifname)); } + virErrorRestore(&save_err); } VIR_FREE(nicstr); @@ -3756,6 +3759,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, int ret = -1; int changeidx = -1; virConnectPtr conn = NULL; + virErrorPtr save_err = NULL; if ((changeidx = virDomainNetFindIdx(vm->def, newdev)) < 0) goto cleanup; @@ -4173,6 +4177,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, ret = 0; cleanup: + virErrorPreserveLast(&save_err); /* When we get here, we will be in one of these two states: * * 1) newdev has been moved into the domain's list of nets and @@ -4194,6 +4199,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, if (newdev && newdev->type == VIR_DOMAIN_NET_TYPE_NETWORK && conn) virDomainNetReleaseActualDevice(conn, vm->def, newdev); virObjectUnref(conn); + virErrorRestore(&save_err); return ret; }