<div dir="ltr">A volume in a logical storage pool only uses the format &#39;raw&#39;. Even if the user specifies a different format type, it will be &#39;raw&#39; in the end. So it would be nice if the interface didn&#39;t allow the user to change the volume format for a logical pool, as it will be ignored anyway.<br><br><a href="https://libvirt.org/storage.html">https://libvirt.org/storage.html</a><br></div><br><div class="gmail_quote">On Tue, Apr 14, 2015 at 3:24 AM Rodrigo Trujillo &lt;<a href="mailto:rodrigo.trujillo@linux.vnet.ibm.com">rodrigo.trujillo@linux.vnet.ibm.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch adds a new field (Disk Format) in Storage tab in Template<br>
edit window. Users will then be allowed to select any disk format<br>
supported by Libvirt and Kimchi backend.<br>
The default disk format is qcow2 (first option), so, for compatibility,<br>
if the template register in objecstore does not contain the disk format<br>
information, the new field is going to set &#39;qcow2&#39; automatically.<br>
For iscsi storagepools, the new field is going to be disabled and the<br>
format is going to be set automatically as &#39;raw&#39;, just like the backend<br>
behaves currently, avoiding errors.<br>
<br>
Signed-off-by: Rodrigo Trujillo &lt;<a href="mailto:rodrigo.trujillo@linux.vnet.ibm.com" target="_blank">rodrigo.trujillo@linux.vnet.ibm.com</a>&gt;<br>
---<br>
 ui/css/theme-default/template-edit.css |  8 +++++--<br>
 ui/js/src/kimchi.template_edit_main.js | 40 +++++++++++++++++++++++++++++-----<br>
 ui/pages/template-edit.html.tmpl       | 16 ++++++++++++++<br>
 3 files changed, 56 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/ui/css/theme-default/template-edit.css b/ui/css/theme-default/template-edit.css<br>
index 7abee7c..ed9f02c 100644<br>
--- a/ui/css/theme-default/template-edit.css<br>
+++ b/ui/css/theme-default/template-edit.css<br>
@@ -95,7 +95,7 @@<br>
<br>
 #edit-template-tabs .template-storage-cell{<br>
     display: inline-block;<br>
-    width: 230px;<br>
+    width: 180px;<br>
 }<br>
<br>
 #edit-template-tabs .template-storage-cell label {<br>
@@ -114,7 +114,11 @@<br>
 }<br>
<br>
 #form-template-storage .template-tab-body .template-storage-name {<br>
-    width: 220px;<br>
+    width: 170px;<br>
+}<br>
+<br>
+#form-template-storage .template-tab-body .template-storage-disk-format {<br>
+    width: 160px;<br>
 }<br>
<br>
 #edit-template-tabs .template-tab-body input[readonly] {<br>
diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js<br>
index 85f76cd..48ae26b 100644<br>
--- a/ui/js/src/kimchi.template_edit_main.js<br>
+++ b/ui/js/src/kimchi.template_edit_main.js<br>
@@ -67,7 +67,7 @@ kimchi.template_edit_main = function() {<br>
                 $(&#39;.template-tab-body&#39;, &#39;#form-template-storage&#39;).append(nodeStorage);<br>
                 var storageOptions = &#39;&#39;;<br>
                 var scsiOptions = &#39;&#39;;<br>
-                $(&#39;select&#39;, &#39;#form-template-storage&#39;).find(&#39;option&#39;).remove();<br>
+                $(&#39;select:first&#39;, &#39;#form-template-storage&#39;).find(&#39;option&#39;).remove();<br>
                 $.each(result, function(index, storageEntities) {<br>
                     if((storageEntities.state === &#39;active&#39;) &amp;&amp; (storageEntities.type != &#39;kimchi-iso&#39;)) {<br>
                         if(storageEntities.type === &#39;iscsi&#39; || storageEntities.type === &#39;scsi&#39;) {<br>
@@ -77,7 +77,7 @@ kimchi.template_edit_main = function() {<br>
                                     var isSlected = tmpPath === thisName ? &#39; selected&#39; : &#39;&#39;;<br>
                                     scsiOptions += &#39;&lt;option&#39; + isSlected + &#39;&gt;&#39; + tmpPath + &#39;&lt;/option&gt;&#39;;<br>
                                 });<br>
-                                $(&#39;select&#39;, &#39;#form-template-storage&#39;).append(scsiOptions);<br>
+                                $(&#39;select:first&#39;, &#39;#form-template-storage&#39;).append(scsiOptions);<br>
                             }, function() {});<br>
                         } else {<br>
                             var isSlected = storageEntities.name === thisName ? &#39; selected&#39; : &#39;&#39;;<br>
@@ -85,8 +85,20 @@ kimchi.template_edit_main = function() {<br>
                         }<br>
                     }<br>
                 });<br>
-                $(&#39;select&#39;, &#39;#form-template-storage&#39;).append(storageOptions);<br>
-                $(&#39;select&#39;, &#39;#form-template-storage&#39;).change(function() {<br>
+                $(&#39;select:first&#39;, &#39;#form-template-storage&#39;).append(storageOptions);<br>
+<br>
+                // Set disk format<br>
+                $(&#39;select:last option&#39;, &#39;#form-template-storage&#39;).each(function() {<br>
+                    if ($(this).text() == storageData.storageDiskFormat) {<br>
+                        $(this).prop(&#39;selected&#39;, true);<br>
+                    }<br>
+                });<br>
+<br>
+                $(&#39;select:last&#39;, &#39;#form-template-storage&#39;).change(function() {<br>
+                    $(&#39;.template-storage-disk-format&#39;).val($(this).val());<br>
+                });<br>
+<br>
+                $(&#39;select:first&#39;, &#39;#form-template-storage&#39;).change(function() {<br>
                     var selectedItem = $(this).parent().parent();<br>
                     var tempStorageNameFull = $(this).val();<br>
                     var tempName = tempStorageNameFull.split(&#39;/&#39;);<br>
@@ -99,9 +111,19 @@ kimchi.template_edit_main = function() {<br>
                             kimchi.getStoragePoolVolume(tempStorageName, tempName[tempName.length-1], function(info) {<br>
                                 volSize = info.capacity / Math.pow(1024, 3);<br>
                                 $(&#39;.template-storage-disk&#39;, selectedItem).attr(&#39;readonly&#39;, true).val(volSize);<br>
+                                $(&#39;select:last option&#39;, selectedItem).each(function() {<br>
+                                    this.selected = (this.text == &#39;raw&#39;);<br>
+                                });<br>
+                                $(&#39;select:last&#39;, selectedItem).prop(&#39;disabled&#39;, true).change();<br>
                             });<br>
                         } else {<br>
                             $(&#39;.template-storage-disk&#39;, selectedItem).attr(&#39;readonly&#39;, false);<br>
+                            if ($(&#39;select:last&#39;, selectedItem).prop(&#39;disabled&#39;) == true) {<br>
+                                $(&#39;select:last option&#39;, selectedItem).each(function() {<br>
+                                    this.selected = (this.text == &#39;qcow2&#39;);<br>
+                                });<br>
+                                $(&#39;select:last&#39;, selectedItem).prop(&#39;disabled&#39;, false).change();<br>
+                            }<br>
                         }<br>
                     });<br>
                 });<br>
@@ -120,7 +142,8 @@ kimchi.template_edit_main = function() {<br>
                             editMode : &#39;hide&#39;,<br>
                             storageName : defaultPool,<br>
                             storageType : defaultType,<br>
-                            storageDisk : diskEntities.size<br>
+                            storageDisk : diskEntities.size,<br>
+                            storageDiskFormat : diskEntities.format ? diskEntities.format : &#39;qcow2&#39;<br>
                         }<br>
<br>
                         if (diskEntities.volume) {<br>
@@ -131,6 +154,10 @@ kimchi.template_edit_main = function() {<br>
                                 nodeData.storageDisk = volSize;<br>
                                 addStorageItem(nodeData);<br>
                                 $(&#39;.template-storage-disk&#39;).attr(&#39;readonly&#39;, true);<br>
+                                $(&#39;select:last option&#39;, &#39;#form-template-storage&#39;).each(function() {<br>
+                                    this.selected = (this.text == &#39;raw&#39;);<br>
+                                });<br>
+                                $(&#39;select:last&#39;, &#39;#form-template-storage&#39;).prop(&#39;disabled&#39;, true).change();<br>
                             });<br>
                         } else {<br>
                             addStorageItem(storageNodeData);<br>
@@ -271,7 +298,8 @@ kimchi.template_edit_main = function() {<br>
                     origDisks[0][&#39;volume&#39;] &amp;&amp; delete origDisks[0][&#39;volume&#39;];<br>
                     origDisks[0].size = Number($(&#39;.template-storage-disk&#39;, tmpItem).val());<br>
                 }<br>
-               data[field] = origDisks;<br>
+                origDisks[0].format = $(&#39;.template-storage-disk-format&#39;, tmpItem).val();<br>
+                data[field] = origDisks;<br>
             }<br>
             else if (field == &#39;graphics&#39;) {<br>
                var type = $(&#39;#form-template-general [name=&quot;&#39; + field + &#39;&quot;]&#39;).val();<br>
diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl<br>
index c7832c9..e64a30f 100644<br>
--- a/ui/pages/template-edit.html.tmpl<br>
+++ b/ui/pages/template-edit.html.tmpl<br>
@@ -104,6 +104,7 @@<br>
                     &lt;span class=&quot;template-storage-cell&quot;&gt;$_(&quot;Storage Pool&quot;)&lt;/span&gt;<br>
                     &lt;span class=&quot;template-storage-cell&quot;&gt;$_(&quot;Type&quot;)&lt;/span&gt;<br>
                     &lt;span class=&quot;template-storage-cell&quot;&gt;$_(&quot;Disk(GB)&quot;)&lt;/span&gt;<br>
+                    &lt;span class=&quot;template-storage-cell&quot;&gt;$_(&quot;Disk Format&quot;)&lt;/span&gt;<br>
                     &lt;button type=&quot;button&quot; id=&quot;template-edit-storage-add-button&quot; class=&quot;action-area&quot;&gt;&lt;/button&gt;<br>
                 &lt;/div&gt;<br>
                 &lt;div class=&quot;template-tab-body&quot;&gt;<br>
@@ -160,6 +161,21 @@<br>
         &lt;span class=&quot;template-storage-cell&quot;&gt;<br>
             &lt;input class=&quot;template-storage-disk&quot; value={storageDisk} type=&quot;text&quot; /&gt;<br>
         &lt;/span&gt;<br>
+        &lt;span class=&quot;template-storage-cell&quot;&gt;<br>
+            &lt;input class=&quot;template-storage-disk-format&quot; value={storageDiskFormat} type=&quot;text&quot; style=&quot;display:none&quot; /&gt;<br>
+            &lt;select&gt;<br>
+               &lt;option&gt;qcow2&lt;/option&gt;<br>
+               &lt;option&gt;raw&lt;/option&gt;<br>
+               &lt;option&gt;bochs&lt;/option&gt;<br>
+               &lt;option&gt;cloop&lt;/option&gt;<br>
+               &lt;option&gt;cow&lt;/option&gt;<br>
+               &lt;option&gt;dmg&lt;/option&gt;<br>
+               &lt;option&gt;qcow&lt;/option&gt;<br>
+               &lt;option&gt;qed&lt;/option&gt;<br>
+               &lt;option&gt;vmdk&lt;/option&gt;<br>
+               &lt;option&gt;vpc&lt;/option&gt;<br>
+            &lt;/select&gt;<br>
+        &lt;/span&gt;<br>
     &lt;/div&gt;<br>
 &lt;/script&gt;<br>
 &lt;script id=&quot;template-interface-tmpl&quot; type=&quot;text/html&quot;&gt;<br>
--<br>
2.1.0<br>
<br>
_______________________________________________<br>
Kimchi-devel mailing list<br>
<a href="mailto:Kimchi-devel@ovirt.org" target="_blank">Kimchi-devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel" target="_blank">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a><br>
</blockquote></div>