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

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