From: Michal Privoznik <mprivozn@redhat.com> Currently, the VMX driver ignores SCSI controllers without disks plugged in (even though they are present in the .vmx file) and relies on post parse callback to fill them in (virDomainDefAddImplicitControllers()). Well, those controllers from the file are visible to the guest so add those to the domain definition instead. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vmx/vmx.c | 24 ++++++++++++++++++------ tests/vmx2xmldata/esx-in-the-wild-15.xml | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 25bfddbf68..8cb04f8490 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -594,7 +594,11 @@ virVMXParseSATAController(virDomainDef *def, virConf *conf, int controllerIdx, bool *present); -static int virVMXParseNVMEController(virConf *conf, int controller, bool *present); +static int +virVMXParseNVMEController(virDomainDef *def, + virConf *conf, + int controllerIdx, + bool *present); static int virVMXParseDisk(virVMXContext *ctx, virDomainXMLOption *xmlopt, virConf *conf, int device, int busType, int controllerOrBus, int unit, virDomainDiskDef **def, @@ -1885,7 +1889,7 @@ virVMXParseConfig(virVMXContext *ctx, /* def:disks (nvme) */ for (controller = 0; controller < 4; ++controller) { - if (virVMXParseNVMEController(conf, controller, &present) < 0) + if (virVMXParseNVMEController(def, conf, controller, &present) < 0) goto cleanup; if (!present) @@ -2268,22 +2272,30 @@ virVMXParseSATAController(virDomainDef *def, static int -virVMXParseNVMEController(virConf *conf, int controller, bool *present) +virVMXParseNVMEController(virDomainDef *def, + virConf *conf, + int controllerIdx, + bool *present) { char present_name[32]; - if (controller < 0 || controller > 3) { + if (controllerIdx < 0 || controllerIdx > 3) { virReportError(VIR_ERR_INTERNAL_ERROR, _("NVMe controller index %1$d out of [0..3] range"), - controller); + controllerIdx); return -1; } - g_snprintf(present_name, sizeof(present_name), "nvme%d.present", controller); + g_snprintf(present_name, sizeof(present_name), "nvme%d.present", controllerIdx); if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0) return -1; + if (!*present) + return 0; + + virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_NVME, + controllerIdx, -1); return 0; } diff --git a/tests/vmx2xmldata/esx-in-the-wild-15.xml b/tests/vmx2xmldata/esx-in-the-wild-15.xml index fb32a5aa59..cc4a9d1631 100644 --- a/tests/vmx2xmldata/esx-in-the-wild-15.xml +++ b/tests/vmx2xmldata/esx-in-the-wild-15.xml @@ -33,8 +33,8 @@ <target dev='nvme0n2' bus='nvme'/> <address type='drive' controller='0' bus='0' target='0' unit='1'/> </disk> - <controller type='ide' index='0'/> <controller type='nvme' index='0'/> + <controller type='ide' index='0'/> <interface type='bridge'> <mac address='00:50:56:83:c9:0c' type='generated'/> <source bridge='inside'/> -- 2.54.0