qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 3/3] tests/acceptance: Add boot linux with kvm test


From: Wainer dos Santos Moschetta
Subject: [Qemu-devel] [PATCH 3/3] tests/acceptance: Add boot linux with kvm test
Date: Fri, 28 Jun 2019 11:02:17 -0400

Until now the suite of acceptance tests doesn't exercise
QEMU with kvm enabled. So this introduces a simple test
that boots the Linux kernel and checks it boots on the
accelerator correctly.

Signed-off-by: Wainer dos Santos Moschetta <address@hidden>
---
 tests/acceptance/kvm.py | 58 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 tests/acceptance/kvm.py

diff --git a/tests/acceptance/kvm.py b/tests/acceptance/kvm.py
new file mode 100644
index 0000000000..aafb865cdb
--- /dev/null
+++ b/tests/acceptance/kvm.py
@@ -0,0 +1,58 @@
+# KVM acceptance tests.
+#
+# Copyright (c) 2019 Red Hat, Inc.
+#
+# Author:
+#  Wainer dos Santos Moschetta <address@hidden>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later.  See the COPYING file in the top-level directory.
+
+import logging
+
+from avocado_qemu import Test
+
+
+class Kvm(Test):
+    """
+    Suite of acceptance tests to check QEMU and KVM integration.
+    """
+
+    def test_boot_linux(self):
+        """
+        Simple Linux boot test with kvm enabled.
+
+        :avocado: tags=arch:x86_64
+        :avocado: tags=accel:kvm
+        """
+        self.vm.add_args('-enable-kvm')
+        kernel_url = ('https://download.fedoraproject.org/pub/fedora/linux/'
+                      
'releases/29/Everything/x86_64/os/images/pxeboot/vmlinuz')
+        kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
+        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+
+        self.vm.set_machine('pc')
+        self.vm.set_console()
+        self.vm.add_args('-kernel', kernel_path,
+                         '-append', 'printk.time=0 console=ttyS0')
+        self.vm.launch()
+
+        query = self.vm.command('query-kvm')
+        self.assertTrue(query['enabled'])
+        self.assertTrue(query['present'])
+
+        console = self.vm.console_socket.makefile()
+        console_logger = logging.getLogger('console')
+        failure_message = 'Kernel panic - not syncing'
+        success_message = 'Booting paravirtualized kernel on KVM'
+
+        while True:
+            msg = console.readline().strip()
+            if not msg:
+                continue
+            console_logger.debug(msg)
+            if success_message in msg:
+                break
+            if failure_message in msg:
+                fail = 'Failure message found in console: %s' % failure_message
+                self.fail(fail)
-- 
2.21.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]