All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Denis Plotnikov <dplotnikov@virtuozzo.com>
Subject: [PULL v3 27/32] tests: add virtio-scsi and virtio-blk seg_max_adjust test
Date: Tue, 7 Jan 2020 11:31:33 -0500	[thread overview]
Message-ID: <20200107162850.411448-28-mst@redhat.com> (raw)
In-Reply-To: <20200107162850.411448-1-mst@redhat.com>

From: Denis Plotnikov <dplotnikov@virtuozzo.com>

It tests proper seg_max_adjust settings for all machine types except
'none', 'isapc', 'microvm'

Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
Message-Id: <20191220140905.1718-3-dplotnikov@virtuozzo.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 tests/acceptance/virtio_seg_max_adjust.py | 134 ++++++++++++++++++++++
 1 file changed, 134 insertions(+)
 create mode 100755 tests/acceptance/virtio_seg_max_adjust.py

diff --git a/tests/acceptance/virtio_seg_max_adjust.py b/tests/acceptance/virtio_seg_max_adjust.py
new file mode 100755
index 0000000000..5458573138
--- /dev/null
+++ b/tests/acceptance/virtio_seg_max_adjust.py
@@ -0,0 +1,134 @@
+#!/usr/bin/env python
+#
+# Test virtio-scsi and virtio-blk queue settings for all machine types
+#
+# Copyright (c) 2019 Virtuozzo International GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import sys
+import os
+import re
+
+sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
+from qemu.machine import QEMUMachine
+from avocado_qemu import Test
+
+#list of machine types and virtqueue properties to test
+VIRTIO_SCSI_PROPS = {'seg_max_adjust': 'seg_max_adjust'}
+VIRTIO_BLK_PROPS = {'seg_max_adjust': 'seg-max-adjust'}
+
+DEV_TYPES = {'virtio-scsi-pci': VIRTIO_SCSI_PROPS,
+             'virtio-blk-pci': VIRTIO_BLK_PROPS}
+
+VM_DEV_PARAMS = {'virtio-scsi-pci': ['-device', 'virtio-scsi-pci,id=scsi0'],
+                 'virtio-blk-pci': ['-device',
+                                    'virtio-blk-pci,id=scsi0,drive=drive0',
+                                    '-drive',
+                                    'driver=null-co,id=drive0,if=none']}
+
+
+class VirtioMaxSegSettingsCheck(Test):
+    @staticmethod
+    def make_pattern(props):
+        pattern_items = ['{0} = \w+'.format(prop) for prop in props]
+        return '|'.join(pattern_items)
+
+    def query_virtqueue(self, vm, dev_type_name):
+        query_ok = False
+        error = None
+        props = None
+
+        output = vm.command('human-monitor-command',
+                            command_line = 'info qtree')
+        props_list = DEV_TYPES[dev_type_name].values();
+        pattern = self.make_pattern(props_list)
+        res = re.findall(pattern, output)
+
+        if len(res) != len(props_list):
+            props_list = set(props_list)
+            res = set(res)
+            not_found = props_list.difference(res)
+            not_found = ', '.join(not_found)
+            error = '({0}): The following properties not found: {1}'\
+                     .format(dev_type_name, not_found)
+        else:
+            query_ok = True
+            props = dict()
+            for prop in res:
+                p = prop.split(' = ')
+                props[p[0]] = p[1]
+        return query_ok, props, error
+
+    def check_mt(self, mt, dev_type_name):
+        with QEMUMachine(self.qemu_bin) as vm:
+            vm.set_machine(mt["name"])
+            for s in VM_DEV_PARAMS[dev_type_name]:
+                vm.add_args(s)
+            vm.launch()
+            query_ok, props, error = self.query_virtqueue(vm, dev_type_name)
+
+        if not query_ok:
+            self.fail('machine type {0}: {1}'.format(mt['name'], error))
+
+        for prop_name, prop_val in props.items():
+            expected_val = mt[prop_name]
+            self.assertEqual(expected_val, prop_val)
+
+    @staticmethod
+    def seg_max_adjust_enabled(mt):
+        # machine types >= 5.0 should have seg_max_adjust = true
+        # others seg_max_adjust = false
+        mt = mt.split("-")
+
+        # machine types with one line name and name like pc-x.x
+        if len(mt) <= 2:
+            return False
+
+        # machine types like pc-<chip_name>-x.x[.x]
+        ver = mt[2]
+        ver = ver.split(".");
+
+        # versions >= 5.0 goes with seg_max_adjust enabled
+        major = int(ver[0])
+
+        if major >= 5:
+            return True
+        return False
+
+    def test_machine_types(self):
+        # collect all machine types except 'none', 'isapc', 'microvm'
+        with QEMUMachine(self.qemu_bin) as vm:
+            vm.launch()
+            machines = [m['name'] for m in vm.command('query-machines')]
+            vm.shutdown()
+        machines.remove('none')
+        machines.remove('isapc')
+        machines.remove('microvm')
+
+        for dev_type in DEV_TYPES:
+            # create the list of machine types and their parameters.
+            mtypes = list()
+            for m in machines:
+                if self.seg_max_adjust_enabled(m):
+                    enabled = 'true'
+                else:
+                    enabled = 'false'
+                mtypes.append({'name': m,
+                               DEV_TYPES[dev_type]['seg_max_adjust']: enabled})
+
+            # test each machine type for a device type
+            for mt in mtypes:
+                self.check_mt(mt, dev_type)
-- 
MST



  parent reply	other threads:[~2020-01-07 16:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 16:29 [PULL v3 00/32] virtio, pci, pc: fixes, features Michael S. Tsirkin
2020-01-07 16:29 ` [PULL v3 01/32] virtio: add ability to delete vq through a pointer Michael S. Tsirkin
2020-01-07 16:29 ` [PULL v3 02/32] virtio: make virtio_delete_queue idempotent Michael S. Tsirkin
2020-01-07 16:29 ` [PULL v3 03/32] virtio-balloon: fix memory leak while attach virtio-balloon device Michael S. Tsirkin
2020-01-07 16:29 ` [PULL v3 04/32] virtio-serial-bus: fix memory leak while attach virtio-serial-bus Michael S. Tsirkin
2020-01-07 16:29 ` [PULL v3 05/32] virtio-input: convert to new virtio_delete_queue Michael S. Tsirkin
2020-01-07 16:29 ` [PULL v3 06/32] intel_iommu: fix bug to read DMAR_RTADDR_REG Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 07/32] virtio: update queue size on guest write Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 08/32] virtio-pci: disable vring processing when bus-mastering is disabled Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 09/32] Implement backend program convention command for vhost-user-blk Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 10/32] virtio: don't enable notifications during polling Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 11/32] numa: Extend CLI to provide initiator information for numa nodes Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 12/32] numa: Extend CLI to provide memory latency and bandwidth information Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 13/32] numa: Extend CLI to provide memory side cache information Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 14/32] hmat acpi: Build Memory Proximity Domain Attributes Structure(s) Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 15/32] hmat acpi: Build System Locality Latency and Bandwidth Information Structure(s) Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 16/32] hmat acpi: Build Memory Side Cache " Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 17/32] tests/numa: Add case for QMP build HMAT Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 18/32] tests/bios-tables-test: add test cases for ACPI HMAT Michael S. Tsirkin
2020-01-07 16:30 ` [PULL v3 19/32] ACPI: add expected files for HMAT tests (acpihmat) Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 20/32] virtio-mmio: Clear v2 transport state on soft reset Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 21/32] hw/pci/pci_host: Remove redundant PCI_DPRINTF() Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 22/32] hw/pci/pci_host: Let pci_data_[read/write] use unsigned 'size' argument Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 23/32] vhost-user: add VHOST_USER_RESET_DEVICE to reset devices Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 24/32] vhost-user-scsi: reset the device if supported Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 25/32] hw: fix using 4.2 compat in 5.0 machine types for i440fx/q35 Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 26/32] virtio: make seg_max virtqueue size dependent Michael S. Tsirkin
2020-01-07 16:31 ` Michael S. Tsirkin [this message]
2020-01-07 16:31 ` [PULL v3 28/32] virtio-mmio: update queue size on guest write Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 29/32] virtio: reset region cache when on queue deletion Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 30/32] virtio-net: delete also control queue when TX/RX deleted Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 31/32] intel_iommu: a fix to vtd_find_as_from_bus_num() Michael S. Tsirkin
2020-01-07 16:31 ` [PULL v3 32/32] intel_iommu: add present bit check for pasid table entries Michael S. Tsirkin
  -- strict thread matches above, loose matches on Subject: below --
2020-01-05 12:57 [PULL v3 00/32] virtio, pci, pc: fixes, features Michael S. Tsirkin
2020-01-05 12:59 ` [PULL v3 27/32] tests: add virtio-scsi and virtio-blk seg_max_adjust test Michael S. Tsirkin

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=20200107162850.411448-28-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=dplotnikov@virtuozzo.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.