[Kimchi-devel] [PATCH] ISSUE#466: Filter valid format only on src_type of 'file'

lvroyce0210 at gmail.com lvroyce0210 at gmail.com
Thu Oct 30 12:08:35 UTC 2014


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

When src_type is block and volume is iscsi,
filter will prevent volume to be attached due to its format is 'unknown'.
Change the filter to only apply to 'file' src_type,
so that iscsi volume will not be blocked.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/model/vmstorages.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
index 055aa50..a48d9fa 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -153,17 +153,19 @@ class VMStoragesModel(object):
             if vol_info['ref_cnt'] != 0:
                 raise InvalidParameter("KCHVMSTOR0016E")
 
-            supported_format = {
+            params['path'] = vol_info['path']
+            params['src_type'] = _check_path(params['path'])
+            valid_format = {
                 "disk": ["raw", "bochs", "qcow", "qcow2", "qed", "vmdk"],
                 "cdrom": "iso"}
-            if vol_info['format'] in supported_format[params['type']]:
-                if params['type'] == 'disk':
+            if params['src_type'] == 'file':
+                if params['type'] == 'disk' and
+                        vol_info['format'] in valid_format[params['type']]:
                     params['format'] = vol_info['format']
-            else:
-                raise InvalidParameter("KCHVMSTOR0018E",
-                                       {"format": vol_info['format'],
-                                        "type": params['type']})
-            params['path'] = vol_info['path']
+                else:
+                    raise InvalidParameter("KCHVMSTOR0018E",
+                                           {"format": vol_info['format'],
+                                            "type": params['type']})
         params['src_type'] = _check_path(params['path'])
         if (params['bus'] not in HOTPLUG_TYPE
                 and DOM_STATE_MAP[dom.info()[0]] != 'shutoff'):
-- 
1.8.3.2




More information about the Kimchi-devel mailing list