Patchwork [09/29] pci: add qom property for PCIBus instances

login
register
mail settings
Submitter Michael Roth
Date Nov. 1, 2012, 1:04 p.m.
Message ID <1351775071-7644-10-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/196212/
State New
Headers show

Comments

Michael Roth - Nov. 1, 2012, 1:04 p.m.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 hw/pci.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 271ca2f..e0b3f4f 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -34,6 +34,7 @@ 
 #include "msi.h"
 #include "msix.h"
 #include "exec-memory.h"
+#include "qidl.h"
 
 QIDL_ENABLE()
 
@@ -268,6 +269,22 @@  int pci_find_domain(const PCIBus *bus)
     return -1;
 }
 
+static void pcibus_get_state(Object *obj, Visitor *v, void *opaque,
+                             const char *name, Error **errp)
+{
+    PCIBus *pci_bus = PCI_BUS(obj);
+
+    QIDL_VISIT_TYPE(PCIBus, v, &pci_bus, name, errp);
+}
+
+static void pcibus_set_state(Object *obj, Visitor *v, void *opaque,
+                             const char *name, Error **errp)
+{
+    PCIBus *pci_bus = PCI_BUS(obj);
+
+    QIDL_VISIT_TYPE(PCIBus, v, &pci_bus, name, errp);
+}
+
 void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
                          const char *name,
                          MemoryRegion *address_space_mem,
@@ -285,6 +302,10 @@  void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
     pci_host_bus_register(0, bus); /* for now only pci domain 0 is supported */
 
     vmstate_register(NULL, -1, &vmstate_pcibus, bus);
+
+    object_property_add(OBJECT(bus), "state", "PCIBus",
+                        pcibus_get_state, pcibus_set_state, NULL, NULL, NULL);
+    QIDL_SCHEMA_ADD_LINK(PCIBus, OBJECT(bus), "state_schema", NULL);
 }
 
 PCIBus *pci_bus_new(DeviceState *parent, const char *name,