mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone
Blob Blame History Raw
From ecbd5983e10adb6c5d95fdae1dc878a9905ae1b4 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 29 May 2018 07:04:50 +0200
Subject: [PATCH] v2v: add and use Create_ovf.ovf_flavour_to_string

Add an helper to convert an OVF flavour to string, and use it in
-o vdsm to print the actual value of the vdsm-ovf-flavour option.

Thanks to Ming Xie.

(cherry picked from commit c0da02f90d9b52413c24dd9dae61662ad033cc16)
---
 v2v/create_ovf.ml  | 4 ++++
 v2v/create_ovf.mli | 3 +++
 v2v/output_vdsm.ml | 5 +++--
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
index 190cf8bed..ac3c61b13 100644
--- a/v2v/create_ovf.ml
+++ b/v2v/create_ovf.ml
@@ -40,6 +40,10 @@ let ovf_flavour_of_string = function
   | "rhvexp" -> RHVExportStorageDomain
   | flav -> invalid_arg flav
 
+let ovf_flavour_to_string = function
+  | OVirt -> "ovirt"
+  | RHVExportStorageDomain -> "rhvexp"
+
 (* We set the creation time to be the same for all dates in
  * all metadata files.  All dates in OVF are UTC.
  *)
diff --git a/v2v/create_ovf.mli b/v2v/create_ovf.mli
index 2d80660e3..8200b76f9 100644
--- a/v2v/create_ovf.mli
+++ b/v2v/create_ovf.mli
@@ -29,6 +29,9 @@ val ovf_flavours : string list
     valid flavour. *)
 val ovf_flavour_of_string : string -> ovf_flavour
 
+(** Convert an OVF flavour to its string representation. *)
+val ovf_flavour_to_string : ovf_flavour -> string
+
 (** Create OVF and related files for RHV.
 
     The format for RHV export storage domain is described in:
diff --git a/v2v/output_vdsm.ml b/v2v/output_vdsm.ml
index 92b3fd122..9a1b748bc 100644
--- a/v2v/output_vdsm.ml
+++ b/v2v/output_vdsm.ml
@@ -118,9 +118,10 @@ object
        | "0.10" -> "" (* currently this is the default, so don't print it *)
        | s -> sprintf " -oo vdsm-compat=%s" s)
       (match vdsm_options.ovf_flavour with
-       | Create_ovf.OVirt -> "-oo vdsm-ovf-flavour=ovf"
        (* currently this is the default, so don't print it *)
-       | Create_ovf.RHVExportStorageDomain -> "")
+       | Create_ovf.RHVExportStorageDomain -> ""
+       | flav -> sprintf "-oo vdsm-ovf-flavour=%s"
+                         (Create_ovf.ovf_flavour_to_string flav))
 
   method supported_firmware = [ TargetBIOS ]
 
-- 
2.20.1