mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
libxl: fix attaching net device of type hostdev
Chunyan sent a correct patch to fix a resource leak on error in libxlDomainAttachNetDevice https://www.redhat.com/archives/libvir-list/2016-March/msg00924.html I made what was thought to be an improvement and pushed the patch as commite6336442. As it turns out, my change broke adding net devices that are actually hostdevs to the list of nets in virDomainDef. This patch changese6336442to resemble Chunyan's original, correct patch.
This commit is contained in:
@@ -3174,12 +3174,13 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
vm->def->nets[vm->def->nnets++] = net;
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
libxl_device_nic_dispose(&nic);
|
||||
if (ret) {
|
||||
if (!ret) {
|
||||
vm->def->nets[vm->def->nnets++] = net;
|
||||
} else {
|
||||
virDomainNetRemoveHostdev(vm->def, net);
|
||||
networkReleaseActualDevice(vm->def, net);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user