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

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