[Kimchi-devel] [PATCH 4/6] Ensure the guest volume exists to remove it

Daniel Henrique Barboza danielhb at linux.vnet.ibm.com
Thu Nov 13 15:55:02 UTC 2014


Reviewed-by: Daniel Barboza <danielhb at linux.vnet.ibm.com>

A comment about the commit message:

"virStorageVol.storagePoolLookupByVolume() will raise an exception which 
will point to user a false negative guest deletion "

Did you mean " virStorageVol.storagePoolLookupByVolume() will raise an 
exception which will point *the* user *to* a false negative guest 
deletion " or something like that?

On 11/11/2014 06:46 PM, Aline Manera wrote:
> In some cases, the guest volume may not be in a pool and
> virStorageVol.storagePoolLookupByVolume() will raise an exception which
> will point to user a false negative guest deletion - as an error is
> shown to him but the guest was really deleted.
> So prevent it by using a try/except block around
> virStorageVol.storagePoolLookupByVolume()
>
> Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/vms.py | 17 +++++++++++------
>   1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
> index d13732b..8c10618 100644
> --- a/src/kimchi/model/vms.py
> +++ b/src/kimchi/model/vms.py
> @@ -761,12 +761,17 @@ class VMModel(object):
>                                     {'name': name, 'err': e.get_error_message()})
>
>           for path in paths:
> -            vol = conn.storageVolLookupByPath(path)
> -            pool = vol.storagePoolLookupByVolume()
> -            xml = pool.XMLDesc(0)
> -            pool_type = xpath_get_text(xml, "/pool/@type")[0]
> -            if pool_type not in READONLY_POOL_TYPE:
> -                vol.delete(0)
> +            try:
> +                vol = conn.storageVolLookupByPath(path)
> +                pool = vol.storagePoolLookupByVolume()
> +                xml = pool.XMLDesc(0)
> +                pool_type = xpath_get_text(xml, "/pool/@type")[0]
> +                if pool_type not in READONLY_POOL_TYPE:
> +                    vol.delete(0)
> +            except Exception as e:
> +                kimchi_log.error('Unable to get storage volume by path: %s' %
> +                                 e.message)
> +
>           try:
>               with self.objstore as session:
>                   session.delete('vm', dom.UUIDString(), ignore_missing=True)




More information about the Kimchi-devel mailing list