[Libguestfs] [virt-v2v wave 2 PATCH v2 15/16] lib/types: replace "source_video" type with plain "string"

Laszlo Ersek lersek at redhat.com
Thu Dec 2 09:46:36 UTC 2021


The "source_video" union type is basically a string, with a distinguished
constructor for the "cirrus" device model ("Source_Cirrus"). However, this
distinction has been useless since commit 255722cbf39a ("v2v: Modular
virt-v2v", 2021-09-07); now "Source_Cirrus" isn't treated specially.
Replace the "source_video" type with just "string".

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1961107
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---

Notes:
    v1:
    
    - new in v1

 lib/types.mli                  |  8 +-------
 input/parse_domain_from_vmx.ml |  2 +-
 input/parse_libvirt_xml.ml     |  4 +---
 lib/types.ml                   | 15 ++-------------
 4 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/lib/types.mli b/lib/types.mli
index e0ef222e0455..65efbcc03fec 100644
--- a/lib/types.mli
+++ b/lib/types.mli
@@ -70,7 +70,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_video : string option;              (** Video adapter. *)
   s_sound : source_sound option;        (** Sound card. *)
   s_disks : source_disk list;           (** Source disks. *)
   s_removables : source_removable list; (** CDROMs etc. *)
@@ -145,10 +145,6 @@ and s_display_listen =
   | LSocket of string option       (** Listen Unix domain socket. *)
   | LNone                          (** <listen type='none'> *)
 
-(** Video adapter model. *)
-and source_video = Source_other_video of string |
-                   Source_Cirrus
-
 and source_sound = {
   s_sound_model : source_sound_model; (** Sound model. *)
 }
@@ -169,8 +165,6 @@ val nic_model_of_string : string -> s_nic_model
 val string_of_vnet_type : vnet_type -> string
 val string_of_source_sound_model : source_sound_model -> string
 val source_sound_model_of_string : string -> source_sound_model option
-val string_of_source_video : source_video -> string
-val source_video_of_string : string -> source_video
 val string_of_source_cpu_topology : source_cpu_topology -> string
 
 val string_of_source_hypervisor : source_hypervisor -> string
diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml
index 05bab40b48d7..5d0f3c862c89 100644
--- a/input/parse_domain_from_vmx.ml
+++ b/input/parse_domain_from_vmx.ml
@@ -404,7 +404,7 @@ let parse_domain_from_vmx vmx_source =
   let video =
     if Parse_vmx.namespace_present vmx ["svga"] then
       (* We could also parse svga.vramSize. *)
-      Some (Source_other_video "vmvga")
+      Some "vmvga"
     else
       None in
 
diff --git a/input/parse_libvirt_xml.ml b/input/parse_libvirt_xml.ml
index c53b8001ca77..835649939d22 100644
--- a/input/parse_libvirt_xml.ml
+++ b/input/parse_libvirt_xml.ml
@@ -193,9 +193,7 @@ let parse_libvirt_xml ?conn xml =
       let node = Xml.xpathobj_node obj 0 in
 
       Xml.xpathctx_set_current_context xpathctx node;
-      match xpath_string "model/@type" with
-      | None -> None
-      | Some model -> Some (source_video_of_string model)
+      xpath_string "model/@type"
     ) in
 
   (* Sound card. *)
diff --git a/lib/types.ml b/lib/types.ml
index acca0d989b91..9629bab50d4e 100644
--- a/lib/types.ml
+++ b/lib/types.ml
@@ -36,7 +36,7 @@ type source = {
   s_features : string list;
   s_firmware : source_firmware;
   s_display : source_display option;
-  s_video : source_video option;
+  s_video : string option;
   s_sound : source_sound option;
   s_disks : source_disk list;
   s_removables : source_removable list;
@@ -89,9 +89,6 @@ and s_display_listen =
   | LSocket of string option
   | LNone
 
-and source_video = Source_other_video of string |
-                   Source_Cirrus
-
 and source_sound = {
   s_sound_model : source_sound_model;
 }
@@ -141,7 +138,7 @@ NICs:
     | Some display -> string_of_source_display display)
     (match s.s_video with
     | None -> ""
-    | Some video -> string_of_source_video video)
+    | Some video -> video)
     (match s.s_sound with
     | None -> ""
     | Some sound -> string_of_source_sound sound)
@@ -259,14 +256,6 @@ and string_of_source_display { s_display_type = typ;
     | LNone -> " listening on private fd"
     )
 
-and string_of_source_video = function
-  | Source_Cirrus -> "cirrus"
-  | Source_other_video video -> video
-
-and source_video_of_string = function
-  | "cirrus" -> Source_Cirrus
-  | video -> Source_other_video video
-
 and string_of_source_sound { s_sound_model = model } =
   string_of_source_sound_model model
 
-- 
2.19.1.3.g30247aa5d201




More information about the Libguestfs mailing list