All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init
@ 2026-10-13 20:05 Yonggang Luo
  2026-10-13 20:05 ` [PATCH 1/3] 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-10-13 20:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Hildenbrand, Philippe Mathieu-Daude, Matthew Rosato,
	Paolo Bonzini, Pierrick Bouvier, Cornelia Huck, Fam Zheng,
	qemu-s390x, Michael S. Tsirkin, Eric Farman

Now we are going to delay the target select to machine select.
So that avoid call to target_info() in class_init so that we wont
face a NULL target_info() error when do class_init. This is because
class_init is called under object_class_get_list(TYPE_MACHINE, false)

Yonggang Luo (3):
  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/pci/pci.c           | 18 ++++++++++--------
 hw/scsi/scsi-disk.c    | 18 ++++++++++--------
 hw/virtio/virtio-mem.c | 12 +++++-------
 3 files changed, 25 insertions(+), 23 deletions(-)

-- 
2.55.0.windows.3



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

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

This is for avoid call target_info() in class_init.
Now we directly guard in pci_qdev_property_set_loadparm instead.
Don't know if its an API break, but the smallest change.

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 0efb4eb4bb0..9d3dcd52942 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2878,6 +2878,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;
@@ -2895,14 +2900,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 2/3] hw/scsi: Avoid guard loadparm with target_s390x() for s390x in class_init
  2026-10-13 20:05 [PATCH 0/3] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init Yonggang Luo
  2026-10-13 20:05 ` [PATCH 1/3] hw/pci: Avoid guard loadparm with target_s390x() for s390x " Yonggang Luo
@ 2026-10-13 20:05 ` Yonggang Luo
  2026-10-13 20:05 ` [PATCH 3/3] hw/virtio/virtio-mem: Avoid call to target_info() " Yonggang Luo
  2026-11-05 11:33 ` [PATCH 0/3] hw/(pci/scsi/virtio-mem): " Daniel P. Berrangé
  3 siblings, 0 replies; 6+ messages in thread
From: Yonggang Luo @ 2026-10-13 20:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Hildenbrand, Philippe Mathieu-Daude, Matthew Rosato,
	Paolo Bonzini, Pierrick Bouvier, Cornelia Huck, Fam Zheng,
	qemu-s390x, Michael S. Tsirkin, Eric Farman

This is for avoid call target_info() in class_init.
Now we directly guard in scsi_property_set_loadparm instead.
Don't know if its an API break, but the smallest change.

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 deb33ac1dda..276941ae537 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -3179,6 +3179,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;
@@ -3196,14 +3201,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 3/3] hw/virtio/virtio-mem: Avoid call to target_info() in class_init
  2026-10-13 20:05 [PATCH 0/3] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init Yonggang Luo
  2026-10-13 20:05 ` [PATCH 1/3] hw/pci: Avoid guard loadparm with target_s390x() for s390x " Yonggang Luo
  2026-10-13 20:05 ` [PATCH 2/3] hw/scsi: " Yonggang Luo
@ 2026-10-13 20:05 ` Yonggang Luo
  2026-11-05 11:33 ` [PATCH 0/3] hw/(pci/scsi/virtio-mem): " Daniel P. Berrangé
  3 siblings, 0 replies; 6+ messages in thread
From: Yonggang Luo @ 2026-10-13 20:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: David Hildenbrand, Philippe Mathieu-Daude, Matthew Rosato,
	Paolo Bonzini, Pierrick Bouvier, Cornelia Huck, Fam Zheng,
	qemu-s390x, Michael S. Tsirkin, Eric Farman

Done by merge virtio_mem_legacy_guests_properties into virtio_mem_properties.
As we already have vmem->unplugged_inaccessible handle in virtio_mem_device_realize
So we can reject the wrong option in virtio_mem_device_realize, then the call
target_info() in class_init no need anymore.

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 7130ed852d9..e528bf2a88b 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -879,7 +879,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 &&
@@ -1568,9 +1572,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),
 };
@@ -1635,9 +1636,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

* Re: [PATCH 1/3] hw/pci: Avoid guard loadparm with target_s390x() for s390x in class_init
  2026-10-13 20:05 ` [PATCH 1/3] hw/pci: Avoid guard loadparm with target_s390x() for s390x " Yonggang Luo
@ 2026-11-05 11:31   ` Daniel P. Berrangé
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2026-11-05 11:31 UTC (permalink / raw)
  To: Yonggang Luo
  Cc: qemu-devel, David Hildenbrand, Philippe Mathieu-Daude,
	Matthew Rosato, Paolo Bonzini, Pierrick Bouvier, Cornelia Huck,
	Fam Zheng, qemu-s390x, Michael S. Tsirkin, Eric Farman

On Wed, Oct 14, 2026 at 04:05:22AM +0800, Yonggang Luo wrote:
> This is for avoid call target_info() in class_init.
> Now we directly guard in pci_qdev_property_set_loadparm instead.
> Don't know if its an API break, but the smallest change.

Suggest to reword this as follows:

 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.

The same can apply to the other patches

> 
> 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 0efb4eb4bb0..9d3dcd52942 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -2878,6 +2878,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;
> @@ -2895,14 +2900,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
> 
> 

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

* Re: [PATCH 0/3] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init
  2026-10-13 20:05 [PATCH 0/3] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init Yonggang Luo
                   ` (2 preceding siblings ...)
  2026-10-13 20:05 ` [PATCH 3/3] hw/virtio/virtio-mem: Avoid call to target_info() " Yonggang Luo
@ 2026-11-05 11:33 ` Daniel P. Berrangé
  3 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2026-11-05 11:33 UTC (permalink / raw)
  To: Yonggang Luo
  Cc: qemu-devel, David Hildenbrand, Philippe Mathieu-Daude,
	Matthew Rosato, Paolo Bonzini, Pierrick Bouvier, Cornelia Huck,
	Fam Zheng, qemu-s390x, Michael S. Tsirkin, Eric Farman

On Wed, Oct 14, 2026 at 04:05:21AM +0800, Yonggang Luo wrote:
> Now we are going to delay the target select to machine select.
> So that avoid call to target_info() in class_init so that we wont
> face a NULL target_info() error when do class_init. This is because
> class_init is called under object_class_get_list(TYPE_MACHINE, false)
> 
> Yonggang Luo (3):
>   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/pci/pci.c           | 18 ++++++++++--------
>  hw/scsi/scsi-disk.c    | 18 ++++++++++--------
>  hw/virtio/virtio-mem.c | 12 +++++-------
>  3 files changed, 25 insertions(+), 23 deletions(-)

If the commit messages are fixed up,

 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-05 11:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 20:05 [PATCH 0/3] hw/(pci/scsi/virtio-mem): Avoid call to target_info() in class_init Yonggang Luo
2026-10-13 20:05 ` [PATCH 1/3] hw/pci: Avoid guard loadparm with target_s390x() for s390x " Yonggang Luo
2026-11-05 11:31   ` Daniel P. Berrangé
2026-10-13 20:05 ` [PATCH 2/3] hw/scsi: " Yonggang Luo
2026-10-13 20:05 ` [PATCH 3/3] hw/virtio/virtio-mem: Avoid call to target_info() " Yonggang Luo
2026-11-05 11:33 ` [PATCH 0/3] hw/(pci/scsi/virtio-mem): " 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.