mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
lib: Preserve error around virDomainNetReleaseActualDevice()
This function is calling public API virNetworkLookupByName() which resets the error. Therefore, if virDomainNetReleaseActualDevice() is used in cleanup path it actually resets the original error that got us jump into 'cleanup' label. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
998a55c49a
commit
2a1ae8fba7
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user