[Ovirt-devel] [PATCH] Add support of image files for NFS Storage Pool during xml vm creation

Pierre Inglebert Pierre.Inglebert at inria.fr
Mon May 19 12:17:44 UTC 2008


Hi,
This is my first contribution to the oVirt project and not the last one
( i will talk about that in my next email ).
This patch adds support of image files for NFS Storage Pool during the
xml vm creation because it is actually hard coded for an iSCSI Pool.

-- 
Pierre Inglebert <Pierre.Inglebert at inria.fr>

----------------------------------------------------------------------------

diff --git a/ovirt3/wui/src/task-omatic/task_vm.rb
b/ovirt2/wui/src/task-omatic/task_vm.rb
index 29bcb1f..1de0c83 100644
--- a/ovirt3/wui/src/task-omatic/task_vm.rb
+++ b/ovirt2/wui/src/task-omatic/task_vm.rb
@@ -66,9 +66,9 @@ def create_vm_xml(name, uuid, memAllocated, memUsed,
vcpus, bootDevice,
   i = 0
   diskDevices.each do |disk|
     diskdev = Element.new("disk")
-    diskdev.add_attribute("type", "block")
+    diskdev.add_attribute("type", disk["type"])
     diskdev.add_attribute("device", "disk")
-    diskdev.add_element("source", {"dev" => disk})
+    diskdev.add_element("source", {disk["source"] => disk["path"]})
     diskdev.add_element("target", {"dev" => devs[i]})
     doc.root.elements["devices"] << diskdev
     i += 1
@@ -342,8 +342,14 @@ def start_vm(task)
         thepool.build(0)
         thepool.create(0)
       end
-
-      storagedevs <<
thepool.lookup_volume_by_name(volume.read_attribute(thisstorage.db_column)).path
+      #We probably could take the xml/Pool_type before
+      doc = Document.new(thepool.xml_desc(0))
+      case doc.root.attributes['type']
+      when "iscsi"
+        storagedevs << {"type" => "block", "source" => "dev", "path" =>
thepool.lookup_volume_by_name(volume.read_attribute(thisstorage.db_column)).path}
+      when "netfs"
+        storagedevs << {"type" => "file", "source" => "file", "path" =>
thepool.lookup_volume_by_name(volume.read_attribute(thisstorage.db_column)).path}
+      end
     end

     conn.close



-------------- next part --------------
A non-text attachment was scrubbed...
Name: add_Imagefile_support_during_vm_creation.patch
Type: text/x-patch
Size: 1484 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20080519/4bfa12a9/attachment.bin>


More information about the ovirt-devel mailing list