From: Chunyan Liu Date: Mon, 21 Mar 2016 08:11:38 +0000 (+0800) Subject: libxlDomainDetachDeviceLive: handle hostdev parent is network device X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=420eff8f26ef192e69978f9c0ff4e61aa5274f45;p=libvirt.git libxlDomainDetachDeviceLive: handle hostdev parent is network device When hostdev parent is network device, should call libxlDomainDetachNetDevice to detach the device from a higher level. Signed-off-by: Chunyan Liu --- diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index b2e23c0a89..cc7f224635 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3438,6 +3438,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver, goto cleanup; } + networkReleaseActualDevice(vm->def, detach); virDomainNetRemove(vm->def, detachidx); ret = 0; @@ -3452,6 +3453,7 @@ libxlDomainDetachDeviceLive(libxlDriverPrivatePtr driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev) { + virDomainHostdevDefPtr hostdev; int ret = -1; switch (dev->type) { @@ -3465,8 +3467,16 @@ libxlDomainDetachDeviceLive(libxlDriverPrivatePtr driver, break; case VIR_DOMAIN_DEVICE_HOSTDEV: - ret = libxlDomainDetachHostDevice(driver, vm, - dev->data.hostdev); + hostdev = dev->data.hostdev; + + /* If this is a network hostdev, we need to use the higher-level + * detach function so that mac address / virtualport are reset + */ + if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET) + ret = libxlDomainDetachNetDevice(driver, vm, + hostdev->parent.data.net); + else + ret = libxlDomainDetachHostDevice(driver, vm, hostdev); break; default: