All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init
@ 2026-11-05 19:49 Yonggang Luo
  2026-11-05 19:49 ` [PATCH v2 1/4] hw/pci: Avoid guard loadparm with target_s390x() for s390x " Yonggang Luo
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Yonggang Luo @ 2026-11-05 19:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Matthew Rosato, Michael S. Tsirkin,
	Paolo Bonzini, Edgar E. Iglesias, Eric Farman, Cornelia Huck,
	Philippe Mathieu-Daude, David Hildenbrand, Fam Zheng, qemu-s390x

With the multi-target work, the goal is to move to a single
unified QOM tree that applies universally across all targets.
This complements the migration away from instance level
properties to class level properties, which again aims to
ensure a fixed QOM object model for each class.

This requires that properties are either unconditionally
registered in the class, with invalid options rejected
at runtime (for example, during realize()), or that distinct
subclasses are used for specialized use cases that need a
distinct impl for some targets.

Also access target_big_endian is not allowed in class_init, so
we can default it to 'unspecified', then call target_big_endian
under realize()

v1: https://lore.kernel.org/qemu-devel/20261013200525.1340-1-luoyonggang@gmail.com/

Yonggang Luo (4):
  hw/pci: Avoid guard loadparm with target_s390x() for s390x in
    class_init
  hw/scsi: Avoid guard loadparm with target_s390x() for s390x in
    class_init
  hw/virtio/virtio-mem: Avoid call to target_info() in class_init
  hw/microblaze: defer PetaLogix endianness default until init

 hw/microblaze/petalogix_s3adsp1800_mmu.c | 11 ++++++++---
 hw/pci/pci.c                             | 18 ++++++++++--------
 hw/scsi/scsi-disk.c                      | 18 ++++++++++--------
 hw/virtio/virtio-mem.c                   | 12 +++++-------
 4 files changed, 33 insertions(+), 26 deletions(-)

-- 
2.55.0.windows.3



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/4] hw/pci: Avoid guard loadparm with target_s390x() for s390x in class_init
  2026-11-05 19:49 [PATCH v2 0/4] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init Yonggang Luo
@ 2026-11-05 19:49 ` Yonggang Luo
  2026-11-05 19:49 ` [PATCH v2 2/4] hw/scsi: " Yonggang Luo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Yonggang Luo @ 2026-11-05 19:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Matthew Rosato, Michael S. Tsirkin,
	Paolo Bonzini, Edgar E. Iglesias, Eric Farman, Cornelia Huck,
	Philippe Mathieu-Daude, David Hildenbrand, Fam Zheng, qemu-s390x

With the multi-target work, the goal is to move to a single
unified QOM tree that applies universally across all targets.
This complements the migration away from instance level
properties to class level properties, which again aims to
ensure a fixed QOM object model for each class.

This requires that properties are either unconditionally
registered in the class, with invalid options rejected
at runtime (for example, during realize()), or that distinct
subclasses are used for specialized use cases that need a
distinct impl for some targets.

It is harmless to have the 'loadparm' property registered
unconditionally so take the simple option.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 hw/pci/pci.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index d8b117799f..3204939469 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2889,6 +2889,11 @@ static void pci_qdev_property_set_loadparm(Object *obj, const char *value,
 {
     void *lp_str;
 
+    if (!target_s390x()) {
+        error_setg(errp, "'loadparm' is only supported on s390x");
+        return;
+    }
+
     if (object_property_get_int(obj, "bootindex", NULL) < 0) {
         error_setg(errp, "'loadparm' is only valid for boot devices");
         return;
@@ -2906,14 +2911,11 @@ void pci_qdev_property_add_specifics(DeviceClass *dc)
 {
     ObjectClass *oc = OBJECT_CLASS(dc);
 
-    /* The loadparm property is only supported on s390x */
-    if (target_s390x()) {
-        object_class_property_add_str(oc, "loadparm",
-                                      pci_qdev_property_get_loadparm,
-                                      pci_qdev_property_set_loadparm);
-        object_class_property_set_description(oc, "loadparm",
-                                              "load parameter (s390x only)");
-    }
+    object_class_property_add_str(oc, "loadparm",
+                                  pci_qdev_property_get_loadparm,
+                                  pci_qdev_property_set_loadparm);
+    object_class_property_set_description(oc, "loadparm",
+                                          "load parameter (s390x only)");
 }
 
 MemoryRegion *pci_address_space(PCIDevice *dev)
-- 
2.55.0.windows.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] hw/scsi: Avoid guard loadparm with target_s390x() for s390x in class_init
  2026-11-05 19:49 [PATCH v2 0/4] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init Yonggang Luo
  2026-11-05 19:49 ` [PATCH v2 1/4] hw/pci: Avoid guard loadparm with target_s390x() for s390x " Yonggang Luo
@ 2026-11-05 19:49 ` Yonggang Luo
  2026-11-05 19:49 ` [PATCH v2 3/4] hw/virtio/virtio-mem: Avoid call to target_info() " Yonggang Luo
  2026-11-05 19:49 ` [PATCH v2 4/4] hw/microblaze: defer PetaLogix endianness default until init Yonggang Luo
  3 siblings, 0 replies; 6+ messages in thread
From: Yonggang Luo @ 2026-11-05 19:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Matthew Rosato, Michael S. Tsirkin,
	Paolo Bonzini, Edgar E. Iglesias, Eric Farman, Cornelia Huck,
	Philippe Mathieu-Daude, David Hildenbrand, Fam Zheng, qemu-s390x

With the multi-target work, the goal is to move to a single
unified QOM tree that applies universally across all targets.
This complements the migration away from instance level
properties to class level properties, which again aims to
ensure a fixed QOM object model for each class.

This requires that properties are either unconditionally
registered in the class, with invalid options rejected
at runtime (for example, during realize()), or that distinct
subclasses are used for specialized use cases that need a
distinct impl for some targets.

It is harmless to have the 'loadparm' property registered
unconditionally so take the simple option.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 hw/scsi/scsi-disk.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index de2b6d85da..7fec5a74d1 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -3212,6 +3212,11 @@ static void scsi_property_set_loadparm(Object *obj, const char *value,
 {
     void *lp_str;
 
+    if (!target_s390x()) {
+        error_setg(errp, "'loadparm' is only supported on s390x");
+        return;
+    }
+
     if (object_property_get_int(obj, "bootindex", NULL) < 0) {
         error_setg(errp, "'loadparm' is only valid for boot devices");
         return;
@@ -3229,14 +3234,11 @@ static void scsi_property_add_specifics(DeviceClass *dc)
 {
     ObjectClass *oc = OBJECT_CLASS(dc);
 
-    /* The loadparm property is only supported on s390x */
-    if (target_s390x()) {
-        object_class_property_add_str(oc, "loadparm",
-                                      scsi_property_get_loadparm,
-                                      scsi_property_set_loadparm);
-        object_class_property_set_description(oc, "loadparm",
-                                              "load parameter (s390x only)");
-    }
+    object_class_property_add_str(oc, "loadparm",
+                                  scsi_property_get_loadparm,
+                                  scsi_property_set_loadparm);
+    object_class_property_set_description(oc, "loadparm",
+                                          "load parameter (s390x only)");
 }
 
 static void scsi_disk_base_class_initfn(ObjectClass *klass, const void *data)
-- 
2.55.0.windows.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] hw/virtio/virtio-mem: Avoid call to target_info() in class_init
  2026-11-05 19:49 [PATCH v2 0/4] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init Yonggang Luo
  2026-11-05 19:49 ` [PATCH v2 1/4] hw/pci: Avoid guard loadparm with target_s390x() for s390x " Yonggang Luo
  2026-11-05 19:49 ` [PATCH v2 2/4] hw/scsi: " Yonggang Luo
@ 2026-11-05 19:49 ` Yonggang Luo
  2026-11-05 19:49 ` [PATCH v2 4/4] hw/microblaze: defer PetaLogix endianness default until init Yonggang Luo
  3 siblings, 0 replies; 6+ messages in thread
From: Yonggang Luo @ 2026-11-05 19:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Matthew Rosato, Michael S. Tsirkin,
	Paolo Bonzini, Edgar E. Iglesias, Eric Farman, Cornelia Huck,
	Philippe Mathieu-Daude, David Hildenbrand, Fam Zheng, qemu-s390x

With the multi-target work, the goal is to move to a single
unified QOM tree that applies universally across all targets.
This complements the migration away from instance level
properties to class level properties, which again aims to
ensure a fixed QOM object model for each class.

This requires that properties are either unconditionally
registered in the class, with invalid options rejected
at runtime (for example, during realize()), or that distinct
subclasses are used for specialized use cases that need a
distinct impl for some targets.

It is harmless to have the "unplugged-inaccessible" property registered
unconditionally so take the simple option.

Done by merge virtio_mem_legacy_guests_properties into virtio_mem_properties.
And the rejection handled in virtio_mem_device_realize

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 hw/virtio/virtio-mem.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index 546ea18b7c..fb02958102 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -880,7 +880,11 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
             break;
         }
     } else {
-        vmem->unplugged_inaccessible = ON_OFF_AUTO_ON;
+        if (vmem->unplugged_inaccessible != ON_OFF_AUTO_ON) {
+            error_setg(errp, "'%s' must be 'on' on non-x86 targets",
+                       VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP);
+            return;
+        }
     }
 
     if (vmem->dynamic_memslots &&
@@ -1573,9 +1577,6 @@ static const Property virtio_mem_properties[] = {
                      early_migration, true),
     DEFINE_PROP_BOOL(VIRTIO_MEM_DYNAMIC_MEMSLOTS_PROP, VirtIOMEM,
                      dynamic_memslots, false),
-};
-
-static const Property virtio_mem_legacy_guests_properties[] = {
     DEFINE_PROP_ON_OFF_AUTO(VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP, VirtIOMEM,
                             unplugged_inaccessible, ON_OFF_AUTO_ON),
 };
@@ -1640,9 +1641,6 @@ static void virtio_mem_class_init(ObjectClass *klass, const void *data)
     RamDiscardSourceClass *rdsc = RAM_DISCARD_SOURCE_CLASS(klass);
 
     device_class_set_props(dc, virtio_mem_properties);
-    if (virtio_mem_has_legacy_guests()) {
-        device_class_set_props(dc, virtio_mem_legacy_guests_properties);
-    }
     dc->vmsd = &vmstate_virtio_mem;
 
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
-- 
2.55.0.windows.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] hw/microblaze: defer PetaLogix endianness default until init
  2026-11-05 19:49 [PATCH v2 0/4] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init Yonggang Luo
                   ` (2 preceding siblings ...)
  2026-11-05 19:49 ` [PATCH v2 3/4] hw/virtio/virtio-mem: Avoid call to target_info() " Yonggang Luo
@ 2026-11-05 19:49 ` Yonggang Luo
  2026-11-13 10:29   ` Daniel P. Berrangé
  3 siblings, 1 reply; 6+ messages in thread
From: Yonggang Luo @ 2026-11-05 19:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Matthew Rosato, Michael S. Tsirkin,
	Paolo Bonzini, Edgar E. Iglesias, Eric Farman, Cornelia Huck,
	Philippe Mathieu-Daude, David Hildenbrand, Fam Zheng, qemu-s390x

The PetaLogix machine read its endianness default from
target_big_endian() in class_init. In a multi-target binary the target
is not selected yet at class_init, so the default cannot be computed
there. Set the property default to "unspecified" instead, and resolve
it to big or little in petalogix_s3adsp1800_init(), where the target is
known.

Until the machine is initialized, endianness reads back as
"unspecified" rather than big or little.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 hw/microblaze/petalogix_s3adsp1800_mmu.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index 4ad04801ce..27f5e477a3 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -84,7 +84,13 @@ petalogix_s3adsp1800_init(MachineState *machine)
     MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
     qemu_irq irq[32];
     MemoryRegion *sysmem = get_system_memory();
-    EndianMode endianness = psms->endianness;
+    EndianMode endianness;
+
+    if (psms->endianness == ENDIAN_MODE_UNSPECIFIED) {
+        psms->endianness = target_big_endian() ? ENDIAN_MODE_BIG :
+                                                 ENDIAN_MODE_LITTLE;
+    }
+    endianness = psms->endianness;
 
     cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
     object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort);
@@ -179,8 +185,7 @@ static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc,
                                           &EndianMode_type_info,
                                           machine_get_endianness,
                                           machine_set_endianness);
-    object_property_set_default_str(prop, target_big_endian() ? "big"
-                                                              : "little");
+    object_property_set_default_str(prop, "unspecified");
     object_class_property_set_description(oc, "endianness",
             "Defines whether the machine runs in big or little endian mode");
 }
-- 
2.55.0.windows.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 4/4] hw/microblaze: defer PetaLogix endianness default until init
  2026-11-05 19:49 ` [PATCH v2 4/4] hw/microblaze: defer PetaLogix endianness default until init Yonggang Luo
@ 2026-11-13 10:29   ` Daniel P. Berrangé
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2026-11-13 10:29 UTC (permalink / raw)
  To: Yonggang Luo
  Cc: qemu-devel, Pierrick Bouvier, Matthew Rosato, Michael S. Tsirkin,
	Paolo Bonzini, Edgar E. Iglesias, Eric Farman, Cornelia Huck,
	Philippe Mathieu-Daude, David Hildenbrand, Fam Zheng, qemu-s390x

On Fri, Nov 06, 2026 at 03:49:57AM +0800, Yonggang Luo wrote:
> The PetaLogix machine read its endianness default from
> target_big_endian() in class_init. In a multi-target binary the target
> is not selected yet at class_init, so the default cannot be computed
> there. Set the property default to "unspecified" instead, and resolve
> it to big or little in petalogix_s3adsp1800_init(), where the target is
> known.
> 
> Until the machine is initialized, endianness reads back as
> "unspecified" rather than big or little.
> 
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  hw/microblaze/petalogix_s3adsp1800_mmu.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-13 10:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-05 19:49 [PATCH v2 0/4] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init Yonggang Luo
2026-11-05 19:49 ` [PATCH v2 1/4] hw/pci: Avoid guard loadparm with target_s390x() for s390x " Yonggang Luo
2026-11-05 19:49 ` [PATCH v2 2/4] hw/scsi: " Yonggang Luo
2026-11-05 19:49 ` [PATCH v2 3/4] hw/virtio/virtio-mem: Avoid call to target_info() " Yonggang Luo
2026-11-05 19:49 ` [PATCH v2 4/4] hw/microblaze: defer PetaLogix endianness default until init Yonggang Luo
2026-11-13 10:29   ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.