]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
test_driver: Pass virt_type to virNodeDeviceDefParse() in testNodeDeviceCreateXML()
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 17 Jul 2023 14:17:19 +0000 (16:17 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 19 Jul 2023 11:09:11 +0000 (13:09 +0200)
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@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/test/test_driver.c
src/util/virrandom.c

index e7fce053b464329dd85d03afc4a20a60a56141eb..3767908d9d329fa6db7aa9386b2f949b122e03e2 100644 (file)
@@ -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
index 58f86d5a00d6c6a7781fde3b78312aa3342f35c1..f719af35f6c2c7e3074409fc55bda282692e9744 100644 (file)
@@ -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
@@ -148,6 +149,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"));