@@ -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
@@ -1776,6 +1777,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));
@@ -2085,6 +2092,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 ret;
+
+ /* Guest must be paused before loading the device state; the RAM state will
+ * already have been loaded by xc
+ */
+ if (runstate_is_running()) {
+ error_setg(errp, "Cannot update device state while vm is running");
+ return;
+ }
+ vm_stop(RUN_STATE_RESTORE_VM);
+
+ f = qemu_fopen(filename, "rb");
+ if (!f) {
+ error_setg_file_open(errp, errno, filename);
+ return;
+ }
+
+ migration_incoming_state_new(f);
+ ret = qemu_loadvm_state(f);
+ qemu_fclose(f);
+ if (ret < 0) {
+ error_setg(errp, QERR_IO_ERROR);
+ }
+ migration_incoming_state_destroy();
+}
+
int load_vmstate(const char *name)
{
BlockDriverState *bs, *bs_vm_state;
@@ -4126,3 +4126,17 @@
##
{ '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.
+#
+# Since: 2.7
+##
+{ 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} }
@@ -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,