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

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