On Thu, Nov 11, 2021 at 11:55:54 +0300, Nikolay Shirokovskiy wrote:
Signed-off-by: Nikolay Shirokovskiy
<nshirokovskiy(a)virtuozzo.com>
---
docs/manpages/virsh.rst | 8 +++++++-
tools/virsh-snapshot.c | 6 ++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index 5f5ccfeafe..64f0eec4a2 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -6948,7 +6948,7 @@ snapshot-create
snapshot-create domain [xmlfile] {[--redefine [--current]] |
[--no-metadata] [--halt] [--disk-only] [--reuse-external]
- [--quiesce] [--atomic] [--live]} [--validate]
+ [--quiesce] [--atomic] [--live]} [--validate] [--instant]
Create a snapshot for domain *domain* with the properties specified in
*xmlfile*. Optionally, the *--validate* option can be passed to
@@ -7010,6 +7010,12 @@ the guest is running. Both disk snapshot and domain memory
snapshot are
taken. This increases the size of the memory image of the external
snapshot. This is currently supported only for full system external snapshots.
+If *--instant* is specified then snapshot will be at the moment the
+snapshot is called. Ordinary snapshot is done at the moment the call
This is misleading and racy. Users must wait for the event to consider
it at least somewhat safe. Virsh man page must not encourage assuming
that it's already in the somewhat safe state.
+is finished. The time difference can be significant if domain
memory
+is large. The flag only makes sense in case of snapshots with memory.
+
+
Existence of snapshot metadata will prevent attempts to ``undefine``
a persistent guest. However, for transient domains, snapshot
metadata is silently lost when the domain quits running (whether
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 154e82b48b..72ed1b2a52 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -152,6 +152,10 @@ static const vshCmdOptDef opts_snapshot_create[] = {
.type = VSH_OT_BOOL,
.help = N_("validate the XML against the schema"),
},
+ {.name = "instant",
+ .type = VSH_OT_BOOL,
+ .help = N_("snapshot at the moment of call"),
+ },
{.name = NULL}
};
@@ -183,6 +187,8 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_SNAPSHOT_CREATE_LIVE;
if (vshCommandOptBool(cmd, "validate"))
flags |= VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE;
+ if (vshCommandOptBool(cmd, "instant"))
+ flags |= VIR_DOMAIN_SNAPSHOT_CREATE_INSTANT;
The implementation in the qemu driver interlocks with the _LIVE flag. In
virsh we mirror these interlocks as it then reports proper flag names to
the user. See VSH_EXCLUSIVE_OPTION...
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
--
2.27.0