For extracting hostdev codes from qemu_hostdev.c to common library, change qemu specific COLD_BOOT handling to be a flag, and pass it to hostdev functions. Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx> --- src/qemu/qemu_hostdev.c | 6 +++--- src/qemu/qemu_hostdev.h | 4 ++-- src/qemu/qemu_process.c | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 5f2dc44..6be58ef 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -1010,7 +1010,7 @@ out: int qemuPrepareHostUSBDevices(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, virDomainDefPtr def, - bool coldBoot) + unsigned int flags) { size_t i; int ret = -1; @@ -1019,6 +1019,7 @@ qemuPrepareHostUSBDevices(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, virDomainHostdevDefPtr *hostdevs = def->hostdevs; int nhostdevs = def->nhostdevs; virHostdevManagerPtr hostdev_mgr; + bool coldBoot = !!(flags & VIR_COLD_BOOT); /* To prevent situation where USB device is assigned to two domains * we need to keep a list of currently assigned USB devices. @@ -1216,7 +1217,6 @@ int qemuPrepareHostDevices(virQEMUDriverPtr driver, virDomainDefPtr def, virQEMUCapsPtr qemuCaps, - bool coldBoot, unsigned int flags) { if (!def->nhostdevs) @@ -1227,7 +1227,7 @@ qemuPrepareHostDevices(virQEMUDriverPtr driver, qemuCaps, flags) < 0) return -1; - if (qemuPrepareHostUSBDevices(driver, def, coldBoot) < 0) + if (qemuPrepareHostUSBDevices(driver, def, flags) < 0) return -1; if (qemuPrepareHostdevSCSIDevices(driver, def->name, diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h index 48ca610..c137302 100644 --- a/src/qemu/qemu_hostdev.h +++ b/src/qemu/qemu_hostdev.h @@ -29,6 +29,7 @@ typedef enum { VIR_STRICT_ACS_CHECK = (1 << 0), /* strict acs check */ + VIR_COLD_BOOT = (1 << 1), /* cold boot */ } virHostdevFlag; int qemuUpdateActivePciHostdevs(virQEMUDriverPtr driver, @@ -49,7 +50,7 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver, int qemuPrepareHostUSBDevices(virQEMUDriverPtr driver, virDomainDefPtr def, - bool coldBoot); + unsigned int flags); int qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver, const char *name, virDomainHostdevDefPtr *hostdevs, @@ -57,7 +58,6 @@ int qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver, int qemuPrepareHostDevices(virQEMUDriverPtr driver, virDomainDefPtr def, virQEMUCapsPtr qemuCaps, - bool coldBoot, unsigned int flags); void qemuDomainReAttachHostUsbDevices(virQEMUDriverPtr driver, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 47ecfe4..3fbe4d1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3688,8 +3688,10 @@ int qemuProcessStart(virConnectPtr conn, VIR_DEBUG("Preparing host devices"); if (!cfg->relaxedACS) hostdev_flags |= VIR_STRICT_ACS_CHECK; + if (!migrateFrom) + hostdev_flags |= VIR_COLD_BOOT; if (qemuPrepareHostDevices(driver, vm->def, priv->qemuCaps, - !migrateFrom, hostdev_flags) < 0) + hostdev_flags) < 0) goto cleanup; VIR_DEBUG("Preparing chr devices"); -- 1.6.0.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list