[Kimchi-devel] [PATCHv2 2/2] disk attachment: avoid checking cdrom ref_cnt

Sheldon shaohef at linux.vnet.ibm.com
Thu May 15 14:32:45 UTC 2014


On 05/13/2014 05:51 PM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> CDROM can be shared by multiple vms, so we shall not check its ref_cnt.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/vmstorages.py | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
> index cf9748f..cff3108 100644
> --- a/src/kimchi/model/vmstorages.py
> +++ b/src/kimchi/model/vmstorages.py
> @@ -160,10 +160,11 @@ class VMStoragesModel(object):
>                   raise InvalidParameter("KCHVMSTOR0012E")
>               except Exception as e:
>                   raise InvalidParameter("KCHVMSTOR0015E", {'error': e})
> -            if vol_info['ref_cnt'] != 0:
> +            if vol_info['ref_cnt'] != 0 and params['type'] == 'disk':
now you just support disk and CDROM, will support other type? what about 
other type?
params['type'] != 'CDROM'
>                   raise InvalidParameter("KCHVMSTOR0016E")
>               params['format'] = vol_info['format']
>               params['path'] = vol_info['path']
> +
>           params['src_type'] = _check_path(params['path'])
>           params.setdefault(
>               'bus', _get_device_bus(params['type'], dom))
> @@ -178,12 +179,15 @@ class VMStoragesModel(object):
>               conn = self.conn.get()
>               dom = conn.lookupByName(vm_name)
>               dom.attachDeviceFlags(dev_xml, libvirt.VIR_DOMAIN_AFFECT_CURRENT)
> +
> +        except Exception as e:
> +            raise OperationFailed("KCHVMSTOR0008E", {'error': e.message})
> +
> +        if params.get('vol'):
>               with self.objstore as session:
>                   ref_cnt = session.store('storagevolume', vol_id,
>                                           {'ref_cnt': vol_info['ref_cnt'] + 1})
>
> -        except Exception as e:
> -            raise OperationFailed("KCHVMSTOR0008E", {'error': e.message})
>           return params['dev']
>
>       def _get_storage_device_name(self, vm_name):


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list