Skip to contentSkip to conversation

hw/misc/macio: Mark the macio devices with user_creatable = false

PATCH Applied Thomas Huth 3 participants 3 messages Mar 7, 2018 – Mar 8, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/misc/macio: Mark the macio devices with user_creatable = false

The macio devices currently cause a crash when the user tries to instantiate them on a different machine:

$ ppc64-softmmu/qemu-system-ppc64 -device macio-newworld
Unexpected error in qemu_chr_fe_init() at chardev/char-fe.c:222:
qemu-system-ppc64: -device macio-newworld: Device 'serial0' is in use
Aborted (core dumped)

These devices are clearly not intended to be creatable by the user since they are using serial_hds[] directly in their instance_init function. So let's mark them with user_creatable = false.

---
 hw/misc/macio/macio.c | 2 ++
 1 file changed, 2 insertions(+)
hw/misc/macio/macio.c +2 -0
index af1bd46..454244f 100644
@@ -406,6 +406,8 @@ static void macio_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_OTHERS << 8;
     dc->props = macio_properties;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
+    /* Reason: Uses serial_hds in macio_instance_init */
+    dc->user_creatable = false;
 }
 
 static const TypeInfo macio_oldworld_type_info = {
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Thomas Huth

The macio devices currently cause a crash when the user tries to instantiate them on a different machine:

$ ppc64-softmmu/qemu-system-ppc64 -device macio-newworld
Unexpected error in qemu_chr_fe_init() at chardev/char-fe.c:222:
qemu-system-ppc64: -device macio-newworld: Device 'serial0' is in use
Aborted (core dumped)

These devices are clearly not intended to be creatable by the user since they are using serial_hds[] directly in their instance_init function. So let's mark them with user_creatable = false.

---
  hw/misc/macio/macio.c | 2 ++
  1 file changed, 2 insertions(+)
hw/misc/macio/macio.c +0 -0
index af1bd46..454244f 100644

hw/misc/macio/macio.c static void macio_class_init(ObjectClass *klass, void *data) · line 413

Quoted 8 lines
hw/misc/macio/macio.c +2 -0
@@ -406,6 +406,8 @@ static void macio_class_init(ObjectClass *klass, void *data)
      k->class_id = PCI_CLASS_OTHERS << 8;
      dc->props = macio_properties;
      set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
+    /* Reason: Uses serial_hds in macio_instance_init */
+    dc->user_creatable = false;
  }
 
  static const TypeInfo macio_oldworld_type_info = {

Looks like both Daniel and Peter also agree this is the correct approach, so:

ATB,

Mark.

Applied
#2 lore raw
In reply to Thomas Huth
Quoted 8 lines · Thomas Huth

The macio devices currently cause a crash when the user tries to instantiate them on a different machine:

$ ppc64-softmmu/qemu-system-ppc64 -device macio-newworld
Unexpected error in qemu_chr_fe_init() at chardev/char-fe.c:222:
qemu-system-ppc64: -device macio-newworld: Device 'serial0' is in use
Aborted (core dumped)
Quoted 5 lines

These devices are clearly not intended to be creatable by the user since they are using serial_hds[] directly in their instance_init function. So let's mark them with user_creatable = false.

Applied, thanks.

Quoted 17 lines
---
 hw/misc/macio/macio.c | 2 ++
 1 file changed, 2 insertions(+)
hw/misc/macio/macio.c +2 -0
index af1bd46..454244f 100644
@@ -406,6 +406,8 @@ static void macio_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_OTHERS << 8;
     dc->props = macio_properties;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
+    /* Reason: Uses serial_hds in macio_instance_init */
+    dc->user_creatable = false;
 }
 
 static const TypeInfo macio_oldworld_type_info = {
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson