virt-v2v/0039-lib-libvirt_utils.ml-Turn-live-domain-error-into-a-w.patch
Richard W.M. Jones 47ce2daa1e Turn live domain error into a warning
resolves: RHEL-88543
2025-04-25 12:06:44 +01:00

58 lines
2.4 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From cd55bd8d160cdcdfe21aaafc15f7a1cefee98b85 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 25 Apr 2025 11:44:15 +0100
Subject: [PATCH] lib/libvirt_utils.ml: Turn live domain error into a warning
As explained in the comment, we cannot easily tell if conversion is
being attempted from a snapshot (which is safe, even if the domain is
running). Therefore turn the error into a strong warning.
Reported-by: Martin Necas
Fixes: https://issues.redhat.com/browse/RHEL-88543
(cherry picked from commit 8c27cb1e525b5e1d380ab27a141de6f026f4b2db)
---
lib/libvirt_utils.ml | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/lib/libvirt_utils.ml b/lib/libvirt_utils.ml
index 4200c7c8..41ee38d2 100644
--- a/lib/libvirt_utils.ml
+++ b/lib/libvirt_utils.ml
@@ -59,20 +59,27 @@ let get_domain conn name =
error (f_"cannot find libvirt domain %s: %s")
name (Option.value ~default:"" message)
) in
- let uri = Libvirt.Connect.get_uri conn in
- (* As a side-effect we check that the domain is shut down. Of course
- * this is only appropriate for virt-v2v. (RHBZ#1138586)
+
+ (* As a side-effect we check that the domain is shut down (RHBZ#1138586).
+ * In earlier versions of virt-v2v this was a hard error. Now it's
+ * a warning, since we can't easily tell if the user is converting
+ * from a snapshot - which is safe (RHEL-88543).
*)
+ let uri = Libvirt.Connect.get_uri conn in
if not (String.is_prefix uri "test:") then (
(match (Libvirt.Domain.get_info dom).Libvirt.Domain.state with
- | InfoRunning | InfoBlocked | InfoPaused ->
- error (f_"libvirt domain %s is running or paused. It must be \
- shut down in order to perform virt-v2v conversion")
- (Libvirt.Domain.get_name dom)
- | InfoNoState | InfoShutdown | InfoShutoff | InfoCrashed | InfoPMSuspended ->
- ()
+ | InfoRunning | InfoBlocked | InfoPaused ->
+ warning (f_"libvirt domain %s is running or paused. Converting \
+ a live guest will result in corrupted output. \
+ However this is safe if you're converting from a \
+ snapshot")
+ (Libvirt.Domain.get_name dom)
+ | InfoNoState | InfoShutdown | InfoShutoff | InfoCrashed
+ | InfoPMSuspended ->
+ ()
)
);
+
dom
let get_pool conn name =