diff mbox series

[v2,1/2] conf: nodedev: Don't refresh host caps in testdriver

Message ID ecc49e6d73b4b57e5f131469815a5a0c79869cd8.1531259066.git.crobinso@redhat.com
State New
Headers show
Series test: Implement virConnectListAllNodeDevices | expand

Commit Message

Cole Robinson July 10, 2018, 9:46 p.m. UTC
Add a 'skipUpdateCaps' bool that we set for test_driver.c nodedevs
which will skip accessing host resources via virNodeDeviceUpdateCaps

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/conf/virnodedeviceobj.c | 13 ++++++++++++-
 src/conf/virnodedeviceobj.h |  4 ++++
 src/test/test_driver.c      |  2 ++
 3 files changed, 18 insertions(+), 1 deletion(-)

-- 
2.17.1

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

Comments

Erik Skultety July 13, 2018, 10:47 a.m. UTC | #1
On Tue, Jul 10, 2018 at 05:46:01PM -0400, Cole Robinson wrote:
> Add a 'skipUpdateCaps' bool that we set for test_driver.c nodedevs

> which will skip accessing host resources via virNodeDeviceUpdateCaps

>

> Signed-off-by: Cole Robinson <crobinso@redhat.com>

>


...

> @@ -5565,6 +5566,7 @@ testNodeDeviceMockCreateVport(testDriverPtr driver,

>          goto cleanup;

>      def = NULL;

>      objdef = virNodeDeviceObjGetDef(obj);

> +    virNodeDeviceObjSetSkipUpdateCaps(obj, true);


I'd probably move this 2 lines up, but I don't really care.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 13e9a17518..6c04caf6ab 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -37,6 +37,8 @@  struct _virNodeDeviceObj {
     virObjectLockable parent;
 
     virNodeDeviceDefPtr def;            /* device definition */
+    bool skipUpdateCaps;                /* whether to skip checking host caps,
+                                           used by testdriver */
 };
 
 struct _virNodeDeviceObjList {
@@ -806,7 +808,8 @@  virNodeDeviceMatch(virNodeDeviceObjPtr obj,
                    unsigned int flags)
 {
     /* Refresh the capabilities first, e.g. due to a driver change */
-    if (virNodeDeviceUpdateCaps(obj->def) < 0)
+    if (!obj->skipUpdateCaps &&
+        virNodeDeviceUpdateCaps(obj->def) < 0)
         return false;
 
     /* filter by cap type */
@@ -915,3 +918,11 @@  virNodeDeviceObjListExport(virConnectPtr conn,
     virObjectListFree(data.devices);
     return -1;
 }
+
+
+void
+virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObjPtr obj,
+                                  bool skipUpdateCaps)
+{
+    obj->skipUpdateCaps = skipUpdateCaps;
+}
diff --git a/src/conf/virnodedeviceobj.h b/src/conf/virnodedeviceobj.h
index 87f9083696..ffbe4e32e5 100644
--- a/src/conf/virnodedeviceobj.h
+++ b/src/conf/virnodedeviceobj.h
@@ -109,4 +109,8 @@  virNodeDeviceObjListExport(virConnectPtr conn,
                            virNodeDeviceObjListFilter filter,
                            unsigned int flags);
 
+void
+virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObjPtr obj,
+                                  bool skipUpdateCaps);
+
 #endif /* __VIRNODEDEVICEOBJ_H__ */
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 951d9c4151..7374c83eaa 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1165,6 +1165,7 @@  testParseNodedevs(testDriverPtr privconn,
             goto error;
         }
 
+        virNodeDeviceObjSetSkipUpdateCaps(obj, true);
         virNodeDeviceObjEndAPI(&obj);
     }
 
@@ -5565,6 +5566,7 @@  testNodeDeviceMockCreateVport(testDriverPtr driver,
         goto cleanup;
     def = NULL;
     objdef = virNodeDeviceObjGetDef(obj);
+    virNodeDeviceObjSetSkipUpdateCaps(obj, true);
 
     event = virNodeDeviceEventLifecycleNew(objdef->name,
                                            VIR_NODE_DEVICE_EVENT_CREATED,