[Libguestfs] [PATCH] v2v: -o libvirt: Don't write only <vendor> without <model> (RHBZ#1591789).

Richard W.M. Jones rjones at redhat.com
Fri Jun 15 15:18:57 UTC 2018


Avoids the libvirt error:

  error: XML error: CPU vendor specified without CPU model
---
 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.16.2




More information about the Libguestfs mailing list