From: Andrea Righi Date: Sat, 6 Sep 2025 13:08:58 +0000 (+0200) Subject: conf: Add nodeset attribute to the element X-Git-Tag: v11.8.0-rc1~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=82754082768e4acb075cc58d2515c743726c1221;p=thirdparty%2Flibvirt.git conf: Add nodeset attribute to the element This enables partitioning of PCI devices into multiple isolated instances, each requiring a dedicated virtual NUMA node definition. Link: https://mail.gnu.org/archive/html/qemu-arm/2024-03/msg00358.html Reviewed-by: Daniel P. Berrangé Signed-off-by: Andrea Righi --- diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index f840efc1b5..d08de68717 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -137,6 +137,7 @@ virDomainDeviceInfoClear(virDomainDeviceInfo *info) info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; VIR_FREE(info->romfile); VIR_FREE(info->loadparm); + virBitmapFree(info->acpiNodeset); info->isolationGroup = 0; info->isolationGroupLocked = false; } diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 2d97410f6e..e570f51824 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -185,6 +185,9 @@ struct _virDomainDeviceInfo { * cases we might want to prevent that from happening by * locking the isolation group */ bool isolationGroupLocked; + + /* NUMA nodeset affinity for this device */ + virBitmap *acpiNodeset; }; int virDeviceHostdevPCIDriverInfoParseXML(xmlNodePtr node, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7766e302ec..8c0bf63925 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5558,8 +5558,20 @@ virDomainDeviceInfoFormat(virBuffer *buf, virBufferAddLit(buf, "/>\n"); } - if (info->acpiIndex != 0) - virBufferAsprintf(buf, "\n", info->acpiIndex); + if (info->acpiIndex != 0 || info->acpiNodeset) { + virBufferAddLit(buf, "acpiIndex != 0) + virBufferAsprintf(buf, " index='%u'", info->acpiIndex); + + if (info->acpiNodeset) { + g_autofree char *nodeset = virBitmapFormat(info->acpiNodeset); + if (nodeset) + virBufferAsprintf(buf, " nodeset='%s'", nodeset); + } + + virBufferAddLit(buf, "/>\n"); + } if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) @@ -5884,9 +5896,23 @@ virDomainDeviceInfoParseXML(virDomainXMLOption *xmlopt, } if ((acpi = virXPathNode("./acpi", ctxt))) { + g_autofree char *nodeset = NULL; + if (virXMLPropUInt(acpi, "index", 10, VIR_XML_PROP_NONZERO, &info->acpiIndex) < 0) goto cleanup; + + if ((nodeset = virXMLPropString(acpi, "nodeset"))) { + if (virBitmapParse(nodeset, &info->acpiNodeset, + VIR_DOMAIN_CPUMASK_LEN) < 0) + goto cleanup; + + if (virBitmapIsAllClear(info->acpiNodeset)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid value of 'nodeset': %1$s"), nodeset); + goto cleanup; + } + } } if ((address = virXPathNode("./address", ctxt)) && diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index e369fb6e81..298afe0b7c 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -7454,6 +7454,11 @@ + + + + +