[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 6/7] migrate: hot remove hostdev at perform phase for
From: |
Chen Fan |
Subject: |
[Qemu-devel] [RFC 6/7] migrate: hot remove hostdev at perform phase for bond device |
Date: |
Fri, 17 Apr 2015 16:53:08 +0800 |
For bond device, we can support the migrate, we can simple
to hot remove the device from source side, and after migration
end, we hot add the new device at destination side.
Signed-off-by: Chen Fan <address@hidden>
---
src/qemu/qemu_driver.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_migration.c | 7 ++++++
2 files changed, 64 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7368145..0ba9e4a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12353,6 +12353,58 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
cookieout, cookieoutlen, flags);
}
+static int
+qemuDomainRemovePciPassThruDevices(virConnectPtr conn,
+ virDomainObjPtr vm)
+{
+ virQEMUDriverPtr driver = conn->privateData;
+ virDomainDeviceDef dev;
+ virDomainDeviceDefPtr dev_copy = NULL;
+ virCapsPtr caps = NULL;
+ int ret = -1;
+ size_t i;
+
+ if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ if (!qemuMigrationJobIsActive(vm, QEMU_ASYNC_JOB_MIGRATION_OUT))
+ goto cleanup;
+
+ /* unplug passthrough bond device */
+ for (i = 0; i < vm->def->nhostdevs; i++) {
+ virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
+
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI
&&
+ hostdev->source.subsys.u.pci.backend ==
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO &&
+ hostdev->source.subsys.u.pci.device ==
VIR_DOMAIN_HOSTDEV_PCI_DEVICE_BOND) {
+
+ dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
+ dev.data.hostdev = hostdev;
+
+ dev_copy = virDomainDeviceDefCopy(&dev, vm->def, caps,
driver->xmlopt);
+ if (!dev_copy)
+ goto cleanup;
+
+ if (qemuDomainDetachHostDevice(driver, vm, dev_copy) < 0) {
+ virDomainDeviceDefFree(dev_copy);
+ goto cleanup;
+ }
+
+ virDomainDeviceDefFree(dev_copy);
+ if (qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE) <
0)
+ goto cleanup;
+ }
+ }
+
+ ret = 0;
+
+ cleanup:
+ virObjectUnref(caps);
+
+ return ret;
+}
+
static char *
qemuDomainMigrateBegin3Params(virDomainPtr domain,
virTypedParameterPtr params,
@@ -12688,6 +12740,11 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
return -1;
}
+ if (qemuDomainRemovePciPassThruDevices(dom->conn, vm) < 0) {
+ qemuDomObjEndAPI(&vm);
+ return -1;
+ }
+
return qemuMigrationPerform(driver, dom->conn, vm, dom_xml,
dconnuri, uri, graphicsuri, listenAddress,
cookiein, cookieinlen, cookieout, cookieoutlen,
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 611f53a..9ea83df 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2000,6 +2000,13 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver,
virDomainObjPtr vm,
forbid = false;
for (i = 0; i < def->nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = def->hostdevs[i];
+
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI
&&
+ hostdev->source.subsys.u.pci.backend ==
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO &&
+ hostdev->source.subsys.u.pci.device ==
VIR_DOMAIN_HOSTDEV_PCI_DEVICE_BOND)
+ continue;
+
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB)
{
forbid = true;
--
1.9.3
- [Qemu-devel] [RFC 0/7] Live Migration with Pass-through Devices proposal, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 1/7] qemu-agent: add agent init callback when detecting guest setup, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 2/7] qemu: add guest init event callback to do the initialize work for guest, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 3/7] hostdev: add a 'bond' type element in <hostdev> element, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 4/7] qemu-agent: add qemuAgentCreateBond interface, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 6/7] migrate: hot remove hostdev at perform phase for bond device,
Chen Fan <=
- [Qemu-devel] [RFC 5/7] hostdev: add parse ip and route for bond configure, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 0/3] add support migration with passthrough device, Chen Fan, 2015/04/17
- [Qemu-devel] [RFC 7/7] migrate: add hostdev migrate status to support hostdev migration, Chen Fan, 2015/04/17
- Re: [Qemu-devel] [libvirt] [RFC 0/7] Live Migration with Pass-through Devices proposal, Laine Stump, 2015/04/19