Skip to contentSkip to conversation

hw/s390x: Attach default virtio-net devices to the /machine/virtual-css-bridge

PATCH In review Thomas Huth 3 participants 3 messages Jul 1, 2024 – Jul 2, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/s390x: Attach default virtio-net devices to the /machine/virtual-css-bridge

The initial virtio-net-ccw devices currently do not have a proper parent in the QOM tree, so they show up under /machine/unattached - which is somewhat ugly. Let's attach them to /machine/virtual-css-bridge/virtual-css instead.

---
 hw/s390x/s390-virtio-ccw.c | 3 +++
 1 file changed, 3 insertions(+)
hw/s390x/s390-virtio-ccw.c +3 -0
index cd063f8b64..0d58e5ab75 100644
@@ -216,8 +216,11 @@ static void s390_init_ipl_dev(const char *kernel_filename,
 static void s390_create_virtio_net(BusState *bus, const char *name)
 {
     DeviceState *dev;
+    int cnt = 0;
 
     while ((dev = qemu_create_nic_device(name, true, "virtio"))) {
+        g_autofree char *childname = g_strdup_printf("%s[%d]", name, cnt++);
+        object_property_add_child(OBJECT(bus), childname, OBJECT(dev));
         qdev_realize_and_unref(dev, bus, &error_fatal);
     }
 }
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Thomas Huth

The initial virtio-net-ccw devices currently do not have a proper parent in the QOM tree, so they show up under /machine/unattached - which is somewhat ugly. Let's attach them to /machine/virtual-css-bridge/virtual-css instead.

Thanks,

C.

Quoted 20 lines
---
  hw/s390x/s390-virtio-ccw.c | 3 +++
  1 file changed, 3 insertions(+)
hw/s390x/s390-virtio-ccw.c +3 -0
index cd063f8b64..0d58e5ab75 100644
@@ -216,8 +216,11 @@ static void s390_init_ipl_dev(const char *kernel_filename,
  static void s390_create_virtio_net(BusState *bus, const char *name)
  {
      DeviceState *dev;
+    int cnt = 0;
 
      while ((dev = qemu_create_nic_device(name, true, "virtio"))) {
+        g_autofree char *childname = g_strdup_printf("%s[%d]", name, cnt++);
+        object_property_add_child(OBJECT(bus), childname, OBJECT(dev));
          qdev_realize_and_unref(dev, bus, &error_fatal);
      }
  }
Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 9 lines · Thomas Huth

The initial virtio-net-ccw devices currently do not have a proper parent in the QOM tree, so they show up under /machine/unattached - which is somewhat ugly. Let's attach them to /machine/virtual-css-bridge/virtual-css instead.

---
  hw/s390x/s390-virtio-ccw.c | 3 +++
  1 file changed, 3 insertions(+)