[PATCH 0/4] Add support for MSDM ACPI table type

This was requested by KubeVirt in https://gitlab.com/libvirt/libvirt/-/issues/748 I've not functionally tested this, since I lack any suitable guest windows environment this is looking for MSDM tables, nor does my machine have MSDM ACPI tables to pass to a guest. I'm blindly assuming that the QEMU CLI code is identical except for s/SLIC/MSDM/. Also I'm pretty unhappy about the situation with the Xen driver support. This is pre-existing, and IMHO should never have been added as it exists today, as it allows arbitrary passthrough of *any* set of ACPI tables, as opposed to a single type of the specific type listed in the XML. This should have been handled with a different XML syntax, but with stuck with this undesirable approach now, so I've kept it as is. Daniel P. Berrangé (4): conf: introduce support for multiple ACPI tables src: validate permitted ACPI table types in libxl/qemu drivers conf: support MSDM ACPI table type qemu: support MSDM ACPI table type docs/formatdomain.rst | 4 +- src/conf/domain_conf.c | 88 ++++++++++++++----- src/conf/domain_conf.h | 22 ++++- src/conf/schemas/domaincommon.rng | 5 +- src/libvirt_private.syms | 2 + src/libxl/libxl_conf.c | 8 +- src/libxl/libxl_domain.c | 21 +++++ src/libxl/xen_xl.c | 22 ++++- src/qemu/qemu_command.c | 14 ++- src/qemu/qemu_validate.c | 16 ++++ src/security/security_dac.c | 18 ++-- src/security/security_selinux.c | 16 ++-- src/security/virt-aa-helper.c | 5 +- .../acpi-table-many.x86_64-latest.args | 34 +++++++ .../acpi-table-many.x86_64-latest.xml | 39 ++++++++ tests/qemuxmlconfdata/acpi-table-many.xml | 31 +++++++ tests/qemuxmlconftest.c | 1 + 17 files changed, 296 insertions(+), 50 deletions(-) create mode 100644 tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.xml create mode 100644 tests/qemuxmlconfdata/acpi-table-many.xml -- 2.47.1

Currently we parse <os> <acpi> <table type="slic">...path...</table> </acpi> </os> into a flat 'char *slic_table' field which is rather an anti-pattern as it has special cased a single attribute type. This rewrites the internal design to permit multiple table types to be parsed, should we add more in future. Each type is permitted to only appear once. The Xen code is fairly dubious in its use of 'slic_table' to hold Xen's 'acpi_firmware' config option, as IIUC Xen's config is not limited to accepting a single table per file. It takes a concatenation of all data and ought to be represented as such. This is left for a future contributor to solve. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/conf/domain_conf.c | 87 +++++++++++++++++++++++++-------- src/conf/domain_conf.h | 21 +++++++- src/libxl/libxl_conf.c | 8 ++- src/libxl/xen_xl.c | 22 +++++++-- src/qemu/qemu_command.c | 13 +++-- src/security/security_dac.c | 18 ++++--- src/security/security_selinux.c | 16 +++--- src/security/virt-aa-helper.c | 5 +- 8 files changed, 143 insertions(+), 47 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 49555efc56..04fb893587 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1457,6 +1457,11 @@ VIR_ENUM_IMPL(virDomainOsDefFirmwareFeature, "secure-boot", ); +VIR_ENUM_IMPL(virDomainOsACPITable, + VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST, + "slic", +); + VIR_ENUM_IMPL(virDomainCFPC, VIR_DOMAIN_CFPC_LAST, "none", @@ -3899,6 +3904,15 @@ virDomainSecDefFree(virDomainSecDef *def) g_free(def); } +void virDomainOSACPITableDefFree(virDomainOSACPITableDef *def) +{ + if (!def) + return; + g_free(def->path); + g_free(def); +} + + static void virDomainOSDefClear(virDomainOSDef *os) { @@ -3924,7 +3938,9 @@ virDomainOSDefClear(virDomainOSDef *os) g_free(os->cmdline); g_free(os->dtb); g_free(os->root); - g_free(os->slic_table); + for (i = 0; i < os->nacpiTables; i++) + virDomainOSACPITableDefFree(os->acpiTables[i]); + g_free(os->acpiTables); virDomainLoaderDefFree(os->loader); g_free(os->bootloader); g_free(os->bootloaderArgs); @@ -17873,40 +17889,64 @@ virDomainDefParseBootAcpiOptions(virDomainDef *def, int n; g_autofree xmlNodePtr *nodes = NULL; g_autofree char *tmp = NULL; + size_t ntables = 0; + virDomainOSACPITableDef **tables = NULL; + size_t i; + size_t j; if ((n = virXPathNodeSet("./os/acpi/table", ctxt, &nodes)) < 0) return -1; - if (n > 1) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Only one acpi table is supported")); - return -1; - } - - if (n == 1) { - tmp = virXMLPropString(nodes[0], "type"); + for (i = 0; i < n; i++) { + int type; + tmp = virXMLPropString(nodes[i], "type"); if (!tmp) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing acpi table type")); - return -1; + goto error; } - if (STREQ_NULLABLE(tmp, "slic")) { - VIR_FREE(tmp); - if (!(tmp = virXMLNodeContentString(nodes[0]))) - return -1; - - def->os.slic_table = virFileSanitizePath(tmp); - } else { + if ((type = virDomainOsACPITableTypeFromString(tmp)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Unknown acpi table type: %1$s"), tmp); - return -1; + goto error; } + + for (j = 0; j < i; j++) { + if (tables[j]->type == type) { + virReportError(VIR_ERR_XML_ERROR, + _("ACPI table type '%1$s' may only appear once"), + tmp); + goto error; + } + } + + VIR_FREE(tmp); + if (!(tmp = virXMLNodeContentString(nodes[i]))) + goto error; + + tables = g_renew(virDomainOSACPITableDef *, tables, ntables + 1); + tables[ntables] = g_new0(virDomainOSACPITableDef, 1); + tables[ntables]->type = type; + tables[ntables]->path = virFileSanitizePath(tmp); + ntables++; + + VIR_FREE(tmp); } + def->os.nacpiTables = ntables; + def->os.acpiTables = tables; + return 0; + + error: + for (i = 0; i < ntables; i++) { + virDomainOSACPITableDefFree(tables[i]); + } + g_free(tables); + return -1; } @@ -28490,11 +28530,16 @@ virDomainDefFormatInternalSetRootName(virDomainDef *def, def->os.dtb); virBufferEscapeString(buf, "<root>%s</root>\n", def->os.root); - if (def->os.slic_table) { + + if (def->os.nacpiTables) { virBufferAddLit(buf, "<acpi>\n"); virBufferAdjustIndent(buf, 2); - virBufferEscapeString(buf, "<table type='slic'>%s</table>\n", - def->os.slic_table); + for (i = 0; i < def->os.nacpiTables; i++) { + virBufferAsprintf(buf, "<table type='%s'>", + virDomainOsACPITableTypeToString(def->os.acpiTables[i]->type)); + virBufferEscapeString(buf, "%s</table>\n", + def->os.acpiTables[i]->path); + } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</acpi>\n"); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9da6586e66..7735cce325 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2474,6 +2474,24 @@ typedef enum { VIR_ENUM_DECL(virDomainOsDefFirmwareFeature); +typedef enum { + VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC, + + VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST +} virDomainOsACPITable; + +VIR_ENUM_DECL(virDomainOsACPITable); + +struct _virDomainOSACPITableDef { + int type; + char *path; +}; + +typedef struct _virDomainOSACPITableDef virDomainOSACPITableDef; +void virDomainOSACPITableDefFree(virDomainOSACPITableDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainOSACPITableDef, virDomainOSACPITableDefFree); + + struct _virDomainOSDef { int type; virDomainOsDefFirmware firmware; @@ -2496,7 +2514,8 @@ struct _virDomainOSDef { char *cmdline; char *dtb; char *root; - char *slic_table; + size_t nacpiTables; + virDomainOSACPITableDef **acpiTables; virDomainLoaderDef *loader; char *bootloader; char *bootloaderArgs; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index c404226e43..7fa1decd67 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -583,7 +583,13 @@ libxlMakeDomBuildInfo(virDomainDef *def, #endif /* copy SLIC table path to acpi_firmware */ - b_info->u.hvm.acpi_firmware = g_strdup(def->os.slic_table); + for (i = 0; i < def->os.nacpiTables; i++) { + if (def->os.acpiTables[i]->type != VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC) + continue; + + b_info->u.hvm.acpi_firmware = g_strdup(def->os.acpiTables[i]->path); + break; + } if (def->nsounds > 0) { /* diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 53f6871efc..a9f41f9ee2 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -106,6 +106,7 @@ xenParseXLOS(virConf *conf, virDomainDef *def, virCaps *caps) g_autofree char *bios = NULL; g_autofree char *bios_path = NULL; g_autofree char *boot = NULL; + g_autofree char *slic = NULL; int val = 0; if (xenConfigGetString(conf, "bios", &bios, NULL) < 0) @@ -133,8 +134,15 @@ xenParseXLOS(virConf *conf, virDomainDef *def, virCaps *caps) } } - if (xenConfigCopyStringOpt(conf, "acpi_firmware", &def->os.slic_table) < 0) + if (xenConfigCopyStringOpt(conf, "acpi_firmware", &slic) < 0) return -1; + if (slic != NULL) { + def->os.nacpiTables = 1; + def->os.acpiTables = g_new0(virDomainOSACPITableDef *, 1); + def->os.acpiTables[0] = g_new0(virDomainOSACPITableDef, 1); + def->os.acpiTables[0]->type = VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC; + def->os.acpiTables[0]->path = g_steal_pointer(&slic); + } if (xenConfigCopyStringOpt(conf, "kernel", &def->os.kernel) < 0) return -1; @@ -1134,9 +1142,15 @@ xenFormatXLOS(virConf *conf, virDomainDef *def) return -1; } - if (def->os.slic_table && - xenConfigSetString(conf, "acpi_firmware", def->os.slic_table) < 0) - return -1; + for (i = 0; i < def->os.nacpiTables; i++) { + if (def->os.acpiTables[i]->type != VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC) + continue; + + if (xenConfigSetString(conf, "acpi_firmware", + def->os.acpiTables[i]->path) < 0) + return -1; + break; + } if (def->os.kernel && xenConfigSetString(conf, "kernel", def->os.kernel) < 0) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 54130ac4f0..1153d8e095 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -127,6 +127,11 @@ VIR_ENUM_IMPL(qemuNumaPolicy, "restrictive", ); +VIR_ENUM_DECL(qemuACPITableSIG); +VIR_ENUM_IMPL(qemuACPITableSIG, + VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST, + "SLIC"); + const char * qemuAudioDriverTypeToString(virDomainAudioType type) @@ -5995,6 +6000,7 @@ qemuBuildBootCommandLine(virCommand *cmd, { g_auto(virBuffer) boot_buf = VIR_BUFFER_INITIALIZER; g_autofree char *boot_opts_str = NULL; + size_t i; if (def->os.bootmenu) { if (def->os.bootmenu == VIR_TRISTATE_BOOL_YES) @@ -6028,11 +6034,12 @@ qemuBuildBootCommandLine(virCommand *cmd, virCommandAddArgList(cmd, "-append", def->os.cmdline, NULL); if (def->os.dtb) virCommandAddArgList(cmd, "-dtb", def->os.dtb, NULL); - if (def->os.slic_table) { + for (i = 0; i < def->os.nacpiTables; i++) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; virCommandAddArg(cmd, "-acpitable"); - virBufferAddLit(&buf, "sig=SLIC,file="); - virQEMUBuildBufferEscapeComma(&buf, def->os.slic_table); + virBufferAsprintf(&buf, "sig=%s,file=", + qemuACPITableSIGTypeToString(def->os.acpiTables[i]->type)); + virQEMUBuildBufferEscapeComma(&buf, def->os.acpiTables[i]->path); virCommandAddArgBuffer(cmd, &buf); } diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 0505f4e4a3..b4d61bc576 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -2050,9 +2050,10 @@ virSecurityDACRestoreAllLabel(virSecurityManager *mgr, virSecurityDACRestoreFileLabel(mgr, def->os.dtb) < 0) rc = -1; - if (def->os.slic_table && - virSecurityDACRestoreFileLabel(mgr, def->os.slic_table) < 0) - rc = -1; + for (i = 0; i < def->os.nacpiTables; i++) { + if (virSecurityDACRestoreFileLabel(mgr, def->os.acpiTables[i]->path) < 0) + rc = -1; + } if (def->pstore && virSecurityDACRestoreFileLabel(mgr, def->pstore->path) < 0) @@ -2300,11 +2301,12 @@ virSecurityDACSetAllLabel(virSecurityManager *mgr, user, group, true) < 0) return -1; - if (def->os.slic_table && - virSecurityDACSetOwnership(mgr, NULL, - def->os.slic_table, - user, group, true) < 0) - return -1; + for (i = 0; i < def->os.nacpiTables; i++) { + if (virSecurityDACSetOwnership(mgr, NULL, + def->os.acpiTables[i]->path, + user, group, true) < 0) + return -1; + } if (def->pstore && virSecurityDACSetOwnership(mgr, NULL, diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index cdc32d9b34..b8659e33d6 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -3013,9 +3013,10 @@ virSecuritySELinuxRestoreAllLabel(virSecurityManager *mgr, virSecuritySELinuxRestoreFileLabel(mgr, def->os.dtb, true) < 0) rc = -1; - if (def->os.slic_table && - virSecuritySELinuxRestoreFileLabel(mgr, def->os.slic_table, true) < 0) - rc = -1; + for (i = 0; i < def->os.nacpiTables; i++) { + if (virSecuritySELinuxRestoreFileLabel(mgr, def->os.acpiTables[i]->path, true) < 0) + rc = -1; + } if (def->pstore && virSecuritySELinuxRestoreFileLabel(mgr, def->pstore->path, true) < 0) @@ -3443,10 +3444,11 @@ virSecuritySELinuxSetAllLabel(virSecurityManager *mgr, data->content_context, true) < 0) return -1; - if (def->os.slic_table && - virSecuritySELinuxSetFilecon(mgr, def->os.slic_table, - data->content_context, true) < 0) - return -1; + for (i = 0; i < def->os.nacpiTables; i++) { + if (virSecuritySELinuxSetFilecon(mgr, def->os.acpiTables[i]->path, + data->content_context, true) < 0) + return -1; + } if (def->pstore && virSecuritySELinuxSetFilecon(mgr, def->pstore->path, diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 1626d5a89c..939478a625 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -974,9 +974,10 @@ get_files(vahControl * ctl) if (vah_add_file(&buf, ctl->def->os.dtb, "r") != 0) goto cleanup; - if (ctl->def->os.slic_table) - if (vah_add_file(&buf, ctl->def->os.slic_table, "r") != 0) + for (i = 0; i < def->os.nacpiTables; i++) { + if (vah_add_file(&buf, ctl->def->os.acpiTables[i]->path, "r") != 0) goto cleanup; + } if (ctl->def->pstore) if (vah_add_file(&buf, ctl->def->pstore->path, "rw") != 0) -- 2.47.1

On 2/18/25 19:12, Daniel P. Berrangé wrote:
Currently we parse
<os> <acpi> <table type="slic">...path...</table> </acpi> </os>
into a flat 'char *slic_table' field which is rather an anti-pattern as it has special cased a single attribute type.
This rewrites the internal design to permit multiple table types to be parsed, should we add more in future. Each type is permitted to only appear once.
The Xen code is fairly dubious in its use of 'slic_table' to hold Xen's 'acpi_firmware' config option, as IIUC Xen's config is not limited to accepting a single table per file. It takes a concatenation of all data and ought to be represented as such. This is left for a future contributor to solve.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/conf/domain_conf.c | 87 +++++++++++++++++++++++++-------- src/conf/domain_conf.h | 21 +++++++- src/libxl/libxl_conf.c | 8 ++- src/libxl/xen_xl.c | 22 +++++++-- src/qemu/qemu_command.c | 13 +++-- src/security/security_dac.c | 18 ++++--- src/security/security_selinux.c | 16 +++--- src/security/virt-aa-helper.c | 5 +- 8 files changed, 143 insertions(+), 47 deletions(-)
Please consider squashing in the following: diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 04fb893587..69e9255494 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17888,29 +17888,30 @@ virDomainDefParseBootAcpiOptions(virDomainDef *def, { int n; g_autofree xmlNodePtr *nodes = NULL; - g_autofree char *tmp = NULL; size_t ntables = 0; virDomainOSACPITableDef **tables = NULL; size_t i; - size_t j; if ((n = virXPathNodeSet("./os/acpi/table", ctxt, &nodes)) < 0) return -1; + if (n == 0) + return 0; + + tables = g_new0(virDomainOSACPITableDef *, n); + for (i = 0; i < n; i++) { - int type; - tmp = virXMLPropString(nodes[i], "type"); + g_autofree char *path = virXMLNodeContentString(nodes[i]); + virDomainOsACPITable type; + size_t j; - if (!tmp) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing acpi table type")); + if (!path) goto error; - } - if ((type = virDomainOsACPITableTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Unknown acpi table type: %1$s"), - tmp); + if (virXMLPropEnum(nodes[i], "type", + virDomainOsACPITableTypeFromString, + VIR_XML_PROP_REQUIRED, + &type) < 0) { goto error; } @@ -17918,22 +17919,15 @@ virDomainDefParseBootAcpiOptions(virDomainDef *def, if (tables[j]->type == type) { virReportError(VIR_ERR_XML_ERROR, _("ACPI table type '%1$s' may only appear once"), - tmp); + virDomainOsACPITableTypeToString(type)); goto error; } } - VIR_FREE(tmp); - if (!(tmp = virXMLNodeContentString(nodes[i]))) - goto error; - - tables = g_renew(virDomainOSACPITableDef *, tables, ntables + 1); tables[ntables] = g_new0(virDomainOSACPITableDef, 1); tables[ntables]->type = type; - tables[ntables]->path = virFileSanitizePath(tmp); + tables[ntables]->path = virFileSanitizePath(path); ntables++; - - VIR_FREE(tmp); } def->os.nacpiTables = ntables; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7735cce325..e5b0c42171 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2483,7 +2483,7 @@ typedef enum { VIR_ENUM_DECL(virDomainOsACPITable); struct _virDomainOSACPITableDef { - int type; + virDomainOsACPITable type; char *path; }; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 30a9f806f0..db8c29ec1d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -611,6 +611,8 @@ virDomainObjTaint; virDomainObjUpdateModificationImpact; virDomainObjWait; virDomainObjWaitUntil; +virDomainOsACPITableTypeFromString; +virDomainOsACPITableTypeToString; virDomainOsDefFirmwareTypeFromString; virDomainOsDefFirmwareTypeToString; virDomainOSTypeFromString; diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 939478a625..23de0be9db 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -974,7 +974,7 @@ get_files(vahControl * ctl) if (vah_add_file(&buf, ctl->def->os.dtb, "r") != 0) goto cleanup; - for (i = 0; i < def->os.nacpiTables; i++) { + for (i = 0; i < ctl->def->os.nacpiTables; i++) { if (vah_add_file(&buf, ctl->def->os.acpiTables[i]->path, "r") != 0) goto cleanup; } Michal

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/libxl/libxl_domain.c | 14 ++++++++++++++ src/qemu/qemu_validate.c | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 6805160923..816ed2f349 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -306,6 +306,7 @@ libxlDomainDefValidate(const virDomainDef *def, libxlDriverPrivate *driver = opaque; g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver); bool reqSecureBoot = false; + size_t i; if (!virCapabilitiesDomainSupported(cfg->caps, def->os.type, def->os.arch, @@ -330,6 +331,19 @@ libxlDomainDefValidate(const virDomainDef *def, return -1; } + for (i = 0; i < def->os.nacpiTables; i++) { + switch ((virDomainOsACPITable)def->os.acpiTables[i]->type) { + case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: + break; + + default: + case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST: + virReportEnumRangeError(virDomainOsACPITable, + def->os.acpiTables[i]->type); + return -1; + } + } + if (def->nsounds > 0) { virDomainSoundDef *snd = def->sounds[0]; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 3e3e368da3..039f5f84e6 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -701,6 +701,8 @@ static int qemuValidateDomainDefBoot(const virDomainDef *def, virQEMUCaps *qemuCaps) { + size_t i; + if (def->os.bootloader || def->os.bootloaderArgs) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("bootloader is not supported by QEMU")); @@ -740,6 +742,19 @@ qemuValidateDomainDefBoot(const virDomainDef *def, return -1; } + for (i = 0; i < def->os.nacpiTables; i++) { + switch ((virDomainOsACPITable)def->os.acpiTables[i]->type) { + case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: + break; + + default: + case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST: + virReportEnumRangeError(virDomainOsACPITable, + def->os.acpiTables[i]->type); + return -1; + } + } + return 0; } -- 2.47.1

On 2/18/25 19:12, Daniel P. Berrangé wrote:
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/libxl/libxl_domain.c | 14 ++++++++++++++ src/qemu/qemu_validate.c | 15 +++++++++++++++ 2 files changed, 29 insertions(+)
Please consider squashing in the following: diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 816ed2f349..0eb414d20d 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -332,7 +332,7 @@ libxlDomainDefValidate(const virDomainDef *def, } for (i = 0; i < def->os.nacpiTables; i++) { - switch ((virDomainOsACPITable)def->os.acpiTables[i]->type) { + switch (def->os.acpiTables[i]->type) { case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: break; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 039f5f84e6..3744252284 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -743,7 +743,7 @@ qemuValidateDomainDefBoot(const virDomainDef *def, } for (i = 0; i < def->os.nacpiTables; i++) { - switch ((virDomainOsACPITable)def->os.acpiTables[i]->type) { + switch (def->os.acpiTables[i]->type) { case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: break; Michal

On Wed, Feb 19, 2025 at 04:57:07PM +0100, Michal Prívozník wrote:
On 2/18/25 19:12, Daniel P. Berrangé wrote:
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/libxl/libxl_domain.c | 14 ++++++++++++++ src/qemu/qemu_validate.c | 15 +++++++++++++++ 2 files changed, 29 insertions(+)
Please consider squashing in the following:
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 816ed2f349..0eb414d20d 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -332,7 +332,7 @@ libxlDomainDefValidate(const virDomainDef *def, }
for (i = 0; i < def->os.nacpiTables; i++) { - switch ((virDomainOsACPITable)def->os.acpiTables[i]->type) { + switch (def->os.acpiTables[i]->type) { case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: break;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 039f5f84e6..3744252284 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -743,7 +743,7 @@ qemuValidateDomainDefBoot(const virDomainDef *def, }
for (i = 0; i < def->os.nacpiTables; i++) { - switch ((virDomainOsACPITable)def->os.acpiTables[i]->type) { + switch (def->os.acpiTables[i]->type) { case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: break;
Why do that ? This means we won't get warned to double check validation when adding new constants. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 2/19/25 17:01, Daniel P. Berrangé wrote:
On Wed, Feb 19, 2025 at 04:57:07PM +0100, Michal Prívozník wrote:
On 2/18/25 19:12, Daniel P. Berrangé wrote:
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/libxl/libxl_domain.c | 14 ++++++++++++++ src/qemu/qemu_validate.c | 15 +++++++++++++++ 2 files changed, 29 insertions(+)
Please consider squashing in the following:
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 816ed2f349..0eb414d20d 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -332,7 +332,7 @@ libxlDomainDefValidate(const virDomainDef *def, }
for (i = 0; i < def->os.nacpiTables; i++) { - switch ((virDomainOsACPITable)def->os.acpiTables[i]->type) { + switch (def->os.acpiTables[i]->type) { case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: break;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 039f5f84e6..3744252284 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -743,7 +743,7 @@ qemuValidateDomainDefBoot(const virDomainDef *def, }
for (i = 0; i < def->os.nacpiTables; i++) { - switch ((virDomainOsACPITable)def->os.acpiTables[i]->type) { + switch (def->os.acpiTables[i]->type) { case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: break;
Why do that ? This means we won't get warned to double check validation when adding new constants.
We will since in the previous patch I've suggested to turn ->type into its proper enum type instead of int. Michal

The MSDM ACPI table is a replacement for the SLIC table type, now preferred by Microsoft for Windows Licensing checks: https://learn.microsoft.com/en-us/previous-versions/windows/hardware/design/...) Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- docs/formatdomain.rst | 4 ++-- src/conf/domain_conf.c | 1 + src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 5 ++++- src/libvirt_private.syms | 2 ++ src/libxl/libxl_domain.c | 7 +++++++ src/qemu/qemu_validate.c | 7 +++++++ 7 files changed, 24 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 381bf84f67..81dfd310ae 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -485,8 +485,8 @@ These options apply to any form of booting of the guest OS. ``acpi`` The ``table`` element contains a fully-qualified path to the ACPI table. The - ``type`` attribute contains the ACPI table type (currently only ``slic`` is - supported) :since:`Since 1.3.5 (QEMU)` :since:`Since 5.9.0 (Xen)` + ``type`` attribute contains the ACPI table type: ``slic`` (:since:`Since 1.3.5 (QEMU)` + :since:`Since 5.9.0 (Xen)`, ``msdm``. SMBIOS System Information diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 04fb893587..e0f9ad3123 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1460,6 +1460,7 @@ VIR_ENUM_IMPL(virDomainOsDefFirmwareFeature, VIR_ENUM_IMPL(virDomainOsACPITable, VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST, "slic", + "msdm", ); VIR_ENUM_IMPL(virDomainCFPC, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7735cce325..d84da21cca 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2476,6 +2476,7 @@ VIR_ENUM_DECL(virDomainOsDefFirmwareFeature); typedef enum { VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC, + VIR_DOMAIN_OS_ACPI_TABLE_TYPE_MSDM, VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST } virDomainOsACPITable; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 3328a63205..9bae953295 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -7191,7 +7191,10 @@ <zeroOrMore> <element name="table"> <attribute name="type"> - <value>slic</value> + <choice> + <value>slic</value> + <value>msdm</value> + </choice> </attribute> <ref name="absFilePath"/> </element> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 30a9f806f0..db8c29ec1d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -611,6 +611,8 @@ virDomainObjTaint; virDomainObjUpdateModificationImpact; virDomainObjWait; virDomainObjWaitUntil; +virDomainOsACPITableTypeFromString; +virDomainOsACPITableTypeToString; virDomainOsDefFirmwareTypeFromString; virDomainOsDefFirmwareTypeToString; virDomainOSTypeFromString; diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 816ed2f349..5fb85931f4 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -336,6 +336,13 @@ libxlDomainDefValidate(const virDomainDef *def, case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: break; + case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_MSDM: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("ACPI table '%1$s' not supported"), + virDomainOsACPITableTypeToString( + def->os.acpiTables[i]->type)); + return -1; + default: case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST: virReportEnumRangeError(virDomainOsACPITable, diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 039f5f84e6..0b3efcd700 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -747,6 +747,13 @@ qemuValidateDomainDefBoot(const virDomainDef *def, case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: break; + case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_MSDM: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("ACPI table '%1$s' not supported"), + virDomainOsACPITableTypeToString( + def->os.acpiTables[i]->type)); + return -1; + default: case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST: virReportEnumRangeError(virDomainOsACPITable, -- 2.47.1

On 2/18/25 19:12, Daniel P. Berrangé wrote:
The MSDM ACPI table is a replacement for the SLIC table type, now preferred by Microsoft for Windows Licensing checks:
https://learn.microsoft.com/en-us/previous-versions/windows/hardware/design/...)
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- docs/formatdomain.rst | 4 ++-- src/conf/domain_conf.c | 1 + src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 5 ++++- src/libvirt_private.syms | 2 ++ src/libxl/libxl_domain.c | 7 +++++++ src/qemu/qemu_validate.c | 7 +++++++ 7 files changed, 24 insertions(+), 3 deletions(-)
Please consider squashing in the following: diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 81dfd310ae..ae46b6e88d 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -485,8 +485,9 @@ These options apply to any form of booting of the guest OS. ``acpi`` The ``table`` element contains a fully-qualified path to the ACPI table. The - ``type`` attribute contains the ACPI table type: ``slic`` (:since:`Since 1.3.5 (QEMU)` - :since:`Since 5.9.0 (Xen)`, ``msdm``. + ``type`` attribute contains the ACPI table type: ``slic`` (:since:`Since + 1.3.5 (QEMU)` :since:`Since 5.9.0 (Xen)`, ``msdm`` (:since:`Since 11.1.0 + (QEMU)`) SMBIOS System Information diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 416edd4a06..497a1a8382 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -339,8 +339,7 @@ libxlDomainDefValidate(const virDomainDef *def, case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_MSDM: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("ACPI table '%1$s' not supported"), - virDomainOsACPITableTypeToString( - def->os.acpiTables[i]->type)); + virDomainOsACPITableTypeToString(def->os.acpiTables[i]->type)); return -1; default: diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1153d8e095..485b82f853 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -130,7 +130,8 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_ENUM_DECL(qemuACPITableSIG); VIR_ENUM_IMPL(qemuACPITableSIG, VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST, - "SLIC"); + "SLIC", + "MSDM"); const char * diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 1389d4db6f..ba376f1279 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -750,8 +750,7 @@ qemuValidateDomainDefBoot(const virDomainDef *def, case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_MSDM: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("ACPI table '%1$s' not supported"), - virDomainOsACPITableTypeToString( - def->os.acpiTables[i]->type)); + virDomainOsACPITableTypeToString(def->os.acpiTables[i]->type)); return -1; default: Michal

The MSDM ACPI table is a replacement for the SLIC table type, now preferred by Microsoft for Windows Licensing checks: https://learn.microsoft.com/en-us/previous-versions/windows/hardware/design/...) Resolves: https://gitlab.com/libvirt/libvirt/-/issues/748 Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/qemu/qemu_command.c | 3 +- src/qemu/qemu_validate.c | 8 +--- .../acpi-table-many.x86_64-latest.args | 34 ++++++++++++++++ .../acpi-table-many.x86_64-latest.xml | 39 +++++++++++++++++++ tests/qemuxmlconfdata/acpi-table-many.xml | 31 +++++++++++++++ tests/qemuxmlconftest.c | 1 + 6 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.xml create mode 100644 tests/qemuxmlconfdata/acpi-table-many.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1153d8e095..485b82f853 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -130,7 +130,8 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_ENUM_DECL(qemuACPITableSIG); VIR_ENUM_IMPL(qemuACPITableSIG, VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST, - "SLIC"); + "SLIC", + "MSDM"); const char * diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 0b3efcd700..42f9b14f25 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -745,14 +745,8 @@ qemuValidateDomainDefBoot(const virDomainDef *def, for (i = 0; i < def->os.nacpiTables; i++) { switch ((virDomainOsACPITable)def->os.acpiTables[i]->type) { case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_SLIC: - break; - case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_MSDM: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("ACPI table '%1$s' not supported"), - virDomainOsACPITableTypeToString( - def->os.acpiTables[i]->type)); - return -1; + break; default: case VIR_DOMAIN_OS_ACPI_TABLE_TYPE_LAST: diff --git a/tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.args b/tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.args new file mode 100644 index 0000000000..a4d4f4b53d --- /dev/null +++ b/tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.args @@ -0,0 +1,34 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=on \ +-accel tcg \ +-cpu qemu64 \ +-m size=219136k \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-boot strict=on \ +-acpitable sig=SLIC,file=/var/lib/libvirt/acpi/slic.dat \ +-acpitable sig=MSDM,file=/var/lib/libvirt/acpi/msdm.dat \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.xml b/tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.xml new file mode 100644 index 0000000000..7d42e377c9 --- /dev/null +++ b/tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.xml @@ -0,0 +1,39 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <acpi> + <table type='slic'>/var/lib/libvirt/acpi/slic.dat</table> + <table type='msdm'>/var/lib/libvirt/acpi/msdm.dat</table> + </acpi> + <boot dev='hd'/> + </os> + <features> + <acpi/> + </features> + <cpu mode='custom' match='exact' check='none'> + <model fallback='forbid'>qemu64</model> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' index='0' model='piix3-uhci'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <audio id='1' type='none'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxmlconfdata/acpi-table-many.xml b/tests/qemuxmlconfdata/acpi-table-many.xml new file mode 100644 index 0000000000..710f3131e1 --- /dev/null +++ b/tests/qemuxmlconfdata/acpi-table-many.xml @@ -0,0 +1,31 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='hd'/> + <acpi> + <table type='slic'>/var/lib/libvirt/acpi/slic.dat</table> + <table type='msdm'>/var/lib/libvirt/acpi/msdm.dat</table> + </acpi> + </os> + <features> + <acpi/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index c271170d25..9af0dfc3e9 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -2774,6 +2774,7 @@ mymain(void) DO_TEST_CAPS_LATEST_PARSE_ERROR("usb-too-long-port-path-invalid"); DO_TEST_CAPS_LATEST("acpi-table"); + DO_TEST_CAPS_LATEST("acpi-table-many"); DO_TEST_CAPS_LATEST("intel-iommu"); DO_TEST_CAPS_LATEST("intel-iommu-caching-mode"); -- 2.47.1

Hi, On Tue, Feb 18, 2025 at 06:12:49PM +0000, Daniel P. Berrangé wrote:
This was requested by KubeVirt in
https://gitlab.com/libvirt/libvirt/-/issues/748
I've not functionally tested this, since I lack any suitable guest windows environment this is looking for MSDM tables, nor does my machine have MSDM ACPI tables to pass to a guest.
I'm blindly assuming that the QEMU CLI code is identical except for s/SLIC/MSDM/.
I think it is the right assumption from what I see people using with the qemu:arg from qemu:commandline option in the thread: https://gist.github.com/Informatic/49bd034d43e054bd1d8d4fec38c305ec#file-dom...
Also I'm pretty unhappy about the situation with the Xen driver support. This is pre-existing, and IMHO should never have been added as it exists today, as it allows arbitrary passthrough of *any* set of ACPI tables, as opposed to a single type of the specific type listed in the XML. This should have been handled with a different XML syntax, but with stuck with this undesirable approach now, so I've kept it as is.
Daniel P. Berrangé (4): conf: introduce support for multiple ACPI tables src: validate permitted ACPI table types in libxl/qemu drivers conf: support MSDM ACPI table type qemu: support MSDM ACPI table type
docs/formatdomain.rst | 4 +- src/conf/domain_conf.c | 88 ++++++++++++++----- src/conf/domain_conf.h | 22 ++++- src/conf/schemas/domaincommon.rng | 5 +- src/libvirt_private.syms | 2 + src/libxl/libxl_conf.c | 8 +- src/libxl/libxl_domain.c | 21 +++++ src/libxl/xen_xl.c | 22 ++++- src/qemu/qemu_command.c | 14 ++- src/qemu/qemu_validate.c | 16 ++++ src/security/security_dac.c | 18 ++-- src/security/security_selinux.c | 16 ++-- src/security/virt-aa-helper.c | 5 +- .../acpi-table-many.x86_64-latest.args | 34 +++++++ .../acpi-table-many.x86_64-latest.xml | 39 ++++++++ tests/qemuxmlconfdata/acpi-table-many.xml | 31 +++++++ tests/qemuxmlconftest.c | 1 + 17 files changed, 296 insertions(+), 50 deletions(-) create mode 100644 tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.xml create mode 100644 tests/qemuxmlconfdata/acpi-table-many.xml
Cheers, Victor

On Tue, Feb 18, 2025 at 07:20:01PM +0100, Victor Toso wrote:
Hi,
On Tue, Feb 18, 2025 at 06:12:49PM +0000, Daniel P. Berrangé wrote:
This was requested by KubeVirt in
https://gitlab.com/libvirt/libvirt/-/issues/748
I've not functionally tested this, since I lack any suitable guest windows environment this is looking for MSDM tables, nor does my machine have MSDM ACPI tables to pass to a guest.
I'm blindly assuming that the QEMU CLI code is identical except for s/SLIC/MSDM/.
I think it is the right assumption from what I see people using with the qemu:arg from qemu:commandline option in the thread:
https://gist.github.com/Informatic/49bd034d43e054bd1d8d4fec38c305ec#file-dom...
Hmm, that's interesting in that they're not passing the 'sig' parameter to -acpitable at all. Reading the QEMU code it seems 'sig' is indeed optional, merely used to override the 'sig' that is embedded in the acpitable content loaded from the file. This is actually good, as it means we would not need to add XML syupport for every possible ACPI table type. We can just rely on the built-in default, which would also make it practical to reconcile the Xen problem below
Also I'm pretty unhappy about the situation with the Xen driver support. This is pre-existing, and IMHO should never have been added as it exists today, as it allows arbitrary passthrough of *any* set of ACPI tables, as opposed to a single type of the specific type listed in the XML. This should have been handled with a different XML syntax, but with stuck with this undesirable approach now, so I've kept it as is.
Daniel P. Berrangé (4): conf: introduce support for multiple ACPI tables src: validate permitted ACPI table types in libxl/qemu drivers conf: support MSDM ACPI table type qemu: support MSDM ACPI table type
docs/formatdomain.rst | 4 +- src/conf/domain_conf.c | 88 ++++++++++++++----- src/conf/domain_conf.h | 22 ++++- src/conf/schemas/domaincommon.rng | 5 +- src/libvirt_private.syms | 2 + src/libxl/libxl_conf.c | 8 +- src/libxl/libxl_domain.c | 21 +++++ src/libxl/xen_xl.c | 22 ++++- src/qemu/qemu_command.c | 14 ++- src/qemu/qemu_validate.c | 16 ++++ src/security/security_dac.c | 18 ++-- src/security/security_selinux.c | 16 ++-- src/security/virt-aa-helper.c | 5 +- .../acpi-table-many.x86_64-latest.args | 34 +++++++ .../acpi-table-many.x86_64-latest.xml | 39 ++++++++ tests/qemuxmlconfdata/acpi-table-many.xml | 31 +++++++ tests/qemuxmlconftest.c | 1 + 17 files changed, 296 insertions(+), 50 deletions(-) create mode 100644 tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.xml create mode 100644 tests/qemuxmlconfdata/acpi-table-many.xml
Cheers, Victor
With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 2/18/25 19:12, Daniel P. Berrangé wrote:
This was requested by KubeVirt in
https://gitlab.com/libvirt/libvirt/-/issues/748
I've not functionally tested this, since I lack any suitable guest windows environment this is looking for MSDM tables, nor does my machine have MSDM ACPI tables to pass to a guest.
I'm blindly assuming that the QEMU CLI code is identical except for s/SLIC/MSDM/.
Also I'm pretty unhappy about the situation with the Xen driver support. This is pre-existing, and IMHO should never have been added as it exists today, as it allows arbitrary passthrough of *any* set of ACPI tables, as opposed to a single type of the specific type listed in the XML. This should have been handled with a different XML syntax, but with stuck with this undesirable approach now, so I've kept it as is.
Daniel P. Berrangé (4): conf: introduce support for multiple ACPI tables src: validate permitted ACPI table types in libxl/qemu drivers conf: support MSDM ACPI table type qemu: support MSDM ACPI table type
docs/formatdomain.rst | 4 +- src/conf/domain_conf.c | 88 ++++++++++++++----- src/conf/domain_conf.h | 22 ++++- src/conf/schemas/domaincommon.rng | 5 +- src/libvirt_private.syms | 2 + src/libxl/libxl_conf.c | 8 +- src/libxl/libxl_domain.c | 21 +++++ src/libxl/xen_xl.c | 22 ++++- src/qemu/qemu_command.c | 14 ++- src/qemu/qemu_validate.c | 16 ++++ src/security/security_dac.c | 18 ++-- src/security/security_selinux.c | 16 ++-- src/security/virt-aa-helper.c | 5 +- .../acpi-table-many.x86_64-latest.args | 34 +++++++ .../acpi-table-many.x86_64-latest.xml | 39 ++++++++ tests/qemuxmlconfdata/acpi-table-many.xml | 31 +++++++ tests/qemuxmlconftest.c | 1 + 17 files changed, 296 insertions(+), 50 deletions(-) create mode 100644 tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/acpi-table-many.x86_64-latest.xml create mode 100644 tests/qemuxmlconfdata/acpi-table-many.xml
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> I even tested this successfully with the following MSDM table (which was reconstructed from various posts on stackoverflow and blog posts): $ hexdump -C msdm.bin 00000000 4d 53 44 4d 55 00 00 00 03 13 48 50 51 4f 45 4d |MSDMU.....HPQOEM| 00000010 53 4c 49 43 2d 4d 50 43 01 00 00 00 48 50 20 20 |SLIC-MPC....HP | 00000020 00 00 04 00 01 00 00 00 00 00 00 00 01 00 00 00 |................| 00000030 00 00 00 00 1d 00 00 00 41 42 43 44 45 2d 46 47 |........ABCDE-FG| 00000040 48 49 4a 2d 4b 4c 4d 4e 4f 2d 50 51 52 53 54 2d |HIJ-KLMNO-PQRST-| 00000050 55 56 57 58 59 |UVWXY| 00000055 Here ABCDE-... is the Windows key. Michal
participants (3)
-
Daniel P. Berrangé
-
Michal Prívozník
-
Victor Toso