Those will be useful when making decisions about what configuration to
set on output.
The data is also included in --print-source so the tests are adjusted
accordingly.
Signed-off-by: Roman Kagan <rkagan(a)virtuozzo.com>
---
Notes:
v2:
- add catch-all string-valued variants for source network and video adapter
models
test-data/phony-guests/guests.xml.in | 8 ++++++++
v2v/input_disk.ml | 2 ++
v2v/input_libvirtxml.ml | 27 +++++++++++++++++++++++++++
v2v/input_ova.ml | 2 ++
v2v/test-v2v-i-ova-formats.expected | 1 +
v2v/test-v2v-i-ova-gz.expected | 1 +
v2v/test-v2v-i-ova-two-disks.expected | 1 +
v2v/test-v2v-print-source.sh | 4 +++-
v2v/types.ml | 30 ++++++++++++++++++++++++++++--
v2v/types.mli | 9 +++++++++
10 files changed, 82 insertions(+), 3 deletions(-)
diff --git a/test-data/phony-guests/guests.xml.in b/test-data/phony-guests/guests.xml.in
index 8f7ac81..9c7c989 100644
--- a/test-data/phony-guests/guests.xml.in
+++ b/test-data/phony-guests/guests.xml.in
@@ -276,6 +276,14 @@
<source file='@abs_builddir(a)/windows.img'/>
<target dev='vda' bus='virtio'/>
</disk>
+ <interface type='network'>
+ <mac address='00:11:22:33:44:55'/>
+ <source network='default'/>
+ <model type='virtio'/>
+ </interface>
+ <video>
+ <model type='qxl' ram='65536' vram='65536'
vgamem='16384' heads='1'/>
+ </video>
</devices>
</domain>
diff --git a/v2v/input_disk.ml b/v2v/input_disk.ml
index 1cb6713..17ad61d 100644
--- a/v2v/input_disk.ml
+++ b/v2v/input_disk.ml
@@ -75,6 +75,7 @@ class input_disk input_format disk = object
(* Give the guest a simple generic network interface. *)
let network = {
s_mac = None;
+ s_nic_model = None;
s_vnet = "default"; s_vnet_orig = "default";
s_vnet_type = Network
} in
@@ -89,6 +90,7 @@ class input_disk input_format disk = object
s_display =
Some { s_display_type = Window; s_keymap = None; s_password = None;
s_listen = LNone; s_port = None };
+ s_video = None;
s_sound = None;
s_disks = [disk];
s_removables = [];
diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
index 3537011..9d8963d 100644
--- a/v2v/input_libvirtxml.ml
+++ b/v2v/input_libvirtxml.ml
@@ -140,6 +140,23 @@ let parse_libvirt_xml ?conn xml =
None
) in
+ (* Video adapter. *)
+ let video =
+ let obj = Xml.xpath_eval_expression xpathctx "/domain/devices/video" in
+ let nr_nodes = Xml.xpathobj_nr_nodes obj in
+ if nr_nodes < 1 then None
+ else (
+ (* Ignore everything except the first <video> device. *)
+ let node = Xml.xpathobj_node obj 0 in
+
+ Xml.xpathctx_set_current_context xpathctx node;
+ match xpath_string "model/@type" with
+ | None -> None
+ | Some "qxl" | Some "virtio" -> Some Source_QXL
+ | Some "cirrus" | Some "vga" -> Some Source_Cirrus
+ | Some model -> Some (Source_other_video model)
+ ) in
+
(* Sound card. *)
let sound =
let obj = Xml.xpath_eval_expression xpathctx "/domain/devices/sound" in
@@ -329,6 +346,14 @@ let parse_libvirt_xml ?conn xml =
| Some "00:00:00:00:00:00" (* thanks, VMware *) -> None
| Some mac -> Some mac in
+ let model =
+ match xpath_string "model/@type" with
+ | None -> None
+ | Some "virtio" -> Some Source_virtio_net
+ | Some "e1000" -> Some Source_e1000
+ | Some "rtl8139" -> Some Source_rtl8139
+ | Some model -> Some (Source_other_nic model) in
+
let vnet_type =
match xpath_string "@type" with
| Some "network" -> Some Network
@@ -340,6 +365,7 @@ let parse_libvirt_xml ?conn xml =
let add_nic vnet =
let nic = {
s_mac = mac;
+ s_nic_model = model;
s_vnet = vnet;
s_vnet_orig = vnet;
s_vnet_type = vnet_type
@@ -366,6 +392,7 @@ let parse_libvirt_xml ?conn xml =
s_features = features;
s_firmware = UnknownFirmware; (* XXX until RHBZ#1217444 is fixed *)
s_display = display;
+ s_video = video;
s_sound = sound;
s_disks = [];
s_removables = removables;
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index c8c6b94..db0588d 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -350,6 +350,7 @@ object
xpath_string_default "rasd:ElementName/text()"
(sprintf"eth%d" i) in
let nic = {
s_mac = None;
+ s_nic_model = None;
s_vnet = vnet;
s_vnet_orig = vnet;
s_vnet_type = Network;
@@ -366,6 +367,7 @@ object
s_features = []; (* XXX *)
s_firmware = firmware;
s_display = None; (* XXX *)
+ s_video = None;
s_sound = None;
s_disks = disks;
s_removables = removables;
diff --git a/v2v/test-v2v-i-ova-formats.expected b/v2v/test-v2v-i-ova-formats.expected
index c83e5dd..7049aee 100644
--- a/v2v/test-v2v-i-ova-formats.expected
+++ b/v2v/test-v2v-i-ova-formats.expected
@@ -7,6 +7,7 @@ hypervisor type: vmware
CPU features:
firmware: uefi
display:
+ video:
sound:
disks:
disk1.vmdk (vmdk) [scsi]
diff --git a/v2v/test-v2v-i-ova-gz.expected b/v2v/test-v2v-i-ova-gz.expected
index be6cde3..50ba746 100644
--- a/v2v/test-v2v-i-ova-gz.expected
+++ b/v2v/test-v2v-i-ova-gz.expected
@@ -7,6 +7,7 @@ hypervisor type: vmware
CPU features:
firmware: bios
display:
+ video:
sound:
disks:
.vmdk (vmdk) [scsi]
diff --git a/v2v/test-v2v-i-ova-two-disks.expected
b/v2v/test-v2v-i-ova-two-disks.expected
index dcbd43e..cc850a7 100644
--- a/v2v/test-v2v-i-ova-two-disks.expected
+++ b/v2v/test-v2v-i-ova-two-disks.expected
@@ -7,6 +7,7 @@ hypervisor type: vmware
CPU features:
firmware: bios
display:
+ video:
sound:
disks:
disk1.vmdk (vmdk) [scsi]
diff --git a/v2v/test-v2v-print-source.sh b/v2v/test-v2v-print-source.sh
index 8dd0145..8af6104 100755
--- a/v2v/test-v2v-print-source.sh
+++ b/v2v/test-v2v-print-source.sh
@@ -60,11 +60,13 @@ hypervisor type: test
CPU features:
firmware: unknown
display:
+ video: qxl
sound:
disks:
/windows.img (raw) [virtio]
removable media:
-NICs:" ]; then
+NICs:
+ Network \"default\" mac: 00:11:22:33:44:55 [virtio]" ]; then
echo "$0: unexpected output from test:"
cat $d/output.orig
exit 1
diff --git a/v2v/types.ml b/v2v/types.ml
index a9d28e0..a082c37 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -32,6 +32,7 @@ type source = {
s_features : string list;
s_firmware : source_firmware;
s_display : source_display option;
+ s_video : source_video option;
s_sound : source_sound option;
s_disks : source_disk list;
s_removables : source_removable list;
@@ -63,10 +64,13 @@ and source_removable = {
and s_removable_type = CDROM | Floppy
and source_nic = {
s_mac : string option;
+ s_nic_model : s_nic_model option;
s_vnet : string;
s_vnet_orig : string;
s_vnet_type : vnet_type;
}
+and s_nic_model = Source_other_nic of string |
+ Source_rtl8139 | Source_e1000 | Source_virtio_net
and vnet_type = Bridge | Network
and source_display = {
s_display_type : s_display_type;
@@ -81,6 +85,9 @@ and s_display_listen =
| LAddress of string
| LNetwork of string
+and source_video = Source_other_video of string |
+ Source_Cirrus | Source_QXL
+
and source_sound = {
s_sound_model : source_sound_model;
}
@@ -95,6 +102,7 @@ hypervisor type: %s
CPU features: %s
firmware: %s
display: %s
+ video: %s
sound: %s
disks:
%s
@@ -112,6 +120,9 @@ NICs:
(match s.s_display with
| None -> ""
| Some display -> string_of_source_display display)
+ (match s.s_video with
+ | None -> ""
+ | Some video -> string_of_source_video video)
(match s.s_sound with
| None -> ""
| Some sound -> string_of_source_sound sound)
@@ -188,13 +199,23 @@ and string_of_source_removable { s_removable_type = typ;
| Some controller -> " [" ^ string_of_controller controller ^
"]")
(match i with None -> "" | Some i -> sprintf " in slot %d"
i)
-and string_of_source_nic { s_mac = mac; s_vnet = vnet; s_vnet_type = typ } =
- sprintf "\t%s \"%s\"%s"
+and string_of_source_nic { s_mac = mac; s_nic_model = model; s_vnet = vnet;
+ s_vnet_type = typ } =
+ sprintf "\t%s \"%s\"%s%s"
(match typ with Bridge -> "Bridge" | Network -> "Network")
vnet
(match mac with
| None -> ""
| Some mac -> " mac: " ^ mac)
+ (match model with
+ | None -> ""
+ | Some model -> " [" ^ string_of_nic_model model ^ "]")
+
+and string_of_nic_model = function
+ | Source_virtio_net -> "virtio"
+ | Source_e1000 -> "e1000"
+ | Source_rtl8139 -> "rtl8139"
+ | Source_other_nic model -> model
and string_of_source_display { s_display_type = typ;
s_keymap = keymap; s_password = password;
@@ -209,6 +230,11 @@ and string_of_source_display { s_display_type = typ;
| LNetwork n -> sprintf " listening on network %s" n
)
+and string_of_source_video = function
+ | Source_QXL -> "qxl"
+ | Source_Cirrus -> "cirrus"
+ | Source_other_video video -> video
+
and string_of_source_sound { s_sound_model = model } =
string_of_source_sound_model model
diff --git a/v2v/types.mli b/v2v/types.mli
index f482a92..f58028f 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -29,6 +29,7 @@ type source = {
s_features : string list; (** Machine features. *)
s_firmware : source_firmware; (** Firmware (BIOS or EFI). *)
s_display : source_display option; (** Guest display. *)
+ s_video : source_video option; (** Video adapter. *)
s_sound : source_sound option; (** Sound card. *)
s_disks : source_disk list; (** Disk images. *)
s_removables : source_removable list; (** CDROMs etc. *)
@@ -82,10 +83,14 @@ and s_removable_type = CDROM | Floppy
and source_nic = {
s_mac : string option; (** MAC address. *)
+ s_nic_model : s_nic_model option; (** Network adapter model. *)
s_vnet : string; (** Source network name. *)
s_vnet_orig : string; (** Original network (if we map it). *)
s_vnet_type : vnet_type; (** Source network type. *)
}
+(** Network adapter models. *)
+and s_nic_model = Source_other_nic of string |
+ Source_rtl8139 | Source_e1000 | Source_virtio_net
(** Network interfaces. *)
and vnet_type = Bridge | Network
@@ -103,6 +108,10 @@ and s_display_listen =
| LAddress of string (** Listen address. *)
| LNetwork of string (** Listen network. *)
+(** Video adapter model. *)
+and source_video = Source_other_video of string |
+ Source_Cirrus | Source_QXL
+
and source_sound = {
s_sound_model : source_sound_model; (** Sound model. *)
}
--
2.5.0