[Libguestfs] [PATCH 1/2] v2v: -o libvirt: Refactor video and graphics elements.
Pino Toscano
ptoscano at redhat.com
Fri Feb 26 10:49:14 UTC 2016
On Friday 26 February 2016 10:15:45 Richard W.M. Jones wrote:
> 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 -> []
The series LGTM.
Thanks,
--
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20160226/9728caab/attachment.sig>
More information about the Libguestfs
mailing list