Skip to contentSkip to conversation

Fixup some dynamic casts in the Qemu device tree to correspond to the QOM type-checking system. These patches change from using Linux kernel style upcasts to typesafe object oriented casts with runtime checking semantics.

PATCH In review Mike Day 4 participants 5 messages Aug 19, 2013

lore
Share & tools
lore

Mike Day

author
#0 lore raw

PATCH 1/1 Fixup some dynamic casts in the Qemu device tree to correspond to the QOM type-checking system. These patches change from using Linux kernel style upcasts to typesafe object oriented casts with runtime checking semantics.

These patches apply to Paolo Bonzini's rcu tree:

https://github.com/bonzini/qemu/tree/rcu
commit 781e47bf1693a80b84eec298a6a1c7b29ab2c135

---
 hw/misc/ivshmem.c              | 2 +-
 hw/pci-bridge/pci_bridge_dev.c | 6 +++---
 hw/pci/pci_bridge.c            | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
hw/misc/ivshmem.c +1 -1
index ebcb52a..46d8c27 100644
@@ -789,7 +789,7 @@ static void pci_ivshmem_uninit(PCIDevice *dev)
 
 static void pci_ivshmem_instance_finalize(Object *obj)
 {
-    IVShmemState *s = IVSHMEM(dev);
+    IVShmemState *s = IVSHMEM(obj);
 
     if (s->migration_blocker) {
         migrate_del_blocker(s->migration_blocker);
hw/pci-bridge/pci_bridge_dev.c +3 -3
index c995d5d..22caf14 100644
@@ -87,7 +87,6 @@ shpc_error:
 bridge_error:
     return err;
 }
-
 static void pci_bridge_dev_exitfn(PCIDevice *dev)
 {
     PCIBridgeDev *bridge_dev = PCI_BRIDGE_DEV(dev);
@@ -102,8 +101,9 @@ static void pci_bridge_dev_exitfn(PCIDevice *dev)
 static void pci_bridge_dev_instance_finalize(Object *obj)
 {
     PCIDevice *dev = PCI_DEVICE(obj);
-    PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev);
-    PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br);
+    PCIBridge *br = PCI_BRIDGE(dev);
+    PCIBridgeDev *bridge_dev = PCI_BRIDGE_DEV(br);
+    
     shpc_free(dev);
     memory_region_destroy(&bridge_dev->bar);
     pci_bridge_free(dev);
hw/pci/pci_bridge.c +1 -1
index 63f9912..307e076 100644
@@ -391,7 +391,7 @@ void pci_bridge_exitfn(PCIDevice *pci_dev)
 
 void pci_bridge_free(PCIDevice *pci_dev)
 {
-    PCIBridge *s = DO_UPCAST(PCIBridge, dev, pci_dev);
+    PCIBridge *s = PCI_BRIDGE(pci_dev);
     pci_bridge_region_cleanup(s, s->windows);
     memory_region_destroy(&s->address_space_mem);
     memory_region_destroy(&s->address_space_io);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 17 lines · Mike Day

These patches apply to Paolo Bonzini's rcu tree:

https://github.com/bonzini/qemu/tree/rcu
commit 781e47bf1693a80b84eec298a6a1c7b29ab2c135

---
 hw/misc/ivshmem.c              | 2 +-
 hw/pci-bridge/pci_bridge_dev.c | 6 +++---
 hw/pci/pci_bridge.c            | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
hw/misc/ivshmem.c +0 -0
index ebcb52a..46d8c27 100644

hw/misc/ivshmem.c static void pci_ivshmem_uninit(PCIDevice *dev) · line 792

Quoted 5 lines
hw/misc/ivshmem.c +1 -1
@@ -789,7 +789,7 @@ static void pci_ivshmem_uninit(PCIDevice *dev)
 
 static void pci_ivshmem_instance_finalize(Object *obj)
 {
-    IVShmemState *s = IVSHMEM(dev);
+    IVShmemState *s = IVSHMEM(obj);

This should have been a flat-out compiler error, right?

hw/pci-bridge/pci_bridge_dev.c shpc_error: · line 90

Quoted 11 lines
hw/misc/ivshmem.c +0 -0
     if (s->migration_blocker) {
         migrate_del_blocker(s->migration_blocker);
hw/pci-bridge/pci_bridge_dev.c +0 -1
index c995d5d..22caf14 100644
@@ -87,7 +87,6 @@ shpc_error:
 bridge_error:
     return err;
 }
-

Stray blank line change.

thanks
-- PMM

author
#2 lore raw
Quoted 19 lines · Peter Maydell
Quoted 18 lines · Mike Day

These patches apply to Paolo Bonzini's rcu tree:

https://github.com/bonzini/qemu/tree/rcu
commit 781e47bf1693a80b84eec298a6a1c7b29ab2c135

---
 hw/misc/ivshmem.c              | 2 +-
 hw/pci-bridge/pci_bridge_dev.c | 6 +++---
 hw/pci/pci_bridge.c            | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
hw/misc/ivshmem.c +0 -0
index ebcb52a..46d8c27 100644
@@ -789,7 +789,7 @@ static void pci_ivshmem_uninit(PCIDevice *dev)
 
Quoted 6 lines

hw/misc/ivshmem.c static void pci_ivshmem_uninit(PCIDevice *dev) · line 792

Quoted 4 lines
hw/misc/ivshmem.c +1 -1
 static void pci_ivshmem_instance_finalize(Object *obj)
 {
-    IVShmemState *s = IVSHMEM(dev);
+    IVShmemState *s = IVSHMEM(obj);

This should have been a flat-out compiler error, right?

Yes, correct, but Paolo hasn't previously submitted this specific change code afaik.

Quoted 5 lines
Quoted 5 lines
hw/misc/ivshmem.c +0 -0
     if (s->migration_blocker) {
         migrate_del_blocker(s->migration_blocker);
hw/pci-bridge/pci_bridge_dev.c +0 -1
index c995d5d..22caf14 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
Quoted 8 lines

hw/pci-bridge/pci_bridge_dev.c shpc_error: · line 90

Quoted 6 lines

+++ b/hw/pci-bridge/pci_bridge_dev.c

hw/pci-bridge/pci_bridge_dev.c +0 -1
@@ -87,7 +87,6 @@ shpc_error:
 bridge_error:
     return err;
 }
-

Stray blank line change.

Thanks - and git just found it for me too. Apologies.

Mike

Signature · 2 lines
Mike Day | + 1 919 371-8786 | [email protected]
"Endurance is a Virtue"
#3 lore raw

Il 19/08/2013 20:57, Mike Day ha scritto:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
hw/misc/ivshmem.c +0 -0
index ebcb52a..46d8c27 100644
@@ -789,7 +789,7 @@ static void pci_ivshmem_uninit(PCIDevice *dev)
 
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

hw/misc/ivshmem.c static void pci_ivshmem_uninit(PCIDevice *dev) · line 792

Quoted 4 lines
hw/misc/ivshmem.c +1 -1
 static void pci_ivshmem_instance_finalize(Object *obj)
 {
-    IVShmemState *s = IVSHMEM(dev);
+    IVShmemState *s = IVSHMEM(obj);

This should have been a flat-out compiler error, right?

Yes, correct, but Paolo hasn't previously submitted this specific change code afaik.

Yes, it's just a conflict resolution pasto.

I squashed the changes into the branch.

Paolo

#4 lore raw
In reply to Mike Day

On 08/19/2013 12:33 PM, Mike Day wrote:

Your subject line is atrociously long. Please put a blank line between the summary (ca. 60 characters or less) and the rest of your commit message. 'git shortlog -30' will give you a hint on typical summary naming.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org