Patchwork [05/12] qdev-core: isolate vmstate handling into separate functions

login
register
mail settings
Submitter Igor Mammedov
Date Oct. 16, 2012, 1:57 a.m.
Message ID <1350352644-14436-6-git-send-email-imammedo@redhat.com>
Download mbox | patch
Permalink /patch/191703/
State New
Headers show

Comments

Igor Mammedov - Oct. 16, 2012, 1:57 a.m.
From: Eduardo Habkost <ehabkost@redhat.com>

Those functions will eventually be moved somewhere else, and won't get
included on *-user.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/qdev-core.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

Patch

diff --git a/hw/qdev-core.c b/hw/qdev-core.c
index ee19dd5..92c3021 100644
--- a/hw/qdev-core.c
+++ b/hw/qdev-core.c
@@ -40,6 +40,22 @@  const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
     return dc->vmsd;
 }
 
+static void qdev_init_vmstate(DeviceState *dev)
+{
+    if (qdev_get_vmsd(dev)) {
+        vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
+                                       dev->instance_id_alias,
+                                       dev->alias_required_for_version);
+    }
+}
+
+static void qdev_finalize_vmstate(DeviceState *dev)
+{
+    if (qdev_get_vmsd(dev)) {
+        vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
+    }
+}
+
 const char *qdev_fw_name(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
@@ -126,11 +142,7 @@  int qdev_init(DeviceState *dev)
         g_free(name);
     }
 
-    if (qdev_get_vmsd(dev)) {
-        vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
-                                       dev->instance_id_alias,
-                                       dev->alias_required_for_version);
-    }
+    qdev_init_vmstate(dev);
     dev->state = DEV_STATE_INITIALIZED;
     if (dev->hotplugged) {
         device_reset(dev);
@@ -615,9 +627,7 @@  static void device_finalize(Object *obj)
             bus = QLIST_FIRST(&dev->child_bus);
             qbus_free(bus);
         }
-        if (qdev_get_vmsd(dev)) {
-            vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
-        }
+        qdev_finalize_vmstate(dev);
         if (dc->exit) {
             dc->exit(dev);
         }