mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20151104' into staging
migration/next for 20151104 # gpg: Signature made Wed 04 Nov 2015 12:45:19 GMT using RSA key ID 5872D723 # gpg: Good signature from "Juan Quintela <quintela@redhat.com>" # gpg: aka "Juan Quintela <quintela@trasno.org>" * remotes/juanquintela/tags/migration/20151104: migration: fix analyze-migration.py script migration: code clean up migration: rename cancel to cleanup in SaveVMHandles migration: rename qemu_savevm_state_cancel migration: defer migration_end & blk_mig_cleanup Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -39,7 +39,7 @@ typedef struct SaveVMHandlers {
|
||||
void (*set_params)(const MigrationParams *params, void * opaque);
|
||||
SaveStateHandler *save_state;
|
||||
|
||||
void (*cancel)(void *opaque);
|
||||
void (*cleanup)(void *opaque);
|
||||
int (*save_live_complete)(QEMUFile *f, void *opaque);
|
||||
|
||||
/* This runs both outside and inside the iothread lock. */
|
||||
|
||||
@@ -89,7 +89,7 @@ void qemu_savevm_state_begin(QEMUFile *f,
|
||||
void qemu_savevm_state_header(QEMUFile *f);
|
||||
int qemu_savevm_state_iterate(QEMUFile *f);
|
||||
void qemu_savevm_state_complete(QEMUFile *f);
|
||||
void qemu_savevm_state_cancel(void);
|
||||
void qemu_savevm_state_cleanup(void);
|
||||
uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
|
||||
int qemu_loadvm_state(QEMUFile *f);
|
||||
|
||||
|
||||
+2
-8
@@ -591,7 +591,7 @@ static int64_t get_remaining_dirty(void)
|
||||
|
||||
/* Called with iothread lock taken. */
|
||||
|
||||
static void blk_mig_cleanup(void)
|
||||
static void block_migration_cleanup(void *opaque)
|
||||
{
|
||||
BlkMigDevState *bmds;
|
||||
BlkMigBlock *blk;
|
||||
@@ -618,11 +618,6 @@ static void blk_mig_cleanup(void)
|
||||
blk_mig_unlock();
|
||||
}
|
||||
|
||||
static void block_migration_cancel(void *opaque)
|
||||
{
|
||||
blk_mig_cleanup();
|
||||
}
|
||||
|
||||
static int block_save_setup(QEMUFile *f, void *opaque)
|
||||
{
|
||||
int ret;
|
||||
@@ -750,7 +745,6 @@ static int block_save_complete(QEMUFile *f, void *opaque)
|
||||
|
||||
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
|
||||
|
||||
blk_mig_cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -885,7 +879,7 @@ static SaveVMHandlers savevm_block_handlers = {
|
||||
.save_live_complete = block_save_complete,
|
||||
.save_live_pending = block_save_pending,
|
||||
.load_state = block_load,
|
||||
.cancel = block_migration_cancel,
|
||||
.cleanup = block_migration_cleanup,
|
||||
.is_active = block_is_active,
|
||||
};
|
||||
|
||||
|
||||
@@ -613,12 +613,9 @@ static void migrate_fd_cleanup(void *opaque)
|
||||
|
||||
assert(s->state != MIGRATION_STATUS_ACTIVE);
|
||||
|
||||
if (s->state != MIGRATION_STATUS_COMPLETED) {
|
||||
qemu_savevm_state_cancel();
|
||||
if (s->state == MIGRATION_STATUS_CANCELLING) {
|
||||
migrate_set_state(s, MIGRATION_STATUS_CANCELLING,
|
||||
MIGRATION_STATUS_CANCELLED);
|
||||
}
|
||||
if (s->state == MIGRATION_STATUS_CANCELLING) {
|
||||
migrate_set_state(s, MIGRATION_STATUS_CANCELLING,
|
||||
MIGRATION_STATUS_CANCELLED);
|
||||
}
|
||||
|
||||
notifier_list_notify(&migration_state_notifiers, s);
|
||||
@@ -1028,6 +1025,7 @@ static void *migration_thread(void *opaque)
|
||||
int64_t initial_bytes = 0;
|
||||
int64_t max_size = 0;
|
||||
int64_t start_time = initial_time;
|
||||
int64_t end_time;
|
||||
bool old_vm_running = false;
|
||||
|
||||
rcu_register_thread();
|
||||
@@ -1089,10 +1087,11 @@ static void *migration_thread(void *opaque)
|
||||
|
||||
/* If we enabled cpu throttling for auto-converge, turn it off. */
|
||||
cpu_throttle_stop();
|
||||
end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
|
||||
|
||||
qemu_mutex_lock_iothread();
|
||||
qemu_savevm_state_cleanup();
|
||||
if (s->state == MIGRATION_STATUS_COMPLETED) {
|
||||
int64_t end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
|
||||
uint64_t transferred_bytes = qemu_ftell(s->file);
|
||||
s->total_time = end_time - s->total_time;
|
||||
s->downtime = end_time - start_time;
|
||||
|
||||
+2
-8
@@ -1100,7 +1100,7 @@ static void migration_bitmap_free(struct BitmapRcu *bmap)
|
||||
g_free(bmap);
|
||||
}
|
||||
|
||||
static void migration_end(void)
|
||||
static void ram_migration_cleanup(void *opaque)
|
||||
{
|
||||
/* caller have hold iothread lock or is in a bh, so there is
|
||||
* no writing race against this migration_bitmap
|
||||
@@ -1124,11 +1124,6 @@ static void migration_end(void)
|
||||
XBZRLE_cache_unlock();
|
||||
}
|
||||
|
||||
static void ram_migration_cancel(void *opaque)
|
||||
{
|
||||
migration_end();
|
||||
}
|
||||
|
||||
static void reset_ram_globals(void)
|
||||
{
|
||||
last_seen_block = NULL;
|
||||
@@ -1344,7 +1339,6 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
|
||||
|
||||
rcu_read_unlock();
|
||||
|
||||
migration_end();
|
||||
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
|
||||
|
||||
return 0;
|
||||
@@ -1686,7 +1680,7 @@ static SaveVMHandlers savevm_ram_handlers = {
|
||||
.save_live_complete = ram_save_complete,
|
||||
.save_live_pending = ram_save_pending,
|
||||
.load_state = ram_load,
|
||||
.cancel = ram_migration_cancel,
|
||||
.cleanup = ram_migration_cleanup,
|
||||
};
|
||||
|
||||
void ram_mig_init(void)
|
||||
|
||||
+5
-5
@@ -902,14 +902,14 @@ uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void qemu_savevm_state_cancel(void)
|
||||
void qemu_savevm_state_cleanup(void)
|
||||
{
|
||||
SaveStateEntry *se;
|
||||
|
||||
trace_savevm_state_cancel();
|
||||
trace_savevm_state_cleanup();
|
||||
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
||||
if (se->ops && se->ops->cancel) {
|
||||
se->ops->cancel(se->opaque);
|
||||
if (se->ops && se->ops->cleanup) {
|
||||
se->ops->cleanup(se->opaque);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -943,7 +943,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
|
||||
ret = qemu_file_get_error(f);
|
||||
}
|
||||
if (ret != 0) {
|
||||
qemu_savevm_state_cancel();
|
||||
qemu_savevm_state_cleanup();
|
||||
error_setg_errno(errp, -ret, "Error while writing VM state");
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -252,6 +252,15 @@ class HTABSection(object):
|
||||
def getDict(self):
|
||||
return ""
|
||||
|
||||
|
||||
class ConfigurationSection(object):
|
||||
def __init__(self, file):
|
||||
self.file = file
|
||||
|
||||
def read(self):
|
||||
name_len = self.file.read32()
|
||||
name = self.file.readstr(len = name_len)
|
||||
|
||||
class VMSDFieldGeneric(object):
|
||||
def __init__(self, desc, file):
|
||||
self.file = file
|
||||
@@ -474,6 +483,7 @@ class MigrationDump(object):
|
||||
QEMU_VM_SECTION_FULL = 0x04
|
||||
QEMU_VM_SUBSECTION = 0x05
|
||||
QEMU_VM_VMDESCRIPTION = 0x06
|
||||
QEMU_VM_CONFIGURATION = 0x07
|
||||
QEMU_VM_SECTION_FOOTER= 0x7e
|
||||
|
||||
def __init__(self, filename):
|
||||
@@ -514,6 +524,9 @@ class MigrationDump(object):
|
||||
section_type = file.read8()
|
||||
if section_type == self.QEMU_VM_EOF:
|
||||
break
|
||||
elif section_type == self.QEMU_VM_CONFIGURATION:
|
||||
section = ConfigurationSection(file)
|
||||
section.read()
|
||||
elif section_type == self.QEMU_VM_SECTION_START or section_type == self.QEMU_VM_SECTION_FULL:
|
||||
section_id = file.read32()
|
||||
name = file.readstr()
|
||||
|
||||
+1
-1
@@ -1211,7 +1211,7 @@ savevm_state_begin(void) ""
|
||||
savevm_state_header(void) ""
|
||||
savevm_state_iterate(void) ""
|
||||
savevm_state_complete(void) ""
|
||||
savevm_state_cancel(void) ""
|
||||
savevm_state_cleanup(void) ""
|
||||
vmstate_save(const char *idstr, const char *vmsd_name) "%s, %s"
|
||||
vmstate_load(const char *idstr, const char *vmsd_name) "%s, %s"
|
||||
qemu_announce_self_iter(const char *mac) "%s"
|
||||
|
||||
Reference in New Issue
Block a user