Use the 'modelName' attribute for the pnv-phb4-root-port device. Let's also take this opportunity to adapt the virDomainControllerIsPowerNVRootPort() helper to also recognize pnv-phb4-root-port as a PowerNV root port. This will spare us from duplicating checks where the constraints of pnv-phb3-root-port also applies for the pnv-phb4-root-port device. Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> --- src/conf/domain_conf.c | 3 ++- src/qemu/qemu_domain_address.c | 14 +++++++++++++- src/qemu/qemu_validate.c | 6 ++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ca22d42f0a..c4d79548cf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2475,7 +2475,8 @@ virDomainControllerIsPowerNVRootPort(const virDomainControllerDef *cont) name = cont->opts.pciopts.modelName; - if (name != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB3_ROOT_PORT) + if ((name != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB3_ROOT_PORT) && + (name != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB4_ROOT_PORT)) return false; return true; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 5d65049c34..f8b5da8b55 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -2412,6 +2412,18 @@ qemuDomainAssignDevicePCISlots(virDomainDef *def, } +static virDomainControllerPCIModelName +virDomainControllerGetPowerNVRootPortName(virDomainDef *def) +{ + if (STREQ(def->os.machine, "powernv8")) + return VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB3_ROOT_PORT; + else if (STREQ(def->os.machine, "powernv9")) + return VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB4_ROOT_PORT; + + return VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE; +} + + static void qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDef *cont, virDomainDef *def, @@ -2435,7 +2447,7 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDef *cont, break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: if (qemuDomainIsPowerNV(def)) { - *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB3_ROOT_PORT; + *modelName = virDomainControllerGetPowerNVRootPortName(def); break; } diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index cfcad91499..e43c49a01a 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -3604,12 +3604,14 @@ qemuValidateDomainDeviceDefControllerPCI(const virDomainControllerDef *cont, case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: if (pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420 && pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT && - pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB3_ROOT_PORT) { + pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB3_ROOT_PORT && + pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB4_ROOT_PORT) { virReportControllerInvalidValue(cont, model, modelName, "modelName"); return -1; } - if (pciopts->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB3_ROOT_PORT && + if ((pciopts->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB3_ROOT_PORT || + pciopts->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PNV_PHB4_ROOT_PORT) && !qemuDomainIsPowerNV(def)) { virReportControllerInvalidValue(cont, model, modelName, "modelName"); return -1; -- 2.34.1