[Kimchi-devel] [PATCH 1/2] Guest storage: Fix attaching type judgement
Aline Manera
alinefm at linux.vnet.ibm.com
Mon Sep 1 17:34:28 UTC 2014
As this patch set is ready, I will apply just this one and send a V2 of
2/2 with comments applied.
On 08/26/2014 06:50 AM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> When we only supportted cdrom attachment, we check if a cdrom is
> a valid block device by reading /proc info.
> Now we added disk attachment support, when a file is neither regular file
> nor url, we need to see if it is a block device according to its stats.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
> src/kimchi/model/vmstorages.py | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
> index 91c2ab8..f11bcec 100644
> --- a/src/kimchi/model/vmstorages.py
> +++ b/src/kimchi/model/vmstorages.py
> @@ -20,6 +20,7 @@
> import os
> import re
> import socket
> +import stat
> import string
> import urlparse
>
> @@ -90,16 +91,8 @@ def _check_path(path):
> if os.path.isfile(path):
> src_type = 'file'
> else:/
> - # Check if path is a valid cdrom drive
> - with open('/proc/sys/dev/cdrom/info') as cdinfo:
> - content = cdinfo.read()
> -
> - cds = re.findall("drive name:\t\t(.*)", content)
> - if not cds:
> - raise InvalidParameter("KCHVMSTOR0003E", {'value': path})
> -
> - drives = [os.path.join('/dev', p) for p in cds[0].split('\t')]
> - if path not in drives:
> + r_path = os.path.realpath(path)
> + if not stat.S_ISBLK(os.stat(r_path).st_mode):
> raise InvalidParameter("KCHVMSTOR0003E", {'value': path})
>
> src_type = 'block'
More information about the Kimchi-devel
mailing list