There are cases in which the disk file does not exist but we know prior
to it what is the disk type so in this case the disk type should be read
from a parameter.
So only when no value for disk type is passed, we get the disk type according
to source path.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
src/kimchi/model/vmstorages.py | 1 +
src/kimchi/xmlutils/disk.py | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
index 72f6bfd..955a20a 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -120,6 +120,7 @@ class VMStoragesModel(object):
params['format'] = vol_info['format']
params['path'] = vol_info['path']
+ params['disk'] = vol_info['type']
params.update(self._get_available_bus_address(params['bus'], vm_name))
params['path'] = check_remote_disk_path(params['path'])
diff --git a/src/kimchi/xmlutils/disk.py b/src/kimchi/xmlutils/disk.py
index f066dbe..2520929 100644
--- a/src/kimchi/xmlutils/disk.py
+++ b/src/kimchi/xmlutils/disk.py
@@ -46,7 +46,9 @@ def get_disk_xml(params):
</disk>
"""
path = params['path']
- disk_type = _get_disk_type(path) if len(path) > 0 else 'file'
+ disk_type = params.get('disk', None)
+ if disk_type is None:
+ disk_type = _get_disk_type(path) if len(path) > 0 else 'file'
disk = E.disk(type=disk_type, device=params['type'])
disk.append(E.driver(name='qemu', type=params['format']))
--
1.9.3