Nothing special going on here. Resolves: https://issues.redhat.com/browse/RHEL-24746 Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/qemu/qemu_alias.c | 10 ++++ src/qemu/qemu_command.c | 51 +++++++++++++++++++ .../pstore-acpi-erst.x86_64-latest.args | 2 + 3 files changed, 63 insertions(+) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 872d940595..3e6bced4a8 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -658,6 +658,14 @@ qemuAssignDeviceCryptoAlias(virDomainDef *def, } +static void +qemuAssignDevicePstoreAlias(virDomainPstoreDef *pstore) +{ + if (!pstore->info.alias) + pstore->info.alias = g_strdup("pstore0"); +} + + int qemuAssignDeviceAliases(virDomainDef *def) { @@ -747,6 +755,8 @@ qemuAssignDeviceAliases(virDomainDef *def) for (i = 0; i < def->ncryptos; i++) { qemuAssignDeviceCryptoAlias(def, def->cryptos[i]); } + if (def->pstore) + qemuAssignDevicePstoreAlias(def->pstore); return 0; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index def124cc27..f15e6bda1e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10341,6 +10341,53 @@ qemuBuildCryptoCommandLine(virCommand *cmd, } +static int +qemuBuildPstoreCommandLine(virCommand *cmd, + const virDomainDef *def, + virDomainPstoreDef *pstore, + virQEMUCaps *qemuCaps) +{ + g_autoptr(virJSONValue) devProps = NULL; + g_autoptr(virJSONValue) memProps = NULL; + g_autofree char *memAlias = NULL; + + if (!pstore->info.alias) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("pstore device is missing alias")); + return -1; + } + + memAlias = g_strdup_printf("mem%s", pstore->info.alias); + + if (qemuMonitorCreateObjectProps(&memProps, + "memory-backend-file", + memAlias, + "s:mem-path", pstore->path, + "U:size", pstore->size * 1024, + "b:share", true, + NULL) < 0) { + return -1; + } + + if (virJSONValueObjectAdd(&devProps, + "s:driver", "acpi-erst", + "s:id", pstore->info.alias, + "s:memdev", memAlias, + NULL) < 0) { + return -1; + } + + if (qemuBuildDeviceAddressProps(devProps, def, &pstore->info) < 0) + return -1; + + if (qemuBuildObjectCommandlineFromJSON(cmd, memProps, qemuCaps) < 0 || + qemuBuildDeviceCommandlineFromJSON(cmd, devProps, def, qemuCaps) < 0) + return -1; + + return 0; +} + + static int qemuBuildAsyncTeardownCommandLine(virCommand *cmd, const virDomainDef *def, @@ -10699,6 +10746,10 @@ qemuBuildCommandLine(virDomainObj *vm, if (qemuBuildCryptoCommandLine(cmd, def, qemuCaps) < 0) return NULL; + if (def->pstore && + qemuBuildPstoreCommandLine(cmd, def, def->pstore, qemuCaps) < 0) + return NULL; + if (qemuBuildAsyncTeardownCommandLine(cmd, def, qemuCaps) < 0) return NULL; diff --git a/tests/qemuxmlconfdata/pstore-acpi-erst.x86_64-latest.args b/tests/qemuxmlconfdata/pstore-acpi-erst.x86_64-latest.args index d7c4708acb..2e217f6c83 100644 --- a/tests/qemuxmlconfdata/pstore-acpi-erst.x86_64-latest.args +++ b/tests/qemuxmlconfdata/pstore-acpi-erst.x86_64-latest.args @@ -33,4 +33,6 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config \ -global ICH9-LPC.noreboot=off \ -watchdog-action reset \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-object '{"qom-type":"memory-backend-file","id":"mempstore0","mem-path":"/tmp/guest_acpi_esrt","size":8192,"share":true}' \ +-device '{"driver":"acpi-erst","id":"pstore0","memdev":"mempstore0","bus":"pci.2","addr":"0x1"}' \ -msg timestamp=on -- 2.44.2