qemu-machine as a QOM object
cover qemu-machine as a QOM object
This is an early RFC, the work is in very early stages, I am interested to know if there is a consensus that this is the right path.
The main benefit of QOMifying the qemu machine would be the possibility to have options per machine type and not global.
However, there are other benefits as:
- accessing qemu object properties instead of a global QemuOpts list from different code subsystems.
- improving the machine "initialization" code (compat and stuff)
- getting more close to QOM's vision of single interface for device creation and so on.
Basically the series aims (in the long run) to convert:
QEMUMachine -> QemuMachineClass
QEMUMachineInitArgs -> QemuMachineState.As a first step, in order to make possible an incremental development, both QEMUMachine and QEMUMachineInitArgs are being embedded into the new types.
Your comments are welcomed,
Marcel
Marcel Apfelbaum (5):
hw/core: introduced qemu machine as QOM object
vl: use qemu machine QOM class instead of global machines list hw/boards: converted current_machine to be an instance of
QemuMachineCLass
hw/machine: add qemu machine opts as properties to QemuMachineState vl.c: set current_machine's properties
device-hotplug.c | 4 +- hw/core/Makefile.objs | 2 +- hw/core/machine.c | 289 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/boards.h | 55 +++++++++- qmp.c | 7 +- vl.c | 122 ++++++++++++++------- 6 files changed, 435 insertions(+), 44 deletions(-) create mode 100644 hw/core/machine.c
Signature · 1 line
1.8.3.1
RFC PATCH 1/5 hw/core: introduced qemu machine as QOM object
The main functionality change is to convert QEMUMachine into QemuMachineClass and QEMUMachineInitArgs into QemuMachineState, instance of QemuMachineClass.
As a first step, in order to make possible an incremental developement, both QEMUMachine and QEMUMachineInitArgs are being embeded into the new types.
--- hw/core/Makefile.objs | 2 +- hw/core/machine.c | 38 ++++++++++++++++++++++++++++++++++++++ include/hw/boards.h | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 hw/core/machine.c
hw/core/Makefile.objs +1 -1
@@ -10,4 +10,4 @@ common-obj-$(CONFIG_SOFTMMU) += sysbus.o common-obj-$(CONFIG_SOFTMMU) += null-machine.o common-obj-$(CONFIG_SOFTMMU) += loader.o common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o - +common-obj-$(CONFIG_SOFTMMU) += machine.o
hw/core/machine.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* QEMU Machine +* +* Copyright (C) 2013 Red Hat Inc +* +* Authors: +* Marcel Apfelbaum <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "hw/boards.h" + +static void qemu_machine_initfn (Object *obj) +{ +} + +static void qemu_machine_class_init (ObjectClass *oc,void *data) +{ +} + +static const TypeInfo qemu_machine_info = { + .name =TYPE_QEMU_MACHINE , + .parent =TYPE_OBJECT , + .abstract = true, + .class_size =sizeof (QemuMachineClass), + .class_init = qemu_machine_class_init, + .instance_size =sizeof (QemuMachineState), + .instance_init = qemu_machine_initfn, +}; + +static void register_types (void ) +{ +type_register_static (&qemu_machine_info); +} + +type_init (register_types);
include/hw/boards.h +36 -0
@@ -5,6 +5,7 @@#include "sysemu/blockdev.h" #include "hw/qdev.h" +#include "qom/object.h" typedef struct QEMUMachine QEMUMachine ;
@@ -53,4 +54,39 @@ QEMUMachine *find_default_machine(void);extern QEMUMachine *current_machine; +#define TYPE_QEMU_MACHINE "machine" +#define QEMU_MACHINE (obj) \ + OBJECT_CHECK(QemuMachineState, (obj), TYPE_QEMU_MACHINE) +#define QEMU_MACHINE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(QemuMachineClass, (obj), TYPE_QEMU_MACHINE) +#define QEMU_MACHINE_CLASS (klass) \ + OBJECT_CLASS_CHECK(QemuMachineClass, (klass), TYPE_QEMU_MACHINE) + +typedef struct QemuMachineState QemuMachineState ; +typedef struct QemuMachineClass QemuMachineClass ; + +/** +* @QemuMachineClass +* +* @parent_class: opaque parent class container +*/ +struct QemuMachineClass { +ObjectClass parent_class; + +QEMUMachine *qemu_machine; +}; + +/** +* @QemuMachineState +* +* @parent: opaque parent object container +*/ +struct QemuMachineState { +/* private */ +Object parent; +/* public */ + +QEMUMachineInitArgs *init_args; +}; +#endif
Signature · 1 line
1.8.3.1
RFC PATCH 2/5 vl: use qemu machine QOM class instead of global machines list
In reply to Marcel ApfelbaumThe machine registration flow is refactored to use the QOM functionality. Instead of linking the machines into a list, each machine has a type and the types can be traversed in the QOM way.
--- vl.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 21 deletions(-)
vl.c +54 -21
@@ -1581,54 +1581,81 @@ void pcmcia_info(Monitor *mon, const QDict *qdict)/***********************************************************/ /* machine registration */ -static QEMUMachine *first_machine =NULL ;QEMUMachine *current_machine =NULL ; +static void qemu_machine_class_init (ObjectClass *klass,void *data) +{ +QemuMachineClass *k =QEMU_MACHINE_CLASS (klass); + + k->qemu_machine = data; +} +int qemu_register_machine (QEMUMachine *m) { -QEMUMachine **pm; - pm = &first_machine; -while (*pm !=NULL ) - pm = &(*pm)->next; - m->next =NULL ; - *pm = m; +TypeInfo ti = { + .name = m->name, + .parent =TYPE_QEMU_MACHINE , + .class_init = qemu_machine_class_init, + .class_data = (void *)m, + }; + +type_register (&ti); +return 0 ; }static QEMUMachine *find_machine (const char *name) { -QEMUMachine *m; +GSList *el, *machines =object_class_get_list (TYPE_QEMU_MACHINE , false); +QEMUMachine *m =NULL ; + +for (el = machines; el; el = el->next) { +QemuMachineClass *k = el->data; -for (m = first_machine; m !=NULL ; m = m->next) { -if (!strcmp (m->name, name)) -return m; -if (m->alias && !strcmp (m->alias, name)) -return m; +if (!strcmp (k->qemu_machine->name, name)) { + m = k->qemu_machine; +break ; + } +if (k->qemu_machine->alias && !strcmp (k->qemu_machine->alias, name)) { + m = k->qemu_machine; +break ; + } } -return NULL ; + +g_slist_free (machines); +return m; }QEMUMachine *find_default_machine (void ) { -QEMUMachine *m; +GSList *el, *machines =object_class_get_list (TYPE_QEMU_MACHINE , false); +QEMUMachine *m =NULL ; -for (m = first_machine; m !=NULL ; m = m->next) { -if (m->is_default) { -return m; +for (el = machines; el; el = el->next) { +QemuMachineClass *k = el->data; + +if (k->qemu_machine->is_default) { + m = k->qemu_machine; +break ; } } -return NULL ; + +g_slist_free (machines); +return m; }MachineInfoList *qmp_query_machines (Error **errp) { +GSList *el, *machines =object_class_get_list (TYPE_QEMU_MACHINE , false);MachineInfoList *mach_list =NULL ;QEMUMachine *m; -for (m = first_machine; m; m = m->next) { +for (el = machines; el; el = el->next) { +QemuMachineClass *k = el->data;MachineInfoList *entry;MachineInfo *info; + m = k->qemu_machine; info =g_malloc0 (sizeof (*info));if (m->is_default) { info->has_is_default = true;
@@ -1649,6 +1676,7 @@ MachineInfoList *qmp_query_machines(Error **errp) mach_list = entry; } +g_slist_free (machines);return mach_list; }
@@ -2592,6 +2620,7 @@ static int debugcon_parse(const char *devname)static QEMUMachine *machine_parse (const char *name) {QEMUMachine *m, *machine =NULL ; +GSList *el, *machines =object_class_get_list (TYPE_QEMU_MACHINE , false);if (name) { machine =find_machine (name);
@@ -2600,13 +2629,17 @@ static QEMUMachine *machine_parse(const char *name)return machine; }printf ("Supported machines are:\n" ); -for (m = first_machine; m !=NULL ; m = m->next) { +for (el = machines; el; el = el->next) { +QemuMachineClass *k = el->data; + m = k->qemu_machine;if (m->alias) {printf ("%-20s %s (alias of %s)\n" , m->alias, m->desc, m->name); }printf ("%-20s %s%s\n" , m->name, m->desc, m->is_default ?" (default)" :"" ); } + +g_slist_free (machines);exit (!name || !is_help_option (name)); }
Signature · 1 line
1.8.3.1
RFC PATCH 3/5 hw/boards: converted current_machine to be an instance of QemuMachineCLass
In reply to Marcel ApfelbaumIn order to allow attaching machine options to a machine instance, current_machine is converted into QemuMachineState.
As a first step of deprecating QEMUMachine, some of the functions were modified to return QemuMachineCLass.
--- device-hotplug.c | 4 +++- include/hw/boards.h | 6 +++--- qmp.c | 7 +++++-- vl.c | 55 +++++++++++++++++++++++++++++------------------------ 4 files changed, 41 insertions(+), 31 deletions(-)
device-hotplug.c +3 -1
@@ -33,12 +33,14 @@ DriveInfo *add_init_drive(const char *optstr) {DriveInfo *dinfo;QemuOpts *opts; +QemuMachineClass *machine_class; opts =drive_def (optstr);if (!opts)return NULL ; - dinfo =drive_init (opts, current_machine->block_default_type); + machine_class =QEMU_MACHINE_GET_CLASS (current_machine); + dinfo =drive_init (opts, machine_class->qemu_machine->block_default_type);if (!dinfo) {qemu_opts_del (opts);return NULL ;
include/hw/boards.h +3 -3
@@ -50,9 +50,6 @@ struct QEMUMachine { };int qemu_register_machine (QEMUMachine *m); -QEMUMachine *find_default_machine (void ); - -extern QEMUMachine *current_machine;#define TYPE_QEMU_MACHINE "machine"#define QEMU_MACHINE (obj) \
@@ -65,6 +62,9 @@ extern QEMUMachine *current_machine;typedef struct QemuMachineState QemuMachineState ;typedef struct QemuMachineClass QemuMachineClass ; +QemuMachineClass *find_default_machine (void ); +extern QemuMachineState *current_machine; +/** * @QemuMachineClass *
qmp.c +5 -2
@@ -113,8 +113,11 @@ void qmp_cpu(int64_t index, Error **errp)void qmp_cpu_add (int64_t id,Error **errp) { -if (current_machine->hot_add_cpu) { - current_machine->hot_add_cpu (id, errp); +QemuMachineClass *machine_class; + + machine_class =QEMU_MACHINE_GET_CLASS (current_machine); +if (machine_class->qemu_machine->hot_add_cpu) { + machine_class->qemu_machine->hot_add_cpu (id, errp); }else {error_setg (errp,"Not supported" ); }
vl.c +30 -25
155 lines not on this page · raw message
Signature · 1 line
1.8.3.1
RFC PATCH 4/5 hw/machine: add qemu machine opts as properties to QemuMachineState
In reply to Marcel ApfelbaumIt is cleaner to query current_machine's properties than accessing QemuOpts from the code.
--- hw/core/machine.c | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/boards.h | 15 ++++ 2 files changed, 266 insertions(+)
hw/core/machine.c +251 -0
@@ -11,15 +11,265 @@*/ #include "hw/boards.h" +#include "qapi/visitor.h" + +static char *machine_get_accel (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return g_strdup (machine_state->accel); +} + +static void machine_set_accel (Object *obj,const char *value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->accel =g_strdup (value); +} + +static bool machine_get_kernel_irqchip (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return machine_state->kernel_irqchip; +} + +static void machine_set_kernel_irqchip (Object *obj,bool value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->kernel_irqchip = value; +} + +static void machine_get_kvm_shadow_mem (Object *obj,Visitor *v, +void *opaque,const char *name, +Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +int64_t value = machine_state->kvm_shadow_mem; + +visit_type_int (v, &value, name, errp); +} + +static void machine_set_kvm_shadow_mem (Object *obj,Visitor *v, +void *opaque,const char *name, +Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +Error *error =NULL ; +int64_t value; + +visit_type_int (v, &value, name, &error); +if (error) { +error_propagate (errp, error); +return ; + } + + machine_state->kvm_shadow_mem = value; +} + +static char *machine_get_kernel (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return g_strdup (machine_state->kernel); +} + +static void machine_set_kernel (Object *obj,const char *value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->kernel =g_strdup (value); +} + +static char *machine_get_initrd (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return g_strdup (machine_state->initrd); +} + +static void machine_set_initrd (Object *obj,const char *value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->initrd =g_strdup (value); +} + +static char *machine_get_append (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return g_strdup (machine_state->append); +} + +static void machine_set_append (Object *obj,const char *value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->append =g_strdup (value); +} + +static char *machine_get_dtb (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return g_strdup (machine_state->dtb); +} + +static void machine_set_dtb (Object *obj,const char *value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->dtb =g_strdup (value); +} + +static char *machine_get_dumpdtb (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return g_strdup (machine_state->dumpdtb); +} + +static void machine_set_dumpdtb (Object *obj,const char *value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->dumpdtb =g_strdup (value); +} + +static void machine_get_phandle_start (Object *obj,Visitor *v, +void *opaque,const char *name, +Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +int64_t value = machine_state->phandle_start; + +visit_type_int (v, &value, name, errp); +} + +static void machine_set_phandle_start (Object *obj,Visitor *v, +void *opaque,const char *name, +Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +Error *error =NULL ; +int64_t value; + +visit_type_int (v, &value, name, &error); +if (error) { +error_propagate (errp, error); +return ; + } + + machine_state->phandle_start = value; +} + +static char *machine_get_dt_compatible (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return g_strdup (machine_state->dt_compatible); +} + +static void machine_set_dt_compatible (Object *obj,const char *value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->dt_compatible =g_strdup (value); +} + +static bool machine_get_dump_guest_core (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return machine_state->dump_guest_core; +} + +static void machine_set_dump_guest_core (Object *obj,bool value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->dump_guest_core = value; +} + +static bool machine_get_mem_merge (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return machine_state->mem_merge; +} + +static void machine_set_mem_merge (Object *obj,bool value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->mem_merge = value; +} + +static bool machine_get_usb (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return machine_state->usb; +} + +static void machine_set_usb (Object *obj,bool value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->usb = value; +} + +static char *machine_get_firmware (Object *obj,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); +return g_strdup (machine_state->firmware); +} + +static void machine_set_firmware (Object *obj,const char *value,Error **errp) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + machine_state->firmware =g_strdup (value); +}static void qemu_machine_initfn (Object *obj) { +object_property_add_str (obj,"accel" , + machine_get_accel, machine_set_accel,NULL ); +object_property_add_bool (obj,"kernel_irqchip" , + machine_get_kernel_irqchip, + machine_set_kernel_irqchip, +NULL ); +object_property_add (obj,"kvm-shadow-mem" ,"int" , + machine_get_kvm_shadow_mem, + machine_set_kvm_shadow_mem, +NULL ,NULL ,NULL ); +object_property_add_str (obj,"kernel" , + machine_get_kernel, machine_set_kernel,NULL ); +object_property_add_str (obj,"initrd" , + machine_get_initrd, machine_set_initrd,NULL ); +object_property_add_str (obj,"append" , + machine_get_append, machine_set_append,NULL ); +object_property_add_str (obj,"dtb" , + machine_get_dtb, machine_set_dtb,NULL ); +object_property_add_str (obj,"dumpdtb" , + machine_get_dumpdtb, machine_set_dumpdtb,NULL ); +object_property_add (obj,"phandle_start" ,"int" , + machine_get_phandle_start, + machine_set_phandle_start, +NULL ,NULL ,NULL ); +object_property_add_str (obj,"dt_compatible" , + machine_get_dt_compatible, + machine_set_dt_compatible, +NULL ); +object_property_add_bool (obj,"dump-guest-core" , + machine_get_dump_guest_core, + machine_set_dump_guest_core, +NULL ); +object_property_add_bool (obj,"mem-merge" , + machine_get_mem_merge, machine_set_mem_merge,NULL ); +object_property_add_bool (obj,"usb" , machine_get_usb, machine_set_usb,NULL ); +object_property_add_str (obj,"firmware" , + machine_get_firmware, machine_set_firmware,NULL ); }static void qemu_machine_class_init (ObjectClass *oc,void *data) { } +static void qemu_machine_finalize (Object *obj) +{ +QemuMachineState *machine_state =QEMU_MACHINE (obj); + +g_free (machine_state->accel); +g_free (machine_state->kernel); +g_free (machine_state->initrd); +g_free (machine_state->append); +g_free (machine_state->dtb); +g_free (machine_state->dumpdtb); +g_free (machine_state->dt_compatible); +g_free (machine_state->firmware); +} +static const TypeInfo qemu_machine_info = { .name =TYPE_QEMU_MACHINE , .parent =TYPE_OBJECT ,
@@ -28,6 +278,7 @@ static const TypeInfo qemu_machine_info = { .class_init = qemu_machine_class_init, .instance_size = sizeof(QemuMachineState), .instance_init = qemu_machine_initfn, + .instance_finalize = qemu_machine_finalize, };static void register_types (void )
include/hw/boards.h +15 -0
@@ -86,6 +86,21 @@ struct QemuMachineState {Object parent;/* public */ +char *accel; +bool kernel_irqchip; +int kvm_shadow_mem; +char *kernel; +char *initrd; +char *append; +char *dtb; +char *dumpdtb; +int phandle_start; +char *dt_compatible; +bool dump_guest_core; +bool mem_merge; +bool usb; +char *firmware; +QEMUMachineInitArgs *init_args; };
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH RFC 4/5] hw/machine: add qemu machine opts as properties to QemuMachineState
Il 30/01/2014 15:47, Marcel Apfelbaum ha scritto:
Quoted 5 lines
include/hw/boards.h +0
-0
include/hw/boards.h struct QemuMachineState { · line 94
Quoted 9 lines
include/hw/boards.h +6
-0@@ -86,6 +86,21 @@ struct QemuMachineState {Object parent;/* public */ +char *accel; +bool kernel_irqchip; +int kvm_shadow_mem; +char *kernel; +char *initrd; +char *append;
Many of these are in init_args as well.
Perhaps you can include the init_args by value instead of having a pointer, and make the setters store into the init_args. It should be fairly easy to use ¤t_machine->init_args in vl.c instead of the current
QEMUMachineInitArgs args = { .machine = machine,
.ram_size = ram_size, .boot_order = boot_order, .kernel_filename = kernel_filename, .kernel_cmdline = kernel_cmdline, .initrd_filename = initrd_filename, .cpu_model = cpu_model };
machine->init(&args);
Otherwise the series is nice!
Do you think it makes sense to prepend something like "machine::" or "machine-" to the class name?
Paolo
Quoted 10 lines
include/hw/boards.h +9
-0+char *dtb; +char *dumpdtb; +int phandle_start; +char *dt_compatible; +bool dump_guest_core; +bool mem_merge; +bool usb; +char *firmware; +QEMUMachineInitArgs *init_args;
Re: [Qemu-devel] [PATCH RFC 4/5] hw/machine: add qemu machine opts as properties to QemuMachineState
Quoted 9 lines · Paolo Bonzini
Il 30/01/2014 15:47, Marcel Apfelbaum ha scritto:
Quoted 8 lines
include/hw/boards.h +0
-0@@ -86,6 +86,21 @@ struct QemuMachineState {Object parent;/* public */
Quoted 6 lines
include/hw/boards.h struct QemuMachineState { · line 94
Quoted 6 lines
include/hw/boards.h +6
-0+char *accel; +bool kernel_irqchip; +int kvm_shadow_mem; +char *kernel; +char *initrd; +char *append;
Hi Paolo,
Thanks for the review,
Quoted 8 lines
Many of these are in
init_argsas well.Perhaps you can include the
init_argsby value instead of having a pointer, and make the setters store into theinit_args. It should be fairly easy to use¤t_machine->init_argsinvl.cinstead of the current
Quoted 8 lines
QEMUMachineInitArgs args = { .machine = machine,
.ram_size =ram_size, .boot_order =boot_order, .kernel_filename =kernel_filename, .kernel_cmdline =kernel_cmdline, .initrd_filename =initrd_filename, .cpu_model =cpu_model};
machine->init(&args);
Sure it will be by value or... I plan to replace QEMUMachineInitArgs with regular QOM properties of QemuMachineState.
Quoted 2 lines
Otherwise the series is nice!
Thanks!
Quoted 3 lines
Do you think it makes sense to prepend something like "machine::" or "machine-" to the class name?
I am not familiar with the QOM classes naming convention, so I see no reason why not... what are the current guidelines? prefix-<name>, prefix::<name>, what is preferable?
Thanks,
Marcel
Quoted 14 lines
Paolo
Quoted 10 lines
include/hw/boards.h +9
-0+char *dtb; +char *dumpdtb; +int phandle_start; +char *dt_compatible; +bool dump_guest_core; +bool mem_merge; +bool usb; +char *firmware; +QEMUMachineInitArgs *init_args;
Re: [Qemu-devel] [PATCH RFC 4/5] hw/machine: add qemu machine opts as properties to QemuMachineState
Il 30/01/2014 18:28, Marcel Apfelbaum ha scritto:
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
QEMUMachineInitArgs args = { .machine = machine,
.ram_size =ram_size, .boot_order =boot_order, .kernel_filename =kernel_filename, .kernel_cmdline =kernel_cmdline, .initrd_filename =initrd_filename, .cpu_model =cpu_model};
machine->init(&args);Sure it will be by value or... I plan to replace QEMUMachineInitArgs with regular QOM properties of QemuMachineState.
Yes---by value for now, then it can removed when you get to s/QEMUMachineInitArgs/QemuMachineState.
Including the "old" object by value BTW is how the CPU conversion started as well.
Paolo
RFC PATCH 5/5 vl.c: set current_machine's properties
In reply to Marcel ApfelbaumSetting machine's properties provides a cleaner
way to get the properties values than using
QemuOpts.
--- vl.c | 5 +++++ 1 file changed, 5 insertions(+)
vl.c +5 -0
@@ -4307,6 +4307,11 @@ int main(int argc, char **argv, char **envp) current_machine =QEMU_MACHINE (object_new (object_class_get_name (OBJECT_CLASS (machine_class)))); +if (qemu_opt_foreach (machine_opts, object_set_property, current_machine,1 ) <0 ) { +object_unref (OBJECT (current_machine)); +exit (1 ); + } +/* init USB devices */ if (usb_enabled (false)) {if (foreach_device_config (DEV_USB , usb_parse) <0 )
Signature · 1 line
1.8.3.1