virtio-scsi: convert VMSTATE_VIRTIO_DEVICE
[qemu.git] / hw / cpu / core.c
blobeff90c12bec53a7773fa6a4c2926d976d59b0c9d
1 /*
2 * CPU core abstract device
4 * Copyright (C) 2016 Bharata B Rao <bharata@linux.vnet.ibm.com>
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9 #include "hw/cpu/core.h"
10 #include "qapi/visitor.h"
11 #include "qapi/error.h"
12 #include "sysemu/cpus.h"
14 static void core_prop_get_core_id(Object *obj, Visitor *v, const char *name,
15 void *opaque, Error **errp)
17 CPUCore *core = CPU_CORE(obj);
18 int64_t value = core->core_id;
20 visit_type_int(v, name, &value, errp);
23 static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name,
24 void *opaque, Error **errp)
26 CPUCore *core = CPU_CORE(obj);
27 Error *local_err = NULL;
28 int64_t value;
30 visit_type_int(v, name, &value, &local_err);
31 if (local_err) {
32 error_propagate(errp, local_err);
33 return;
36 core->core_id = value;
39 static void core_prop_get_nr_threads(Object *obj, Visitor *v, const char *name,
40 void *opaque, Error **errp)
42 CPUCore *core = CPU_CORE(obj);
43 int64_t value = core->nr_threads;
45 visit_type_int(v, name, &value, errp);
48 static void core_prop_set_nr_threads(Object *obj, Visitor *v, const char *name,
49 void *opaque, Error **errp)
51 CPUCore *core = CPU_CORE(obj);
52 Error *local_err = NULL;
53 int64_t value;
55 visit_type_int(v, name, &value, &local_err);
56 if (local_err) {
57 error_propagate(errp, local_err);
58 return;
61 core->nr_threads = value;
64 static void cpu_core_instance_init(Object *obj)
66 CPUCore *core = CPU_CORE(obj);
68 object_property_add(obj, "core-id", "int", core_prop_get_core_id,
69 core_prop_set_core_id, NULL, NULL, NULL);
70 object_property_add(obj, "nr-threads", "int", core_prop_get_nr_threads,
71 core_prop_set_nr_threads, NULL, NULL, NULL);
72 core->nr_threads = smp_threads;
75 static const TypeInfo cpu_core_type_info = {
76 .name = TYPE_CPU_CORE,
77 .parent = TYPE_DEVICE,
78 .abstract = true,
79 .instance_size = sizeof(CPUCore),
80 .instance_init = cpu_core_instance_init,
83 static void cpu_core_register_types(void)
85 type_register_static(&cpu_core_type_info);
88 type_init(cpu_core_register_types)