Blob Blame History Raw
From 70f1d97ef7b12fddceb3b16618072ad4c142da5c Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 15 Jun 2018 16:17:35 +0100
Subject: [PATCH] v2v: -o libvirt: Don't write only <vendor> without <model>
 (RHBZ#1591789).

Avoids the libvirt error:

  error: XML error: CPU vendor specified without CPU model

(cherry picked from commit e2910eeaf84afe63887afdc62b319bff1549d296)
---
 v2v/create_libvirt_xml.ml | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/v2v/create_libvirt_xml.ml b/v2v/create_libvirt_xml.ml
index 582419f00..fbe90eeaa 100644
--- a/v2v/create_libvirt_xml.ml
+++ b/v2v/create_libvirt_xml.ml
@@ -51,15 +51,17 @@ let create_libvirt_xml ?pool source target_buses guestcaps
      source.s_cpu_topology <> None then (
     let cpu = ref [] in
 
-    (match source.s_cpu_vendor with
-     | None -> ()
-     | Some vendor ->
-        List.push_back cpu (e "vendor" [] [PCData vendor])
-    );
-    (match source.s_cpu_model with
-     | None -> ()
-     | Some model ->
+    (match source.s_cpu_vendor, source.s_cpu_model with
+     | None, None
+     (* Avoid libvirt error: "CPU vendor specified without CPU model" *)
+     | Some _, None -> ()
+     | None, Some model ->
         List.push_back cpu (e "model" ["fallback", "allow"] [PCData model])
+     | Some vendor, Some model ->
+        List.push_back_list cpu [
+          e "vendor" [] [PCData vendor];
+          e "model" ["fallback", "allow"] [PCData model]
+        ]
     );
     (match source.s_cpu_topology with
      | None -> ()
-- 
2.17.1