[PATCH 03/20] domain_driver.c: use PCI address with virDomainDriverNodeDeviceGetPCIInfo()

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

 



Instead of receiving 4 uints in order and write domain/bus/slot/function,
receive a virPCIDeviceAddressPtr instead and write into it.

This change will allow us to simplify the API for virPCIDeviceNew()
in the next patch.

Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 src/hypervisor/domain_driver.c | 13 +++++--------
 src/hypervisor/domain_driver.h |  5 +----
 src/libxl/libxl_driver.c       | 18 +++++++++---------
 src/qemu/qemu_driver.c         | 18 +++++++++---------
 4 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c
index 68dbf10ac6..cdb53bcf3e 100644
--- a/src/hypervisor/domain_driver.c
+++ b/src/hypervisor/domain_driver.c
@@ -341,20 +341,17 @@ virDomainDriverSetupPersistentDefBlkioParams(virDomainDefPtr persistentDef,
 
 int
 virDomainDriverNodeDeviceGetPCIInfo(virNodeDeviceDefPtr def,
-                                    unsigned *domain,
-                                    unsigned *bus,
-                                    unsigned *slot,
-                                    unsigned *function)
+                                    virPCIDeviceAddressPtr devAddr)
 {
     virNodeDevCapsDefPtr cap;
 
     cap = def->caps;
     while (cap) {
         if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
-            *domain   = cap->data.pci_dev.domain;
-            *bus      = cap->data.pci_dev.bus;
-            *slot     = cap->data.pci_dev.slot;
-            *function = cap->data.pci_dev.function;
+            devAddr->domain = cap->data.pci_dev.domain;
+            devAddr->bus = cap->data.pci_dev.bus;
+            devAddr->slot = cap->data.pci_dev.slot;
+            devAddr->function = cap->data.pci_dev.function;
             break;
         }
 
diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h
index 2bb053d559..86b92d0284 100644
--- a/src/hypervisor/domain_driver.h
+++ b/src/hypervisor/domain_driver.h
@@ -48,7 +48,4 @@ int virDomainDriverSetupPersistentDefBlkioParams(virDomainDefPtr persistentDef,
                                                  int nparams);
 
 int virDomainDriverNodeDeviceGetPCIInfo(virNodeDeviceDefPtr def,
-                                        unsigned *domain,
-                                        unsigned *bus,
-                                        unsigned *slot,
-                                        unsigned *function);
+                                        virPCIDeviceAddressPtr devAddr);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ac2564a563..691cecb1e9 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -5786,7 +5786,7 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
                            unsigned int flags)
 {
     virPCIDevicePtr pci = NULL;
-    unsigned domain = 0, bus = 0, slot = 0, function = 0;
+    virPCIDeviceAddress devAddr;
     int ret = -1;
     virNodeDeviceDefPtr def = NULL;
     char *xml = NULL;
@@ -5821,10 +5821,10 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
     if (virNodeDeviceDetachFlagsEnsureACL(dev->conn, def) < 0)
         goto cleanup;
 
-    if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
+    if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
         goto cleanup;
 
-    pci = virPCIDeviceNew(domain, bus, slot, function);
+    pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
     if (!pci)
         goto cleanup;
 
@@ -5859,7 +5859,7 @@ static int
 libxlNodeDeviceReAttach(virNodeDevicePtr dev)
 {
     virPCIDevicePtr pci = NULL;
-    unsigned domain = 0, bus = 0, slot = 0, function = 0;
+    virPCIDeviceAddress devAddr;
     int ret = -1;
     virNodeDeviceDefPtr def = NULL;
     char *xml = NULL;
@@ -5892,10 +5892,10 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev)
     if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
         goto cleanup;
 
-    if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
+    if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
         goto cleanup;
 
-    pci = virPCIDeviceNew(domain, bus, slot, function);
+    pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
     if (!pci)
         goto cleanup;
 
@@ -5917,7 +5917,7 @@ static int
 libxlNodeDeviceReset(virNodeDevicePtr dev)
 {
     virPCIDevicePtr pci = NULL;
-    unsigned domain = 0, bus = 0, slot = 0, function = 0;
+    virPCIDeviceAddress devAddr;
     int ret = -1;
     virNodeDeviceDefPtr def = NULL;
     char *xml = NULL;
@@ -5950,10 +5950,10 @@ libxlNodeDeviceReset(virNodeDevicePtr dev)
     if (virNodeDeviceResetEnsureACL(dev->conn, def) < 0)
         goto cleanup;
 
-    if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
+    if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
         goto cleanup;
 
-    pci = virPCIDeviceNew(domain, bus, slot, function);
+    pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
     if (!pci)
         goto cleanup;
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6c09d95164..8c59a5e589 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11958,7 +11958,7 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
 {
     virQEMUDriverPtr driver = dev->conn->privateData;
     virPCIDevicePtr pci = NULL;
-    unsigned domain = 0, bus = 0, slot = 0, function = 0;
+    virPCIDeviceAddress devAddr;
     int ret = -1;
     virNodeDeviceDefPtr def = NULL;
     g_autofree char *xml = NULL;
@@ -11993,10 +11993,10 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
     if (virNodeDeviceDetachFlagsEnsureACL(dev->conn, def) < 0)
         goto cleanup;
 
-    if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
+    if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
         goto cleanup;
 
-    pci = virPCIDeviceNew(domain, bus, slot, function);
+    pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
     if (!pci)
         goto cleanup;
 
@@ -12042,7 +12042,7 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
 {
     virQEMUDriverPtr driver = dev->conn->privateData;
     virPCIDevicePtr pci = NULL;
-    unsigned domain = 0, bus = 0, slot = 0, function = 0;
+    virPCIDeviceAddress devAddr;
     int ret = -1;
     virNodeDeviceDefPtr def = NULL;
     g_autofree char *xml = NULL;
@@ -12074,10 +12074,10 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
     if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
         goto cleanup;
 
-    if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
+    if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
         goto cleanup;
 
-    pci = virPCIDeviceNew(domain, bus, slot, function);
+    pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
     if (!pci)
         goto cleanup;
 
@@ -12096,7 +12096,7 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
 {
     virQEMUDriverPtr driver = dev->conn->privateData;
     virPCIDevicePtr pci;
-    unsigned domain = 0, bus = 0, slot = 0, function = 0;
+    virPCIDeviceAddress devAddr;
     int ret = -1;
     virNodeDeviceDefPtr def = NULL;
     g_autofree char *xml = NULL;
@@ -12128,10 +12128,10 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
     if (virNodeDeviceResetEnsureACL(dev->conn, def) < 0)
         goto cleanup;
 
-    if (virDomainDriverNodeDeviceGetPCIInfo(def, &domain, &bus, &slot, &function) < 0)
+    if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0)
         goto cleanup;
 
-    pci = virPCIDeviceNew(domain, bus, slot, function);
+    pci = virPCIDeviceNew(devAddr.domain, devAddr.bus, devAddr.slot, devAddr.function);
     if (!pci)
         goto cleanup;
 
-- 
2.26.2




[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