test suite reviews and discussions
 help / color / mirror / Atom feed
From: Phil Yang <phil.yang@arm.com>
To: dts@dpdk.org
Cc: nd@arm.com, Jianbo.Liu@arm.com, Herbert.Guan@arm.com,
	yong.liu@intel.com, phil.yang@arm.com
Subject: [dts] [PATCH v2] framework/qemu_kvm: Add machine and pflash option support
Date: Mon, 27 Nov 2017 17:54:11 +0800	[thread overview]
Message-ID: <1511776451-3804-1-git-send-email-phil.yang@arm.com> (raw)
In-Reply-To: <1511343401-6459-1-git-send-email-phil.yang@arm.com>

1. Add machine and pflash option support;
2. Set default machine type 'virt' for Aarch64;
3. Fix Aarch64 vhost vm case failure when using the default "-net nic
model", since the default nic type in vm is "virtio".
4. Add opt_format, opt_if, opt_index, opt_media for disk option.

Signed-off-by: Phil Yang <phil.yang@arm.com>
---
 conf/vhost_sample.cfg          | 10 +++++++
 doc/dts_gsg/virtualization.rst | 17 +++++++++---
 framework/qemu_kvm.py          | 60 ++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 82 insertions(+), 5 deletions(-)

diff --git a/conf/vhost_sample.cfg b/conf/vhost_sample.cfg
index 8bdc20e..ab71936 100644
--- a/conf/vhost_sample.cfg
+++ b/conf/vhost_sample.cfg
@@ -2,6 +2,9 @@
 # name
 #       name: vm0
 #
+# machine
+#       machine: [virt | ...]
+#
 # enable_kvm
 #       enable: [yes | no]
 #
@@ -18,6 +21,13 @@
 #
 # disk
 #       file: /path/to/image/test.img
+#       opt_format: raw
+#       opt_if: virtio
+#       opt_index: 0
+#       opt_media: disk
+#
+# pflash
+#       file: /path/to/image/pflash0.img
 #
 # char
 #       opt_path: define the file path to vhost-net socket file
diff --git a/doc/dts_gsg/virtualization.rst b/doc/dts_gsg/virtualization.rst
index 375083d..1848563 100644
--- a/doc/dts_gsg/virtualization.rst
+++ b/doc/dts_gsg/virtualization.rst
@@ -92,8 +92,9 @@ Add Configuration File
 
 Configuration file should be placed in conf/{suite_name}.cfg and in test suite this file will be loaded for VM configurations. Below is one sample for virtualization suite configuration file.
 
-The section name between [] is the VM name. Here we changed default cpu, mem, disk configurations. And add two local configurations login and vnc into configuration file. 
+The section name between [] is the VM name. Here we changed default cpu, mem, disk, UEFI configurations. And add two local configurations login and vnc into configuration file.
 For cpu parameter, we changed core number to 2 and pin these two cores to socket 1 cores for performance concern. For mem parameter, we changed guest using with hugepage backend memory. It also concerned about performance. For disk parameter, we should change it local disk image absolute path.
+For pflash parameter, we changed UEFI CODE and UEFI VARs file, which you specified when you created the VM.
 
 Login parameter should be added when guest login username and password not same as host. VNC parameter should be added when need debug guest with vnc display. 
 
@@ -106,7 +107,10 @@ Login parameter should be added when guest login username and password not same
     mem =
         size=4096,hugepage=yes;
     disk =
-        file=/home/img/vm0.img;
+        file=/home/img/vm0.img,opt_format=raw,opt_if=virtio,opt_index=0,opt_media=disk;
+    pflash =
+        file=/home/img/flash_code.img;
+        file=/home/img/flash_vars.img;
     login =
         user=root,password=tester;
     vnc =
@@ -128,7 +132,9 @@ Below is the brief view of the qemu parameters of vxlan sample virtual machine.
     {'device': [{'opt_mac': '00:00:20:00:00:20', 'opt_path': './vhost-net', 'driver': 'vhost-user'}, {'opt_mac': '00:00:20:00:00:21', 'opt_path': './vhost-net', 'driver': 'vhost-user'}]},
     {'cpu': [{'model': 'host', 'number': '4', 'cpupin': '24 25 26 27'}]},
     {'mem': [{'hugepage': 'yes', 'size': '4096'}]},
-    {'disk': [{'file': '/storage/vm-image/vm0.img'}]},
+    {'disk': [{'file': '/storage/vm-image/vm0.img', 'opt_format': 'raw', 'opt_if': 'virtio', 'opt_index': '0', 'opt_media': 'disk'}]},
+    {'pflash': [{'file': '/storage/vm-image/flash_code.img'}]},
+    {'pflash': [{'file': '/storage/vm-image/flash_vars.img'}]},
     {'login': [{'password': 'tester', 'user': 'root'}]},
     {'vnc': [{'displayNum': '1'}]}]
 
@@ -389,6 +395,11 @@ Connection to monitor socket on DUT.
 
     For More detail information about qemu monitor. https://en.wikibooks.org/wiki/QEMU/Monitor#info
 
+Qemu Machine
+""""""""""
+
+DTS set default qemu machine type as virt for Aarch64. This option is mandatory for qemu-system-aarch64.
+
 Configured Parameters
 ~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py
index 79095bd..84f961b 100644
--- a/framework/qemu_kvm.py
+++ b/framework/qemu_kvm.py
@@ -98,12 +98,17 @@ class QEMUKvm(VirtBase):
         # internal variable to track whether default nic has been added
         self.__default_nic = False
 
+        # arch info for multi-paltform init
+        self.arch = self.host_session.send_expect('uname -m', '# ')
+
         # set some default values for vm,
         # if there is not the values of the specified options
         self.set_vm_default()
 
     def set_vm_default(self):
         self.set_vm_name(self.vm_name)
+        if self.arch == 'aarch64':
+            self.set_vm_machine('virt')
         self.set_vm_enable_kvm()
         self.set_vm_pid_file()
         self.set_vm_qga()
@@ -249,6 +254,25 @@ class QEMUKvm(VirtBase):
             enable_kvm_boot_line = '-enable-kvm'
             self.__add_boot_line(enable_kvm_boot_line)
 
+    def set_vm_machine(self, machine):
+        """
+        Set VM boot option to specify the option 'machine'.
+        """
+        index = self.find_option_index('machine')
+        if index:
+            self.params[index] = {'machine': [{'machine': '%s' % machine}]}
+        else:
+            self.params.append({'machine': [{'machine': '%s' % machine}]})
+
+    def add_vm_machine(self, **options):
+        """
+        'machine': 'virt'
+        """
+        if 'machine' in options.keys() and \
+                options['machine']:
+            machine_boot_line = '-machine %s' % options['machine']
+            self.__add_boot_line(machine_boot_line)
+
     def set_vm_pid_file(self):
         """
         Set VM pidfile option for manage qemu process
@@ -329,11 +353,39 @@ class QEMUKvm(VirtBase):
     def add_vm_disk(self, **options):
         """
         file: /home/image/test.img
+        opt_format: raw
+        opt_if: virtio
+        opt_index: 0
+        opt_media: disk
         """
-        if 'file' in options.keys():
+        separator = ','
+        if 'file' in options.keys() and \
+                options['file']:
             disk_boot_line = '-drive file=%s' % options['file']
+        if 'opt_format' in options.keys() and \
+                options['opt_format']:
+            disk_boot_line += separator + 'format=%s' % options['opt_format']
+        if 'opt_if' in options.keys() and \
+                options['opt_if']:
+            disk_boot_line += separator + 'if=%s' % options['opt_if']
+        if 'opt_index' in options.keys() and \
+                options['opt_index']:
+            disk_boot_line += separator + 'index=%s' % options['opt_index']
+        if 'opt_media' in options.keys() and \
+                options['opt_media']:
+            disk_boot_line += separator + 'media=%s' % options['opt_media']
+
+        if self.__string_has_multi_fields(disk_boot_line, separator):
             self.__add_boot_line(disk_boot_line)
 
+    def add_vm_pflash(self, **options):
+        """
+        file: /home/image/flash0.img
+        """
+        if 'file' in options.keys():
+            pflash_boot_line = '-pflash %s' % options['file']
+            self.__add_boot_line(pflash_boot_line)
+
     def add_vm_login(self, **options):
         """
         user: login username of virtual machine
@@ -411,7 +463,11 @@ class QEMUKvm(VirtBase):
 
         if 'opt_model' in options.keys() and \
                 options['opt_model']:
-            net_boot_line += separator + 'model=%s' % options['opt_model']
+            model = options['opt_model']
+        else:
+            model = 'e1000'
+        net_boot_line += separator + 'model=%s' % model
+
         if 'opt_name' in options.keys() and \
                 options['opt_name']:
             net_boot_line += separator + 'name=%s' % options['opt_name']
-- 
2.7.4

  parent reply	other threads:[~2017-11-27  9:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22  9:36 [dts] [PATCH] " Phil Yang
2017-11-27  7:21 ` Liu, Yong
2017-11-27  9:54 ` Phil Yang [this message]
2017-12-04  9:13   ` [dts] [PATCH v2] " 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=1511776451-3804-1-git-send-email-phil.yang@arm.com \
    --to=phil.yang@arm.com \
    --cc=Herbert.Guan@arm.com \
    --cc=Jianbo.Liu@arm.com \
    --cc=dts@dpdk.org \
    --cc=nd@arm.com \
    --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).