mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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;
|
int ret = -1;
|
||||||
char mac[VIR_MAC_STRING_BUFLEN];
|
char mac[VIR_MAC_STRING_BUFLEN];
|
||||||
virConnectPtr conn = NULL;
|
virConnectPtr conn = NULL;
|
||||||
|
virErrorPtr save_err = NULL;
|
||||||
|
|
||||||
libxl_device_nic_init(&nic);
|
libxl_device_nic_init(&nic);
|
||||||
|
|
||||||
@ -3440,6 +3441,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virErrorPreserveLast(&save_err);
|
||||||
libxl_device_nic_dispose(&nic);
|
libxl_device_nic_dispose(&nic);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
vm->def->nets[vm->def->nnets++] = net;
|
vm->def->nets[vm->def->nnets++] = net;
|
||||||
@ -3450,6 +3452,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver,
|
|||||||
}
|
}
|
||||||
virObjectUnref(conn);
|
virObjectUnref(conn);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
|
virErrorRestore(&save_err);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3838,6 +3841,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
|
|||||||
libxl_device_nic nic;
|
libxl_device_nic nic;
|
||||||
char mac[VIR_MAC_STRING_BUFLEN];
|
char mac[VIR_MAC_STRING_BUFLEN];
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
virErrorPtr save_err = NULL;
|
||||||
|
|
||||||
libxl_device_nic_init(&nic);
|
libxl_device_nic_init(&nic);
|
||||||
|
|
||||||
@ -3868,6 +3872,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virErrorPreserveLast(&save_err);
|
||||||
libxl_device_nic_dispose(&nic);
|
libxl_device_nic_dispose(&nic);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
if (detach->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
if (detach->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
||||||
@ -3882,6 +3887,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
|
|||||||
virDomainNetRemove(vm->def, detachidx);
|
virDomainNetRemove(vm->def, detachidx);
|
||||||
}
|
}
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
|
virErrorRestore(&save_err);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4337,6 +4337,7 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm,
|
|||||||
virDomainNetType actualType;
|
virDomainNetType actualType;
|
||||||
virDomainNetDefPtr detach = NULL;
|
virDomainNetDefPtr detach = NULL;
|
||||||
virNetDevVPortProfilePtr vport = NULL;
|
virNetDevVPortProfilePtr vport = NULL;
|
||||||
|
virErrorPtr save_err = NULL;
|
||||||
|
|
||||||
if ((detachidx = virDomainNetFindIdx(vm->def, dev->data.net)) < 0)
|
if ((detachidx = virDomainNetFindIdx(vm->def, dev->data.net)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4396,6 +4397,7 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
virErrorPreserveLast(&save_err);
|
||||||
if (detach->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
if (detach->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
||||||
virConnectPtr conn = virGetConnectNetwork();
|
virConnectPtr conn = virGetConnectNetwork();
|
||||||
if (conn) {
|
if (conn) {
|
||||||
@ -4407,6 +4409,7 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
virDomainNetRemove(vm->def, detachidx);
|
virDomainNetRemove(vm->def, detachidx);
|
||||||
virDomainNetDefFree(detach);
|
virDomainNetDefFree(detach);
|
||||||
|
virErrorRestore(&save_err);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -550,6 +550,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
|
|||||||
virDomainNetDefPtr net;
|
virDomainNetDefPtr net;
|
||||||
virDomainNetType type;
|
virDomainNetType type;
|
||||||
virConnectPtr netconn = NULL;
|
virConnectPtr netconn = NULL;
|
||||||
|
virErrorPtr save_err = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(*veths, def->nnets + 1) < 0)
|
if (VIR_ALLOC_N(*veths, def->nnets + 1) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -642,6 +643,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
virErrorPreserveLast(&save_err);
|
||||||
for (i = 0; i < def->nnets; i++) {
|
for (i = 0; i < def->nnets; i++) {
|
||||||
virDomainNetDefPtr iface = def->nets[i];
|
virDomainNetDefPtr iface = def->nets[i];
|
||||||
virNetDevVPortProfilePtr vport = virDomainNetGetActualVirtPortProfile(iface);
|
virNetDevVPortProfilePtr vport = virDomainNetGetActualVirtPortProfile(iface);
|
||||||
@ -652,6 +654,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
|
|||||||
if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK && netconn)
|
if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK && netconn)
|
||||||
virDomainNetReleaseActualDevice(netconn, def, iface);
|
virDomainNetReleaseActualDevice(netconn, def, iface);
|
||||||
}
|
}
|
||||||
|
virErrorRestore(&save_err);
|
||||||
}
|
}
|
||||||
virObjectUnref(netconn);
|
virObjectUnref(netconn);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1383,6 +1383,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
bool netdevPlugged = false;
|
bool netdevPlugged = false;
|
||||||
char *netdev_name;
|
char *netdev_name;
|
||||||
virConnectPtr conn = NULL;
|
virConnectPtr conn = NULL;
|
||||||
|
virErrorPtr save_err = NULL;
|
||||||
|
|
||||||
/* preallocate new slot for device */
|
/* preallocate new slot for device */
|
||||||
if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0)
|
if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0)
|
||||||
@ -1678,6 +1679,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
if (!ret) {
|
if (!ret) {
|
||||||
vm->def->nets[vm->def->nnets++] = net;
|
vm->def->nets[vm->def->nnets++] = net;
|
||||||
} else {
|
} else {
|
||||||
|
virErrorPreserveLast(&save_err);
|
||||||
if (releaseaddr)
|
if (releaseaddr)
|
||||||
qemuDomainReleaseDeviceAddress(vm, &net->info);
|
qemuDomainReleaseDeviceAddress(vm, &net->info);
|
||||||
|
|
||||||
@ -1706,6 +1708,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
else
|
else
|
||||||
VIR_WARN("Unable to release network device '%s'", NULLSTR(net->ifname));
|
VIR_WARN("Unable to release network device '%s'", NULLSTR(net->ifname));
|
||||||
}
|
}
|
||||||
|
virErrorRestore(&save_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(nicstr);
|
VIR_FREE(nicstr);
|
||||||
@ -3756,6 +3759,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
int changeidx = -1;
|
int changeidx = -1;
|
||||||
virConnectPtr conn = NULL;
|
virConnectPtr conn = NULL;
|
||||||
|
virErrorPtr save_err = NULL;
|
||||||
|
|
||||||
if ((changeidx = virDomainNetFindIdx(vm->def, newdev)) < 0)
|
if ((changeidx = virDomainNetFindIdx(vm->def, newdev)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4173,6 +4177,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virErrorPreserveLast(&save_err);
|
||||||
/* When we get here, we will be in one of these two states:
|
/* 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
|
* 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)
|
if (newdev && newdev->type == VIR_DOMAIN_NET_TYPE_NETWORK && conn)
|
||||||
virDomainNetReleaseActualDevice(conn, vm->def, newdev);
|
virDomainNetReleaseActualDevice(conn, vm->def, newdev);
|
||||||
virObjectUnref(conn);
|
virObjectUnref(conn);
|
||||||
|
virErrorRestore(&save_err);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user