[Kimchi-devel] [PATCH 1/5] Fix wrong create/update/delete flags for vmstorages

Aline Manera alinefm at linux.vnet.ibm.com
Mon Jun 9 21:01:20 UTC 2014


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

On 06/03/2014 04:20 AM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> For vmstorages now, we always use 'CURRENT' flag,
> this will result in change not take effective when vm's reboot.
> Now use get_vm_config_flag probe the current status of vm,
> and change according to vm status.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/vmstorages.py | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
> index ecc20cf..6511515 100644
> --- a/src/kimchi/model/vmstorages.py
> +++ b/src/kimchi/model/vmstorages.py
> @@ -32,6 +32,7 @@ from kimchi.exception import InvalidOperation, InvalidParameter, NotFoundError
>   from kimchi.exception import OperationFailed
>   from kimchi.model.vms import DOM_STATE_MAP, VMModel
>   from kimchi.model.storagevolumes import StorageVolumeModel
> +from kimchi.model.utils import get_vm_config_flag
>   from kimchi.utils import check_url_path
>   from kimchi.osinfo import lookup
>   from kimchi.vmdisks import get_device_xml, get_vm_disk, get_vm_disk_list
> @@ -176,7 +177,7 @@ class VMStoragesModel(object):
>           try:
>               conn = self.conn.get()
>               dom = conn.lookupByName(vm_name)
> -            dom.attachDeviceFlags(dev_xml, libvirt.VIR_DOMAIN_AFFECT_CURRENT)
> +            dom.attachDeviceFlags(dev_xml, get_vm_config_flag(dom, 'all'))
>           except Exception as e:
>               raise OperationFailed("KCHVMSTOR0008E", {'error': e.message})
>           return params['dev']
> @@ -224,7 +225,7 @@ class VMStorageModel(object):
>               dom = conn.lookupByName(vm_name)
>               disk = get_device_xml(dom, dev_name)
>               dom.detachDeviceFlags(etree.tostring(disk),
> -                                  libvirt.VIR_DOMAIN_AFFECT_CURRENT)
> +                                  get_vm_config_flag(dom, 'all'))
>           except Exception as e:
>               raise OperationFailed("KCHVMSTOR0010E", {'error': e.message})
>
> @@ -239,7 +240,7 @@ class VMStorageModel(object):
>           xml = _get_storage_xml(dev_info)
>
>           try:
> -            dom.updateDeviceFlags(xml, libvirt.VIR_DOMAIN_AFFECT_CURRENT)
> +            dom.updateDeviceFlags(xml, get_vm_config_flag(dom, 'all'))
>           except Exception as e:
>               raise OperationFailed("KCHVMSTOR0009E", {'error': e.message})
>           return dev_name




More information about the Kimchi-devel mailing list