[Pkg-libvirt-commits] [libguestfs] 113/179: v2v: Add a unique number to source disks.

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 31 19:08:44 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit 63387fd8d0d77f7fdaaad14e5053b86ae51cbd6e
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Mon Oct 20 18:18:54 2014 +0100

    v2v: Add a unique number to source disks.
    
    Note that it doesn't matter what the number is, as long as it's
    different for each disk.
    
    The unique number lets us store extra data in input objects which is
    associated with each disk.
---
 v2v/input_disk.ml       | 1 +
 v2v/input_libvirtxml.ml | 6 ++++--
 v2v/input_ova.ml        | 1 +
 v2v/types.ml            | 1 +
 v2v/types.mli           | 1 +
 5 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/v2v/input_disk.ml b/v2v/input_disk.ml
index 0b68ccf..ef28b43 100644
--- a/v2v/input_disk.ml
+++ b/v2v/input_disk.ml
@@ -66,6 +66,7 @@ class input_disk verbose input_format disk = object
         | format -> format in
 
     let disk = {
+      s_disk_id = 0;
       s_qemu_uri = disk_absolute;
       s_format = Some format;
       s_target_dev = None;
diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
index 3b19685..0cfd75c 100644
--- a/v2v/input_libvirtxml.ml
+++ b/v2v/input_libvirtxml.ml
@@ -103,11 +103,13 @@ let parse_libvirt_xml ~verbose xml =
   (* Non-removable disk devices. *)
   let disks =
     let get_disks, add_disk =
-      let disks = ref [] in
+      let disks = ref [] and i = ref 0 in
       let get_disks () = List.rev !disks in
       let add_disk qemu_uri format target_dev =
+        incr i;
         disks :=
-          { s_qemu_uri = qemu_uri; s_format = format;
+          { s_disk_id = !i;
+            s_qemu_uri = qemu_uri; s_format = format;
             s_target_dev = target_dev } :: !disks
       in
       get_disks, add_disk
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 001a579..6349c76 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -210,6 +210,7 @@ object
             else filename in
 
           let disk = {
+            s_disk_id = i;
             s_qemu_uri = filename;
             s_format = Some "vmdk";
             s_target_dev = Some target_dev;
diff --git a/v2v/types.ml b/v2v/types.ml
index ba04161..5124f3c 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -33,6 +33,7 @@ type source = {
   s_nics : source_nic list;
 }
 and source_disk = {
+  s_disk_id : int;
   s_qemu_uri : string;
   s_format : string option;
   s_target_dev : string option;
diff --git a/v2v/types.mli b/v2v/types.mli
index 863371c..c077dc2 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -35,6 +35,7 @@ type source = {
 (** The source: metadata, disk images. *)
 
 and source_disk = {
+  s_disk_id : int;                      (** A unique ID for each source disk. *)
   s_qemu_uri : string;                  (** QEMU URI of source disk. *)
   s_format : string option;             (** Format. *)
   s_target_dev : string option;         (** Target @dev from libvirt XML. *)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list