mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
libxlDomainDetachNetDevice: cleanup codes
Adjust codes to make it cleaner. Signed-off-by: Chunyan Liu <cyliu@suse.com>
This commit is contained in:
parent
e633644229
commit
b5534e5391
@ -3412,8 +3412,10 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
|
|||||||
char mac[VIR_MAC_STRING_BUFLEN];
|
char mac[VIR_MAC_STRING_BUFLEN];
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
libxl_device_nic_init(&nic);
|
||||||
|
|
||||||
if ((detachidx = virDomainNetFindIdx(vm->def, net)) < 0)
|
if ((detachidx = virDomainNetFindIdx(vm->def, net)) < 0)
|
||||||
goto out;
|
goto cleanup;
|
||||||
|
|
||||||
detach = vm->def->nets[detachidx];
|
detach = vm->def->nets[detachidx];
|
||||||
|
|
||||||
@ -3423,10 +3425,9 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
|
|||||||
*/
|
*/
|
||||||
ret = libxlDomainDetachHostDevice(driver, vm,
|
ret = libxlDomainDetachHostDevice(driver, vm,
|
||||||
virDomainNetGetActualHostdev(detach));
|
virDomainNetGetActualHostdev(detach));
|
||||||
goto out;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
libxl_device_nic_init(&nic);
|
|
||||||
if (libxl_mac_to_device_nic(cfg->ctx, vm->def->id,
|
if (libxl_mac_to_device_nic(cfg->ctx, vm->def->id,
|
||||||
virMacAddrFormat(&detach->mac, mac), &nic))
|
virMacAddrFormat(&detach->mac, mac), &nic))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3437,13 +3438,11 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virDomainNetRemove(vm->def, detachidx);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
libxl_device_nic_dispose(&nic);
|
libxl_device_nic_dispose(&nic);
|
||||||
out:
|
|
||||||
if (!ret)
|
|
||||||
virDomainNetRemove(vm->def, detachidx);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user