[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/10] RFC: Add get_current_snapshot_info to get the
From: |
junyan . he |
Subject: |
[Qemu-devel] [PATCH 07/10] RFC: Add get_current_snapshot_info to get the snapshot state. |
Date: |
Wed, 14 Mar 2018 09:20:15 +0800 |
From: Junyan He <address@hidden>
We need to know the snapshot saving information when we do dependent
snapshot saving, e.g the name of previous snapshot. Add this global
function to query the snapshot status is usable.
Signed-off-by: Junyan He <address@hidden>
---
include/migration/snapshot.h | 3 +++
migration/savevm.c | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/include/migration/snapshot.h b/include/migration/snapshot.h
index c85b6ec..0b950ce 100644
--- a/include/migration/snapshot.h
+++ b/include/migration/snapshot.h
@@ -15,7 +15,10 @@
#ifndef QEMU_MIGRATION_SNAPSHOT_H
#define QEMU_MIGRATION_SNAPSHOT_H
+#include "block/snapshot.h"
+
int save_snapshot(const char *name, Error **errp);
int load_snapshot(const char *name, Error **errp);
+int get_current_snapshot_info(QEMUSnapshotInfo *sn);
#endif
diff --git a/migration/savevm.c b/migration/savevm.c
index 1bbd6aa..3a9b904 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2212,6 +2212,29 @@ int qemu_loadvm_state(QEMUFile *f)
return ret;
}
+static int in_snap_saving;
+static QEMUSnapshotInfo in_snap_saving_sn;
+
+int get_current_snapshot_info(QEMUSnapshotInfo *sn)
+{
+ if (in_snap_saving && sn) {
+ memcpy(sn, &in_snap_saving_sn, sizeof(QEMUSnapshotInfo));
+ }
+
+ return in_snap_saving;
+}
+
+static void set_current_snapshot_info(QEMUSnapshotInfo *sn)
+{
+ if (sn) {
+ memcpy(&in_snap_saving_sn, sn, sizeof(QEMUSnapshotInfo));
+ in_snap_saving = 1;
+ } else {
+ memset(&in_snap_saving_sn, 0, sizeof(QEMUSnapshotInfo));
+ in_snap_saving = 0;
+ }
+}
+
int save_snapshot(const char *name, Error **errp)
{
BlockDriverState *bs, *bs1;
@@ -2282,6 +2305,8 @@ int save_snapshot(const char *name, Error **errp)
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm);
}
+ set_current_snapshot_info(sn);
+
/* save the VM state */
f = qemu_fopen_bdrv(bs, 1);
if (!f) {
@@ -2313,6 +2338,8 @@ int save_snapshot(const char *name, Error **errp)
ret = 0;
the_end:
+ set_current_snapshot_info(NULL);
+
if (aio_context) {
aio_context_release(aio_context);
}
--
2.7.4
- [Qemu-devel] [PATCH 00/10] RFC: Optimize nvdimm kind memory for snapshot., junyan . he, 2018/03/13
- [Qemu-devel] [PATCH 01/10] RFC: Add save and support snapshot dependency function to block driver., junyan . he, 2018/03/13
- [Qemu-devel] [PATCH 02/10] RFC: Implement qcow2's snapshot dependent saving function., junyan . he, 2018/03/13
- [Qemu-devel] [PATCH 03/10] RFC: Implement save and support snapshot dependency in block driver layer., junyan . he, 2018/03/13
- [Qemu-devel] [PATCH 04/10] RFC: Set memory_region_set_log available for more client., junyan . he, 2018/03/13
- [Qemu-devel] [PATCH 05/10] RFC: Add memory region snapshot bitmap get function., junyan . he, 2018/03/13
- [Qemu-devel] [PATCH 07/10] RFC: Add get_current_snapshot_info to get the snapshot state.,
junyan . he <=
- [Qemu-devel] [PATCH 06/10] RFC: Add save dependency functions to qemu_file, junyan . he, 2018/03/13
- [Qemu-devel] [PATCH 08/10] RFC: Add a section_id parameter to save_live_iterate call., junyan . he, 2018/03/13
- [Qemu-devel] [PATCH 09/10] RFC: Add nvdimm snapshot saving to migration., junyan . he, 2018/03/13
- [Qemu-devel] [PATCH 10/10] RFC: Enable nvdimm snapshot functions., junyan . he, 2018/03/13
- Re: [Qemu-devel] [PATCH 00/10] RFC: Optimize nvdimm kind memory for snapshot., no-reply, 2018/03/13
- Re: [Qemu-devel] [PATCH 00/10] RFC: Optimize nvdimm kind memory for snapshot., no-reply, 2018/03/14