migration: objectify MigrationState
PATCH 1/6 migration: let MigrationState be a qdev
In reply to Peter XuLet the old man "MigrationState" join the object family. Direct benefit is that we can start to use all the property features derived from current QDev, like: HW_COMPAT_* bits, command line setup for migration parameters (so will never need to set them up each time using HMP/QMP, this is really, really attractive for test writters), etc.
I see no reason to disallow this happen yet. So let's start from this one, to see whether it would be anything good.
No functional change at all.
--- include/migration/migration.h | 19 +++++++++++++++ migration/migration.c | 57 +++++++++++++++++++++++++++++-------------- 2 files changed, 58 insertions(+), 18 deletions(-)
include/migration/migration.h +19 -0
@@ -21,6 +21,7 @@#include "qapi-types.h" #include "exec/cpu-common.h" #include "qemu/coroutine_int.h" +#include "hw/qdev.h" #define QEMU_VM_FILE_MAGIC 0x5145564d#define QEMU_VM_FILE_VERSION_COMPAT 0x00000002
@@ -49,6 +50,8 @@ enum mig_rp_message_type {MIG_RP_MSG_MAX }; +#define TYPE_MIGRATION "migration" +/* State for the incoming migration */ struct MigrationIncomingState {QEMUFile *from_src_file;
@@ -91,8 +94,24 @@ struct MigrationIncomingState {MigrationIncomingState *migration_incoming_get_current (void );void migration_incoming_state_destroy (void ); +#define MIGRATION_CLASS (klass) \ + OBJECT_CLASS_CHECK(MigrationClass, (klass), TYPE_MIGRATION) +#define MIGRATION_OBJ (obj) \ + OBJECT_CHECK(MigrationState, (obj), TYPE_MIGRATION) +#define MIGRATION_GET_CLASS (obj) \ + OBJECT_GET_CLASS(MigrationClass, (obj), TYPE_MIGRATION) + +typedef struct MigrationClass { +/*< private >*/ +DeviceClass parent_class; +}MigrationClass ; +struct MigrationState { +/*< private >*/ +DeviceState parent_obj; + +/*< public >*/ size_t bytes_xfer;size_t xfer_limit;QemuThread thread;
migration/migration.c +39 -18
70 lines not on this page · raw message
Signature · 1 line
2.7.4
cover migration: objectify MigrationState
I picked this topic out as suggested by Juan. Also I did what Juan has suggested in previous discussions that I moved lots of global parameters into MigrationState, and let them be properties. Then we can use HW_COMPAT_* and "-global migration.xxx=xxx" formular.
If without xen_init(), we can remove more LOC. However there is it, so I changed the bits as best as I can.
If this can be merged and okay, we can move on to convert more things into properties for migration.
Please review. Thanks.
Peter Xu (6):
migration: let MigrationState be a qdev
migration: move global_state.optional out
migration: use compat bit for global_state
migration: move only_migratable to MigrationState
migration: move skip_configuration out
migration: move skip_section_footers
hw/i386/pc_piix.c | 3 -- hw/ppc/spapr.c | 3 -- include/hw/compat.h | 12 ++++++ include/migration/migration.h | 33 +++++++++++++++++ include/sysemu/sysemu.h | 1 - migration/migration.c | 85 +++++++++++++++++++++++++++++++------------ migration/savevm.c | 22 +++++------ vl.c | 9 ++++- 8 files changed, 123 insertions(+), 45 deletions(-)
Signature · 1 line
2.7.4
PATCH 2/6 migration: move global_state.optional out
Put it into MigrationState then we can use the properties to specify whether to enable storing global state.
--- include/migration/migration.h | 6 ++++++ migration/migration.c | 21 +++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-)
include/migration/migration.h +6 -0
@@ -162,6 +162,12 @@ struct MigrationState/* Do we have to clean up -b/-i from old migrate parameters */ /* This feature is deprecated and will be removed */ bool must_remove_block_options; + +/* +* Global switch on whether we need to store the global state +* during migration. +*/ +bool store_global_state; };void migrate_set_state (int *state,int old_state,int new_state);
migration/migration.c +17 -4
@@ -140,13 +140,13 @@ void migration_incoming_state_destroy(void)typedef struct { -bool optional;uint32_t size;uint8_t runstate[100 ];RunState state;bool received; }GlobalState ; +/* This is only used if MigrationState.store_global_state is set. */ static GlobalState global_state;int global_state_store (void )
@@ -179,7 +179,7 @@ static RunState global_state_get_runstate(void)void global_state_set_optional (void ) { - global_state.optional = true; +migrate_get_current ()->store_global_state = false; }static bool global_state_needed (void *opaque)
@@ -188,8 +188,7 @@ static bool global_state_needed(void *opaque)char *runstate = (char *)s->runstate;/* If it is not optional, it is mandatory */ - -if (s->optional == false) { +if (migrate_get_current ()->store_global_state) {return true; }
@@ -2109,6 +2108,19 @@ void migrate_fd_connect(MigrationState *s) s->migration_thread_running = true; } +static Property migration_properties[] = { +DEFINE_PROP_BOOL ("store-global-state" , MigrationState, + store_global_state, true), +DEFINE_PROP_END_OF_LIST (), +}; + +static void migration_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->props = migration_properties; +} +static void migration_instance_init (Object *obj) {MigrationState *ms =MIGRATION_OBJ (obj);
@@ -2133,6 +2145,7 @@ static void migration_instance_init(Object *obj)static const TypeInfo migration_type = { .name =TYPE_MIGRATION , .parent =TYPE_DEVICE , + .class_init = migration_class_init, .class_size =sizeof (MigrationClass), .instance_size =sizeof (MigrationState), .instance_init = migration_instance_init,
Signature · 1 line
2.7.4
PATCH 3/6 migration: use compat bit for global_state
In reply to Peter XuRemoving two callers of global_state_set_optional() since now we can use HW_COMPAT_2_3. However there is still one more caller (xen_init), so we still need to keep the function until it disappears.
--- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - include/hw/compat.h | 4 ++++ 3 files changed, 4 insertions(+), 2 deletions(-)
hw/i386/pc_piix.c +0 -1
@@ -317,7 +317,6 @@ static void pc_compat_2_3(MachineState *machine)if (kvm_enabled ()) { pcms->smm =ON_OFF_AUTO_OFF ; } -global_state_set_optional ();savevm_skip_configuration (); }
hw/ppc/spapr.c +0 -1
@@ -3593,7 +3593,6 @@ static void spapr_machine_2_3_instance_options(MachineState *machine) {spapr_machine_2_4_instance_options (machine);savevm_skip_section_footers (); -global_state_set_optional ();savevm_skip_configuration (); }
include/hw/compat.h +4 -0
@@ -177,6 +177,10 @@ .driver = TYPE_PCI_DEVICE,\ .property = "x-pcie-lnksta-dllla",\ .value = "off",\ + },{\ + .driver = "migration",\ + .property = "store-global-state",\ + .value = "off",\ },#define HW_COMPAT_2_2 \
Signature · 1 line
2.7.4
PATCH 4/6 migration: move only_migratable to MigrationState
In reply to Peter XuOne less global variable, and it does only matter with migration.
We keep the old "--only-migratable" option, but also now we support:
-global migration.only-migratable=true
Currently still keep the old interface.
--- include/migration/migration.h | 3 +++ include/sysemu/sysemu.h | 1 - migration/migration.c | 3 ++- migration/savevm.c | 2 +- vl.c | 9 +++++++-- 5 files changed, 13 insertions(+), 5 deletions(-)
include/migration/migration.h +3 -0
@@ -168,6 +168,9 @@ struct MigrationState* during migration. */ bool store_global_state; + +/* Whether the VM is only allowing for migratable devices */ +bool only_migratable; };void migrate_set_state (int *state,int old_state,int new_state);
include/sysemu/sysemu.h +0 -1
@@ -15,7 +15,6 @@/* vl.c */ extern const char *bios_name; -extern int only_migratable;extern const char *qemu_name;extern QemuUUID qemu_uuid;extern bool qemu_uuid_set;
migration/migration.c +2 -1
@@ -1120,7 +1120,7 @@ static GSList *migration_blockers;int migrate_add_blocker (Error *reason,Error **errp) { -if (only_migratable) { +if (migrate_get_current ()->only_migratable) {error_propagate (errp,error_copy (reason));error_prepend (errp,"disallowing migration blocker " "(--only_migratable) for: " );
@@ -2111,6 +2111,7 @@ void migrate_fd_connect(MigrationState *s)static Property migration_properties[] = {DEFINE_PROP_BOOL ("store-global-state" , MigrationState, store_global_state, true), +DEFINE_PROP_BOOL ("only-migratable" , MigrationState, only_migratable, false),DEFINE_PROP_END_OF_LIST (), };
migration/savevm.c +1 -1
@@ -2321,7 +2321,7 @@ void vmstate_register_ram_global(MemoryRegion *mr)bool vmstate_check_only_migratable (const VMStateDescription *vmsd) {/* check needed if --only-migratable is specified */ -if (!only_migratable) { +if (!migrate_get_current ()->only_migratable) {return true; }
vl.c +7 -2
@@ -188,7 +188,6 @@ bool boot_strict;uint8_t *boot_splash_filedata;size_t boot_splash_filedata_size;uint8_t qemu_extra_params_fw[2 ]; -int only_migratable;/* turn it off unless user states otherwise */ int icount_align_option;
@@ -3937,7 +3936,13 @@ int main(int argc, char **argv, char **envp) incoming = optarg;break ;case QEMU_OPTION_only_migratable: - only_migratable =1 ; +/* +* TODO: we can remove this option one day, and we +* should all use: +* +* "-global migration.only-migratable=true" +*/ +migrate_get_current ()->only_migratable = true;break ;case QEMU_OPTION_nodefaults: has_defaults =0 ;
Signature · 1 line
2.7.4
PATCH 6/6 migration: move skip_section_footers
In reply to Peter XuMove it into MigrationState, with a property binded to it.
Same trick played with HW_COMPAT_2_3.
--- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - include/hw/compat.h | 4 ++++ include/migration/migration.h | 2 ++ migration/migration.c | 2 ++ migration/savevm.c | 8 +++----- 6 files changed, 11 insertions(+), 7 deletions(-)
hw/i386/pc_piix.c +0 -1
@@ -313,7 +313,6 @@ static void pc_init1(MachineState *machine,static void pc_compat_2_3 (MachineState *machine) {PCMachineState *pcms =PC_MACHINE (machine); -savevm_skip_section_footers ();if (kvm_enabled ()) { pcms->smm =ON_OFF_AUTO_OFF ; }
hw/ppc/spapr.c +0 -1
@@ -3592,7 +3592,6 @@ DEFINE_SPAPR_MACHINE(2_4, "2.4", false);static void spapr_machine_2_3_instance_options (MachineState *machine) {spapr_machine_2_4_instance_options (machine); -savevm_skip_section_footers (); }static void spapr_machine_2_3_class_options (MachineClass *mc)
include/hw/compat.h +4 -0
@@ -183,6 +183,10 @@ .value = "on",\ },{\ .driver = "migration",\ + .property = "skip-section-footer",\ + .value = "on",\ + },{\ + .driver = "migration",\ .property = "store-global-state",\ .value = "off",\ },
include/migration/migration.h +2 -0
@@ -174,6 +174,8 @@ struct MigrationState/* Whether we skip QEMU_VM_CONFIGURATION for migration */ bool skip_configuration; +/* Whether we skip section footer */ +bool skip_section_footer; };void migrate_set_state (int *state,int old_state,int new_state);
migration/migration.c +2 -0
@@ -2114,6 +2114,8 @@ static Property migration_properties[] = {DEFINE_PROP_BOOL ("only-migratable" , MigrationState, only_migratable, false),DEFINE_PROP_BOOL ("skip-configuration" , MigrationState, skip_configuration, false), +DEFINE_PROP_BOOL ("skip-section-footer" , MigrationState, + skip_section_footer, false), DEFINE_PROP_END_OF_LIST(), };
migration/savevm.c +3 -5
@@ -65,8 +65,6 @@const unsigned int postcopy_ram_discard_version =0 ; -static bool skip_section_footers; -/* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd {MIG_CMD_INVALID =0 ,/* Must be 0 */
@@ -787,7 +785,7 @@ static void vmstate_save(QEMUFile *f, SaveStateEntry *se, QJSON *vmdesc)void savevm_skip_section_footers (void ) { - skip_section_footers = true; +migrate_get_current ()->skip_section_footer = true; }/*
@@ -817,7 +815,7 @@ static void save_section_header(QEMUFile *f, SaveStateEntry *se,*/ static void save_section_footer (QEMUFile *f,SaveStateEntry *se) { -if (!skip_section_footers) { +if (!migrate_get_current ()->skip_section_footer) {qemu_put_byte (f,QEMU_VM_SECTION_FOOTER );qemu_put_be32 (f, se->section_id); }
@@ -1815,7 +1813,7 @@ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se)uint8_t read_mark;uint32_t read_section_id; -if (skip_section_footers) { +if (migrate_get_current ()->skip_section_footer) {/* No footer to check */ return true; }
Signature · 1 line
2.7.4
PATCH 5/6 migration: move skip_configuration out
In reply to Peter XuIt was in SaveState but now moved to MigrationState altogether. Again, using HW_COMPAT_2_3 for old PC/SPAPR machines but still we'll have to keep savevm_skip_configuration() since used by xen_init().
--- hw/i386/pc_piix.c | 1 - hw/ppc/spapr.c | 1 - include/hw/compat.h | 4 ++++ include/migration/migration.h | 3 +++ migration/migration.c | 2 ++ migration/savevm.c | 12 +++++------- 6 files changed, 14 insertions(+), 9 deletions(-)
hw/i386/pc_piix.c +0 -1
@@ -317,7 +317,6 @@ static void pc_compat_2_3(MachineState *machine)if (kvm_enabled ()) { pcms->smm =ON_OFF_AUTO_OFF ; } -savevm_skip_configuration (); }static void pc_compat_2_2 (MachineState *machine)
hw/ppc/spapr.c +0 -1
@@ -3593,7 +3593,6 @@ static void spapr_machine_2_3_instance_options(MachineState *machine) {spapr_machine_2_4_instance_options (machine);savevm_skip_section_footers (); -savevm_skip_configuration (); }static void spapr_machine_2_3_class_options (MachineClass *mc)
include/hw/compat.h +4 -0
@@ -179,6 +179,10 @@ .value = "off",\ },{\ .driver = "migration",\ + .property = "skip-configuration",\ + .value = "on",\ + },{\ + .driver = "migration",\ .property = "store-global-state",\ .value = "off",\ },
include/migration/migration.h +3 -0
@@ -171,6 +171,9 @@ struct MigrationState/* Whether the VM is only allowing for migratable devices */ bool only_migratable; + +/* Whether we skip QEMU_VM_CONFIGURATION for migration */ +bool skip_configuration; };void migrate_set_state (int *state,int old_state,int new_state);
migration/migration.c +2 -0
@@ -2112,6 +2112,8 @@ static Property migration_properties[] = {DEFINE_PROP_BOOL ("store-global-state" , MigrationState, store_global_state, true),DEFINE_PROP_BOOL ("only-migratable" , MigrationState, only_migratable, false), +DEFINE_PROP_BOOL ("skip-configuration" , MigrationState, + skip_configuration, false), DEFINE_PROP_END_OF_LIST(), };
migration/savevm.c +5 -7
@@ -290,7 +290,6 @@ typedef struct SaveStateEntry { typedef struct SaveState { QTAILQ_HEAD(, SaveStateEntry) handlers; int global_section_id; - bool skip_configuration; uint32_t len; const char *name; uint32_t target_page_bits;
@@ -299,15 +298,13 @@ typedef struct SaveState {static SaveState savevm_state = { .handlers =QTAILQ_HEAD_INITIALIZER (savevm_state.handlers), .global_section_id =0 , - .skip_configuration = false, };void savevm_skip_configuration (void ) { - savevm_state.skip_configuration = true; +migrate_get_current ()->skip_configuration = true; } -static void configuration_pre_save (void *opaque) {SaveState *state = opaque;
@@ -989,11 +986,11 @@ void qemu_savevm_state_header(QEMUFile *f)qemu_put_be32 (f,QEMU_VM_FILE_MAGIC );qemu_put_be32 (f,QEMU_VM_FILE_VERSION ); -if (!savevm_state.skip_configuration ||enforce_config_section ()) { +if (!migrate_get_current ()->skip_configuration || +enforce_config_section ()) {qemu_put_byte (f,QEMU_VM_CONFIGURATION );vmstate_save_state (f, &vmstate_configuration, &savevm_state,0 ); } - }void qemu_savevm_state_begin (QEMUFile *f)
@@ -2003,7 +2000,8 @@ int qemu_loadvm_state(QEMUFile *f)return -ENOTSUP ; } -if (!savevm_state.skip_configuration ||enforce_config_section ()) { +if (!migrate_get_current ()->skip_configuration || +enforce_config_section ()) {if (qemu_get_byte (f) !=QEMU_VM_CONFIGURATION ) {error_report ("Configuration section missing" );return -EINVAL ;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 1/6] migration: let MigrationState be a qdev
In reply to Peter XuQuoted 6 lines · Peter Xu
Let the old man "MigrationState" join the object family. Direct benefit is that we can start to use all the property features derived from current QDev, like: HW_COMPAT_* bits, command line setup for migration parameters (so will never need to set them up each time using HMP/QMP, this is really, really attractive for test writters), etc.
Quoted 6 lines
I see no reason to disallow this happen yet. So let's start from this one, to see whether it would be anything good.
No functional change at all.
Signed-off-by Peter Xu <[email protected]>
I am not qapi expert, but for the migration bits:
Re: [Qemu-devel] [PATCH 2/6] migration: move global_state.optional out
In reply to Peter XuQuoted 46 lines · Peter Xu
Put it into MigrationState then we can use the properties to specify whether to enable storing global state.
Signed-off-by Peter Xu <[email protected]>--- include/migration/migration.h | 6 ++++++ migration/migration.c | 21 +++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-)include/migration/migration.h +6
-0@@ -162,6 +162,12 @@ struct MigrationState/* Do we have to clean up -b/-i from old migrate parameters */ /* This feature is deprecated and will be removed */ bool must_remove_block_options; + +/* +* Global switch on whether we need to store the global state +* during migration. +*/ +bool store_global_state; };void migrate_set_state (int *state,int old_state,int new_state);migration/migration.c +1
-1@@ -140,13 +140,13 @@ void migration_incoming_state_destroy(void)typedef struct { -bool optional;uint32_t size;uint8_t runstate[100 ];RunState state;bool received; }GlobalState ; +/* This is only used if MigrationState.store_global_state is set. */ static GlobalState global_state;int global_state_store (void )
migration/migration.c static RunState global_state_get_runstate(void) · line 182
Quoted 5 lines
migration/migration.c +1
-1@@ -179,7 +179,7 @@ static RunState global_state_get_runstate(void)void global_state_set_optional (void ) { - global_state.optional = true; +migrate_get_current ()->store_global_state = false;
Part of the advantage (for me) of using qapi was not to have to export a function to set this. I.e. isn't a way to call
qemu_opt_get_bool(migration_opts, "store_global_state", true)
qapi_<magic>_set_bool(migration_opts, "store_global_state",false); ?
So, I don't have to eport global_state_set_optional()?
My goal would be that when I need to add a new propertly, I add it to migration_properties and to MigrationState and call it a day?
migration/migration.c static bool global_state_needed(void *opaque) · line 191
Quoted 8 lines
migration/migration.c +1
-2static bool global_state_needed (void *opaque)@@ -188,8 +188,7 @@ static bool global_state_needed(void *opaque)char *runstate = (char *)s->runstate;/* If it is not optional, it is mandatory */ - -if (s->optional == false) { +if (migrate_get_current ()->store_global_state) {
Being able to query without having a function would also be nice.
Later, Juan.
Quoted 31 lines
migration/migration.c +14
-0return true; }@@ -2109,6 +2108,19 @@ void migrate_fd_connect(MigrationState *s) s->migration_thread_running = true; } +static Property migration_properties[] = { +DEFINE_PROP_BOOL ("store-global-state" , MigrationState, + store_global_state, true), +DEFINE_PROP_END_OF_LIST (), +}; + +static void migration_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->props = migration_properties; +} +static void migration_instance_init (Object *obj) {MigrationState *ms =MIGRATION_OBJ (obj);@@ -2133,6 +2145,7 @@ static void migration_instance_init(Object *obj)static const TypeInfo migration_type = { .name =TYPE_MIGRATION , .parent =TYPE_DEVICE , + .class_init = migration_class_init, .class_size =sizeof (MigrationClass), .instance_size =sizeof (MigrationState), .instance_init = migration_instance_init,
Re: [Qemu-devel] [PATCH 3/6] migration: use compat bit for global_state
In reply to Peter XuQuoted 5 lines · Peter Xu
Removing two callers of
global_state_set_optional()since now we can useHW_COMPAT_2_3. However there is still one more caller (xen_init), so we still need to keep the function until it disappears.Signed-off-by Peter Xu <[email protected]>
Ah, you do it here, nice.
Re: [Qemu-devel] [PATCH 5/6] migration: move skip_configuration out
In reply to Peter XuQuoted 3 lines · Peter Xu
It was in SaveState but now moved to MigrationState altogether. Again, using
HW_COMPAT_2_3for old PC/SPAPR machines but still we'll have to keepsavevm_skip_configuration()since used byxen_init().
oops.
Quoted 2 lines
Signed-off-by Peter Xu <[email protected]>
Re: [Qemu-devel] [PATCH 6/6] migration: move skip_section_footers
In reply to Peter XuQuoted 5 lines · Peter Xu
Move it into MigrationState, with a property binded to it.
Same trick played with
HW_COMPAT_2_3.Signed-off-by Peter Xu <[email protected]>
Re: [Qemu-devel] [PATCH 2/6] migration: move global_state.optional out
In reply to Juan QuintelaQuoted 56 lines · Juan Quintela
Quoted 46 lines · Peter Xu
Put it into MigrationState then we can use the properties to specify whether to enable storing global state.
Signed-off-by Peter Xu <[email protected]>--- include/migration/migration.h | 6 ++++++ migration/migration.c | 21 +++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-)include/migration/migration.h +6
-0@@ -162,6 +162,12 @@ struct MigrationState/* Do we have to clean up -b/-i from old migrate parameters */ /* This feature is deprecated and will be removed */ bool must_remove_block_options; + +/* +* Global switch on whether we need to store the global state +* during migration. +*/ +bool store_global_state; };void migrate_set_state (int *state,int old_state,int new_state);migration/migration.c +1
-1@@ -140,13 +140,13 @@ void migration_incoming_state_destroy(void)typedef struct { -bool optional;uint32_t size;uint8_t runstate[100 ];RunState state;bool received; }GlobalState ; +/* This is only used if MigrationState.store_global_state is set. */ static GlobalState global_state;int global_state_store (void )migration/migration.c static RunState global_state_get_runstate(void) · line 182
Quoted 5 lines
migration/migration.c +1
-1@@ -179,7 +179,7 @@ static RunState global_state_get_runstate(void)void global_state_set_optional (void ) { - global_state.optional = true; +migrate_get_current ()->store_global_state = false;Part of the advantage (for me) of using qapi was not to have to export a function to set this. I.e. isn't a way to call
Quoted 4 lines
qemu_opt_get_bool(migration_opts, "store_global_state", true)qapi_<magic>_set_bool(migration_opts, "store_global_state",false); ?
I didn't catch the comment here... Do you mean e.g. qemu_opt_set_bool()? Here can we use it in some way?
(I thought we were using the "-global migration.store_global_state"
parameter, then it'll setup MigrationState.store_global_state, isn't that the trick?)
Quoted 3 lines
So, I don't have to eport
global_state_set_optional()?
As mentioned in latter patch, xen_init() still uses it, so looks like we still need it?
I can squash this patch with the next if you like it.
Thanks,
Quoted 48 lines
My goal would be that when I need to add a new propertly, I add it to
migration_propertiesand to MigrationState and call it a day?migration/migration.c static bool global_state_needed(void *opaque) · line 191
Quoted 8 lines
migration/migration.c +1
-2static bool global_state_needed (void *opaque)@@ -188,8 +188,7 @@ static bool global_state_needed(void *opaque)char *runstate = (char *)s->runstate;/* If it is not optional, it is mandatory */ - -if (s->optional == false) { +if (migrate_get_current ()->store_global_state) {Being able to query without having a function would also be nice.
Later, Juan.
Quoted 31 lines
migration/migration.c +14
-0return true; }@@ -2109,6 +2108,19 @@ void migrate_fd_connect(MigrationState *s) s->migration_thread_running = true; } +static Property migration_properties[] = { +DEFINE_PROP_BOOL ("store-global-state" , MigrationState, + store_global_state, true), +DEFINE_PROP_END_OF_LIST (), +}; + +static void migration_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->props = migration_properties; +} +static void migration_instance_init (Object *obj) {MigrationState *ms =MIGRATION_OBJ (obj);@@ -2133,6 +2145,7 @@ static void migration_instance_init(Object *obj)static const TypeInfo migration_type = { .name =TYPE_MIGRATION , .parent =TYPE_DEVICE , + .class_init = migration_class_init, .class_size =sizeof (MigrationClass), .instance_size =sizeof (MigrationState), .instance_init = migration_instance_init,
Signature · 1 line
Peter Xu
Re: [Qemu-devel] [PATCH 2/6] migration: move global_state.optional out
Quoted 21 lines · Peter Xu
Quoted 14 lines · Juan Quintela
migration/migration.c static RunState global_state_get_runstate(void) · line 182
Quoted 10 lines
migration/migration.c +2
-1+/* This is only used if MigrationState.store_global_state is set. */ static GlobalState global_state;int global_state_store (void )@@ -179,7 +179,7 @@ static RunState global_state_get_runstate(void)void global_state_set_optional (void ) { - global_state.optional = true; +migrate_get_current ()->store_global_state = false;Part of the advantage (for me) of using qapi was not to have to export a function to set this. I.e. isn't a way to call
Quoted 4 lines
qemu_opt_get_bool(migration_opts, "store_global_state", true)qapi_<magic>_set_bool(migration_opts, "store_global_state",false); ?
Quoted 6 lines
I didn't catch the comment here... Do you mean e.g.
qemu_opt_set_bool()? Here can we use it in some way?(I thought we were using the "-global migration.store_global_state"
parameter, then it'll setup MigrationState.store_global_state, isn't that the trick?)
Yeap. Althought for me would be the same if that is stored anywhare else. I don't really care where it is stored.
Quoted 6 lines
Quoted 3 lines
So, I don't have to eport
global_state_set_optional()?As mentioned in latter patch,
xen_init()still uses it, so looks like we still need it?
Yeap. I *thought* that there was a way to test/set thing programatically also so I didn't have to create/export that functions. My ideal world would be that there were something like that
qemu_opt_get_bool(migration_opts, "store_global_state", true);
so I only have to export migration_opts (or whatever), and just set/read values from places like xen_init. Im my ideal world, if I have to create a new "property", I don't want to have to export a function to set/read it. For instance, the case of xen_init(). We haven't been able to remove global_state_set_optional() because they don't know about properties.
I still love the patches are they are. Boing able to set things from the command line makes things so much better/easier O:-)
Quoted 1 line
I can squash this patch with the next if you like it.
That is up to you.
Thanks, Juan.
Re: [Qemu-devel] [PATCH 2/6] migration: move global_state.optional out
Quoted 52 lines · Juan Quintela
Quoted 21 lines · Peter Xu
Quoted 14 lines · Juan Quintela
migration/migration.c static RunState global_state_get_runstate(void) · line 182
Quoted 10 lines
migration/migration.c +2
-1+/* This is only used if MigrationState.store_global_state is set. */ static GlobalState global_state;int global_state_store (void )@@ -179,7 +179,7 @@ static RunState global_state_get_runstate(void)void global_state_set_optional (void ) { - global_state.optional = true; +migrate_get_current ()->store_global_state = false;Part of the advantage (for me) of using qapi was not to have to export a function to set this. I.e. isn't a way to call
Quoted 4 lines
qemu_opt_get_bool(migration_opts, "store_global_state", true)qapi_<magic>_set_bool(migration_opts, "store_global_state",false); ?
Quoted 6 lines
I didn't catch the comment here... Do you mean e.g.
qemu_opt_set_bool()? Here can we use it in some way?(I thought we were using the "-global migration.store_global_state"
parameter, then it'll setup MigrationState.store_global_state, isn't that the trick?)Yeap. Althought for me would be the same if that is stored anywhare else. I don't really care where it is stored.
Quoted 6 lines
Quoted 3 lines
So, I don't have to eport
global_state_set_optional()?As mentioned in latter patch,
xen_init()still uses it, so looks like we still need it?Yeap. I *thought* that there was a way to test/set thing programatically also so I didn't have to create/export that functions. My ideal world would be that there were something like that
qemu_opt_get_bool(migration_opts, "store_global_state", true);so I only have to export
migration_opts(or whatever), and just set/read values from places likexen_init. Im my ideal world, if I have to create a new "property", I don't want to have to export a function to set/read it. For instance, the case ofxen_init(). We haven't been able to removeglobal_state_set_optional()because they don't know about properties.
Quoted 2 lines
I still love the patches are they are. Boing able to set things from the command line makes things so much better/easier O:-)
Oh, looks like what we need to do is just export register_compat_prop(), then xen_init() can use it.
I'll try that tomorrow. :)
Signature · 1 line
Peter Xu
Re: [Qemu-devel] [PATCH 2/6] migration: move global_state.optional out
Quoted 3 lines · Peter Xu
Quoted 2 lines · Juan Quintela
Quoted 1 line · Peter Xu
On Wed, Jun 07, 2017 at 07:42:57PM +0200, Juan Quintela wrote:
...
Quoted 14 lines
Quoted 14 lines
Yeap. I *thought* that there was a way to test/set thing programatically also so I didn't have to create/export that functions. My ideal world would be that there were something like that
qemu_opt_get_bool(migration_opts, "store_global_state", true);so I only have to export
migration_opts(or whatever), and just set/read values from places likexen_init. Im my ideal world, if I have to create a new "property", I don't want to have to export a function to set/read it. For instance, the case ofxen_init(). We haven't been able to removeglobal_state_set_optional()because they don't know about properties.
Quoted 7 lines
Quoted 2 lines
I still love the patches are they are. Boing able to set things from the command line makes things so much better/easier O:-)
Oh, looks like what we need to do is just export
register_compat_prop(), thenxen_init()can use it.I'll try that tomorrow. :)
Thanks, Juan.