[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 2/4] add option to p2v ui to mount client disks on server



---
 p2v/client/lib/virt-p2v/ui/convert.rb | 43 +++++++++++++++++++++++------------
 p2v/client/lib/virt-p2v/ui/p2v.ui     | 14 ++++++++++++
 2 files changed, 43 insertions(+), 14 deletions(-)

diff --git a/p2v/client/lib/virt-p2v/ui/convert.rb b/p2v/client/lib/virt-p2v/ui/convert.rb
index 244125e..4fe61ab 100644
--- a/p2v/client/lib/virt-p2v/ui/convert.rb
+++ b/p2v/client/lib/virt-p2v/ui/convert.rb
@@ -14,6 +14,8 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
+# TODO add option to toggle mounting disks using nbd or iscsi
+
 require 'gtk2'
 
 require 'virt-p2v/blockdevice'
@@ -26,9 +28,10 @@ module VirtP2V::UI::Convert
     CONVERT_NETWORK_DEVICE  = 1
 
     CONVERT_FIXED_CONVERT   = 0
-    CONVERT_FIXED_DEVICE    = 1
-    CONVERT_FIXED_PROGRESS  = 2
-    CONVERT_FIXED_SIZE_GB   = 3
+    CONVERT_FIXED_MOUNT     = 1
+    CONVERT_FIXED_DEVICE    = 2
+    CONVERT_FIXED_PROGRESS  = 3
+    CONVERT_FIXED_SIZE_GB   = 4
 
     CONVERT_REMOVABLE_CONVERT   = 0
     CONVERT_REMOVABLE_DEVICE    = 1
@@ -99,6 +102,7 @@ module VirtP2V::UI::Convert
         VirtP2V::FixedBlockDevice.all_devices.each { |dev|
             fixed = @fixeds.append
             fixed[CONVERT_FIXED_CONVERT]    = true
+            fixed[CONVERT_FIXED_MOUNT]      = false
             fixed[CONVERT_FIXED_DEVICE]     = dev.device
             fixed[CONVERT_FIXED_PROGRESS]   = 0
             fixed[CONVERT_FIXED_SIZE_GB]    = dev.size / 1024 / 1024 / 1024
@@ -134,6 +138,8 @@ module VirtP2V::UI::Convert
                             method(:update_values))
         ui.register_handler('convert_fixed_select_toggled',
                             method(:convert_fixed_select_toggled))
+        ui.register_handler('mount_fixed_select_toggled',
+                            method(:mount_fixed_select_toggled))
         ui.register_handler('convert_removable_select_toggled',
                             method(:convert_removable_select_toggled))
         ui.register_handler('convert_network_select_toggled',
@@ -319,16 +325,19 @@ module VirtP2V::UI::Convert
             raise InvalidUIState if memory.nil?
             @converter.memory = memory * 1024 * 1024
 
-            # Check that at least 1 fixed storage device is selected
-            fixed = false
+            # Check that at least 1 fixed or mounted storage device is selected
+            has_disk = false
             @converter.disks.clear
             @fixeds.each { |model, path, iter|
                 if iter[CONVERT_FIXED_CONVERT] then
-                    fixed = true
+                    has_disk = true
                     @converter.disks << iter[CONVERT_FIXED_DEVICE]
+                elsif iter[CONVERT_FIXED_MOUNT] then
+                    has_disk = true
+                    @converter.mounts << iter[CONVERT_FIXED_MOUNT]
                 end
             }
-            raise InvalidUIState unless fixed
+            raise InvalidUIState unless has_disk
 
             # Populate removables and nics, although these aren't required to be
             # selected for the ui state to be valid
@@ -373,17 +382,16 @@ module VirtP2V::UI::Convert
         memory = Integer(memory) rescue nil
         return false if memory.nil?
 
-        # Check that at least 1 fixed storage device is selected
-        fixed = false
+        # Check that at least 1 fixed or mounted storage device is selected
+        has_disk = false
         @fixeds.each { |model, path, iter|
-            if iter[CONVERT_FIXED_CONVERT] then
-                fixed = true
+            if iter[CONVERT_FIXED_CONVERT] ||
+               iter[CONVERT_FIXED_MOUNT]   then
+                has_disk = true
                 break
             end
         }
-        return false unless fixed
-
-        return true
+        return has_disk
     end
 
     def self.convert_cpus_changed
@@ -416,6 +424,13 @@ module VirtP2V::UI::Convert
     def self.convert_fixed_select_toggled(widget, path)
         iter = @fixeds.get_iter(path)
         iter[CONVERT_FIXED_CONVERT] = !iter[CONVERT_FIXED_CONVERT]
+        iter[CONVERT_FIXED_MOUNT]   = false if iter[CONVERT_FIXED_CONVERT]
+    end
+
+    def self.mount_fixed_select_toggled(widget, path)
+        iter = @fixeds.get_iter(path)
+        iter[CONVERT_FIXED_MOUNT]   = !iter[CONVERT_FIXED_MOUNT]
+        iter[CONVERT_FIXED_CONVERT] = false if iter[CONVERT_FIXED_MOUNT]
     end
 
     def self.convert_removable_select_toggled(widget, path)
diff --git a/p2v/client/lib/virt-p2v/ui/p2v.ui b/p2v/client/lib/virt-p2v/ui/p2v.ui
index a27bd20..f4d24a8 100644
--- a/p2v/client/lib/virt-p2v/ui/p2v.ui
+++ b/p2v/client/lib/virt-p2v/ui/p2v.ui
@@ -276,6 +276,20 @@
                                   </object>
                                 </child>
                                 <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn13">
+                                    <property name="title">Mount</property>
+                                    <property name="clickable">True</property>
+                                    <child>
+                                      <object class="GtkCellRendererToggle" id="mount_fixed_select">
+                                        <signal name="toggled" handler="mount_fixed_select_toggled" swapped="no"/>
+                                      </object>
+                                      <attributes>
+                                        <attribute name="active">0</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
+                                <child>
                                   <object class="GtkTreeViewColumn" id="treeviewcolumn5">
                                     <property name="title">Device</property>
                                     <child>
-- 
1.7.11.7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]