Skip to contentSkip to conversation

hw/s390x: Attach the sclpconsole to the /machine/sclp node

PATCH Superseded Thomas Huth 4 participants 7 messages Apr 30, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/s390x: Attach the sclpconsole to the /machine/sclp node

The sclpconsole currently does not have a proper parent in the QOM tree, so it shows up under /machine/unattached - which is somewhat ugly. Let's attach it to /machine/sclp instead.

---
 include/hw/s390x/sclp.h    |  2 +-
 hw/s390x/s390-virtio-ccw.c | 11 +++++++----
 hw/s390x/sclp.c            |  4 +++-
 3 files changed, 11 insertions(+), 6 deletions(-)
include/hw/s390x/sclp.h +1 -1
index b405a387b6..abfd6d8868 100644
@@ -222,7 +222,7 @@ static inline int sccb_data_len(SCCB *sccb)
 }
 
 
-void s390_sclp_init(void);
+Object *s390_sclp_init(void);
 void sclp_service_interrupt(uint32_t sccb);
 void raise_irq_cpu_hotplug(void);
 int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code);
hw/s390x/s390-virtio-ccw.c +7 -4
index 4dcc213820..e2f9206ded 100644
@@ -237,11 +237,13 @@ static void s390_create_virtio_net(BusState *bus, const char *name)
     }
 }
 
-static void s390_create_sclpconsole(const char *type, Chardev *chardev)
+static void s390_create_sclpconsole(Object *sclp, const char *type,
+                                    Chardev *chardev)
 {
     DeviceState *dev;
 
     dev = qdev_new(type);
+    object_property_add_child(sclp, type, OBJECT(dev));
     qdev_prop_set_chr(dev, "chardev", chardev);
     qdev_realize_and_unref(dev, sclp_get_event_facility_bus(), &error_fatal);
 }
@@ -252,8 +254,9 @@ static void ccw_init(MachineState *machine)
     int ret;
     VirtualCssBus *css_bus;
     DeviceState *dev;
+    Object *sclp;
 
-    s390_sclp_init();
+    sclp = s390_sclp_init();
     /* init memory + setup max page size. Required for the CPU model */
     s390_memory_init(machine->ram);
 
@@ -302,10 +305,10 @@ static void ccw_init(MachineState *machine)
 
     /* init consoles */
     if (serial_hd(0)) {
-        s390_create_sclpconsole("sclpconsole", serial_hd(0));
+        s390_create_sclpconsole(sclp, "sclpconsole", serial_hd(0));
     }
     if (serial_hd(1)) {
-        s390_create_sclpconsole("sclplmconsole", serial_hd(1));
+        s390_create_sclpconsole(sclp, "sclplmconsole", serial_hd(1));
     }
 
     /* init the TOD clock */
hw/s390x/sclp.c +3 -1
index 893e71a41b..75d45fb184 100644
@@ -379,13 +379,15 @@ void sclp_service_interrupt(uint32_t sccb)
 
 /* qemu object creation and initialization functions */
 
-void s390_sclp_init(void)
+Object *s390_sclp_init(void)
 {
     Object *new = object_new(TYPE_SCLP);
 
     object_property_add_child(qdev_get_machine(), TYPE_SCLP, new);
     object_unref(new);
     qdev_realize(DEVICE(new), NULL, &error_fatal);
+
+    return new;
 }
 
 static void sclp_realize(DeviceState *dev, Error **errp)
Signature · 1 line
2.44.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Thomas Huth

The sclpconsole currently does not have a proper parent in the QOM tree, so it shows up under /machine/unattached - which is somewhat ugly. Let's attach it to /machine/sclp instead.

IIRC, this should not affect migration

Signature · 3 lines
Cheers,

David / dhildenb
#2 lore raw
Quoted 6 lines · David Hildenbrand
Quoted 3 lines · Thomas Huth

The sclpconsole currently does not have a proper parent in the QOM tree, so it shows up under /machine/unattached - which is somewhat ugly. Let's attach it to /machine/sclp instead.

IIRC, this should not affect migration

Yes, that's my understanding, too. I also did a quick check from one QEMU without this patch to a QEMU that includes this patch, and migration just succeeded fine.

Quoted 1 line

Thanks!

Thomas

#3 lore raw
Quoted 10 lines · Thomas Huth
Quoted 6 lines · David Hildenbrand
Quoted 3 lines · Thomas Huth

The sclpconsole currently does not have a proper parent in the QOM tree, so it shows up under /machine/unattached - which is somewhat ugly. Let's attach it to /machine/sclp instead.

IIRC, this should not affect migration

Yes, that's my understanding, too. I also did a quick check from one QEMU without this patch to a QEMU that includes this patch, and migration just succeeded fine.

Indeed, QOM path isn't used in migration streams.

Quoted 8 lines
Quoted 2 lines

Thanks!

 Thomas

#4 lore raw
In reply to Thomas Huth
Quoted 44 lines · Thomas Huth

The sclpconsole currently does not have a proper parent in the QOM tree, so it shows up under /machine/unattached - which is somewhat ugly. Let's attach it to /machine/sclp instead.

---
  include/hw/s390x/sclp.h    |  2 +-
  hw/s390x/s390-virtio-ccw.c | 11 +++++++----
  hw/s390x/sclp.c            |  4 +++-
  3 files changed, 11 insertions(+), 6 deletions(-)
include/hw/s390x/sclp.h +1 -1
index b405a387b6..abfd6d8868 100644
@@ -222,7 +222,7 @@ static inline int sccb_data_len(SCCB *sccb)
  }
 
 
-void s390_sclp_init(void);
+Object *s390_sclp_init(void);
  void sclp_service_interrupt(uint32_t sccb);
  void raise_irq_cpu_hotplug(void);
  int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code);
hw/s390x/s390-virtio-ccw.c +3 -1
index 4dcc213820..e2f9206ded 100644
@@ -237,11 +237,13 @@ static void s390_create_virtio_net(BusState *bus, const char *name)
      }
  }
 
-static void s390_create_sclpconsole(const char *type, Chardev *chardev)
+static void s390_create_sclpconsole(Object *sclp, const char *type,
+                                    Chardev *chardev)
  {
      DeviceState *dev;
 
      dev = qdev_new(type);
+    object_property_add_child(sclp, type, OBJECT(dev));
      qdev_prop_set_chr(dev, "chardev", chardev);
      qdev_realize_and_unref(dev, sclp_get_event_facility_bus(), &error_fatal);
  }

hw/s390x/s390-virtio-ccw.c static void ccw_init(MachineState *machine) · line 259

Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +2 -1
@@ -252,8 +254,9 @@ static void ccw_init(MachineState *machine)
      int ret;
      VirtualCssBus *css_bus;
      DeviceState *dev;
+    Object *sclp;
 
-    s390_sclp_init();
+    sclp = s390_sclp_init();

I would simply drop s390_sclp_init(), same for :

  void s390_init_tod(void);
  void s390_init_ap(void);
  void s390_stattrib_init(void);
  void s390_skeys_init(void);
  void s390_flic_init(void);

These routines all do the same and are not very useful TBH, and I would add pointers under the s390x MachineState possibly.

Thanks,

C.

Quoted 37 lines
hw/s390x/s390-virtio-ccw.c +2 -2
      /* init memory + setup max page size. Required for the CPU model */
      s390_memory_init(machine->ram);
 
@@ -302,10 +305,10 @@ static void ccw_init(MachineState *machine)
 
      /* init consoles */
      if (serial_hd(0)) {
-        s390_create_sclpconsole("sclpconsole", serial_hd(0));
+        s390_create_sclpconsole(sclp, "sclpconsole", serial_hd(0));
      }
      if (serial_hd(1)) {
-        s390_create_sclpconsole("sclplmconsole", serial_hd(1));
+        s390_create_sclpconsole(sclp, "sclplmconsole", serial_hd(1));
      }
 
      /* init the TOD clock */
hw/s390x/sclp.c +3 -1
index 893e71a41b..75d45fb184 100644
@@ -379,13 +379,15 @@ void sclp_service_interrupt(uint32_t sccb)
 
  /* qemu object creation and initialization functions */
 
-void s390_sclp_init(void)
+Object *s390_sclp_init(void)
  {
      Object *new = object_new(TYPE_SCLP);
 
      object_property_add_child(qdev_get_machine(), TYPE_SCLP, new);
      object_unref(new);
      qdev_realize(DEVICE(new), NULL, &error_fatal);
+
+    return new;
  }
 
  static void sclp_realize(DeviceState *dev, Error **errp)
#5 lore raw
Quoted 51 lines · Cédric Le Goater
Quoted 41 lines · Thomas Huth

The sclpconsole currently does not have a proper parent in the QOM tree, so it shows up under /machine/unattached - which is somewhat ugly. Let's attach it to /machine/sclp instead.

---
  include/hw/s390x/sclp.h    |  2 +-
  hw/s390x/s390-virtio-ccw.c | 11 +++++++----
  hw/s390x/sclp.c            |  4 +++-

  3 files changed, 11 insertions(+), 6 deletions(-)
include/hw/s390x/sclp.h +1 -1
index b405a387b6..abfd6d8868 100644
@@ -222,7 +222,7 @@ static inline int sccb_data_len(SCCB *sccb)
   }
-void s390_sclp_init(void);
+Object *s390_sclp_init(void);
   void sclp_service_interrupt(uint32_t sccb);
   void raise_irq_cpu_hotplug(void);
   int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code);
hw/s390x/s390-virtio-ccw.c +3 -1
index 4dcc213820..e2f9206ded 100644
@@ -237,11 +237,13 @@ static void s390_create_virtio_net(BusState *bus, 
 const char *name)
       }
   }
-static void s390_create_sclpconsole(const char *type, Chardev *chardev)
+static void s390_create_sclpconsole(Object *sclp, const char *type,
+                                    Chardev *chardev)
   {
       DeviceState *dev;
       dev = qdev_new(type);
+    object_property_add_child(sclp, type, OBJECT(dev));
       qdev_prop_set_chr(dev, "chardev", chardev);
       qdev_realize_and_unref(dev, sclp_get_event_facility_bus(), &error_fatal);
   }

hw/s390x/s390-virtio-ccw.c static void ccw_init(MachineState *machine) · line 258

Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +2 -1
@@ -252,8 +254,9 @@ static void ccw_init(MachineState *machine)
       int ret;
       VirtualCssBus *css_bus;
       DeviceState *dev;
+    Object *sclp;
-    s390_sclp_init();
+    sclp = s390_sclp_init();

I would simply drop s390_sclp_init(), same for :

Quoted 8 lines

  void s390_init_tod(void);
  void s390_init_ap(void);
  void s390_stattrib_init(void);
  void s390_skeys_init(void);
  void s390_flic_init(void);

These routines all do the same and are not very useful TBH, and I would add pointers under the s390x MachineState possibly.

Some of them seem to do a little bit more things, like checking whether the feature is available or not, e.g. s390_init_ap() ... IMHO it makes sense to keep at least those?

But for s390_sclp_init ... it could be inlined, indeed, especially if we also switch the object_unref + qdev_realize in there into qdev_realize_and_unref. Let me try to do that in a v2 ...

Thomas

#6 lore raw
Quoted 58 lines · Thomas Huth
Quoted 57 lines · Cédric Le Goater
Quoted 41 lines · Thomas Huth

The sclpconsole currently does not have a proper parent in the QOM tree, so it shows up under /machine/unattached - which is somewhat ugly. Let's attach it to /machine/sclp instead.

---
  include/hw/s390x/sclp.h    |  2 +-
  hw/s390x/s390-virtio-ccw.c | 11 +++++++----
  hw/s390x/sclp.c            |  4 +++-

  3 files changed, 11 insertions(+), 6 deletions(-)
include/hw/s390x/sclp.h +1 -1
index b405a387b6..abfd6d8868 100644
@@ -222,7 +222,7 @@ static inline int sccb_data_len(SCCB *sccb)
   }
-void s390_sclp_init(void);
+Object *s390_sclp_init(void);
   void sclp_service_interrupt(uint32_t sccb);
   void raise_irq_cpu_hotplug(void);
   int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code);
hw/s390x/s390-virtio-ccw.c +3 -1
index 4dcc213820..e2f9206ded 100644
@@ -237,11 +237,13 @@ static void s390_create_virtio_net(BusState *bus, 
 const char *name)
       }
   }
-static void s390_create_sclpconsole(const char *type, Chardev *chardev)
+static void s390_create_sclpconsole(Object *sclp, const char *type,
+                                    Chardev *chardev)
   {
       DeviceState *dev;
       dev = qdev_new(type);
+    object_property_add_child(sclp, type, OBJECT(dev));
       qdev_prop_set_chr(dev, "chardev", chardev);
       qdev_realize_and_unref(dev, sclp_get_event_facility_bus(), &error_fatal);
   }

hw/s390x/s390-virtio-ccw.c static void ccw_init(MachineState *machine) · line 258

Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +2 -1
@@ -252,8 +254,9 @@ static void ccw_init(MachineState *machine)
       int ret;
       VirtualCssBus *css_bus;
       DeviceState *dev;
+    Object *sclp;
-    s390_sclp_init();
+    sclp = s390_sclp_init();

I would simply drop s390_sclp_init(), same for :

   void s390_init_tod(void);
   void s390_init_ap(void);
   void s390_stattrib_init(void);
   void s390_skeys_init(void);
   void s390_flic_init(void);

Quoted 6 lines
Quoted 2 lines

These routines all do the same and are not very useful TBH, and I would add pointers under the s390x MachineState possibly.

Some of them seem to do a little bit more things, like checking whether the feature is available or not, e.g. s390_init_ap() ... IMHO it makes sense to keep at least those?

But for s390_sclp_init ... it could be inlined, indeed, especially if we also switch the object_unref + qdev_realize in there into qdev_realize_and_unref. Let me try to do that in a v2 ...

Actually, after looking at the code a little bit longer, it seems to me like the sclpconsole should be attached to /machine/sclp/s390-sclp-event-facility
instead of just /machine/sclp, since the other devices of type TYPE_SCLP_EVENT are also located there. That makes the patch even easier since we already have the pointer from sclp_get_event_facility_bus() in that function.

Thomas