mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +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];
|
||||
int ret = -1;
|
||||
|
||||
libxl_device_nic_init(&nic);
|
||||
|
||||
if ((detachidx = virDomainNetFindIdx(vm->def, net)) < 0)
|
||||
goto out;
|
||||
goto cleanup;
|
||||
|
||||
detach = vm->def->nets[detachidx];
|
||||
|
||||
@ -3423,10 +3425,9 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
|
||||
*/
|
||||
ret = libxlDomainDetachHostDevice(driver, vm,
|
||||
virDomainNetGetActualHostdev(detach));
|
||||
goto out;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
libxl_device_nic_init(&nic);
|
||||
if (libxl_mac_to_device_nic(cfg->ctx, vm->def->id,
|
||||
virMacAddrFormat(&detach->mac, mac), &nic))
|
||||
goto cleanup;
|
||||
@ -3437,13 +3438,11 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
virDomainNetRemove(vm->def, detachidx);
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
libxl_device_nic_dispose(&nic);
|
||||
out:
|
||||
if (!ret)
|
||||
virDomainNetRemove(vm->def, detachidx);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user