test_driver: Pass virt_type to virNodeDeviceDefParse() in testNodeDeviceCreateXML()

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>
This commit is contained in:
Michal Privoznik 2023-07-17 16:17:19 +02:00
parent b857ad0696
commit ae7df11377
2 changed files with 8 additions and 2 deletions

View 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

View 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"));