Patchwork [16/29] i440fx: a qom property for i440FX state

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

Patch

diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index a4c32aa..563ded6 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -32,6 +32,8 @@ 
 #include "xen.h"
 #include "qidl.h"
 
+QIDL_ENABLE()
+
 /*
  * I440FX chipset data sheet.
  * http://download.intel.com/design/chipsets/datashts/29054901.pdf
@@ -241,6 +243,23 @@  static int i440fx_pcihost_initfn(SysBusDevice *dev)
     return 0;
 }
 
+static void i440fx_get_state(Object *obj, Visitor *v, void *opaque,
+                             const char *name, Error **errp)
+{
+    PCIDevice *pci = PCI_DEVICE(obj);
+    PCII440FXState *s = DO_UPCAST(PCII440FXState, dev, pci);
+    QIDL_VISIT_TYPE(PCII440FXState, v, &s, name, errp);
+}
+
+static void i440fx_set_state(Object *obj, Visitor *v, void *opaque,
+                             const char *name, Error **errp)
+{
+    PCIDevice *pci = PCI_DEVICE(obj);
+    PCII440FXState *s = DO_UPCAST(PCII440FXState, dev, pci);
+    QIDL_VISIT_TYPE(PCII440FXState, v, &s, name, errp);
+    i440fx_post_load(s, -1);
+}
+
 static int i440fx_initfn(PCIDevice *dev)
 {
     PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev);
@@ -248,6 +267,11 @@  static int i440fx_initfn(PCIDevice *dev)
     d->dev.config[I440FX_SMRAM] = 0x02;
 
     cpu_smm_register(&i440fx_set_smm, d);
+
+    object_property_add(OBJECT(d), "state", "PCII440FXState",
+                        i440fx_get_state, i440fx_set_state, NULL, NULL, NULL);
+    QIDL_SCHEMA_ADD_LINK(PCII440FXState, OBJECT(d), "state_schema", NULL);
+
     return 0;
 }