[RFC PATCH-for-10.2 10/10] hw/misc/vmcoreinfo: Remove legacy '-device vmcoreinfo'

Philippe Mathieu-Daudé posted 10 patches 2 days, 10 hours ago
There is a newer version of this series
[RFC PATCH-for-10.2 10/10] hw/misc/vmcoreinfo: Remove legacy '-device vmcoreinfo'
Posted by Philippe Mathieu-Daudé 2 days, 10 hours ago
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 docs/about/deprecated.rst       |  5 ----
 docs/about/removed-features.rst |  5 ++++
 include/hw/misc/vmcoreinfo.h    |  3 +--
 hw/misc/vmcoreinfo.c            | 44 ++++++---------------------------
 4 files changed, 13 insertions(+), 44 deletions(-)

diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 57a3d734081..d6809f94ea1 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -79,11 +79,6 @@ described with -smp are supported by the target machine.
 
 Use ``-run-with user=..`` instead.
 
-``-device vmcoreinfo`` (since 10.0)
-'''''''''''''''''''''''''''''''''''
-
-Use ``-object vmcore-info`` instead.
-
 
 User-mode emulator command line arguments
 -----------------------------------------
diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst
index cb1388049a8..6fedf13c133 100644
--- a/docs/about/removed-features.rst
+++ b/docs/about/removed-features.rst
@@ -555,6 +555,11 @@ to produce an odd effect (rotating input but not display output). But
 this was never intended or documented behaviour, so we have dropped
 the options along with the machine models they were intended for.
 
+``-device vmcoreinfo`` (removed in 10.2)
+''''''''''''''''''''''''''''''''''''''''
+
+``-device vmcoreinfo`` has been replaced by ``-object vmcore-info``.
+
 User-mode emulator command line arguments
 -----------------------------------------
 
diff --git a/include/hw/misc/vmcoreinfo.h b/include/hw/misc/vmcoreinfo.h
index d4cce42cee6..56af12d33a4 100644
--- a/include/hw/misc/vmcoreinfo.h
+++ b/include/hw/misc/vmcoreinfo.h
@@ -12,7 +12,6 @@
 #ifndef VMCOREINFO_H
 #define VMCOREINFO_H
 
-#include "hw/qdev-core.h"
 #include "standard-headers/linux/qemu_fw_cfg.h"
 #include "qom/object.h"
 
@@ -26,7 +25,7 @@ DECLARE_INSTANCE_CHECKER(VMCoreInfoState, VMCOREINFO_DEVICE,
 typedef struct fw_cfg_vmcoreinfo FWCfgVMCoreInfo;
 
 struct VMCoreInfoState {
-    DeviceState parent_obj;
+    Object parent_obj;
 
     bool has_vmcoreinfo;
     FWCfgVMCoreInfo vmcoreinfo;
diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c
index e2258e08fb1..36d1143722e 100644
--- a/hw/misc/vmcoreinfo.c
+++ b/hw/misc/vmcoreinfo.c
@@ -54,8 +54,9 @@ static void vmcoreinfo_reset_hold(Object *obj, ResetType type)
     s->vmcoreinfo.host_format = cpu_to_le16(FW_CFG_VMCOREINFO_FORMAT_ELF);
 }
 
-static void vmcoreinfo_realize(VMCoreInfoState *s, Error **errp)
+static void vmcoreinfo_complete(UserCreatable *uc, Error **errp)
 {
+    VMCoreInfoState *s = VMCOREINFO(uc);
     FWCfgState *fw_cfg = fw_cfg_find();
     /* for gdb script dump-guest-memory.py */
     static VMCoreInfoState * volatile vmcoreinfo_state G_GNUC_UNUSED;
@@ -76,6 +77,10 @@ static void vmcoreinfo_realize(VMCoreInfoState *s, Error **errp)
         return;
     }
 
+    if (vmstate_register_any(VMSTATE_IF(s), &vmstate_vmcoreinfo, s) < 0) {
+        error_setg(errp, "%s: Failed to register vmstate", TYPE_VMCOREINFO);
+    }
+
     fw_cfg_add_file_callback(fw_cfg, FW_CFG_VMCOREINFO_FILENAME,
                              NULL, fw_cfg_vmci_write, s,
                              &s->vmcoreinfo, sizeof(s->vmcoreinfo), false);
@@ -88,25 +93,11 @@ static void vmcoreinfo_realize(VMCoreInfoState *s, Error **errp)
     vmcoreinfo_state = s;
 }
 
-static void vmcoreinfo_device_realize(DeviceState *dev, Error **errp)
-{
-    vmcoreinfo_realize(VMCOREINFO_DEVICE(dev), errp);
-}
-
 static bool vmcoreinfo_can_be_deleted(UserCreatable *uc)
 {
     return false;
 }
 
-static void vmcoreinfo_complete(UserCreatable *uc, Error **errp)
-{
-    if (vmstate_register_any(VMSTATE_IF(uc), &vmstate_vmcoreinfo, uc) < 0) {
-        error_setg(errp, "%s: Failed to register vmstate", TYPE_VMCOREINFO);
-    }
-
-    vmcoreinfo_realize(VMCOREINFO(uc), errp);
-}
-
 static void vmcoreinfo_class_init(ObjectClass *oc, void *data)
 {
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
@@ -119,25 +110,7 @@ static void vmcoreinfo_class_init(ObjectClass *oc, void *data)
     rc->phases.hold = vmcoreinfo_reset_hold;
 }
 
-static void vmcoreinfo_device_class_init(ObjectClass *klass, void *data)
-{
-    DeviceClass *dc = DEVICE_CLASS(klass);
-    ResettableClass *rc = RESETTABLE_CLASS(klass);
-
-    dc->vmsd = &vmstate_vmcoreinfo;
-    dc->realize = vmcoreinfo_device_realize;
-    dc->hotpluggable = false;
-    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
-    rc->phases.hold = vmcoreinfo_reset_hold;
-}
-
 static const TypeInfo vmcoreinfo_types[] = {
-    {
-        .name           = TYPE_VMCOREINFO_DEVICE,
-        .parent         = TYPE_DEVICE,
-        .instance_size  = sizeof(VMCoreInfoState),
-        .class_init     = vmcoreinfo_device_class_init,
-    },
     {
         .name           = TYPE_VMCOREINFO,
         .parent         = TYPE_OBJECT,
@@ -158,10 +131,7 @@ VMCoreInfoState *vmcoreinfo_find(void)
 {
     Object *obj;
 
-    obj = object_resolve_path_type("", TYPE_VMCOREINFO_DEVICE, NULL);
-    if (!obj) {
-        obj = object_resolve_path_type("", TYPE_VMCOREINFO, NULL);
-    }
+    obj = object_resolve_path_type("", TYPE_VMCOREINFO, NULL);
 
     return obj ? (VMCoreInfoState *)obj : NULL;
 }
-- 
2.47.1