On 04/03/2026 03.59, [email protected] wrote:
From: Jared Rossi <[email protected]>
The loadparm is required on s390x to pass the information to the boot loader
such as which kernel should be started or whether the boot menu should be shown.
Because PCI devices do not naturally allocate space for this, the property is
added on an architecture specific basis for supported device types.
Signed-off-by: Jared Rossi <[email protected]>
---
hw/pci/pci.c | 38 +++++++++++++++++++++++++++++++++++++
hw/s390x/ipl.c | 11 +++++++++--
hw/virtio/virtio-blk-pci.c | 1 +
include/hw/pci/pci.h | 1 +
include/hw/pci/pci_device.h | 3 +++
5 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 90d6d71efd..04559f8312 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -36,6 +36,7 @@
#include "migration/qemu-file-types.h"
#include "migration/vmstate.h"
#include "net/net.h"
+#include "system/arch_init.h"
#include "system/numa.h"
#include "system/runstate.h"
#include "system/system.h"
@@ -2845,6 +2846,43 @@ int pci_qdev_find_device(const char *id, PCIDevice
**pdev)
return rc;
}
+static char *pci_qdev_property_get_loadparm(Object *obj, Error **errp)
+{
+ return g_strdup(PCI_DEVICE(obj)->loadparm);
+}
+
+static void pci_qdev_property_set_loadparm(Object *obj, const char *value,
+ Error **errp)
+{
+ void *lp_str;
+
+ if (object_property_get_int(obj, "bootindex", NULL) < 0) {
+ error_setg(errp, "'loadparm' is only valid for boot devices");
+ return;
+ }
+
+ lp_str = g_malloc0(strlen(value) + 1);
+ if (!qdev_prop_sanitize_s390x_loadparm(lp_str, value, errp)) {
+ g_free(lp_str);
+ return;
+ }
+ PCI_DEVICE(obj)->loadparm = lp_str;
+}
+
+void pci_qdev_property_add_specifics(DeviceClass *dc)
+{
+ ObjectClass *oc = OBJECT_CLASS(dc);
+
+ /* The loadparm property is only supported on s390x */
+ if (qemu_arch_available(QEMU_ARCH_S390X)) {
Philippe replaced qemu_arch_available(QEMU_ARCH_S390X) with target_s390x()
in commit 1afc7da7dbc3f4c3b8cf310ff30a08f6f02587c8 ... I guess it's better
to do the same here now, too?
With that changed:
Reviewed-by: Thomas Huth <[email protected]>