
All storage volumes belonging to a logical storage pool are reported by libvirt as 'raw', even when they are ISO images. When creating a template, only the volumes listed as 'iso' are displayed, so it's currently not possible to create a template using a volume from a logical storage pool. Instead of relying only on the volume format reported by libvirt, open and inspect the storage volumes which belong to a logical storage pool in order to find out whether they're ISO images. Fix issue #564 (List volumes other than "format=iso" when creating a template). Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com> --- src/kimchi/model/storagevolumes.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/kimchi/model/storagevolumes.py b/src/kimchi/model/storagevolumes.py index 0480496..f02efca 100644 --- a/src/kimchi/model/storagevolumes.py +++ b/src/kimchi/model/storagevolumes.py @@ -294,6 +294,7 @@ class StorageVolumeModel(object): self.objstore = kargs['objstore'] self.task = TaskModel(**kargs) self.storagevolumes = StorageVolumesModel(**kargs) + self.storagepool = StoragePoolModel(**kargs) @staticmethod def get_storagevolume(poolname, name, conn): @@ -321,6 +322,21 @@ class StorageVolumeModel(object): # infomation. When there is no format information, we assume # it's 'raw'. fmt = 'raw' + + iso_img = None + + # 'raw' volumes from 'logical' pools may actually be 'iso'; + # libvirt always reports them as 'raw' + pool_info = self.storagepool.lookup(pool) + if pool_info['type'] == 'logical' and fmt == 'raw': + try: + iso_img = IsoImage(path) + except IsoFormatError: + # not 'iso' afterall + pass + else: + fmt = 'iso' + ref_cnt = get_disk_ref_cnt(self.objstore, self.conn, path) res = dict(type=VOLUME_TYPE_MAP[info[0]], capacity=info[1], @@ -333,7 +349,8 @@ class StorageVolumeModel(object): path = os.path.join(os.path.dirname(path), os.readlink(path)) os_distro = os_version = 'unknown' try: - iso_img = IsoImage(path) + if iso_img is None: + iso_img = IsoImage(path) os_distro, os_version = iso_img.probe() bootable = True except IsoFormatError: -- 2.1.0