test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] framework: add virt_type option for virt type(kvm/libvirt) selection
@ 2018-01-09  6:00 Herbert Guan
  2018-01-09  6:54 ` Liu, Yong
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Herbert Guan @ 2018-01-09  6:00 UTC (permalink / raw)
  To: dts; +Cc: Herbert Guan

Allow users to use test config file to specify virt type(kvm, libvirt, etc) by
'virt_type' option.  If not specified in config file, the default virt_type
is kvm (qemu_kvm).


Signed-off-by: Herbert Guan <herbert.guan@arm.com>
---
 framework/virt_base.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/framework/virt_base.py b/framework/virt_base.py
index 1838ca1..cd6dc0c 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -98,13 +98,22 @@ class VirtBase(object):
         """
         Get the virtual type, such as KVM, XEN or LIBVIRT.
         """
-        NotImplemented
+        conf = VirtConf(CONFIG_ROOT_PATH + os.sep + self.suite + '.cfg')
+        conf.load_virt_config(self.vm_name)
+        local_conf = conf.get_virt_config()
+        for param in local_conf:
+            if 'virt_type' in param.keys():
+                return param['virt_type'][0]['virt_type']
+        # if virt_type is not existing in config file, return 'KVM' by default
+        return 'KVM'
+
 
     def has_virtual_ability(self):
         """
         Check if the host have the ability of virtualization.
         """
-        NotImplemented
+        # Return True for non-derived virt_base object.
+        return True
 
     def enable_virtual_ability(self):
         """
@@ -140,6 +149,9 @@ class VirtBase(object):
             if 'cpu' in param.keys():
                 self.__save_local_config('cpu', param['cpu'])
                 continue
+            if 'virt_type' in param.keys():
+                # param 'virt_type' is for virt_base only
+                continue
             # save local configurations
             for key in param.keys():
                 self.__save_local_config(key, param[key])
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dts] [PATCH] framework: add virt_type option for virt type(kvm/libvirt) selection
  2018-01-09  6:00 [dts] [PATCH] framework: add virt_type option for virt type(kvm/libvirt) selection Herbert Guan
@ 2018-01-09  6:54 ` Liu, Yong
  2018-01-09  7:11   ` Herbert Guan
  2018-01-25  9:17 ` [dts] [PATCH v2] " Herbert Guan
  2018-01-30  5:28 ` [dts] [PATCH v3] " Herbert Guan
  2 siblings, 1 reply; 7+ messages in thread
From: Liu, Yong @ 2018-01-09  6:54 UTC (permalink / raw)
  To: Herbert Guan, dts

Hi Herbert,
I think argument "virt_type" is not needed for suite level configuration. There will be one possible scenario like libvirt and qemu VMs enabled in one suite. 
Please see my inline comment. 

Thanks,
Marvin

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Herbert Guan
> Sent: Tuesday, January 09, 2018 2:01 PM
> To: dts@dpdk.org
> Cc: Herbert Guan <herbert.guan@arm.com>
> Subject: [dts] [PATCH] framework: add virt_type option for virt
> type(kvm/libvirt) selection
> 
> Allow users to use test config file to specify virt type(kvm, libvirt, etc)
> by
> 'virt_type' option.  If not specified in config file, the default
> virt_type
> is kvm (qemu_kvm).
> 
> 
> Signed-off-by: Herbert Guan <herbert.guan@arm.com>
> ---
>  framework/virt_base.py | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/framework/virt_base.py b/framework/virt_base.py
> index 1838ca1..cd6dc0c 100644
> --- a/framework/virt_base.py
> +++ b/framework/virt_base.py
> @@ -98,13 +98,22 @@ class VirtBase(object):
>          """
>          Get the virtual type, such as KVM, XEN or LIBVIRT.
>          """
> -        NotImplemented
> +        conf = VirtConf(CONFIG_ROOT_PATH + os.sep + self.suite + '.cfg')
> +        conf.load_virt_config(self.vm_name)
> +        local_conf = conf.get_virt_config()
> +        for param in local_conf:
> +            if 'virt_type' in param.keys():
> +                return param['virt_type'][0]['virt_type']
> +        # if virt_type is not existing in config file, return 'KVM' by
> default
> +        return 'KVM'
> +

Virt_type has been specified when instantiating virtual machine object, so can initialize virt_type variable in init function of VM object.

> 
>      def has_virtual_ability(self):
>          """
>          Check if the host have the ability of virtualization.
>          """
> -        NotImplemented
> +        # Return True for non-derived virt_base object.
> +        return True
> 
>      def enable_virtual_ability(self):
>          """
> @@ -140,6 +149,9 @@ class VirtBase(object):
>              if 'cpu' in param.keys():
>                  self.__save_local_config('cpu', param['cpu'])
>                  continue
> +            if 'virt_type' in param.keys():
> +                # param 'virt_type' is for virt_base only
> +                continue
>              # save local configurations
>              for key in param.keys():
>                  self.__save_local_config(key, param[key])
> --
> 1.8.3.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dts] [PATCH] framework: add virt_type option for virt type(kvm/libvirt) selection
  2018-01-09  6:54 ` Liu, Yong
@ 2018-01-09  7:11   ` Herbert Guan
  0 siblings, 0 replies; 7+ messages in thread
From: Herbert Guan @ 2018-01-09  7:11 UTC (permalink / raw)
  To: Liu, Yong, dts

Marvin,

The "virt_type" is actually in the vm level configuration, means one VM will be qemu and the other one can be libvirt.  The example of test suite configure file will be:

[vm0]
virt_type =
    virt_type=LIBVIRT;
os =
    loader=/usr/share/AAVMF/AAVMF_CODE.fd,nvram=/var/lib/libvirt/qemu/nvram/c2400-vm-04_VARS.fd;

[vm1]
virt_type =
    virt_type=KVM;

Before we create a VM, we need to decide whether it'll be a libvirt or qemu.  So a virt_base object will be created and read VM type from config file.
In test script, a patch like below will be applied:
             # set up VM0 ENV
-            self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_macfilter')
-            self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop)
-            self.vm0.set_vm_device(driver=self.vf_assign_method, **vf1_prop)
+            self.vm0_name = "vm0"
+            vm_base = VirtBase(self.dut, self.vm0_name, self.suite_name)
+            if vm_base.virt_type == 'KVM':
+                # setup KVM VM0
+                self.vm0 = QEMUKvm(self.dut, self.vm0_name, self.suite_name)
+                self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop)
+                self.vm0.set_vm_device(driver=self.vf_assign_method, **vf1_prop)
+            elif vm_base.virt_type == 'LIBVIRT':
+                # setup libvirt VM0
+                self.vm0 = LibvirtKvm(self.dut, self.vm0_name, self.suite_name)
+                self.vm0.add_vm_device(**vf0_prop)
+                self.vm0.add_vm_device(**vf1_prop)
+            else:
+                raise Exception("Virt type %s is not supported!"
+                    % vm_base.virt_type)


Best reagrds,
Herbert

> -----Original Message-----
> From: Liu, Yong [mailto:yong.liu@intel.com]
> Sent: Tuesday, January 9, 2018 14:55
> To: Herbert Guan <Herbert.Guan@arm.com>; dts@dpdk.org
> Subject: RE: [dts] [PATCH] framework: add virt_type option for virt
> type(kvm/libvirt) selection
>
> Hi Herbert,
> I think argument "virt_type" is not needed for suite level configuration.
> There will be one possible scenario like libvirt and qemu VMs enabled in one
> suite.
> Please see my inline comment.
>
> Thanks,
> Marvin
>
> > -----Original Message-----
> > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Herbert Guan
> > Sent: Tuesday, January 09, 2018 2:01 PM
> > To: dts@dpdk.org
> > Cc: Herbert Guan <herbert.guan@arm.com>
> > Subject: [dts] [PATCH] framework: add virt_type option for virt
> > type(kvm/libvirt) selection
> >
> > Allow users to use test config file to specify virt type(kvm, libvirt,
> > etc) by 'virt_type' option.  If not specified in config file, the
> > default virt_type is kvm (qemu_kvm).
> >
> >
> > Signed-off-by: Herbert Guan <herbert.guan@arm.com>
> > ---
> >  framework/virt_base.py | 16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/framework/virt_base.py b/framework/virt_base.py index
> > 1838ca1..cd6dc0c 100644
> > --- a/framework/virt_base.py
> > +++ b/framework/virt_base.py
> > @@ -98,13 +98,22 @@ class VirtBase(object):
> >          """
> >          Get the virtual type, such as KVM, XEN or LIBVIRT.
> >          """
> > -        NotImplemented
> > +        conf = VirtConf(CONFIG_ROOT_PATH + os.sep + self.suite + '.cfg')
> > +        conf.load_virt_config(self.vm_name)
> > +        local_conf = conf.get_virt_config()
> > +        for param in local_conf:
> > +            if 'virt_type' in param.keys():
> > +                return param['virt_type'][0]['virt_type']
> > +        # if virt_type is not existing in config file, return 'KVM'
> > + by
> > default
> > +        return 'KVM'
> > +
>
> Virt_type has been specified when instantiating virtual machine object, so
> can initialize virt_type variable in init function of VM object.
>

Please refer to above patch example.  Before we create a VM, we need to decide whether it'll be a libvirt or qemu.  So a virt_base object will be created and read VM type from config file.

> >
> >      def has_virtual_ability(self):
> >          """
> >          Check if the host have the ability of virtualization.
> >          """
> > -        NotImplemented
> > +        # Return True for non-derived virt_base object.
> > +        return True
> >
> >      def enable_virtual_ability(self):
> >          """
> > @@ -140,6 +149,9 @@ class VirtBase(object):
> >              if 'cpu' in param.keys():
> >                  self.__save_local_config('cpu', param['cpu'])
> >                  continue
> > +            if 'virt_type' in param.keys():
> > +                # param 'virt_type' is for virt_base only
> > +                continue
> >              # save local configurations
> >              for key in param.keys():
> >                  self.__save_local_config(key, param[key])
> > --
> > 1.8.3.1

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dts] [PATCH v2] framework: add virt_type option for virt type(kvm/libvirt) selection
  2018-01-09  6:00 [dts] [PATCH] framework: add virt_type option for virt type(kvm/libvirt) selection Herbert Guan
  2018-01-09  6:54 ` Liu, Yong
@ 2018-01-25  9:17 ` Herbert Guan
  2018-01-29 16:37   ` Liu, Yong
  2018-01-30  5:28 ` [dts] [PATCH v3] " Herbert Guan
  2 siblings, 1 reply; 7+ messages in thread
From: Herbert Guan @ 2018-01-25  9:17 UTC (permalink / raw)
  To: dts; +Cc: Herbert Guan

Allow users to use test config file to specify virt type (kvm,
libvirt, etc) by 'virt_type' option.  If not specified in config
file, the default virt_type is kvm (qemu_kvm).
qemu_libvirt is modified to make the api interface compatible with
qemu_kvm with below 2 changes:
1) added function set_vm_device().
2) support guestpci auto-generate when adding a PCI device

Test suite developers will only need to use 'CreateVirt' instead of
'QEMUKvm' for VM creation and then this test suite will be able to
support both kvm and libvirt.

Signed-off-by: Herbert Guan <herbert.guan@arm.com>
---
 framework/qemu_libvirt.py | 33 +++++++++++++++------------
 framework/virt_base.py    |  7 +++---
 framework/virt_common.py  | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+), 18 deletions(-)
 mode change 100644 => 100755 framework/qemu_libvirt.py
 mode change 100644 => 100755 framework/virt_base.py
 create mode 100755 framework/virt_common.py

diff --git a/framework/qemu_libvirt.py b/framework/qemu_libvirt.py
old mode 100644
new mode 100755
index 59a0c9e..66fc54b
--- a/framework/qemu_libvirt.py
+++ b/framework/qemu_libvirt.py
@@ -229,7 +229,6 @@ class LibvirtKvm(VirtBase):
         ET.SubElement(os, 'boot', {'dev': 'hd'})
         features = ET.SubElement(self.domain, 'features')
         ET.SubElement(features, 'acpi')
-        ET.SubElement(features, 'gic', {'version': '3'})
 
         ET.SubElement(self.domain, 'cpu',
             {'mode': 'host-passthrough', 'check': 'none'})
@@ -408,6 +407,9 @@ class LibvirtKvm(VirtBase):
             return (bus, slot, func, dom)
         return None
 
+    def set_vm_device(self, driver='pci-assign', **opts):
+        self.add_vm_device(**opts)
+
     def add_vm_device(self, **options):
         """
         options:
@@ -437,20 +439,23 @@ class LibvirtKvm(VirtBase):
                       'slot': '0x%s' % slot,
                       'function': '0x%s' % func})
         if 'guestpci' in options.keys():
-            pci = self.__parse_pci(options['guestpci'])
-            if pci is None:
-                return False
-            bus, slot, func, dom = pci
-            ET.SubElement(hostdevice, 'address', {
-                  'type': 'pci', 'domain': '0x%s' % dom, 'bus': '0x%s' % bus,
-                  'slot': '0x%s' % slot, 'function': '0x%s' % func})
-            # save host and guest pci address mapping
-            pci_map = {}
-            pci_map['hostpci'] = pci_addr
-            pci_map['guestpci'] = options['guestpci']
-            self.pci_maps.append(pci_map)
+            guest_pci_addr = options['guestpci']
         else:
-            print utils.RED('Host device pass-through need guestpci option!!!')
+            guest_pci_addr = '0000:%s:00.0' % hex(self.pciindex)[2:]
+            self.pciindex += 1
+        pci = self.__parse_pci(guest_pci_addr)
+        if pci is None:
+            print utils.RED('Invalid guestpci for host device pass-through!!!')
+            return False
+        bus, slot, func, dom = pci
+        ET.SubElement(hostdevice, 'address', {
+              'type': 'pci', 'domain': '0x%s' % dom, 'bus': '0x%s' % bus,
+              'slot': '0x%s' % slot, 'function': '0x%s' % func})
+        # save host and guest pci address mapping
+        pci_map = {}
+        pci_map['hostpci'] = pci_addr
+        pci_map['guestpci'] = guest_pci_addr
+        self.pci_maps.append(pci_map)
 
     def add_vm_net(self, **options):
         """
diff --git a/framework/virt_base.py b/framework/virt_base.py
old mode 100644
new mode 100755
index e93cbab..b26a25a
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -144,10 +144,9 @@ class VirtBase(object):
 
         # replace global configurations with local configurations
         for param in self.local_conf:
-            if 'mem' in param.keys():
-                self.__save_local_config('mem', param['mem'])
-            if 'cpu' in param.keys():
-                self.__save_local_config('cpu', param['cpu'])
+            if 'virt_type' in param.keys():
+                # param 'virt_type' is for virt_base only
+                continue
             # save local configurations
             for key in param.keys():
                 self.__save_local_config(key, param[key])
diff --git a/framework/virt_common.py b/framework/virt_common.py
new file mode 100755
index 0000000..ce4c9a5
--- /dev/null
+++ b/framework/virt_common.py
@@ -0,0 +1,58 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#   * Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#   * Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#   * Neither the name of Intel Corporation nor the names of its
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import os
+import exception
+
+from config import VirtConf
+from settings import CONFIG_ROOT_PATH
+
+from qemu_kvm import QEMUKvm
+from qemu_libvirt import LibvirtKvm
+
+def CreateVirt(dut, vm_name, suite_name):
+    conf = VirtConf(CONFIG_ROOT_PATH + os.sep + suite_name + '.cfg')
+    conf.load_virt_config(vm_name)
+    local_conf = conf.get_virt_config()
+    # Default virt_type is 'KVM'
+    virt_type = 'KVM'
+    for param in local_conf:
+        if 'virt_type' in param.keys():
+            virt_type = param['virt_type'][0]['virt_type']
+
+    if virt_type == 'KVM':
+        return QEMUKvm(dut, vm_name, suite_name)
+    elif virt_type == 'LIBVIRT':
+        return LibvirtKvm(dut, vm_name, suite_name)
+    else:
+        raise Exception("Virt type %s is not supported!" 
+            % virt_type)
+
+
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dts] [PATCH v2] framework: add virt_type option for virt type(kvm/libvirt) selection
  2018-01-25  9:17 ` [dts] [PATCH v2] " Herbert Guan
@ 2018-01-29 16:37   ` Liu, Yong
  0 siblings, 0 replies; 7+ messages in thread
From: Liu, Yong @ 2018-01-29 16:37 UTC (permalink / raw)
  To: Herbert Guan, dts

Herbert,

I  think there i’s no need to add verb in the function name. This 
function just return the object represent for virtual machine.
How about use abbr. “"VM"”? It i’s short and widely-known by everyone.

Thanks,
Marvin

On 01/25/2018 05:17 PM, Herbert Guan wrote:
> +def CreateVirt(dut, vm_name, suite_name):
> +    conf = VirtConf(CONFIG_ROOT_PATH + os.sep + suite_name + '.cfg')
> +    conf.load_virt_config(vm_name)
> +    local_conf = conf.get_virt_config()
> +    # Default virt_type is 'KVM'

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dts] [PATCH v3] framework: add virt_type option for virt type(kvm/libvirt) selection
  2018-01-09  6:00 [dts] [PATCH] framework: add virt_type option for virt type(kvm/libvirt) selection Herbert Guan
  2018-01-09  6:54 ` Liu, Yong
  2018-01-25  9:17 ` [dts] [PATCH v2] " Herbert Guan
@ 2018-01-30  5:28 ` Herbert Guan
  2018-01-30 14:33   ` Liu, Yong
  2 siblings, 1 reply; 7+ messages in thread
From: Herbert Guan @ 2018-01-30  5:28 UTC (permalink / raw)
  To: dts; +Cc: Herbert Guan

Allow users to use test config file to specify virt type (kvm,
libvirt, etc) by 'virt_type' option.  If not specified in config
file, the default virt_type is kvm (qemu_kvm).
qemu_libvirt is modified to make the api interface compatible with
qemu_kvm with below 2 changes:
1) added function set_vm_device().
2) support guestpci auto-generate when adding a PCI device

Test suite developers will only need to use 'VM' instead of
'QEMUKvm' for VM creation and then this test suite will be able to
support both kvm and libvirt.


Signed-off-by: Herbert Guan <herbert.guan@arm.com>
---
 framework/qemu_libvirt.py | 33 +++++++++++++++------------
 framework/virt_base.py    |  7 +++---
 framework/virt_common.py  | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+), 18 deletions(-)
 create mode 100644 framework/virt_common.py

diff --git a/framework/qemu_libvirt.py b/framework/qemu_libvirt.py
index 59a0c9e..66fc54b 100644
--- a/framework/qemu_libvirt.py
+++ b/framework/qemu_libvirt.py
@@ -229,7 +229,6 @@ class LibvirtKvm(VirtBase):
         ET.SubElement(os, 'boot', {'dev': 'hd'})
         features = ET.SubElement(self.domain, 'features')
         ET.SubElement(features, 'acpi')
-        ET.SubElement(features, 'gic', {'version': '3'})
 
         ET.SubElement(self.domain, 'cpu',
             {'mode': 'host-passthrough', 'check': 'none'})
@@ -408,6 +407,9 @@ class LibvirtKvm(VirtBase):
             return (bus, slot, func, dom)
         return None
 
+    def set_vm_device(self, driver='pci-assign', **opts):
+        self.add_vm_device(**opts)
+
     def add_vm_device(self, **options):
         """
         options:
@@ -437,20 +439,23 @@ class LibvirtKvm(VirtBase):
                       'slot': '0x%s' % slot,
                       'function': '0x%s' % func})
         if 'guestpci' in options.keys():
-            pci = self.__parse_pci(options['guestpci'])
-            if pci is None:
-                return False
-            bus, slot, func, dom = pci
-            ET.SubElement(hostdevice, 'address', {
-                  'type': 'pci', 'domain': '0x%s' % dom, 'bus': '0x%s' % bus,
-                  'slot': '0x%s' % slot, 'function': '0x%s' % func})
-            # save host and guest pci address mapping
-            pci_map = {}
-            pci_map['hostpci'] = pci_addr
-            pci_map['guestpci'] = options['guestpci']
-            self.pci_maps.append(pci_map)
+            guest_pci_addr = options['guestpci']
         else:
-            print utils.RED('Host device pass-through need guestpci option!!!')
+            guest_pci_addr = '0000:%s:00.0' % hex(self.pciindex)[2:]
+            self.pciindex += 1
+        pci = self.__parse_pci(guest_pci_addr)
+        if pci is None:
+            print utils.RED('Invalid guestpci for host device pass-through!!!')
+            return False
+        bus, slot, func, dom = pci
+        ET.SubElement(hostdevice, 'address', {
+              'type': 'pci', 'domain': '0x%s' % dom, 'bus': '0x%s' % bus,
+              'slot': '0x%s' % slot, 'function': '0x%s' % func})
+        # save host and guest pci address mapping
+        pci_map = {}
+        pci_map['hostpci'] = pci_addr
+        pci_map['guestpci'] = guest_pci_addr
+        self.pci_maps.append(pci_map)
 
     def add_vm_net(self, **options):
         """
diff --git a/framework/virt_base.py b/framework/virt_base.py
index e93cbab..b26a25a 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -144,10 +144,9 @@ class VirtBase(object):
 
         # replace global configurations with local configurations
         for param in self.local_conf:
-            if 'mem' in param.keys():
-                self.__save_local_config('mem', param['mem'])
-            if 'cpu' in param.keys():
-                self.__save_local_config('cpu', param['cpu'])
+            if 'virt_type' in param.keys():
+                # param 'virt_type' is for virt_base only
+                continue
             # save local configurations
             for key in param.keys():
                 self.__save_local_config(key, param[key])
diff --git a/framework/virt_common.py b/framework/virt_common.py
new file mode 100644
index 0000000..c114bf5
--- /dev/null
+++ b/framework/virt_common.py
@@ -0,0 +1,58 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#   * Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#   * Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#   * Neither the name of Intel Corporation nor the names of its
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import os
+import exception
+
+from config import VirtConf
+from settings import CONFIG_ROOT_PATH
+
+from qemu_kvm import QEMUKvm
+from qemu_libvirt import LibvirtKvm
+
+def VM(dut, vm_name, suite_name):
+    conf = VirtConf(CONFIG_ROOT_PATH + os.sep + suite_name + '.cfg')
+    conf.load_virt_config(vm_name)
+    local_conf = conf.get_virt_config()
+    # Default virt_type is 'KVM'
+    virt_type = 'KVM'
+    for param in local_conf:
+        if 'virt_type' in param.keys():
+            virt_type = param['virt_type'][0]['virt_type']
+
+    if virt_type == 'KVM':
+        return QEMUKvm(dut, vm_name, suite_name)
+    elif virt_type == 'LIBVIRT':
+        return LibvirtKvm(dut, vm_name, suite_name)
+    else:
+        raise Exception("Virt type %s is not supported!" 
+            % virt_type)
+
+
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dts] [PATCH v3] framework: add virt_type option for virt type(kvm/libvirt) selection
  2018-01-30  5:28 ` [dts] [PATCH v3] " Herbert Guan
@ 2018-01-30 14:33   ` Liu, Yong
  0 siblings, 0 replies; 7+ messages in thread
From: Liu, Yong @ 2018-01-30 14:33 UTC (permalink / raw)
  To: Herbert Guan, dts

Thanks, Herbert. Applied.

On 01/30/2018 01:28 PM, Herbert Guan wrote:
> Allow users to use test config file to specify virt type (kvm,
> libvirt, etc) by 'virt_type' option.  If not specified in config
> file, the default virt_type is kvm (qemu_kvm).
> qemu_libvirt is modified to make the api interface compatible with
> qemu_kvm with below 2 changes:
> 1) added function set_vm_device().
> 2) support guestpci auto-generate when adding a PCI device
>
> Test suite developers will only need to use 'VM' instead of
> 'QEMUKvm' for VM creation and then this test suite will be able to
> support both kvm and libvirt.
>
>
> Signed-off-by: Herbert Guan<herbert.guan@arm.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-01-30  6:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-09  6:00 [dts] [PATCH] framework: add virt_type option for virt type(kvm/libvirt) selection Herbert Guan
2018-01-09  6:54 ` Liu, Yong
2018-01-09  7:11   ` Herbert Guan
2018-01-25  9:17 ` [dts] [PATCH v2] " Herbert Guan
2018-01-29 16:37   ` Liu, Yong
2018-01-30  5:28 ` [dts] [PATCH v3] " Herbert Guan
2018-01-30 14:33   ` Liu, Yong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).