[PATCH v2 26/39] qemu: prepare NVMe devices too

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
ACKed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 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 ebbca817b8..5ab0217858 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -96,13 +96,28 @@ qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver,
 }
 
 
+int
+qemuHostdevUpdateActiveNVMeDisks(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 (qemuHostdevUpdateActiveNVMeDisks(driver, def) < 0)
+        return -1;
+
     if (qemuHostdevUpdateActivePCIDevices(driver, def) < 0)
         return -1;
 
@@ -197,6 +212,17 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs,
     return true;
 }
 
+int
+qemuHostdevPrepareNVMeDisks(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,
@@ -313,9 +339,12 @@ qemuHostdevPrepareDomainDevices(virQEMUDriverPtr driver,
                                 virQEMUCapsPtr qemuCaps,
                                 unsigned int flags)
 {
-    if (!def->nhostdevs)
+    if (!def->nhostdevs && !def->ndisks)
         return 0;
 
+    if (qemuHostdevPrepareNVMeDisks(driver, def->name, def->disks, def->ndisks) < 0)
+        return -1;
+
     if (qemuHostdevPreparePCIDevices(driver, def->name, def->uuid,
                                      def->hostdevs, def->nhostdevs,
                                      qemuCaps, flags) < 0)
@@ -340,6 +369,17 @@ qemuHostdevPrepareDomainDevices(virQEMUDriverPtr driver,
     return 0;
 }
 
+void
+qemuHostdevReAttachNVMeDisks(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,
@@ -419,9 +459,12 @@ void
 qemuHostdevReAttachDomainDevices(virQEMUDriverPtr driver,
                                  virDomainDefPtr def)
 {
-    if (!def->nhostdevs)
+    if (!def->nhostdevs && !def->ndisks)
         return;
 
+    qemuHostdevReAttachNVMeDisks(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 536069fe8a..735414b6aa 100644
--- a/src/qemu/qemu_hostdev.h
+++ b/src/qemu/qemu_hostdev.h
@@ -28,6 +28,8 @@ bool qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev);
 
 bool qemuHostdevHostSupportsPassthroughVFIO(void);
 
+int qemuHostdevUpdateActiveNVMeDisks(virQEMUDriverPtr driver,
+                                     virDomainDefPtr def);
 int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver,
                                            virDomainDefPtr def);
 int qemuHostdevUpdateActivePCIDevices(virQEMUDriverPtr driver,
@@ -39,6 +41,10 @@ int qemuHostdevUpdateActiveSCSIDevices(virQEMUDriverPtr driver,
 int qemuHostdevUpdateActiveDomainDevices(virQEMUDriverPtr driver,
                                          virDomainDefPtr def);
 
+int qemuHostdevPrepareNVMeDisks(virQEMUDriverPtr driver,
+                                const char *name,
+                                virDomainDiskDefPtr *disks,
+                                size_t ndisks);
 int qemuHostdevPreparePCIDevices(virQEMUDriverPtr driver,
                                  const char *name,
                                  const unsigned char *uuid,
@@ -68,6 +74,10 @@ int qemuHostdevPrepareDomainDevices(virQEMUDriverPtr driver,
                                     virQEMUCapsPtr qemuCaps,
                                     unsigned int flags);
 
+void qemuHostdevReAttachNVMeDisks(virQEMUDriverPtr driver,
+                                  const char *name,
+                                  virDomainDiskDefPtr *disks,
+                                  size_t ndisks);
 void qemuHostdevReAttachPCIDevices(virQEMUDriverPtr driver,
                                    const char *name,
                                    virDomainHostdevDefPtr *hostdevs,
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux