Patchwork [18/29] piix3: add qom property for PIIX3 state

login
register
mail settings
Submitter Michael Roth
Date Nov. 1, 2012, 1:04 p.m.
Message ID <1351775071-7644-19-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/196222/
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/piix_pci.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Patch

diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 0242399..a867e3f 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -544,12 +544,37 @@  static const VMStateDescription vmstate_piix3 = {
     }
 };
 
+static void piix3_get_state(Object *obj, Visitor *v, void *opaque,
+                            const char *name, Error **errp)
+{
+    PCIDevice *pci = PCI_DEVICE(obj);
+    PIIX3State *s = DO_UPCAST(PIIX3State, dev, pci);
+
+    piix3_pre_save(s);
+    QIDL_VISIT_TYPE(PIIX3State, v, &s, name, errp);
+}
+
+static void piix3_set_state(Object *obj, Visitor *v, void *opaque,
+                            const char *name, Error **errp)
+{
+    PCIDevice *pci = PCI_DEVICE(obj);
+    PIIX3State *s = DO_UPCAST(PIIX3State, dev, pci);
+
+    QIDL_VISIT_TYPE(PIIX3State, v, &s, name, errp);
+    piix3_post_load(s, -1);
+}
+
 static int piix3_initfn(PCIDevice *dev)
 {
     PIIX3State *d = DO_UPCAST(PIIX3State, dev, dev);
 
     isa_bus_new(&d->dev.qdev, pci_address_space_io(dev));
     qemu_register_reset(piix3_reset, d);
+
+    object_property_add(OBJECT(d), "state", "PIIX3State",
+                        piix3_get_state, piix3_set_state, NULL, NULL, NULL);
+    QIDL_SCHEMA_ADD_LINK(PIIX3State, OBJECT(d), "state_schema", NULL);
+
     return 0;
 }