From nobody Sun Feb 8 19:55:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1521120555316479.65413956373243; Thu, 15 Mar 2018 06:29:15 -0700 (PDT) Received: from localhost ([::1]:51544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewSwR-0008Ek-3N for importer@patchew.org; Thu, 15 Mar 2018 09:29:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewSvA-0007FE-SS for qemu-devel@nongnu.org; Thu, 15 Mar 2018 09:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ewSv9-0005V7-TY for qemu-devel@nongnu.org; Thu, 15 Mar 2018 09:27:52 -0400 Received: from [112.64.68.174] (port=34617 helo=robinhe-hp.sh.intel.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ewSv8-0005Sq-U1 for qemu-devel@nongnu.org; Thu, 15 Mar 2018 09:27:51 -0400 Received: from robinhe-hp.sh.intel.com (localhost [127.0.0.1]) by robinhe-hp (8.15.2/8.15.2/Debian-3) with ESMTP id w2D8Xx2i018964; Tue, 13 Mar 2018 16:33:59 +0800 Received: (from robinhe@localhost) by robinhe-hp.sh.intel.com (8.15.2/8.15.2/Submit) id w2D8Xxip018963; Tue, 13 Mar 2018 16:33:59 +0800 From: junyan.he@intel.com To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2018 16:33:50 +0800 Message-Id: <1520930033-18885-8-git-send-email-junyan.he@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520930033-18885-1-git-send-email-junyan.he@intel.com> References: <1520930033-18885-1-git-send-email-junyan.he@intel.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 112.64.68.174 Subject: [Qemu-devel] [PATCH 07/10] RFC: Add get_current_snapshot_info to get the snapshot state. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, famz@redhat.com, crosthwaite.peter@gmail.com, quintela@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, Junyan He , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Junyan He 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 --- 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 =20 +#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); =20 #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; } =20 +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 =3D 1; + } else { + memset(&in_snap_saving_sn, 0, sizeof(QEMUSnapshotInfo)); + in_snap_saving =3D 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); } =20 + set_current_snapshot_info(sn); + /* save the VM state */ f =3D qemu_fopen_bdrv(bs, 1); if (!f) { @@ -2313,6 +2338,8 @@ int save_snapshot(const char *name, Error **errp) ret =3D 0; =20 the_end: + set_current_snapshot_info(NULL); + if (aio_context) { aio_context_release(aio_context); } --=20 2.7.4