Message ID | 1457605407-679-1-git-send-email-xiecl.fnst@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 03/10/2016 03:23 AM, Changlong Xie wrote: > From: Wen Congyang <wency@cn.fujitsu.com> > > Introduce a "xen-load-devices-state" QAPI command that can be used to load > the state of all devices, but not the RAM or the block devices of the > VM. > > We only have hmp commands savevm/loadvm, and qmp commands > xen-save-devices-state. > > We use this new command for COLO: > 1. suspend both primay vm and secondary vm s/primay/primary/ > 2. sync the state > 3. resume both primary vm and secondary vm > > In such case, we need to update all devices's state in any time. s/devices's/devices/' > > Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> > Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com> > --- > +++ b/qapi-schema.json > @@ -4122,3 +4122,21 @@ > ## > { 'enum': 'ReplayMode', > 'data': [ 'none', 'record', 'play' ] } > + > +## > +# @xen-load-devices-state: > +# > +# Load the state of all devices from file. The RAM and the block devices > +# of the VM are not loaded by this command. > +# > +# @filename: the file to load the state of the devices from as binary > +# data. See xen-save-devices-state.txt for a description of the binary > +# format. > +# > +# Returns: Nothing on success > +# If @filename cannot be opened, OpenFileFailed > +# If an I/O error occurs while reading the file, IOError Drop the whole Returns: paragraph. We have very few distinguished error categories, and you are not using anything other than a generic error category here (that is, OpenFileFailed and IOError are NOT valid QMP error categories). > +# > +# Since: 2.6 You missed soft freeze; is this still 2.6 material? > +++ b/qmp-commands.hx > @@ -587,6 +587,33 @@ Example: > EQMP > > { > + .name = "xen-load-devices-state", > + .args_type = "filename:F", > + .mhandler.cmd_new = qmp_marshal_xen_load_devices_state, > + }, > + > +SQMP > +xen-load-devices-state > +------- Make the ---- separator line the same length as the text it is underlining.
On 03/11/2016 04:31 AM, Eric Blake wrote: > On 03/10/2016 03:23 AM, Changlong Xie wrote: >> From: Wen Congyang <wency@cn.fujitsu.com> >> >> Introduce a "xen-load-devices-state" QAPI command that can be used to load >> the state of all devices, but not the RAM or the block devices of the >> VM. >> >> We only have hmp commands savevm/loadvm, and qmp commands >> xen-save-devices-state. >> >> We use this new command for COLO: >> 1. suspend both primay vm and secondary vm > > s/primay/primary/ Hi Eric Will fix in next version. > >> 2. sync the state >> 3. resume both primary vm and secondary vm >> >> In such case, we need to update all devices's state in any time. > > s/devices's/devices/' Ditto. > >> >> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> >> Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com> >> --- > >> +++ b/qapi-schema.json >> @@ -4122,3 +4122,21 @@ >> ## >> { 'enum': 'ReplayMode', >> 'data': [ 'none', 'record', 'play' ] } >> + >> +## >> +# @xen-load-devices-state: >> +# >> +# Load the state of all devices from file. The RAM and the block devices >> +# of the VM are not loaded by this command. >> +# >> +# @filename: the file to load the state of the devices from as binary >> +# data. See xen-save-devices-state.txt for a description of the binary >> +# format. >> +# >> +# Returns: Nothing on success >> +# If @filename cannot be opened, OpenFileFailed >> +# If an I/O error occurs while reading the file, IOError > > Drop the whole Returns: paragraph. We have very few distinguished error > categories, and you are not using anything other than a generic error > category here (that is, OpenFileFailed and IOError are NOT valid QMP > error categories). > Ditto. >> +# >> +# Since: 2.6 > > You missed soft freeze; is this still 2.6 material? > "Since: 2.7" should be fine. > >> +++ b/qmp-commands.hx >> @@ -587,6 +587,33 @@ Example: >> EQMP >> >> { >> + .name = "xen-load-devices-state", >> + .args_type = "filename:F", >> + .mhandler.cmd_new = qmp_marshal_xen_load_devices_state, >> + }, >> + >> +SQMP >> +xen-load-devices-state >> +------- > > Make the ---- separator line the same length as the text it is underlining. > Surely. Thanks -Xie
Eric Blake <eblake@redhat.com> writes: > On 03/10/2016 03:23 AM, Changlong Xie wrote: [...] >> +++ b/qapi-schema.json >> @@ -4122,3 +4122,21 @@ >> ## >> { 'enum': 'ReplayMode', >> 'data': [ 'none', 'record', 'play' ] } >> + >> +## >> +# @xen-load-devices-state: >> +# >> +# Load the state of all devices from file. The RAM and the block devices >> +# of the VM are not loaded by this command. >> +# >> +# @filename: the file to load the state of the devices from as binary >> +# data. See xen-save-devices-state.txt for a description of the binary >> +# format. >> +# >> +# Returns: Nothing on success >> +# If @filename cannot be opened, OpenFileFailed >> +# If an I/O error occurs while reading the file, IOError > > Drop the whole Returns: paragraph. We have very few distinguished error > categories, and you are not using anything other than a generic error > category here (that is, OpenFileFailed and IOError are NOT valid QMP > error categories). I have a patch in my tree that cleans up the remaining bad examples. [...]
diff --git a/migration/savevm.c b/migration/savevm.c index 96e7db5..aaead12 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -50,6 +50,7 @@ #include "qemu/iov.h" #include "block/snapshot.h" #include "block/qapi.h" +#include "hw/xen/xen.h" #ifndef ETH_P_RARP @@ -1768,6 +1769,12 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) return -EINVAL; } + /* Validate if it is a device's state */ + if (xen_enabled() && se->is_ram) { + error_report("loadvm: %s RAM loading not allowed on Xen", idstr); + return -EINVAL; + } + /* Add entry */ le = g_malloc0(sizeof(*le)); @@ -2077,6 +2084,35 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp) } } +void qmp_xen_load_devices_state(const char *filename, Error **errp) +{ + QEMUFile *f; + int saved_vm_running; + int ret; + + saved_vm_running = runstate_is_running(); + vm_stop(RUN_STATE_RESTORE_VM); + + f = qemu_fopen(filename, "rb"); + if (!f) { + error_setg_file_open(errp, errno, filename); + goto out; + } + + migration_incoming_state_new(f); + ret = qemu_loadvm_state(f); + qemu_fclose(f); + migration_incoming_state_destroy(); + if (ret < 0) { + error_setg(errp, QERR_IO_ERROR); + } + +out: + if (saved_vm_running) { + vm_start(); + } +} + int load_vmstate(const char *name) { BlockDriverState *bs, *bs_vm_state; diff --git a/qapi-schema.json b/qapi-schema.json index 362c9d8..27416b6 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4122,3 +4122,21 @@ ## { 'enum': 'ReplayMode', 'data': [ 'none', 'record', 'play' ] } + +## +# @xen-load-devices-state: +# +# Load the state of all devices from file. The RAM and the block devices +# of the VM are not loaded by this command. +# +# @filename: the file to load the state of the devices from as binary +# data. See xen-save-devices-state.txt for a description of the binary +# format. +# +# Returns: Nothing on success +# If @filename cannot be opened, OpenFileFailed +# If an I/O error occurs while reading the file, IOError +# +# Since: 2.6 +## +{ 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} } diff --git a/qmp-commands.hx b/qmp-commands.hx index b629673..5af24a0 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -587,6 +587,33 @@ Example: EQMP { + .name = "xen-load-devices-state", + .args_type = "filename:F", + .mhandler.cmd_new = qmp_marshal_xen_load_devices_state, + }, + +SQMP +xen-load-devices-state +------- + +Load the state of all devices from file. The RAM and the block devices +of the VM are not loaded by this command. + +Arguments: + +- "filename": the file to load the state of the devices from as binary +data. See xen-save-devices-state.txt for a description of the binary +format. + +Example: + +-> { "execute": "xen-load-devices-state", + "arguments": { "filename": "/tmp/resume" } } +<- { "return": {} } + +EQMP + + { .name = "xen-set-global-dirty-log", .args_type = "enable:b", .mhandler.cmd_new = qmp_marshal_xen_set_global_dirty_log,