[libvirt PATCH 0/2] snapshot revert fix followup

Pavel Hrdina (2): qemu_monitor: remove unused load snapshot code virsh: man: update snapshot-revert description docs/manpages/virsh.rst | 4 ++++ src/qemu/qemu_monitor.c | 11 ----------- src/qemu/qemu_monitor.h | 1 - src/qemu/qemu_monitor_text.c | 36 ------------------------------------ src/qemu/qemu_monitor_text.h | 1 - 5 files changed, 4 insertions(+), 49 deletions(-) -- 2.31.1

Recent cleanup of snapshot revert code made these function unused. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_monitor.c | 11 ----------- src/qemu/qemu_monitor.h | 1 - src/qemu/qemu_monitor_text.c | 36 ------------------------------------ src/qemu/qemu_monitor_text.h | 1 - 4 files changed, 49 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index ac988e063b..26b59801b8 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3016,17 +3016,6 @@ qemuMonitorCreateSnapshot(qemuMonitor *mon, const char *name) return qemuMonitorTextCreateSnapshot(mon, name); } -int -qemuMonitorLoadSnapshot(qemuMonitor *mon, const char *name) -{ - VIR_DEBUG("name=%s", name); - - QEMU_CHECK_MONITOR(mon); - - /* there won't ever be a direct QMP replacement for this function */ - return qemuMonitorTextLoadSnapshot(mon, name); -} - int qemuMonitorDeleteSnapshot(qemuMonitor *mon, const char *name) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 0dd7b1c4e2..99ecebc648 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1057,7 +1057,6 @@ int qemuMonitorDriveDel(qemuMonitor *mon, const char *drivestr); int qemuMonitorCreateSnapshot(qemuMonitor *mon, const char *name); -int qemuMonitorLoadSnapshot(qemuMonitor *mon, const char *name); int qemuMonitorDeleteSnapshot(qemuMonitor *mon, const char *name); int qemuMonitorTransaction(qemuMonitor *mon, virJSONValue **actions) diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 6a1a913055..0ca7f5a470 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -144,42 +144,6 @@ qemuMonitorTextCreateSnapshot(qemuMonitor *mon, return 0; } -int qemuMonitorTextLoadSnapshot(qemuMonitor *mon, const char *name) -{ - g_autofree char *cmd = NULL; - g_autofree char *reply = NULL; - - cmd = g_strdup_printf("loadvm \"%s\"", name); - - if (qemuMonitorJSONHumanCommand(mon, cmd, &reply)) - return -1; - - if (strstr(reply, "No block device supports snapshots")) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("this domain does not have a device to load snapshots")); - return -1; - } else if (strstr(reply, "Could not find snapshot")) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("the snapshot '%s' does not exist, and was not loaded"), - name); - return -1; - } else if (strstr(reply, "Snapshots not supported on device")) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("Failed to load snapshot: %s"), reply); - return -1; - } else if (strstr(reply, "Could not open VM state file") || - strstr(reply, "Error: ") || - (strstr(reply, "Error") && - (strstr(reply, "while loading VM state") || - strstr(reply, "while activating snapshot on")))) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("Failed to load snapshot: %s"), reply); - return -1; - } - - return 0; -} - int qemuMonitorTextDeleteSnapshot(qemuMonitor *mon, const char *name) { g_autofree char *cmd = NULL; diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h index c8177d3b3b..d959fc8889 100644 --- a/src/qemu/qemu_monitor_text.h +++ b/src/qemu/qemu_monitor_text.h @@ -32,5 +32,4 @@ int qemuMonitorTextDriveDel(qemuMonitor *mon, const char *drivestr); int qemuMonitorTextCreateSnapshot(qemuMonitor *mon, const char *name); -int qemuMonitorTextLoadSnapshot(qemuMonitor *mon, const char *name); int qemuMonitorTextDeleteSnapshot(qemuMonitor *mon, const char *name); -- 2.31.1

We've changed the behavior of this API that from now on it will always restart the VM process and we are no longer able to revert to snapshots created by libvirt older then 0.9.5. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- docs/manpages/virsh.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 5f5ccfeafe..39636a565e 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -7293,6 +7293,10 @@ no vm state leaves the domain in an inactive state. Passing either the transient domains cannot be inactive, it is required to use one of these flags when reverting to a disk snapshot of a transient domain. +Since libvirt 7.10.0 the VM process is always restarted so the following +paragraph is no longer valid. If the snapshot metadata lacks the full +VM XML it's no longer possible to revert to such snapshot. + There are a number of cases where a snapshot revert involves extra risk, which requires the use of *--force* to proceed: -- 2.31.1

On a Tuesday in 2021, Pavel Hrdina wrote:
Pavel Hrdina (2): qemu_monitor: remove unused load snapshot code virsh: man: update snapshot-revert description
docs/manpages/virsh.rst | 4 ++++ src/qemu/qemu_monitor.c | 11 ----------- src/qemu/qemu_monitor.h | 1 - src/qemu/qemu_monitor_text.c | 36 ------------------------------------ src/qemu/qemu_monitor_text.h | 1 - 5 files changed, 4 insertions(+), 49 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Pavel Hrdina