From 3d9e35b8375c295b9dbebae0f18bea32b8e3ac77 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 17 Jul 2023 15:05:11 +0200 Subject: [PATCH] virrandom: Accept "nodedev" driver in virRandomGenerateWWN() The virRandomGenerateWWN() is used solely by nodedev driver to autogenerate WWNN and WWNP when parsing a nodedev XML. Now, the idea was (at least during monolithic daemon) that depending on which hypervisor driver called the nodedev XML parsing (and virRandomGenerateWWN() under the hood) the corresponding OUI is used (e.g. "001a4a" for the QEMU driver). But in era of split daemons things are not that easy. We do not know which hypervisor driver called us. And there might be no hypervisor driver at all - users are allowed to connect to individual drivers directly (e.g. "nodedev:///system"). In this case, we can't use proper OUI. Well, do the next best thing: pick one (QUMRANET_OUI). Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/util/virrandom.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/virrandom.c b/src/util/virrandom.c index f719af35f6..11f3a94611 100644 --- a/src/util/virrandom.c +++ b/src/util/virrandom.c @@ -139,7 +139,13 @@ virRandomGenerateWWN(char **wwn, return -1; } - if (STREQ(virt_type, "QEMU")) { + /* In case of split daemon we don't really see the hypervisor + * driver that just re-routed the nodedev driver API. There + * might not be any hypervisor driver even. Yet, we have to + * pick OUI. Pick "QEMU". */ + + if (STREQ(virt_type, "QEMU") || + STREQ(virt_type, "nodedev")) { oui = QUMRANET_OUI; } else if (STREQ(virt_type, "Xen") || STREQ(virt_type, "xenlight")) {