diff mbox series

[06/15] migration/savevm: Replace current_machine by qdev_get_machine()

Message ID 20200109152133.23649-7-philmd@redhat.com
State New
Headers show
Series Replace current_machine by qdev_get_machine() | expand

Commit Message

Philippe Mathieu-Daudé Jan. 9, 2020, 3:21 p.m. UTC
As we want to remove the global current_machine,
replace MACHINE_GET_CLASS(current_machine) by
MACHINE_GET_CLASS(qdev_get_machine()).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 migration/savevm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Dr. David Alan Gilbert Jan. 9, 2020, 3:52 p.m. UTC | #1
* Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
> As we want to remove the global current_machine,
> replace MACHINE_GET_CLASS(current_machine) by
> MACHINE_GET_CLASS(qdev_get_machine()).
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  migration/savevm.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 59efc1981d..0e8b6a4715 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -292,7 +292,8 @@ static uint32_t get_validatable_capabilities_count(void)
>  static int configuration_pre_save(void *opaque)
>  {
>      SaveState *state = opaque;
> -    const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
> +    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
> +    const char *current_name = mc->name;

For migration:

Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

(Personally I'd keep it on one line, but that's just taste)


>      MigrationState *s = migrate_get_current();
>      int i, j;
>  
> @@ -362,7 +363,8 @@ static bool configuration_validate_capabilities(SaveState *state)
>  static int configuration_post_load(void *opaque, int version_id)
>  {
>      SaveState *state = opaque;
> -    const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
> +    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
> +    const char *current_name = mc->name;
>  
>      if (strncmp(state->name, current_name, state->len) != 0) {
>          error_report("Machine type received is '%.*s' and local is '%s'",
> @@ -615,9 +617,7 @@ static void dump_vmstate_vmsd(FILE *out_file,
>  
>  static void dump_machine_type(FILE *out_file)
>  {
> -    MachineClass *mc;
> -
> -    mc = MACHINE_GET_CLASS(current_machine);
> +    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
>  
>      fprintf(out_file, "  \"vmschkmachine\": {\n");
>      fprintf(out_file, "    \"Name\": \"%s\"\n", mc->name);
> -- 
> 2.21.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Alistair Francis Jan. 12, 2020, 9:43 a.m. UTC | #2
On Thu, Jan 9, 2020 at 11:30 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> As we want to remove the global current_machine,
> replace MACHINE_GET_CLASS(current_machine) by
> MACHINE_GET_CLASS(qdev_get_machine()).
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  migration/savevm.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 59efc1981d..0e8b6a4715 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -292,7 +292,8 @@ static uint32_t get_validatable_capabilities_count(void)
>  static int configuration_pre_save(void *opaque)
>  {
>      SaveState *state = opaque;
> -    const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
> +    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
> +    const char *current_name = mc->name;
>      MigrationState *s = migrate_get_current();
>      int i, j;
>
> @@ -362,7 +363,8 @@ static bool configuration_validate_capabilities(SaveState *state)
>  static int configuration_post_load(void *opaque, int version_id)
>  {
>      SaveState *state = opaque;
> -    const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
> +    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
> +    const char *current_name = mc->name;
>
>      if (strncmp(state->name, current_name, state->len) != 0) {
>          error_report("Machine type received is '%.*s' and local is '%s'",
> @@ -615,9 +617,7 @@ static void dump_vmstate_vmsd(FILE *out_file,
>
>  static void dump_machine_type(FILE *out_file)
>  {
> -    MachineClass *mc;
> -
> -    mc = MACHINE_GET_CLASS(current_machine);
> +    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
>
>      fprintf(out_file, "  \"vmschkmachine\": {\n");
>      fprintf(out_file, "    \"Name\": \"%s\"\n", mc->name);
> --
> 2.21.1
>
>
Juan Quintela Jan. 14, 2020, 1:27 p.m. UTC | #3
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> As we want to remove the global current_machine,
> replace MACHINE_GET_CLASS(current_machine) by
> MACHINE_GET_CLASS(qdev_get_machine()).
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

by the migration bits.
diff mbox series

Patch

diff --git a/migration/savevm.c b/migration/savevm.c
index 59efc1981d..0e8b6a4715 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -292,7 +292,8 @@  static uint32_t get_validatable_capabilities_count(void)
 static int configuration_pre_save(void *opaque)
 {
     SaveState *state = opaque;
-    const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
+    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+    const char *current_name = mc->name;
     MigrationState *s = migrate_get_current();
     int i, j;
 
@@ -362,7 +363,8 @@  static bool configuration_validate_capabilities(SaveState *state)
 static int configuration_post_load(void *opaque, int version_id)
 {
     SaveState *state = opaque;
-    const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
+    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+    const char *current_name = mc->name;
 
     if (strncmp(state->name, current_name, state->len) != 0) {
         error_report("Machine type received is '%.*s' and local is '%s'",
@@ -615,9 +617,7 @@  static void dump_vmstate_vmsd(FILE *out_file,
 
 static void dump_machine_type(FILE *out_file)
 {
-    MachineClass *mc;
-
-    mc = MACHINE_GET_CLASS(current_machine);
+    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
 
     fprintf(out_file, "  \"vmschkmachine\": {\n");
     fprintf(out_file, "    \"Name\": \"%s\"\n", mc->name);