[Libguestfs] [PATCH 1/2] v2v: -o libvirt: Refactor video and graphics elements.

Richard W.M. Jones rjones at redhat.com
Fri Feb 26 10:15:45 UTC 2016


This is just a refactoring and doesn't change the meaning of the code.
---
 v2v/output_libvirt.ml | 60 +++++++++++++++++++++++++--------------------------
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
index 68af3de..d1cbaa1 100644
--- a/v2v/output_libvirt.ml
+++ b/v2v/output_libvirt.ml
@@ -222,46 +222,44 @@ let create_libvirt_xml ?pool source target_buses guestcaps
   (* Same as old virt-v2v, we always add a display here even if it was
    * missing from the old metadata.
    *)
-  let video, graphics =
-    let video_model, graphics =
+  let video =
+    let video_model =
       match guestcaps.gcaps_video with
-      | QXL ->
-        e "model" [ "type", "qxl"; "ram", "65536" ] [],
-        e "graphics" [ "type", "vnc" ] []
-      | Cirrus ->
-        e "model" [ "type", "cirrus"; "vram", "9216" ] [],
-        e "graphics" [ "type", "spice" ] [] in
-
+      | QXL ->    e "model" [ "type", "qxl"; "ram", "65536" ] []
+      | Cirrus -> e "model" [ "type", "cirrus"; "vram", "9216" ] [] in
     append_attr ("heads", "1") video_model;
-    let video = e "video" [] [ video_model ] in
+    e "video" [] [ video_model ] in
 
-    (match source.s_display with
-    | Some { s_keymap = Some km } -> append_attr ("keymap", km) graphics
-    | _ -> ());
-    (match source.s_display with
-    | Some { s_password = Some pw } -> append_attr ("passwd", pw) graphics
-    | _ -> ());
-    (match source.s_display with
-    | Some { s_listen = listen } ->
+  let graphics =
+    match guestcaps.gcaps_video with
+    | QXL ->    e "graphics" [ "type", "vnc" ] []
+    | Cirrus -> e "graphics" [ "type", "spice" ] [] in
+
+  (match source.s_display with
+   | Some { s_keymap = Some km } -> append_attr ("keymap", km) graphics
+   | _ -> ());
+  (match source.s_display with
+   | Some { s_password = Some pw } -> append_attr ("passwd", pw) graphics
+   | _ -> ());
+  (match source.s_display with
+   | Some { s_listen = listen } ->
       (match listen with
-      | LAddress a ->
-        let sub = e "listen" [ "type", "address"; "address", a ] [] in
-        append_child sub graphics
-      | LNetwork n ->
-        let sub = e "listen" [ "type", "network"; "network", n ] [] in
-        append_child sub graphics
-      | LNone -> ())
-    | _ -> ());
-    (match source.s_display with
-    | Some { s_port = Some p } ->
+       | LAddress a ->
+          let sub = e "listen" [ "type", "address"; "address", a ] [] in
+          append_child sub graphics
+       | LNetwork n ->
+          let sub = e "listen" [ "type", "network"; "network", n ] [] in
+          append_child sub graphics
+       | LNone -> ())
+   | _ -> ());
+  (match source.s_display with
+   | Some { s_port = Some p } ->
       append_attr ("autoport", "no") graphics;
       append_attr ("port", string_of_int p) graphics
-    | _ ->
+   | _ ->
       append_attr ("autoport", "yes") graphics;
       append_attr ("port", "-1") graphics);
 
-    video, graphics in
-
   let sound =
     match source.s_sound with
     | None -> []
-- 
2.5.0




More information about the Libguestfs mailing list