machine: Replace underscores in machine's property names
[qemu.git] / hw / core / machine.c
blob7a66c57ab7687e588d33dcbd28dac32834082bab
1 /*
2 * QEMU Machine
4 * Copyright (C) 2014 Red Hat Inc
6 * Authors:
7 * Marcel Apfelbaum <marcel.a@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "hw/boards.h"
14 #include "qapi/visitor.h"
16 static char *machine_get_accel(Object *obj, Error **errp)
18 MachineState *ms = MACHINE(obj);
20 return g_strdup(ms->accel);
23 static void machine_set_accel(Object *obj, const char *value, Error **errp)
25 MachineState *ms = MACHINE(obj);
27 ms->accel = g_strdup(value);
30 static bool machine_get_kernel_irqchip(Object *obj, Error **errp)
32 MachineState *ms = MACHINE(obj);
34 return ms->kernel_irqchip;
37 static void machine_set_kernel_irqchip(Object *obj, bool value, Error **errp)
39 MachineState *ms = MACHINE(obj);
41 ms->kernel_irqchip = value;
44 static void machine_get_kvm_shadow_mem(Object *obj, Visitor *v,
45 void *opaque, const char *name,
46 Error **errp)
48 MachineState *ms = MACHINE(obj);
49 int64_t value = ms->kvm_shadow_mem;
51 visit_type_int(v, &value, name, errp);
54 static void machine_set_kvm_shadow_mem(Object *obj, Visitor *v,
55 void *opaque, const char *name,
56 Error **errp)
58 MachineState *ms = MACHINE(obj);
59 Error *error = NULL;
60 int64_t value;
62 visit_type_int(v, &value, name, &error);
63 if (error) {
64 error_propagate(errp, error);
65 return;
68 ms->kvm_shadow_mem = value;
71 static char *machine_get_kernel(Object *obj, Error **errp)
73 MachineState *ms = MACHINE(obj);
75 return g_strdup(ms->kernel_filename);
78 static void machine_set_kernel(Object *obj, const char *value, Error **errp)
80 MachineState *ms = MACHINE(obj);
82 ms->kernel_filename = g_strdup(value);
85 static char *machine_get_initrd(Object *obj, Error **errp)
87 MachineState *ms = MACHINE(obj);
89 return g_strdup(ms->initrd_filename);
92 static void machine_set_initrd(Object *obj, const char *value, Error **errp)
94 MachineState *ms = MACHINE(obj);
96 ms->initrd_filename = g_strdup(value);
99 static char *machine_get_append(Object *obj, Error **errp)
101 MachineState *ms = MACHINE(obj);
103 return g_strdup(ms->kernel_cmdline);
106 static void machine_set_append(Object *obj, const char *value, Error **errp)
108 MachineState *ms = MACHINE(obj);
110 ms->kernel_cmdline = g_strdup(value);
113 static char *machine_get_dtb(Object *obj, Error **errp)
115 MachineState *ms = MACHINE(obj);
117 return g_strdup(ms->dtb);
120 static void machine_set_dtb(Object *obj, const char *value, Error **errp)
122 MachineState *ms = MACHINE(obj);
124 ms->dtb = g_strdup(value);
127 static char *machine_get_dumpdtb(Object *obj, Error **errp)
129 MachineState *ms = MACHINE(obj);
131 return g_strdup(ms->dumpdtb);
134 static void machine_set_dumpdtb(Object *obj, const char *value, Error **errp)
136 MachineState *ms = MACHINE(obj);
138 ms->dumpdtb = g_strdup(value);
141 static void machine_get_phandle_start(Object *obj, Visitor *v,
142 void *opaque, const char *name,
143 Error **errp)
145 MachineState *ms = MACHINE(obj);
146 int64_t value = ms->phandle_start;
148 visit_type_int(v, &value, name, errp);
151 static void machine_set_phandle_start(Object *obj, Visitor *v,
152 void *opaque, const char *name,
153 Error **errp)
155 MachineState *ms = MACHINE(obj);
156 Error *error = NULL;
157 int64_t value;
159 visit_type_int(v, &value, name, &error);
160 if (error) {
161 error_propagate(errp, error);
162 return;
165 ms->phandle_start = value;
168 static char *machine_get_dt_compatible(Object *obj, Error **errp)
170 MachineState *ms = MACHINE(obj);
172 return g_strdup(ms->dt_compatible);
175 static void machine_set_dt_compatible(Object *obj, const char *value, Error **errp)
177 MachineState *ms = MACHINE(obj);
179 ms->dt_compatible = g_strdup(value);
182 static bool machine_get_dump_guest_core(Object *obj, Error **errp)
184 MachineState *ms = MACHINE(obj);
186 return ms->dump_guest_core;
189 static void machine_set_dump_guest_core(Object *obj, bool value, Error **errp)
191 MachineState *ms = MACHINE(obj);
193 ms->dump_guest_core = value;
196 static bool machine_get_mem_merge(Object *obj, Error **errp)
198 MachineState *ms = MACHINE(obj);
200 return ms->mem_merge;
203 static void machine_set_mem_merge(Object *obj, bool value, Error **errp)
205 MachineState *ms = MACHINE(obj);
207 ms->mem_merge = value;
210 static bool machine_get_usb(Object *obj, Error **errp)
212 MachineState *ms = MACHINE(obj);
214 return ms->usb;
217 static void machine_set_usb(Object *obj, bool value, Error **errp)
219 MachineState *ms = MACHINE(obj);
221 ms->usb = value;
224 static char *machine_get_firmware(Object *obj, Error **errp)
226 MachineState *ms = MACHINE(obj);
228 return g_strdup(ms->firmware);
231 static void machine_set_firmware(Object *obj, const char *value, Error **errp)
233 MachineState *ms = MACHINE(obj);
235 ms->firmware = g_strdup(value);
238 static void machine_initfn(Object *obj)
240 object_property_add_str(obj, "accel",
241 machine_get_accel, machine_set_accel, NULL);
242 object_property_add_bool(obj, "kernel-irqchip",
243 machine_get_kernel_irqchip,
244 machine_set_kernel_irqchip,
245 NULL);
246 object_property_add(obj, "kvm-shadow-mem", "int",
247 machine_get_kvm_shadow_mem,
248 machine_set_kvm_shadow_mem,
249 NULL, NULL, NULL);
250 object_property_add_str(obj, "kernel",
251 machine_get_kernel, machine_set_kernel, NULL);
252 object_property_add_str(obj, "initrd",
253 machine_get_initrd, machine_set_initrd, NULL);
254 object_property_add_str(obj, "append",
255 machine_get_append, machine_set_append, NULL);
256 object_property_add_str(obj, "dtb",
257 machine_get_dtb, machine_set_dtb, NULL);
258 object_property_add_str(obj, "dumpdtb",
259 machine_get_dumpdtb, machine_set_dumpdtb, NULL);
260 object_property_add(obj, "phandle-start", "int",
261 machine_get_phandle_start,
262 machine_set_phandle_start,
263 NULL, NULL, NULL);
264 object_property_add_str(obj, "dt-compatible",
265 machine_get_dt_compatible,
266 machine_set_dt_compatible,
267 NULL);
268 object_property_add_bool(obj, "dump-guest-core",
269 machine_get_dump_guest_core,
270 machine_set_dump_guest_core,
271 NULL);
272 object_property_add_bool(obj, "mem-merge",
273 machine_get_mem_merge, machine_set_mem_merge, NULL);
274 object_property_add_bool(obj, "usb", machine_get_usb, machine_set_usb, NULL);
275 object_property_add_str(obj, "firmware",
276 machine_get_firmware, machine_set_firmware, NULL);
279 static void machine_finalize(Object *obj)
281 MachineState *ms = MACHINE(obj);
283 g_free(ms->accel);
284 g_free(ms->kernel_filename);
285 g_free(ms->initrd_filename);
286 g_free(ms->kernel_cmdline);
287 g_free(ms->dtb);
288 g_free(ms->dumpdtb);
289 g_free(ms->dt_compatible);
290 g_free(ms->firmware);
293 static const TypeInfo machine_info = {
294 .name = TYPE_MACHINE,
295 .parent = TYPE_OBJECT,
296 .abstract = true,
297 .class_size = sizeof(MachineClass),
298 .instance_size = sizeof(MachineState),
299 .instance_init = machine_initfn,
300 .instance_finalize = machine_finalize,
303 static void machine_register_types(void)
305 type_register_static(&machine_info);
308 type_init(machine_register_types)