mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0011-v2v-warn-when-the-guest-has-direct-network-interface.patch

4ebc84
From 6a89d52b408885a8151939798ab5dfb57fac3fda Mon Sep 17 00:00:00 2001
4ebc84
From: Pino Toscano <ptoscano@redhat.com>
4ebc84
Date: Fri, 12 Apr 2019 17:28:12 +0200
4ebc84
Subject: [PATCH] v2v: warn when the guest has direct network interfaces
4ebc84
 (RHBZ#1518539)
4ebc84
4ebc84
virt-v2v obviously cannot convert this kind of devices, since they are
4ebc84
specific to the host of the hypervisor.  Thus, emit a warning about the
4ebc84
presence of direct network interfaces, so at least this can be noticed
4ebc84
when converting a guest.
4ebc84
4ebc84
(cherry picked from commit 1629ec6a5639cf5e226e80bcee749ae8851b1fae)
4ebc84
---
4ebc84
 v2v/parse_libvirt_xml.ml | 18 ++++++++++++++++++
4ebc84
 1 file changed, 18 insertions(+)
4ebc84
4ebc84
diff --git a/v2v/parse_libvirt_xml.ml b/v2v/parse_libvirt_xml.ml
4ebc84
index d5d78d367..b9970cee8 100644
4ebc84
--- a/v2v/parse_libvirt_xml.ml
4ebc84
+++ b/v2v/parse_libvirt_xml.ml
4ebc84
@@ -492,6 +492,24 @@ let parse_libvirt_xml ?conn xml =
4ebc84
     )
4ebc84
   in
4ebc84
 
4ebc84
+  (* Check for direct attachments to physical network interfaces.
4ebc84
+   * (RHBZ#1518539)
4ebc84
+   *)
4ebc84
+  let () =
4ebc84
+    let obj = Xml.xpath_eval_expression xpathctx "/domain/devices/interface[@type='direct']" in
4ebc84
+    let nr_nodes = Xml.xpathobj_nr_nodes obj in
4ebc84
+    if nr_nodes > 0 then (
4ebc84
+      (* Sadly fn_ in ocaml-gettext seems broken, and always returns the
4ebc84
+       * singular string no matter what.  Work around this by using a simple
4ebc84
+       * string with sn_ (which works), and outputting it as a whole.
4ebc84
+       *)
4ebc84
+      let msg = sn_ "this guest has a direct network interface which will be ignored"
4ebc84
+                    "this guest has direct network interfaces which will be ignored"
4ebc84
+                    nr_nodes in
4ebc84
+      warning "%s" msg
4ebc84
+    )
4ebc84
+  in
4ebc84
+
4ebc84
   ({
4ebc84
     s_hypervisor = hypervisor;
4ebc84
     s_name = name; s_orig_name = name;
4ebc84
-- 
4ebc84
2.21.0
4ebc84