diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2017-05-05 16:52:12 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2017-05-05 16:52:35 +0100 |
commit | 4aee86c60a53a3478d9799a4464cf0bc08071148 (patch) | |
tree | a8fa7c5aba4aa18e52fd8182cce9cc5872df1fa3 /migration/savevm.c | |
parent | bc56fd3a23c94302937ed023d33e17a2de1a1b2a (diff) | |
parent | 1db9d8e501fc99fa2201f228627952aee6cfc349 (diff) | |
download | qemu-4aee86c60a53a3478d9799a4464cf0bc08071148.zip |
Merge remote-tracking branch 'quintela/tags/migration/20170504' into staging
migration/next for 20170504
# gpg: Signature made Thu 04 May 2017 10:35:41 AM BST
# gpg: using RSA key 0xF487EF185872D723
# gpg: Good signature from "Juan Quintela <quintela@redhat.com>"
# gpg: aka "Juan Quintela <quintela@trasno.org>"
# Primary key fingerprint: 1899 FF8E DEBF 58CC EE03 4B82 F487 EF18 5872 D723
* quintela/tags/migration/20170504:
migration: Extra tracing
migration: Move postcopy-ram.h to migration/
monitor: Move hmp_info_snapshots from savevm.c to hmp.c
monitor: Move hmp_delvm from savevm.c to hmp.c
monitor: Move hmp_savevm from savevm.c to hmp.c
monitor: Move hmp_loadvm from monitor.c to hmp.c
monitor: Remove monitor parameter from save_vmstate
migration: to_dst_file at that point is NULL
migration: setup bi-directional I/O channel for exec: protocol
ram: Split dirty bitmap by RAMBlock
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'migration/savevm.c')
-rw-r--r-- | migration/savevm.c | 185 |
1 files changed, 10 insertions, 175 deletions
diff --git a/migration/savevm.c b/migration/savevm.c index a00c1ab0af..352a8f23b5 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -33,15 +33,12 @@ #include "hw/qdev.h" #include "hw/xen/xen.h" #include "net/net.h" -#include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "qemu/timer.h" -#include "audio/audio.h" #include "migration/migration.h" -#include "migration/postcopy-ram.h" +#include "postcopy-ram.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" -#include "qemu/sockets.h" #include "qemu/queue.h" #include "sysemu/cpus.h" #include "exec/memory.h" @@ -50,7 +47,6 @@ #include "qemu/bitops.h" #include "qemu/iov.h" #include "block/snapshot.h" -#include "block/qapi.h" #include "qemu/cutils.h" #include "io/channel-buffer.h" #include "io/channel-file.h" @@ -2078,7 +2074,7 @@ int qemu_loadvm_state(QEMUFile *f) return ret; } -int save_vmstate(Monitor *mon, const char *name) +int save_vmstate(const char *name) { BlockDriverState *bs, *bs1; QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1; @@ -2092,8 +2088,8 @@ int save_vmstate(Monitor *mon, const char *name) AioContext *aio_context; if (!bdrv_all_can_snapshot(&bs)) { - monitor_printf(mon, "Device '%s' is writable but does not " - "support snapshots.\n", bdrv_get_device_name(bs)); + error_report("Device '%s' is writable but does not support snapshots", + bdrv_get_device_name(bs)); return ret; } @@ -2110,7 +2106,7 @@ int save_vmstate(Monitor *mon, const char *name) bs = bdrv_all_find_vmstate_bs(); if (bs == NULL) { - monitor_printf(mon, "No block device can accept snapshots\n"); + error_report("No block device can accept snapshots"); return ret; } aio_context = bdrv_get_aio_context(bs); @@ -2119,7 +2115,7 @@ int save_vmstate(Monitor *mon, const char *name) ret = global_state_store(); if (ret) { - monitor_printf(mon, "Error saving global state\n"); + error_report("Error saving global state"); return ret; } vm_stop(RUN_STATE_SAVE_VM); @@ -2151,7 +2147,7 @@ int save_vmstate(Monitor *mon, const char *name) /* save the VM state */ f = qemu_fopen_bdrv(bs, 1); if (!f) { - monitor_printf(mon, "Could not open VM state file\n"); + error_report("Could not open VM state file"); goto the_end; } ret = qemu_savevm_state(f, &local_err); @@ -2164,8 +2160,8 @@ int save_vmstate(Monitor *mon, const char *name) ret = bdrv_all_create_snapshot(sn, bs, vm_state_size, &bs); if (ret < 0) { - monitor_printf(mon, "Error while creating snapshot on '%s'\n", - bdrv_get_device_name(bs)); + error_report("Error while creating snapshot on '%s'", + bdrv_get_device_name(bs)); goto the_end; } @@ -2179,11 +2175,6 @@ int save_vmstate(Monitor *mon, const char *name) return ret; } -void hmp_savevm(Monitor *mon, const QDict *qdict) -{ - save_vmstate(mon, qdict_get_try_str(qdict, "name")); -} - void qmp_xen_save_devices_state(const char *filename, Error **errp) { QEMUFile *f; @@ -2253,7 +2244,7 @@ int load_vmstate(const char *name) MigrationIncomingState *mis = migration_incoming_get_current(); if (!bdrv_all_can_snapshot(&bs)) { - error_report("Device '%s' is writable but does not support snapshots.", + error_report("Device '%s' is writable but does not support snapshots", bdrv_get_device_name(bs)); return -ENOTSUP; } @@ -2317,162 +2308,6 @@ int load_vmstate(const char *name) return 0; } -void hmp_delvm(Monitor *mon, const QDict *qdict) -{ - BlockDriverState *bs; - Error *err; - const char *name = qdict_get_str(qdict, "name"); - - if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) { - error_reportf_err(err, - "Error while deleting snapshot on device '%s': ", - bdrv_get_device_name(bs)); - } -} - -void hmp_info_snapshots(Monitor *mon, const QDict *qdict) -{ - BlockDriverState *bs, *bs1; - BdrvNextIterator it1; - QEMUSnapshotInfo *sn_tab, *sn; - bool no_snapshot = true; - int nb_sns, i; - int total; - int *global_snapshots; - AioContext *aio_context; - - typedef struct SnapshotEntry { - QEMUSnapshotInfo sn; - QTAILQ_ENTRY(SnapshotEntry) next; - } SnapshotEntry; - - typedef struct ImageEntry { - const char *imagename; - QTAILQ_ENTRY(ImageEntry) next; - QTAILQ_HEAD(, SnapshotEntry) snapshots; - } ImageEntry; - - QTAILQ_HEAD(, ImageEntry) image_list = - QTAILQ_HEAD_INITIALIZER(image_list); - - ImageEntry *image_entry, *next_ie; - SnapshotEntry *snapshot_entry; - - bs = bdrv_all_find_vmstate_bs(); - if (!bs) { - monitor_printf(mon, "No available block device supports snapshots\n"); - return; - } - aio_context = bdrv_get_aio_context(bs); - - aio_context_acquire(aio_context); - nb_sns = bdrv_snapshot_list(bs, &sn_tab); - aio_context_release(aio_context); - - if (nb_sns < 0) { - monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns); - return; - } - - for (bs1 = bdrv_first(&it1); bs1; bs1 = bdrv_next(&it1)) { - int bs1_nb_sns = 0; - ImageEntry *ie; - SnapshotEntry *se; - AioContext *ctx = bdrv_get_aio_context(bs1); - - aio_context_acquire(ctx); - if (bdrv_can_snapshot(bs1)) { - sn = NULL; - bs1_nb_sns = bdrv_snapshot_list(bs1, &sn); - if (bs1_nb_sns > 0) { - no_snapshot = false; - ie = g_new0(ImageEntry, 1); - ie->imagename = bdrv_get_device_name(bs1); - QTAILQ_INIT(&ie->snapshots); - QTAILQ_INSERT_TAIL(&image_list, ie, next); - for (i = 0; i < bs1_nb_sns; i++) { - se = g_new0(SnapshotEntry, 1); - se->sn = sn[i]; - QTAILQ_INSERT_TAIL(&ie->snapshots, se, next); - } - } - g_free(sn); - } - aio_context_release(ctx); - } - - if (no_snapshot) { - monitor_printf(mon, "There is no snapshot available.\n"); - return; - } - - global_snapshots = g_new0(int, nb_sns); - total = 0; - for (i = 0; i < nb_sns; i++) { - SnapshotEntry *next_sn; - if (bdrv_all_find_snapshot(sn_tab[i].name, &bs1) == 0) { - global_snapshots[total] = i; - total++; - QTAILQ_FOREACH(image_entry, &image_list, next) { - QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots, - next, next_sn) { - if (!strcmp(sn_tab[i].name, snapshot_entry->sn.name)) { - QTAILQ_REMOVE(&image_entry->snapshots, snapshot_entry, - next); - g_free(snapshot_entry); - } - } - } - } - } - - monitor_printf(mon, "List of snapshots present on all disks:\n"); - - if (total > 0) { - bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, NULL); - monitor_printf(mon, "\n"); - for (i = 0; i < total; i++) { - sn = &sn_tab[global_snapshots[i]]; - /* The ID is not guaranteed to be the same on all images, so - * overwrite it. - */ - pstrcpy(sn->id_str, sizeof(sn->id_str), "--"); - bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, sn); - monitor_printf(mon, "\n"); - } - } else { - monitor_printf(mon, "None\n"); - } - - QTAILQ_FOREACH(image_entry, &image_list, next) { - if (QTAILQ_EMPTY(&image_entry->snapshots)) { - continue; - } - monitor_printf(mon, - "\nList of partial (non-loadable) snapshots on '%s':\n", - image_entry->imagename); - bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, NULL); - monitor_printf(mon, "\n"); - QTAILQ_FOREACH(snapshot_entry, &image_entry->snapshots, next) { - bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, - &snapshot_entry->sn); - monitor_printf(mon, "\n"); - } - } - - QTAILQ_FOREACH_SAFE(image_entry, &image_list, next, next_ie) { - SnapshotEntry *next_sn; - QTAILQ_FOREACH_SAFE(snapshot_entry, &image_entry->snapshots, next, - next_sn) { - g_free(snapshot_entry); - } - g_free(image_entry); - } - g_free(sn_tab); - g_free(global_snapshots); - -} - void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev) { qemu_ram_set_idstr(mr->ram_block, |