[PATCH 4/5] test_driver: Pass virt_type to virNodeDeviceDefParse() in testNodeDeviceCreateXML()

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

 



This brings the code closer to real implementation:
nodeDeviceCreateXML(). For the unique OUI, let's take the value
from tests/virrandommock.c: 100000.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/test/test_driver.c | 7 +++++--
 src/util/virrandom.c   | 3 +++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index e7fce053b4..3767908d9d 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -7685,11 +7685,14 @@ testNodeDeviceCreateXML(virConnectPtr conn,
     g_autofree char *wwnn = NULL;
     g_autofree char *wwpn = NULL;
     bool validate = flags & VIR_NODE_DEVICE_CREATE_XML_VALIDATE;
+    const char *virt_type;
 
     virCheckFlags(VIR_NODE_DEVICE_CREATE_XML_VALIDATE, NULL);
 
-    if (!(def = virNodeDeviceDefParse(xmlDesc, NULL, CREATE_DEVICE, NULL, NULL,
-                                      NULL, validate)))
+    virt_type = virConnectGetType(conn);
+
+    if (!(def = virNodeDeviceDefParse(xmlDesc, NULL, CREATE_DEVICE, virt_type,
+                                      NULL, NULL, validate)))
         goto cleanup;
 
     /* We run this simply for validation - it essentially validates that
diff --git a/src/util/virrandom.c b/src/util/virrandom.c
index 38fcfbc6ba..11f3a94611 100644
--- a/src/util/virrandom.c
+++ b/src/util/virrandom.c
@@ -124,6 +124,7 @@ virRandomBytes(unsigned char *buf,
 #define VMWARE_OUI "000569"
 #define MICROSOFT_OUI "0050f2"
 #define XEN_OUI "00163e"
+#define TEST_DRIVER_OUI "100000"
 
 
 int
@@ -154,6 +155,8 @@ virRandomGenerateWWN(char **wwn,
         oui = VMWARE_OUI;
     } else if (STREQ(virt_type, "HYPER-V")) {
         oui = MICROSOFT_OUI;
+    } else if (STREQ(virt_type, "TEST")) {
+        oui = TEST_DRIVER_OUI;
     } else {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Unsupported virt type"));
-- 
2.41.0




[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