|
|
ffd6ed |
From 04426a61a5dc72dbaaee666c94398371bd385f76 Mon Sep 17 00:00:00 2001
|
|
|
ffd6ed |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
ffd6ed |
Date: Tue, 14 Apr 2015 10:38:54 +0200
|
|
|
ffd6ed |
Subject: [PATCH] v2v: convert libvirt display listen configuration
|
|
|
ffd6ed |
(RHBZ#1174073)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
Read the listen configuration from the XML of libvirt domains, restoring
|
|
|
ffd6ed |
it when writing new libvirt XMLs.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(cherry picked from commit 9360675dc244a8762e07a8a4289e7a30ca3e1eef)
|
|
|
ffd6ed |
---
|
|
|
ffd6ed |
v2v/input_disk.ml | 3 ++-
|
|
|
ffd6ed |
v2v/input_libvirtxml.ml | 26 ++++++++++++++++++++++++--
|
|
|
ffd6ed |
v2v/output_libvirt.ml | 11 +++++++++++
|
|
|
ffd6ed |
v2v/types.ml | 15 +++++++++++++--
|
|
|
ffd6ed |
v2v/types.mli | 5 +++++
|
|
|
ffd6ed |
5 files changed, 55 insertions(+), 5 deletions(-)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
diff --git a/v2v/input_disk.ml b/v2v/input_disk.ml
|
|
|
ffd6ed |
index 98b321c..e5a07b4 100644
|
|
|
ffd6ed |
--- a/v2v/input_disk.ml
|
|
|
ffd6ed |
+++ b/v2v/input_disk.ml
|
|
|
ffd6ed |
@@ -86,7 +86,8 @@ class input_disk verbose input_format disk = object
|
|
|
ffd6ed |
s_vcpu = 1; (* 1 vCPU is a safe default *)
|
|
|
ffd6ed |
s_features = [ "acpi"; "apic"; "pae" ];
|
|
|
ffd6ed |
s_display =
|
|
|
ffd6ed |
- Some { s_display_type = Window; s_keymap = None; s_password = None };
|
|
|
ffd6ed |
+ Some { s_display_type = Window; s_keymap = None; s_password = None;
|
|
|
ffd6ed |
+ s_listen = LNone };
|
|
|
ffd6ed |
s_disks = [disk];
|
|
|
ffd6ed |
s_removables = [];
|
|
|
ffd6ed |
s_nics = [network];
|
|
|
ffd6ed |
diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
|
|
|
ffd6ed |
index 8057a00..037405c 100644
|
|
|
ffd6ed |
--- a/v2v/input_libvirtxml.ml
|
|
|
ffd6ed |
+++ b/v2v/input_libvirtxml.ml
|
|
|
ffd6ed |
@@ -93,14 +93,36 @@ let parse_libvirt_xml ~verbose xml =
|
|
|
ffd6ed |
match xpath_to_string "@keymap" "" with "" -> None | k -> Some k in
|
|
|
ffd6ed |
let password =
|
|
|
ffd6ed |
match xpath_to_string "@passwd" "" with "" -> None | pw -> Some pw in
|
|
|
ffd6ed |
+ let listen =
|
|
|
ffd6ed |
+ let obj = Xml.xpath_eval_expression xpathctx "listen" in
|
|
|
ffd6ed |
+ let nr_nodes = Xml.xpathobj_nr_nodes obj in
|
|
|
ffd6ed |
+ if nr_nodes < 1 then LNone
|
|
|
ffd6ed |
+ else (
|
|
|
ffd6ed |
+ (* Use only the first <listen> configuration. *)
|
|
|
ffd6ed |
+ match xpath_to_string "listen[1]/@type" "" with
|
|
|
ffd6ed |
+ | "" -> LNone
|
|
|
ffd6ed |
+ | "address" ->
|
|
|
ffd6ed |
+ (match xpath_to_string "listen[1]/@address" "" with
|
|
|
ffd6ed |
+ | "" -> LNone
|
|
|
ffd6ed |
+ | a -> LAddress a
|
|
|
ffd6ed |
+ )
|
|
|
ffd6ed |
+ | "network" ->
|
|
|
ffd6ed |
+ (match xpath_to_string "listen[1]/@network" "" with
|
|
|
ffd6ed |
+ | "" -> LNone
|
|
|
ffd6ed |
+ | n -> LNetwork n
|
|
|
ffd6ed |
+ )
|
|
|
ffd6ed |
+ | t ->
|
|
|
ffd6ed |
+ warning ~prog (f_"<listen type='%s'> in the input libvirt XML was ignored") t;
|
|
|
ffd6ed |
+ LNone
|
|
|
ffd6ed |
+ ) in
|
|
|
ffd6ed |
match xpath_to_string "@type" "" with
|
|
|
ffd6ed |
| "" -> None
|
|
|
ffd6ed |
| "vnc" ->
|
|
|
ffd6ed |
Some { s_display_type = VNC;
|
|
|
ffd6ed |
- s_keymap = keymap; s_password = password }
|
|
|
ffd6ed |
+ s_keymap = keymap; s_password = password; s_listen = listen }
|
|
|
ffd6ed |
| "spice" ->
|
|
|
ffd6ed |
Some { s_display_type = Spice;
|
|
|
ffd6ed |
- s_keymap = keymap; s_password = password }
|
|
|
ffd6ed |
+ s_keymap = keymap; s_password = password; s_listen = listen }
|
|
|
ffd6ed |
| "sdl"|"desktop" as t ->
|
|
|
ffd6ed |
warning ~prog (f_"virt-v2v does not support local displays, so <graphics type='%s'> in the input libvirt XML was ignored") t;
|
|
|
ffd6ed |
None
|
|
|
ffd6ed |
diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
|
|
|
ffd6ed |
index f4e480a..118d4a4 100644
|
|
|
ffd6ed |
--- a/v2v/output_libvirt.ml
|
|
|
ffd6ed |
+++ b/v2v/output_libvirt.ml
|
|
|
ffd6ed |
@@ -237,6 +237,17 @@ let create_libvirt_xml ?pool source targets guestcaps target_features =
|
|
|
ffd6ed |
(match source.s_display with
|
|
|
ffd6ed |
| Some { s_password = Some pw } -> append_attr ("passwd", pw) graphics
|
|
|
ffd6ed |
| _ -> ());
|
|
|
ffd6ed |
+ (match source.s_display with
|
|
|
ffd6ed |
+ | Some { s_listen = listen } ->
|
|
|
ffd6ed |
+ (match listen with
|
|
|
ffd6ed |
+ | LAddress a ->
|
|
|
ffd6ed |
+ let sub = e "listen" [ "type", "address"; "address", a ] [] in
|
|
|
ffd6ed |
+ append_child sub graphics
|
|
|
ffd6ed |
+ | LNetwork n ->
|
|
|
ffd6ed |
+ let sub = e "listen" [ "type", "network"; "network", n ] [] in
|
|
|
ffd6ed |
+ append_child sub graphics
|
|
|
ffd6ed |
+ | LNone -> ())
|
|
|
ffd6ed |
+ | _ -> ());
|
|
|
ffd6ed |
|
|
|
ffd6ed |
video, graphics in
|
|
|
ffd6ed |
|
|
|
ffd6ed |
diff --git a/v2v/types.ml b/v2v/types.ml
|
|
|
ffd6ed |
index 97120c2..e8ee288 100644
|
|
|
ffd6ed |
--- a/v2v/types.ml
|
|
|
ffd6ed |
+++ b/v2v/types.ml
|
|
|
ffd6ed |
@@ -55,8 +55,13 @@ and source_display = {
|
|
|
ffd6ed |
s_display_type : s_display_type;
|
|
|
ffd6ed |
s_keymap : string option;
|
|
|
ffd6ed |
s_password : string option;
|
|
|
ffd6ed |
+ s_listen : s_display_listen;
|
|
|
ffd6ed |
}
|
|
|
ffd6ed |
and s_display_type = Window | VNC | Spice
|
|
|
ffd6ed |
+and s_display_listen =
|
|
|
ffd6ed |
+ | LNone
|
|
|
ffd6ed |
+ | LAddress of string
|
|
|
ffd6ed |
+ | LNetwork of string
|
|
|
ffd6ed |
|
|
|
ffd6ed |
let rec string_of_source s =
|
|
|
ffd6ed |
sprintf " source name: %s
|
|
|
ffd6ed |
@@ -117,11 +122,17 @@ and string_of_source_nic { s_mac = mac; s_vnet = vnet; s_vnet_type = typ } =
|
|
|
ffd6ed |
| Some mac -> " mac: " ^ mac)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
and string_of_source_display { s_display_type = typ;
|
|
|
ffd6ed |
- s_keymap = keymap; s_password = password } =
|
|
|
ffd6ed |
- sprintf "%s%s%s"
|
|
|
ffd6ed |
+ s_keymap = keymap; s_password = password;
|
|
|
ffd6ed |
+ s_listen = listen } =
|
|
|
ffd6ed |
+ sprintf "%s%s%s%s"
|
|
|
ffd6ed |
(match typ with Window -> "window" | VNC -> "vnc" | Spice -> "spice")
|
|
|
ffd6ed |
(match keymap with None -> "" | Some km -> " " ^ km)
|
|
|
ffd6ed |
(match password with None -> "" | Some _ -> " with password")
|
|
|
ffd6ed |
+ (match listen with
|
|
|
ffd6ed |
+ | LNone -> ""
|
|
|
ffd6ed |
+ | LAddress a -> sprintf " listening on address %s" a
|
|
|
ffd6ed |
+ | LNetwork n -> sprintf " listening on network %s" n
|
|
|
ffd6ed |
+ )
|
|
|
ffd6ed |
|
|
|
ffd6ed |
type overlay = {
|
|
|
ffd6ed |
ov_overlay_file : string;
|
|
|
ffd6ed |
diff --git a/v2v/types.mli b/v2v/types.mli
|
|
|
ffd6ed |
index 3d65596..e1aa6f9 100644
|
|
|
ffd6ed |
--- a/v2v/types.mli
|
|
|
ffd6ed |
+++ b/v2v/types.mli
|
|
|
ffd6ed |
@@ -71,8 +71,13 @@ and source_display = {
|
|
|
ffd6ed |
s_keymap : string option; (** Guest keymap. *)
|
|
|
ffd6ed |
s_password : string option; (** If required, password to access
|
|
|
ffd6ed |
the display. *)
|
|
|
ffd6ed |
+ s_listen : s_display_listen; (** Listen address. *)
|
|
|
ffd6ed |
}
|
|
|
ffd6ed |
and s_display_type = Window | VNC | Spice
|
|
|
ffd6ed |
+and s_display_listen =
|
|
|
ffd6ed |
+ | LNone
|
|
|
ffd6ed |
+ | LAddress of string (** Listen address. *)
|
|
|
ffd6ed |
+ | LNetwork of string (** Listen network. *)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
val string_of_source : source -> string
|
|
|
ffd6ed |
val string_of_source_disk : source_disk -> string
|
|
|
ffd6ed |
--
|
|
|
ffd6ed |
1.8.3.1
|
|
|
ffd6ed |
|