mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
v2v: collect source network and video adapter types
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@virtuozzo.com> Signed-off-by: "Richard W.M. Jones" <rjones@redhat.com>
This commit is contained in:
@@ -276,6 +276,14 @@
|
||||
<source file='@abs_builddir@/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>
|
||||
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -7,6 +7,7 @@ hypervisor type: vmware
|
||||
CPU features:
|
||||
firmware: uefi
|
||||
display:
|
||||
video:
|
||||
sound:
|
||||
disks:
|
||||
disk1.vmdk (vmdk) [scsi]
|
||||
|
||||
@@ -7,6 +7,7 @@ hypervisor type: vmware
|
||||
CPU features:
|
||||
firmware: bios
|
||||
display:
|
||||
video:
|
||||
sound:
|
||||
disks:
|
||||
.vmdk (vmdk) [scsi]
|
||||
|
||||
@@ -7,6 +7,7 @@ hypervisor type: vmware
|
||||
CPU features:
|
||||
firmware: bios
|
||||
display:
|
||||
video:
|
||||
sound:
|
||||
disks:
|
||||
disk1.vmdk (vmdk) [scsi]
|
||||
|
||||
@@ -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
|
||||
|
||||
30
v2v/types.ml
30
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
|
||||
|
||||
|
||||
@@ -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. *)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user