[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 13/47] Migration commands
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v6 13/47] Migration commands |
Date: |
Tue, 14 Apr 2015 18:03:39 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Create QEMU_VM_COMMAND section type for sending commands from
source to destination. These commands are not intended to convey
guest state but to control the migration process.
For use in postcopy.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
include/migration/migration.h | 1 +
include/sysemu/sysemu.h | 7 +++++++
savevm.c | 47 +++++++++++++++++++++++++++++++++++++++++++
trace-events | 1 +
4 files changed, 56 insertions(+)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 7a6f521..f221c99 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -34,6 +34,7 @@
#define QEMU_VM_SECTION_FULL 0x04
#define QEMU_VM_SUBSECTION 0x05
#define QEMU_VM_VMDESCRIPTION 0x06
+#define QEMU_VM_COMMAND 0x07
struct MigrationParams {
bool blk;
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 8402e6e..e82b205 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -82,6 +82,11 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
void qemu_announce_self(void);
+/* Subcommands for QEMU_VM_COMMAND */
+enum qemu_vm_cmd {
+ MIG_CMD_INVALID = 0, /* Must be 0 */
+};
+
bool qemu_savevm_state_blocked(Error **errp);
void qemu_savevm_state_begin(QEMUFile *f,
const MigrationParams *params);
@@ -90,6 +95,8 @@ int qemu_savevm_state_iterate(QEMUFile *f);
void qemu_savevm_state_complete_precopy(QEMUFile *f);
void qemu_savevm_state_cancel(void);
uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
+void qemu_savevm_command_send(QEMUFile *f, enum qemu_vm_cmd command,
+ uint16_t len, uint8_t *data);
int qemu_loadvm_state(QEMUFile *f);
typedef enum DisplayType
diff --git a/savevm.c b/savevm.c
index eba9174..2dc5fbb 100644
--- a/savevm.c
+++ b/savevm.c
@@ -602,6 +602,24 @@ static void vmstate_save(QEMUFile *f, SaveStateEntry *se,
QJSON *vmdesc)
vmstate_save_state(f, se->vmsd, se->opaque, vmdesc);
}
+
+/* Send a 'QEMU_VM_COMMAND' type element with the command
+ * and associated data.
+ */
+void qemu_savevm_command_send(QEMUFile *f,
+ enum qemu_vm_cmd command,
+ uint16_t len,
+ uint8_t *data)
+{
+ qemu_put_byte(f, QEMU_VM_COMMAND);
+ qemu_put_be16(f, (uint16_t)command);
+ qemu_put_be16(f, len);
+ if (len) {
+ qemu_put_buffer(f, data, len);
+ }
+ qemu_fflush(f);
+}
+
bool qemu_savevm_state_blocked(Error **errp)
{
SaveStateEntry *se;
@@ -927,6 +945,29 @@ static SaveStateEntry *find_se(const char *idstr, int
instance_id)
return NULL;
}
+/*
+ * Process an incoming 'QEMU_VM_COMMAND'
+ * negative return on error (will issue error message)
+ */
+static int loadvm_process_command(QEMUFile *f)
+{
+ uint16_t com;
+ uint16_t len;
+
+ com = qemu_get_be16(f);
+ len = qemu_get_be16(f);
+
+ trace_loadvm_process_command(com, len);
+ switch (com) {
+
+ default:
+ error_report("VM_COMMAND 0x%x unknown (len 0x%x)", com, len);
+ return -1;
+ }
+
+ return 0;
+}
+
typedef struct LoadStateEntry {
QLIST_ENTRY(LoadStateEntry) entry;
SaveStateEntry *se;
@@ -1042,6 +1083,12 @@ int qemu_loadvm_state(QEMUFile *f)
goto out;
}
break;
+ case QEMU_VM_COMMAND:
+ ret = loadvm_process_command(f);
+ if (ret < 0) {
+ goto out;
+ }
+ break;
default:
error_report("Unknown savevm section type %d", section_type);
ret = -EINVAL;
diff --git a/trace-events b/trace-events
index 39957fe..4d093dc 100644
--- a/trace-events
+++ b/trace-events
@@ -1171,6 +1171,7 @@ vmware_setmode(uint32_t w, uint32_t h, uint32_t bpp)
"%dx%d @ %d bpp"
qemu_loadvm_state_section(unsigned int section_type) "%d"
qemu_loadvm_state_section_partend(uint32_t section_id) "%u"
qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr,
uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u"
+loadvm_process_command(uint16_t com, uint16_t len) "com=0x%x len=%d"
savevm_section_start(const char *id, unsigned int section_id) "%s, section_id
%u"
savevm_section_end(const char *id, unsigned int section_id, int ret) "%s,
section_id %u -> %d"
savevm_state_begin(void) ""
--
2.1.0
- [Qemu-devel] [PATCH v6 00/47] Postcopy implementation, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 02/47] Split header writing out of qemu_savevm_state_begin, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 01/47] Start documenting how postcopy works., Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 04/47] Add qemu_get_counted_string to read a string prefixed by a count byte, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 03/47] qemu_ram_foreach_block: pass up error value, and down the ramblock name, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 05/47] Create MigrationIncomingState, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 06/47] Provide runtime Target page information, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 09/47] Add wrapper for setting blocking status on a QEMUFile, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 07/47] Move copy out of qemu_peek_buffer, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 13/47] Migration commands,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v6 10/47] Rename save_live_complete to save_live_complete_precopy, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 12/47] Return path: socket_writev_buffer: Block even on non-blocking fd's, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 08/47] Add qemu_get_buffer_less_copy to avoid copies some of the time, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 11/47] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 15/47] Return path: Send responses from destination to source, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 14/47] Return path: Control commands, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 17/47] ram_debug_dump_bitmap: Dump a migration bitmap as text, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 18/47] Move loadvm_handlers into MigrationIncomingState, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 16/47] Return path: Source handling of return path, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 19/47] Rework loadvm path for subloops, Dr. David Alan Gilbert (git), 2015/04/14