From c34c2f3701e38a06bc9849bee9eac9131a4fdaad Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Tue, 18 Apr 2017 11:35:04 +0200 Subject: monitor: Remove monitor parameter from save_vmstate load_vmstate() already use error_report, so be consistent. There is an identical error message in load_vmstate() that ends in a period. Remove it. Signed-off-by: Juan Quintela Reviewed-by: Laurent Vivier Reviewed-by: Dr. David Alan Gilbert --- migration/savevm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'migration/savevm.c') diff --git a/migration/savevm.c b/migration/savevm.c index 03ae1bdeb4..a89af80378 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2070,7 +2070,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; @@ -2084,8 +2084,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; } @@ -2102,7 +2102,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); @@ -2111,7 +2111,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); @@ -2143,7 +2143,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); @@ -2156,8 +2156,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; } @@ -2173,7 +2173,7 @@ int save_vmstate(Monitor *mon, const char *name) void hmp_savevm(Monitor *mon, const QDict *qdict) { - save_vmstate(mon, qdict_get_try_str(qdict, "name")); + save_vmstate(qdict_get_try_str(qdict, "name")); } void qmp_xen_save_devices_state(const char *filename, Error **errp) @@ -2245,7 +2245,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; } -- cgit v1.2.3 From d9c7d137c8f208fbe5b72f64eff96565e4380d8f Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Tue, 18 Apr 2017 11:44:16 +0200 Subject: monitor: Move hmp_savevm from savevm.c to hmp.c It is a monitor command, and has nothing migration specific in it. Signed-off-by: Juan Quintela Reviewed-by: Laurent Vivier Reviewed-by: Dr. David Alan Gilbert --- migration/savevm.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'migration/savevm.c') diff --git a/migration/savevm.c b/migration/savevm.c index a89af80378..834525522a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2171,11 +2171,6 @@ int save_vmstate(const char *name) return ret; } -void hmp_savevm(Monitor *mon, const QDict *qdict) -{ - save_vmstate(qdict_get_try_str(qdict, "name")); -} - void qmp_xen_save_devices_state(const char *filename, Error **errp) { QEMUFile *f; -- cgit v1.2.3 From d905bb7b747dbb6409b1498396fa8569312e779f Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Tue, 18 Apr 2017 11:46:23 +0200 Subject: monitor: Move hmp_delvm from savevm.c to hmp.c It really uses block/* stuff, not migration one. Signed-off-by: Juan Quintela Reviewed-by: Laurent Vivier Reviewed-by: Dr. David Alan Gilbert --- migration/savevm.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'migration/savevm.c') diff --git a/migration/savevm.c b/migration/savevm.c index 834525522a..9e0bd9d5d2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2304,19 +2304,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; -- cgit v1.2.3 From 6683061873095ad3f34f73bd32553c1d2c559e82 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Tue, 18 Apr 2017 11:51:06 +0200 Subject: monitor: Move hmp_info_snapshots from savevm.c to hmp.c It only uses block/* functions, nothing from migration. Signed-off-by: Juan Quintela Reviewed-by: Laurent Vivier Reviewed-by: Dr. David Alan Gilbert --- migration/savevm.c | 147 ----------------------------------------------------- 1 file changed, 147 deletions(-) (limited to 'migration/savevm.c') diff --git a/migration/savevm.c b/migration/savevm.c index 9e0bd9d5d2..ff78a8948d 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 "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" @@ -2304,149 +2300,6 @@ int load_vmstate(const char *name) return 0; } -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, -- cgit v1.2.3 From be07b0ace82b0f23bee194de9e4481c308645376 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 20 Apr 2017 13:12:24 +0200 Subject: migration: Move postcopy-ram.h to migration/ It is internal to migration, not intended for other users. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/savevm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'migration/savevm.c') diff --git a/migration/savevm.c b/migration/savevm.c index ff78a8948d..7668510cfc 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -36,7 +36,7 @@ #include "sysemu/sysemu.h" #include "qemu/timer.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/queue.h" -- cgit v1.2.3