mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0112-v2v-o-vdsm-should-assume-data-domain-at-os-path.patch

ffd6ed
From 766c53d1d28006cbefa2837f6f3bd9fd2bee64b8 Mon Sep 17 00:00:00 2001
ffd6ed
From: Shahar Havivi <shaharh@redhat.com>
ffd6ed
Date: Mon, 26 Jan 2015 12:13:49 +0200
ffd6ed
Subject: [PATCH] v2v: -o vdsm should assume data domain at -os path
ffd6ed
ffd6ed
Unlike -o rhev which have only one data domin, -o vdsm can and usually
ffd6ed
does have multiple data domain.
ffd6ed
The path to vdsm is pre mounted so no need to assume nfs path with -os
ffd6ed
Example:
ffd6ed
-o vdsm -os /rhev/data-center/<data-center-uuid>/<data-domain-uuid>
ffd6ed
ffd6ed
Bug-Url: https://bugzilla.redhat.com/1176591
ffd6ed
Signed-off-by: Shahar Havivi <shaharh@redhat.com>
ffd6ed
(cherry picked from commit 889e55516869d1eadcdeae15e38dd8d3bbca8d20)
ffd6ed
---
ffd6ed
 v2v/output_vdsm.ml             | 18 ++++++++++++++----
ffd6ed
 v2v/test-v2v-o-vdsm-options.sh |  2 +-
ffd6ed
 v2v/virt-v2v.pod               |  6 ++++--
ffd6ed
 3 files changed, 19 insertions(+), 7 deletions(-)
ffd6ed
ffd6ed
diff --git a/v2v/output_vdsm.ml b/v2v/output_vdsm.ml
ffd6ed
index 492f586..c7a243e 100644
ffd6ed
--- a/v2v/output_vdsm.ml
ffd6ed
+++ b/v2v/output_vdsm.ml
ffd6ed
@@ -63,9 +63,8 @@ object
ffd6ed
    * name of the target files that eventually get written by the main
ffd6ed
    * code.
ffd6ed
    *
ffd6ed
-   * 'os' is the output storage (-os nfs:/export).  'source' contains a
ffd6ed
-   * few useful fields such as the guest name.  'targets' describes the
ffd6ed
-   * destination files.  We modify and return this list.
ffd6ed
+   * 'os' is the output storage domain (-os /rhev/data/<data center>/<data domain>)
ffd6ed
+   * this is already mounted path.
ffd6ed
    *
ffd6ed
    * Note it's good to fail here (early) if there are any problems, since
ffd6ed
    * the next time we are called (in {!create_metadata}) we have already
ffd6ed
@@ -79,7 +78,18 @@ object
ffd6ed
         (List.length targets);
ffd6ed
 
ffd6ed
     let mp, uuid =
ffd6ed
-      Output_rhev.mount_and_check_storage_domain verbose (s_"Data Domain") os in
ffd6ed
+      let fields = string_nsplit "/" os in (* ... "data-center" "UUID" *)
ffd6ed
+      let fields = List.rev fields in      (* "UUID" "data-center" ... *)
ffd6ed
+      match fields with
ffd6ed
+      | "" :: uuid :: rest                 (* handles trailing "/" case *)
ffd6ed
+      | uuid :: rest
ffd6ed
+          when String.length uuid = 36 ->
ffd6ed
+        let mp = String.concat "/" (List.rev rest) in
ffd6ed
+        mp, uuid
ffd6ed
+      | _ ->
ffd6ed
+        error (f_"vdsm: invalid -os parameter does not contain a valid UUID: %s")
ffd6ed
+          os in
ffd6ed
+
ffd6ed
     dd_mp <- mp;
ffd6ed
     dd_uuid <- uuid;
ffd6ed
     if verbose then
ffd6ed
diff --git a/v2v/test-v2v-o-vdsm-options.sh b/v2v/test-v2v-o-vdsm-options.sh
ffd6ed
index e2098fa..c170467 100755
ffd6ed
--- a/v2v/test-v2v-o-vdsm-options.sh
ffd6ed
+++ b/v2v/test-v2v-o-vdsm-options.sh
ffd6ed
@@ -64,7 +64,7 @@ mkdir $d/12345678-1234-1234-1234-123456789abc/master/vms/VM
ffd6ed
 
ffd6ed
 $VG virt-v2v --debug-gc \
ffd6ed
     -i libvirt -ic "$libvirt_uri" windows \
ffd6ed
-    -o vdsm -os $d \
ffd6ed
+    -o vdsm -os $d/12345678-1234-1234-1234-123456789abc \
ffd6ed
     --vmtype desktop \
ffd6ed
     --vdsm-image-uuid IMAGE \
ffd6ed
     --vdsm-vol-uuid VOL \
ffd6ed
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
ffd6ed
index 7ed2dda..2e49fbf 100644
ffd6ed
--- a/v2v/virt-v2v.pod
ffd6ed
+++ b/v2v/virt-v2v.pod
ffd6ed
@@ -360,8 +360,10 @@ See L</OUTPUT TO RHEV> below.
ffd6ed
 
ffd6ed
 Set the output method to I<vdsm>.
ffd6ed
 
ffd6ed
-This mode is similar to I<-o rhev> but is only used by RHEV VDSM
ffd6ed
-when it runs virt-v2v under VDSM control.
ffd6ed
+This mode is similar to I<-o rhev>, but the full path to the
ffd6ed
+data domain must be given:
ffd6ed
+C</rhev/data-center/E<lt>data-center-uuidE<gt>/E<lt>data-domain-uuidE<gt>>.
ffd6ed
+This mode is only used when virt-v2v runs under VDSM control.
ffd6ed
 
ffd6ed
 =item B<-oa sparse>
ffd6ed
 
ffd6ed
-- 
ffd6ed
1.8.3.1
ffd6ed