The qemu driver has its own wrappers around virHostdev module (so
that some arguments are filled in automatically). Extend these to
include NVMe devices too.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_hostdev.c | 49 ++++++++++++++++++++++++++++++++++++++---
src/qemu/qemu_hostdev.h | 10 +++++++++
2 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 92b037e1ed..efa4d62f1f 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -96,13 +96,28 @@ qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver,
}
+int
+qemuHostdevUpdateActiveNVMeDevices(virQEMUDriverPtr driver,
+ virDomainDefPtr def)
+{
+ return virHostdevUpdateActiveNVMeDevices(driver->hostdevMgr,
+ QEMU_DRIVER_NAME,
+ def->name,
+ def->disks,
+ def->ndisks);
+}
+
+
int
qemuHostdevUpdateActiveDomainDevices(virQEMUDriverPtr driver,
virDomainDefPtr def)
{
- if (!def->nhostdevs)
+ if (!def->nhostdevs && !def->ndisks)
return 0;
+ if (qemuHostdevUpdateActiveNVMeDevices(driver, def) < 0)
+ return -1;
+
if (qemuHostdevUpdateActivePCIDevices(driver, def) < 0)
return -1;
@@ -226,6 +241,17 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr
*hostdevs,
return true;
}
+int
+qemuHostdevPrepareNVMeDevices(virQEMUDriverPtr driver,
+ const char *name,
+ virDomainDiskDefPtr *disks,
+ size_t ndisks)
+{
+ return virHostdevPrepareNVMeDevices(driver->hostdevMgr,
+ QEMU_DRIVER_NAME,
+ name, disks, ndisks);
+}
+
int
qemuHostdevPreparePCIDevices(virQEMUDriverPtr driver,
const char *name,
@@ -342,9 +368,12 @@ qemuHostdevPrepareDomainDevices(virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps,
unsigned int flags)
{
- if (!def->nhostdevs)
+ if (!def->nhostdevs && !def->ndisks)
return 0;
+ if (qemuHostdevPrepareNVMeDevices(driver, def->name, def->disks,
def->ndisks) < 0)
+ return -1;
+
if (qemuHostdevPreparePCIDevices(driver, def->name, def->uuid,
def->hostdevs, def->nhostdevs,
qemuCaps, flags) < 0)
@@ -369,6 +398,17 @@ qemuHostdevPrepareDomainDevices(virQEMUDriverPtr driver,
return 0;
}
+void
+qemuHostdevReAttachNVMeDevices(virQEMUDriverPtr driver,
+ const char *name,
+ virDomainDiskDefPtr *disks,
+ size_t ndisks)
+{
+ virHostdevReAttachNVMeDevices(driver->hostdevMgr,
+ QEMU_DRIVER_NAME,
+ name, disks, ndisks);
+}
+
void
qemuHostdevReAttachPCIDevices(virQEMUDriverPtr driver,
const char *name,
@@ -448,9 +488,12 @@ void
qemuHostdevReAttachDomainDevices(virQEMUDriverPtr driver,
virDomainDefPtr def)
{
- if (!def->nhostdevs)
+ if (!def->nhostdevs && !def->ndisks)
return;
+ qemuHostdevReAttachNVMeDevices(driver, def->name, def->disks,
+ def->ndisks);
+
qemuHostdevReAttachPCIDevices(driver, def->name, def->hostdevs,
def->nhostdevs);
diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h
index f6d76c1c2a..4afb103354 100644
--- a/src/qemu/qemu_hostdev.h
+++ b/src/qemu/qemu_hostdev.h
@@ -27,6 +27,8 @@
bool qemuHostdevHostSupportsPassthroughLegacy(void);
bool qemuHostdevHostSupportsPassthroughVFIO(void);
+int qemuHostdevUpdateActiveNVMeDevices(virQEMUDriverPtr driver,
+ virDomainDefPtr def);
int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver,
virDomainDefPtr def);
int qemuHostdevUpdateActivePCIDevices(virQEMUDriverPtr driver,
@@ -38,6 +40,10 @@ int qemuHostdevUpdateActiveSCSIDevices(virQEMUDriverPtr driver,
int qemuHostdevUpdateActiveDomainDevices(virQEMUDriverPtr driver,
virDomainDefPtr def);
+int qemuHostdevPrepareNVMeDevices(virQEMUDriverPtr driver,
+ const char *name,
+ virDomainDiskDefPtr *disks,
+ size_t ndisks);
int qemuHostdevPreparePCIDevices(virQEMUDriverPtr driver,
const char *name,
const unsigned char *uuid,
@@ -67,6 +73,10 @@ int qemuHostdevPrepareDomainDevices(virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps,
unsigned int flags);
+void qemuHostdevReAttachNVMeDevices(virQEMUDriverPtr driver,
+ const char *name,
+ virDomainDiskDefPtr *disks,
+ size_t ndisks);
void qemuHostdevReAttachPCIDevices(virQEMUDriverPtr driver,
const char *name,
virDomainHostdevDefPtr *hostdevs,
--
2.21.0