test suite reviews and discussions
 help / color / mirror / Atom feed
From: Herbert Guan <Herbert.Guan@arm.com>
To: "Liu, Yong" <yong.liu@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Subject: Re: [dts] [PATCH] framework: add virt_type option for virt	type(kvm/libvirt) selection
Date: Tue, 9 Jan 2018 07:11:16 +0000	[thread overview]
Message-ID: <HE1PR08MB28098E198C942109F25CCC0986100@HE1PR08MB2809.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <86228AFD5BCD8E4EBFD2B90117B5E81E62F42AB7@SHSMSX103.ccr.corp.intel.com>

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.

  reply	other threads:[~2018-01-09  7:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09  6:00 Herbert Guan
2018-01-09  6:54 ` Liu, Yong
2018-01-09  7:11   ` Herbert Guan [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=HE1PR08MB28098E198C942109F25CCC0986100@HE1PR08MB2809.eurprd08.prod.outlook.com \
    --to=herbert.guan@arm.com \
    --cc=dts@dpdk.org \
    --cc=yong.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).