test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] framework/qemu_kvm: Add machine and pflash option support
@ 2017-11-22  9:36 Phil Yang
  2017-11-27  7:21 ` Liu, Yong
  2017-11-27  9:54 ` [dts] [PATCH v2] " Phil Yang
  0 siblings, 2 replies; 4+ messages in thread
From: Phil Yang @ 2017-11-22  9:36 UTC (permalink / raw)
  To: dts; +Cc: nd, Jianbo.Liu, Herbert.Guan, phil.yang

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 ++++++++++
 framework/qemu_kvm.py | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

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/framework/qemu_kvm.py b/framework/qemu_kvm.py
index 79095bd..42acd69 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,32 @@ 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
         """
+        separator = ','
         if 'file' in options.keys():
             disk_boot_line = '-drive file=%s' % options['file']
+            if 'opt_format' in options.keys():
+                disk_boot_line += separator + 'format=%s' % options['opt_format']
+            if 'opt_if' in options.keys():
+                disk_boot_line += separator + 'if=%s' % options['opt_if']
+            if 'opt_index' in options.keys():
+                disk_boot_line += separator + 'index=%s' % options['opt_index']
+            if 'opt_media' in options.keys():
+                disk_boot_line += separator + 'media=%s' % options['opt_media']
             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
-- 
2.7.4

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

* Re: [dts] [PATCH] framework/qemu_kvm: Add machine and pflash option support
  2017-11-22  9:36 [dts] [PATCH] framework/qemu_kvm: Add machine and pflash option support Phil Yang
@ 2017-11-27  7:21 ` Liu, Yong
  2017-11-27  9:54 ` [dts] [PATCH v2] " Phil Yang
  1 sibling, 0 replies; 4+ messages in thread
From: Liu, Yong @ 2017-11-27  7:21 UTC (permalink / raw)
  To: Phil Yang, dts; +Cc: nd, Jianbo.Liu, Herbert.Guan

Hi Phil,
Overall I'm fine with your patch. Just two comments as below.

1. I can't find code for the fix which mentioned in commit log line 3.
2. Since you are adding some options for virtual machine, please add some descriptions in doc/dts_gsg/virtualization.rst and reference configuration file.

Thanks,
Marvin

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Phil Yang
> Sent: Wednesday, November 22, 2017 5:37 PM
> To: dts@dpdk.org
> Cc: nd@arm.com; Jianbo.Liu@arm.com; Herbert.Guan@arm.com;
> phil.yang@arm.com
> Subject: [dts] [PATCH] framework/qemu_kvm: Add machine and pflash option
> support
> 
> 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 ++++++++++
>  framework/qemu_kvm.py | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 55 insertions(+)
> 
> 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/framework/qemu_kvm.py b/framework/qemu_kvm.py
> index 79095bd..42acd69 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,32 @@ 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
>          """
> +        separator = ','
>          if 'file' in options.keys():
>              disk_boot_line = '-drive file=%s' % options['file']
> +            if 'opt_format' in options.keys():
> +                disk_boot_line += separator + 'format=%s' %
> options['opt_format']
> +            if 'opt_if' in options.keys():
> +                disk_boot_line += separator + 'if=%s' % options['opt_if']
> +            if 'opt_index' in options.keys():
> +                disk_boot_line += separator + 'index=%s' %
> options['opt_index']
> +            if 'opt_media' in options.keys():
> +                disk_boot_line += separator + 'media=%s' %
> options['opt_media']
>              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
> --
> 2.7.4

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

* [dts] [PATCH v2] framework/qemu_kvm: Add machine and pflash option support
  2017-11-22  9:36 [dts] [PATCH] framework/qemu_kvm: Add machine and pflash option support Phil Yang
  2017-11-27  7:21 ` Liu, Yong
@ 2017-11-27  9:54 ` Phil Yang
  2017-12-04  9:13   ` Liu, Yong
  1 sibling, 1 reply; 4+ messages in thread
From: Phil Yang @ 2017-11-27  9:54 UTC (permalink / raw)
  To: dts; +Cc: nd, Jianbo.Liu, Herbert.Guan, yong.liu, phil.yang

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

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

* Re: [dts] [PATCH v2] framework/qemu_kvm: Add machine and pflash option support
  2017-11-27  9:54 ` [dts] [PATCH v2] " Phil Yang
@ 2017-12-04  9:13   ` Liu, Yong
  0 siblings, 0 replies; 4+ messages in thread
From: Liu, Yong @ 2017-12-04  9:13 UTC (permalink / raw)
  To: Phil Yang, dts; +Cc: nd, Jianbo.Liu, Herbert.Guan

Thanks, Phil. Applied in.

On 11/27/2017 05:54 PM, Phil Yang wrote:
> 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>

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

end of thread, other threads:[~2017-12-04  1:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22  9:36 [dts] [PATCH] framework/qemu_kvm: Add machine and pflash option support Phil Yang
2017-11-27  7:21 ` Liu, Yong
2017-11-27  9:54 ` [dts] [PATCH v2] " Phil Yang
2017-12-04  9:13   ` 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).