[Kimchi-devel] [PATCH 1/4] Read io and cache option from disks

Ramon Medeiros posted 4 patches 5 years, 3 months ago
[Kimchi-devel] [PATCH 1/4] Read io and cache option from disks
Posted by Ramon Medeiros 5 years, 3 months ago
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com>
---
 xmlutils/disk.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/xmlutils/disk.py b/xmlutils/disk.py
index 02d6811..8edb991 100644
--- a/xmlutils/disk.py
+++ b/xmlutils/disk.py
@@ -147,12 +147,21 @@ def get_vm_disk_info(dom, dev_name):
     except:
         path = ""
 
-    return {'dev': dev_name,
+    base = {'dev': dev_name,
             'path': path,
             'type': disk.attrib['device'],
             'format': disk.driver.attrib['type'],
             'bus': disk.target.attrib['bus']}
 
+    # optional parameters
+    if disk.driver.attrib.get('io') != None:
+        base.update({'io': disk.driver.attrib['io']})
+
+    if disk.driver.attrib.get('cache') != None:
+        base.update({'cache': disk.driver.attrib['cache']})
+
+    return base
+
 
 def get_vm_disks(dom):
     xml = dom.XMLDesc(0)
-- 
2.9.3

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
Re: [Kimchi-devel] [PATCH 1/4] Read io and cache option from disks
Posted by Aline Manera 5 years, 3 months ago

On 03/10/2017 08:19 PM, Ramon Medeiros wrote:
> Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com>
> ---
>   xmlutils/disk.py | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/xmlutils/disk.py b/xmlutils/disk.py
> index 02d6811..8edb991 100644
> --- a/xmlutils/disk.py
> +++ b/xmlutils/disk.py
> @@ -147,12 +147,21 @@ def get_vm_disk_info(dom, dev_name):
>       except:
>           path = ""
>
> -    return {'dev': dev_name,
> +    base = {'dev': dev_name,
>               'path': path,
>               'type': disk.attrib['device'],
>               'format': disk.driver.attrib['type'],
>               'bus': disk.target.attrib['bus']}

> +    # optional parameters
> +    if disk.driver.attrib.get('io') != None:
> +        base.update({'io': disk.driver.attrib['io']})
> +
> +    if disk.driver.attrib.get('cache') != None:
> +        base.update({'cache': disk.driver.attrib['cache']})
> +

You should return always the same group of data. Fallback io and cache 
to None or empty string in case it is not set for a given XML.

> +    return base
> +
>
>   def get_vm_disks(dom):
>       xml = dom.XMLDesc(0)

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel