[PATCH 3/3] virpcitest: Introduce testVirPCIDeviceReattach

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

 



This test will reattach the PCI device detached in the previous test.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tests/virpcitest.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/tests/virpcitest.c b/tests/virpcitest.c
index 6740a5d..727cad2 100644
--- a/tests/virpcitest.c
+++ b/tests/virpcitest.c
@@ -104,6 +104,42 @@ cleanup:
 }
 
 static int
+testVirPCIDeviceReattach(const void *oaque ATTRIBUTE_UNUSED)
+{
+    int ret = -1;
+    virPCIDevicePtr dev;
+    virPCIDeviceListPtr activeDevs = NULL, inactiveDevs = NULL;
+    int count;
+
+    if (!(dev = virPCIDeviceNew(0, 0, 1, 0)) ||
+        !(activeDevs = virPCIDeviceListNew()) ||
+        !(inactiveDevs = virPCIDeviceListNew()))
+        goto cleanup;
+
+    if (virPCIDeviceListAdd(inactiveDevs, dev) < 0)
+        goto cleanup;
+
+    CHECK_LIST_COUNT(activeDevs, 0);
+    CHECK_LIST_COUNT(inactiveDevs, 1);
+
+    if (virPCIDeviceSetStubDriver(dev, "pci-stub") < 0)
+        goto cleanup;
+
+    if (virPCIDeviceReattach(dev, activeDevs, inactiveDevs) < 0)
+        goto cleanup;
+
+    CHECK_LIST_COUNT(activeDevs, 0);
+    CHECK_LIST_COUNT(inactiveDevs, 0);
+
+    dev = NULL;
+    ret = 0;
+cleanup:
+    virPCIDeviceFree(dev);
+    virObjectUnref(activeDevs);
+    virObjectUnref(inactiveDevs);
+    return ret;
+}
+static int
 mymain(void)
 {
     int ret = 0;
@@ -128,6 +164,7 @@ mymain(void)
 
     DO_TEST(testVirPCIDeviceNew);
     DO_TEST(testVirPCIDeviceDetach);
+    DO_TEST(testVirPCIDeviceReattach);
 
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
         virFileDeleteTree(fakesysfsdir);
-- 
1.8.1.5

--
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]