Message ID | 1367247776-7695-6-git-send-email-imammedo@redhat.com |
---|---|
State | New |
Headers | show |
在 2013-04-29一的 17:02 +0200,Igor Mammedov写道: > hot_add_cpu hook should be overriden by target that implements > cpu hot-add via cpu-add QMP command. > > Make machine_args available globaly, it allows to reuse > machine_args->cpu_model during hotplug, instead of adding target > specific globals to keep a copy of cpu_model. > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > --- > v2: > * convert stack veriable args to global machine_args > * don't move current_machine before machine->init(), override hot_add_cpu > staticaly instead. > --- > include/hw/boards.h | 3 +++ > vl.c | 8 ++++++-- > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 425bdc7..657f379 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -18,6 +18,8 @@ typedef struct QEMUMachineInitArgs { > const char *cpu_model; > } QEMUMachineInitArgs; > > +extern QEMUMachineInitArgs machine_args; > + I'm goint to think whether we can pus machine_args into current_machine, that is add QEMUMachineInitArgs member for QEMUMachine. by this, we can avoid this global extern. > typedef void QEMUMachineInitFunc(QEMUMachineInitArgs *args); > > typedef void QEMUMachineResetFunc(void); > @@ -43,6 +45,7 @@ typedef struct QEMUMachine { > GlobalProperty *compat_props; > struct QEMUMachine *next; > const char *hw_version; > + void (*hot_add_cpu)(const int64_t id, Error **errp); > } QEMUMachine; > > int qemu_register_machine(QEMUMachine *m); > diff --git a/vl.c b/vl.c > index 1e7d474..3fe5e94 100644 > --- a/vl.c > +++ b/vl.c > @@ -179,6 +179,8 @@ int main(int argc, char **argv) > #define MAX_VIRTIO_CONSOLES 1 > #define MAX_SCLP_CONSOLES 1 > > +QEMUMachineInitArgs machine_args; > + > static const char *data_dir[16]; > static int data_dir_idx; > const char *bios_name = NULL; > @@ -4291,7 +4293,8 @@ int main(int argc, char **argv, char **envp) > > qdev_machine_init(); > > - QEMUMachineInitArgs args = { .ram_size = ram_size, > + machine_args = (QEMUMachineInitArgs){ > + .ram_size = ram_size, > .boot_device = (boot_devices[0] == '\0') ? > machine->boot_order : > boot_devices, > @@ -4299,7 +4302,8 @@ int main(int argc, char **argv, char **envp) > .kernel_cmdline = kernel_cmdline, > .initrd_filename = initrd_filename, > .cpu_model = cpu_model }; > - machine->init(&args); > + > + machine->init(&machine_args); > > cpu_synchronize_all_post_init(); >
diff --git a/include/hw/boards.h b/include/hw/boards.h index 425bdc7..657f379 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -18,6 +18,8 @@ typedef struct QEMUMachineInitArgs { const char *cpu_model; } QEMUMachineInitArgs; +extern QEMUMachineInitArgs machine_args; + typedef void QEMUMachineInitFunc(QEMUMachineInitArgs *args); typedef void QEMUMachineResetFunc(void); @@ -43,6 +45,7 @@ typedef struct QEMUMachine { GlobalProperty *compat_props; struct QEMUMachine *next; const char *hw_version; + void (*hot_add_cpu)(const int64_t id, Error **errp); } QEMUMachine; int qemu_register_machine(QEMUMachine *m); diff --git a/vl.c b/vl.c index 1e7d474..3fe5e94 100644 --- a/vl.c +++ b/vl.c @@ -179,6 +179,8 @@ int main(int argc, char **argv) #define MAX_VIRTIO_CONSOLES 1 #define MAX_SCLP_CONSOLES 1 +QEMUMachineInitArgs machine_args; + static const char *data_dir[16]; static int data_dir_idx; const char *bios_name = NULL; @@ -4291,7 +4293,8 @@ int main(int argc, char **argv, char **envp) qdev_machine_init(); - QEMUMachineInitArgs args = { .ram_size = ram_size, + machine_args = (QEMUMachineInitArgs){ + .ram_size = ram_size, .boot_device = (boot_devices[0] == '\0') ? machine->boot_order : boot_devices, @@ -4299,7 +4302,8 @@ int main(int argc, char **argv, char **envp) .kernel_cmdline = kernel_cmdline, .initrd_filename = initrd_filename, .cpu_model = cpu_model }; - machine->init(&args); + + machine->init(&machine_args); cpu_synchronize_all_post_init();
hot_add_cpu hook should be overriden by target that implements cpu hot-add via cpu-add QMP command. Make machine_args available globaly, it allows to reuse machine_args->cpu_model during hotplug, instead of adding target specific globals to keep a copy of cpu_model. Signed-off-by: Igor Mammedov <imammedo@redhat.com> --- v2: * convert stack veriable args to global machine_args * don't move current_machine before machine->init(), override hot_add_cpu staticaly instead. --- include/hw/boards.h | 3 +++ vl.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)