qemu: Build cmd line for pstore device

Nothing special going on here.

Resolves: https://issues.redhat.com/browse/RHEL-24746
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
This commit is contained in:
Michal Privoznik 2024-06-05 14:42:23 +02:00
parent 90e50e67c6
commit 3cfe4caa0a
3 changed files with 63 additions and 0 deletions

View File

@ -658,6 +658,14 @@ qemuAssignDeviceCryptoAlias(virDomainDef *def,
} }
static void
qemuAssignDevicePstoreAlias(virDomainPstoreDef *pstore)
{
if (!pstore->info.alias)
pstore->info.alias = g_strdup("pstore0");
}
int int
qemuAssignDeviceAliases(virDomainDef *def) qemuAssignDeviceAliases(virDomainDef *def)
{ {
@ -747,6 +755,8 @@ qemuAssignDeviceAliases(virDomainDef *def)
for (i = 0; i < def->ncryptos; i++) { for (i = 0; i < def->ncryptos; i++) {
qemuAssignDeviceCryptoAlias(def, def->cryptos[i]); qemuAssignDeviceCryptoAlias(def, def->cryptos[i]);
} }
if (def->pstore)
qemuAssignDevicePstoreAlias(def->pstore);
return 0; return 0;
} }

View File

@ -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 static int
qemuBuildAsyncTeardownCommandLine(virCommand *cmd, qemuBuildAsyncTeardownCommandLine(virCommand *cmd,
const virDomainDef *def, const virDomainDef *def,
@ -10699,6 +10746,10 @@ qemuBuildCommandLine(virDomainObj *vm,
if (qemuBuildCryptoCommandLine(cmd, def, qemuCaps) < 0) if (qemuBuildCryptoCommandLine(cmd, def, qemuCaps) < 0)
return NULL; return NULL;
if (def->pstore &&
qemuBuildPstoreCommandLine(cmd, def, def->pstore, qemuCaps) < 0)
return NULL;
if (qemuBuildAsyncTeardownCommandLine(cmd, def, qemuCaps) < 0) if (qemuBuildAsyncTeardownCommandLine(cmd, def, qemuCaps) < 0)
return NULL; return NULL;

View File

@ -33,4 +33,6 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config \
-global ICH9-LPC.noreboot=off \ -global ICH9-LPC.noreboot=off \
-watchdog-action reset \ -watchdog-action reset \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -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 -msg timestamp=on