Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS
@ 2025-12-16 23:14 Julien Olivain via buildroot
  2025-12-16 23:14 ` [Buildroot] [PATCH 2/3] package/kvmtool: bump to git version 7ad32e5514 Julien Olivain via buildroot
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Julien Olivain via buildroot @ 2025-12-16 23:14 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

Buildroot commit [1] "kvmtool: bump to f77d646ba0" removed the
definition of KVMTOOL_EXTRA_LDFLAGS but forgot to remove its usage
in KVMTOOL_MAKE_OPTS.

This commit removes it since it is no longer needed.

[1] https://gitlab.com/buildroot.org/buildroot/-/commit/f20615b53e83d6263346cb038d59df8e8d6b2b74

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 package/kvmtool/kvmtool.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/kvmtool/kvmtool.mk b/package/kvmtool/kvmtool.mk
index f5637e5384..58ca2d3642 100644
--- a/package/kvmtool/kvmtool.mk
+++ b/package/kvmtool/kvmtool.mk
@@ -22,7 +22,7 @@ KVMTOOL_CPE_ID_VALID = YES
 # Disable -Werror, otherwise musl is not happy
 KVMTOOL_MAKE_OPTS = \
 	CROSS_COMPILE="$(TARGET_CROSS)" \
-	LDFLAGS="$(TARGET_LDFLAGS) $(KVMTOOL_EXTRA_LDFLAGS)" \
+	LDFLAGS="$(TARGET_LDFLAGS)" \
 	WERROR=0
 
 define KVMTOOL_BUILD_CMDS
-- 
2.52.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* [Buildroot] [PATCH 2/3] package/kvmtool: bump to git version 7ad32e5514
  2025-12-16 23:14 [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS Julien Olivain via buildroot
@ 2025-12-16 23:14 ` Julien Olivain via buildroot
  2025-12-16 23:14 ` [Buildroot] [PATCH 3/3] support/testing: new kvmtool runtime test Julien Olivain via buildroot
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Julien Olivain via buildroot @ 2025-12-16 23:14 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

For the commit log, see:
https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git/log/?id=7ad32e5514aca2b6d19398fd3ae5a7c5e0e1ce24

This commit also removes package patches which are now upstream.

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 ...lude-libgen-h-for-musl-compatibility.patch | 48 -------------------
 package/kvmtool/kvmtool.hash                  |  2 +-
 package/kvmtool/kvmtool.mk                    |  2 +-
 3 files changed, 2 insertions(+), 50 deletions(-)
 delete mode 100644 package/kvmtool/0002-vfio-include-libgen-h-for-musl-compatibility.patch

diff --git a/package/kvmtool/0002-vfio-include-libgen-h-for-musl-compatibility.patch b/package/kvmtool/0002-vfio-include-libgen-h-for-musl-compatibility.patch
deleted file mode 100644
index e75ede6af1..0000000000
--- a/package/kvmtool/0002-vfio-include-libgen-h-for-musl-compatibility.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From ba6830eec0f5ab734b093657b16b555e0437b927 Mon Sep 17 00:00:00 2001
-From: Thomas Perale <thomas.perale@mind.be>
-Date: Sun, 29 Jun 2025 22:22:21 +0200
-Subject: vfio: include libgen.h (for musl compatibility)
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Starting GCC14 'implicit-function-declaration' are treated as errors by
-default. When building kvmtool with musl libc, the following error
-occurs due to missing declaration of 'basename':
-
-vfio/core.c:537:22: error: implicit declaration of function ‘basename’ [-Wimplicit-function-declaration]
-  537 |         group_name = basename(group_path);
-      |                      ^~~~~~~~
-vfio/core.c:537:22: warning: nested extern declaration of ‘basename’ [-Wnested-externs]
-vfio/core.c:537:20: error: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
-  537 |         group_name = basename(group_path);
-      |                    ^
-
-This patch fixes the issue by including the appropriate header, ensuring
-compatibility with musl and GCC14.
-
-Signed-off-by: Thomas Perale <thomas.perale@mind.be>
-Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
-Link: https://lore.kernel.org/r/20250629202221.893360-1-thomas.perale@mind.be
-Signed-off-by: Will Deacon <will@kernel.org>
-Upstream: https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git/patch/?id=ba6830eec0f5ab734b093657b16b555e0437b927
-Signed-off-by: Thomas Perale <thomas.perale@mind.be>
----
- vfio/core.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/vfio/core.c b/vfio/core.c
-index 3ff2c0b0..8f884898 100644
---- a/vfio/core.c
-+++ b/vfio/core.c
-@@ -3,6 +3,7 @@
- #include "kvm/ioport.h"
- 
- #include <linux/list.h>
-+#include <libgen.h>
- 
- #define VFIO_DEV_DIR		"/dev/vfio"
- #define VFIO_DEV_NODE		VFIO_DEV_DIR "/vfio"
--- 
-cgit 1.2.3-korg
-
diff --git a/package/kvmtool/kvmtool.hash b/package/kvmtool/kvmtool.hash
index 8df6f929df..6a4219372f 100644
--- a/package/kvmtool/kvmtool.hash
+++ b/package/kvmtool/kvmtool.hash
@@ -1,3 +1,3 @@
 # Locally computed
-sha256  18841c414e82b405a0bd6f5c546bc088becd298c1145a2bac97563e699231925  kvmtool-1117dbc8ceb21abc6e8cd9861450695995852290-git4.tar.gz
+sha256  655f7691fc80416161b1d832575abfcd1223fbefa2900653ed5ddaab3ee738ec  kvmtool-7ad32e5514aca2b6d19398fd3ae5a7c5e0e1ce24-git4.tar.gz
 sha256  0d5bf346df9e635a29dcdddf832dc5b002ca6cdc1c5c9c6c567d2a61bb0c5c15  COPYING
diff --git a/package/kvmtool/kvmtool.mk b/package/kvmtool/kvmtool.mk
index 58ca2d3642..80248807e1 100644
--- a/package/kvmtool/kvmtool.mk
+++ b/package/kvmtool/kvmtool.mk
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-KVMTOOL_VERSION = 1117dbc8ceb21abc6e8cd9861450695995852290
+KVMTOOL_VERSION = 7ad32e5514aca2b6d19398fd3ae5a7c5e0e1ce24
 KVMTOOL_SITE = https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git
 KVMTOOL_SITE_METHOD = git
 KVMTOOL_DEPENDENCIES = \
-- 
2.52.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* [Buildroot] [PATCH 3/3] support/testing: new kvmtool runtime test
  2025-12-16 23:14 [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS Julien Olivain via buildroot
  2025-12-16 23:14 ` [Buildroot] [PATCH 2/3] package/kvmtool: bump to git version 7ad32e5514 Julien Olivain via buildroot
@ 2025-12-16 23:14 ` Julien Olivain via buildroot
  2026-01-07 17:49   ` Arnout Vandecappelle via buildroot
  2025-12-28 22:23 ` [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS Thomas Petazzoni via buildroot
  2026-01-07 17:49 ` Arnout Vandecappelle via buildroot
  3 siblings, 1 reply; 6+ messages in thread
From: Julien Olivain via buildroot @ 2025-12-16 23:14 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch series tested in:
https://gitlab.com/jolivain/buildroot/-/jobs/12462463585
---
 DEVELOPERS                                    |  2 +
 support/testing/tests/package/test_kvmtool.py | 97 +++++++++++++++++++
 .../package/test_kvmtool/linux-kvm.fragment   |  6 ++
 .../rootfs-overlay/etc/profile.d/stty-raw.sh  |  3 +
 4 files changed, 108 insertions(+)
 create mode 100644 support/testing/tests/package/test_kvmtool.py
 create mode 100644 support/testing/tests/package/test_kvmtool/linux-kvm.fragment
 create mode 100644 support/testing/tests/package/test_kvmtool/rootfs-overlay/etc/profile.d/stty-raw.sh

diff --git a/DEVELOPERS b/DEVELOPERS
index 1b27df9beb..ca2cb44b87 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1926,6 +1926,8 @@ F:	support/testing/tests/package/test_kmod.py
 F:	support/testing/tests/package/test_kmod/
 F:	support/testing/tests/package/test_kmscube.py
 F:	support/testing/tests/package/test_kmscube/
+F:	support/testing/tests/package/test_kvmtool.py
+F:	support/testing/tests/package/test_kvmtool/
 F:	support/testing/tests/package/test_lame.py
 F:	support/testing/tests/package/test_less.py
 F:	support/testing/tests/package/test_libcamera.py
diff --git a/support/testing/tests/package/test_kvmtool.py b/support/testing/tests/package/test_kvmtool.py
new file mode 100644
index 0000000000..d6859172bd
--- /dev/null
+++ b/support/testing/tests/package/test_kvmtool.py
@@ -0,0 +1,97 @@
+import os
+
+import infra.basetest
+
+
+class TestKvmTool(infra.basetest.BRTest):
+    # This test passes the Buildroot image directory to the emulated
+    # guest using the 9p virtiofs. This guest enables the
+    # virtualization support. It will start a nested KVM virtual
+    # machine, using the same Kernel/initramfs images. For these
+    # reasons, we need a specific kernel configuration that enables
+    # KVM and 9P.
+    kern_frag = \
+        infra.filepath("tests/package/test_kvmtool/linux-kvm.fragment")
+    rootfs_overlay = \
+        infra.filepath("tests/package/test_kvmtool/rootfs-overlay")
+    config = \
+        f"""
+        BR2_aarch64=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_LINUX_KERNEL=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.18.1"
+        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+        BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kern_frag}"
+        BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+        BR2_PACKAGE_KVMTOOL=y
+        BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def test_run(self):
+        img = os.path.join(self.builddir, "images", "rootfs.cpio")
+        kern = os.path.join(self.builddir, "images", "Image")
+        img_dir = os.path.join(self.builddir, "images")
+        virtfs_tag = "br-imgs"
+        virtfs_opts = [
+            f"local,path={img_dir}",
+            f"mount_tag={virtfs_tag}",
+            "security_model=mapped-xattr",
+            "readonly"
+        ]
+        qemu_opts = ["-M", "virt,gic-version=3,virtualization=on",
+                     "-cpu", "cortex-a57",
+                     "-smp", "4",
+                     "-m", "1G",
+                     "-virtfs", ','.join(virtfs_opts),
+                     "-initrd", img]
+        self.emulator.boot(arch="aarch64",
+                           kernel=kern,
+                           options=qemu_opts)
+        self.emulator.login()
+
+        # Test the program can execute.
+        self.assertRunOk("lkvm --version")
+
+        # We mount the virtfs to get the Kernel and initramfs from the
+        # test host.
+        self.assertRunOk(f"mount -t 9p {virtfs_tag} /mnt/")
+
+        # We define an arbitrary kernel command line argument that we
+        # will use to detect we are in our virtual machine.
+        kvm_karg = "br-kvm"
+
+        # The number of CPU of our virtual machine
+        kvm_nproc = 2
+
+        # We run the KVM virtual machine
+        cmd = "lkvm run"
+        cmd += " --kernel /mnt/Image"
+        cmd += " --initrd /mnt/rootfs.cpio"
+        cmd += f" --cpus {kvm_nproc}"
+        cmd += " --mem 320M"
+        cmd += " --console virtio"
+        cmd += " --irqchip gicv3"
+        cmd += f" --params {kvm_karg}"
+
+        # We use qemu.sendline() to run the command because the
+        # program will not return an exit code. The command "lkvm run"
+        # will spawn the new virtual machine console. The login is
+        # expected to be reached after the command is issued.
+        self.emulator.qemu.sendline(cmd)
+
+        # We login in the virtual machine.
+        self.emulator.login()
+
+        # We check we can see our kernel argument.
+        out, ret = self.emulator.run("cat /proc/cmdline")
+        self.assertEqual(ret, 0)
+        self.assertIn(kvm_karg, out[0])
+
+        # We check the virtual machine has the expected number of CPU.
+        out, ret = self.emulator.run("nproc")
+        self.assertEqual(ret, 0)
+        self.assertEqual(int(out[0]), kvm_nproc)
diff --git a/support/testing/tests/package/test_kvmtool/linux-kvm.fragment b/support/testing/tests/package/test_kvmtool/linux-kvm.fragment
new file mode 100644
index 0000000000..8058ac41c3
--- /dev/null
+++ b/support/testing/tests/package/test_kvmtool/linux-kvm.fragment
@@ -0,0 +1,6 @@
+CONFIG_VIRTUALIZATION=y
+CONFIG_KVM=y
+CONFIG_NET_9P=y
+CONFIG_NET_9P_VIRTIO=y
+CONFIG_9P_FS=y
+CONFIG_9P_FS_POSIX_ACL=y
diff --git a/support/testing/tests/package/test_kvmtool/rootfs-overlay/etc/profile.d/stty-raw.sh b/support/testing/tests/package/test_kvmtool/rootfs-overlay/etc/profile.d/stty-raw.sh
new file mode 100644
index 0000000000..24d72995e6
--- /dev/null
+++ b/support/testing/tests/package/test_kvmtool/rootfs-overlay/etc/profile.d/stty-raw.sh
@@ -0,0 +1,3 @@
+# Avoid double-cooking the terminal, otherwise the test infrastructure
+# would not be able to retrieve return codes properly.
+grep -Fq br-kvm /proc/cmdline && stty raw
-- 
2.52.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS
  2025-12-16 23:14 [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS Julien Olivain via buildroot
  2025-12-16 23:14 ` [Buildroot] [PATCH 2/3] package/kvmtool: bump to git version 7ad32e5514 Julien Olivain via buildroot
  2025-12-16 23:14 ` [Buildroot] [PATCH 3/3] support/testing: new kvmtool runtime test Julien Olivain via buildroot
@ 2025-12-28 22:23 ` Thomas Petazzoni via buildroot
  2026-01-07 17:49 ` Arnout Vandecappelle via buildroot
  3 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni via buildroot @ 2025-12-28 22:23 UTC (permalink / raw)
  To: Julien Olivain via buildroot; +Cc: Julien Olivain

On Wed, 17 Dec 2025 00:14:43 +0100
Julien Olivain via buildroot <buildroot@buildroot.org> wrote:

> Buildroot commit [1] "kvmtool: bump to f77d646ba0" removed the
> definition of KVMTOOL_EXTRA_LDFLAGS but forgot to remove its usage
> in KVMTOOL_MAKE_OPTS.
> 
> This commit removes it since it is no longer needed.
> 
> [1] https://gitlab.com/buildroot.org/buildroot/-/commit/f20615b53e83d6263346cb038d59df8e8d6b2b74
> 
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
>  package/kvmtool/kvmtool.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Series applied, thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS
  2025-12-16 23:14 [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS Julien Olivain via buildroot
                   ` (2 preceding siblings ...)
  2025-12-28 22:23 ` [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS Thomas Petazzoni via buildroot
@ 2026-01-07 17:49 ` Arnout Vandecappelle via buildroot
  3 siblings, 0 replies; 6+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2026-01-07 17:49 UTC (permalink / raw)
  To: Julien Olivain; +Cc: Arnout Vandecappelle, buildroot

In reply of:
> Buildroot commit [1] "kvmtool: bump to f77d646ba0" removed the
> definition of KVMTOOL_EXTRA_LDFLAGS but forgot to remove its usage
> in KVMTOOL_MAKE_OPTS.
> 
> This commit removes it since it is no longer needed.
> 
> [1] https://gitlab.com/buildroot.org/buildroot/-/commit/f20615b53e83d6263346cb038d59df8e8d6b2b74
> 
> Signed-off-by: Julien Olivain <ju.o@free.fr>

Applied to 2025.02.x and 2025.11.x. Thanks

> ---
>  package/kvmtool/kvmtool.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/package/kvmtool/kvmtool.mk b/package/kvmtool/kvmtool.mk
> index f5637e5384..58ca2d3642 100644
> --- a/package/kvmtool/kvmtool.mk
> +++ b/package/kvmtool/kvmtool.mk
> @@ -22,7 +22,7 @@ KVMTOOL_CPE_ID_VALID = YES
>  # Disable -Werror, otherwise musl is not happy
>  KVMTOOL_MAKE_OPTS = \
>  	CROSS_COMPILE="$(TARGET_CROSS)" \
> -	LDFLAGS="$(TARGET_LDFLAGS) $(KVMTOOL_EXTRA_LDFLAGS)" \
> +	LDFLAGS="$(TARGET_LDFLAGS)" \
>  	WERROR=0
>  
>  define KVMTOOL_BUILD_CMDS
> -- 
> 2.52.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 3/3] support/testing: new kvmtool runtime test
  2025-12-16 23:14 ` [Buildroot] [PATCH 3/3] support/testing: new kvmtool runtime test Julien Olivain via buildroot
@ 2026-01-07 17:49   ` Arnout Vandecappelle via buildroot
  0 siblings, 0 replies; 6+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2026-01-07 17:49 UTC (permalink / raw)
  To: Julien Olivain; +Cc: Arnout Vandecappelle, buildroot

In reply of:
> Signed-off-by: Julien Olivain <ju.o@free.fr>

Applied to 2025.02.x and 2025.11.x. Thanks

> ---
> Patch series tested in:
> https://gitlab.com/jolivain/buildroot/-/jobs/12462463585
> ---
>  DEVELOPERS                                    |  2 +
>  support/testing/tests/package/test_kvmtool.py | 97 +++++++++++++++++++
>  .../package/test_kvmtool/linux-kvm.fragment   |  6 ++
>  .../rootfs-overlay/etc/profile.d/stty-raw.sh  |  3 +
>  4 files changed, 108 insertions(+)
>  create mode 100644 support/testing/tests/package/test_kvmtool.py
>  create mode 100644 support/testing/tests/package/test_kvmtool/linux-kvm.fragment
>  create mode 100644 support/testing/tests/package/test_kvmtool/rootfs-overlay/etc/profile.d/stty-raw.sh
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 1b27df9beb..ca2cb44b87 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1926,6 +1926,8 @@ F:	support/testing/tests/package/test_kmod.py
>  F:	support/testing/tests/package/test_kmod/
>  F:	support/testing/tests/package/test_kmscube.py
>  F:	support/testing/tests/package/test_kmscube/
> +F:	support/testing/tests/package/test_kvmtool.py
> +F:	support/testing/tests/package/test_kvmtool/
>  F:	support/testing/tests/package/test_lame.py
>  F:	support/testing/tests/package/test_less.py
>  F:	support/testing/tests/package/test_libcamera.py
> diff --git a/support/testing/tests/package/test_kvmtool.py b/support/testing/tests/package/test_kvmtool.py
> new file mode 100644
> index 0000000000..d6859172bd
> --- /dev/null
> +++ b/support/testing/tests/package/test_kvmtool.py
> @@ -0,0 +1,97 @@
> +import os
> +
> +import infra.basetest
> +
> +
> +class TestKvmTool(infra.basetest.BRTest):
> +    # This test passes the Buildroot image directory to the emulated
> +    # guest using the 9p virtiofs. This guest enables the
> +    # virtualization support. It will start a nested KVM virtual
> +    # machine, using the same Kernel/initramfs images. For these
> +    # reasons, we need a specific kernel configuration that enables
> +    # KVM and 9P.
> +    kern_frag = \
> +        infra.filepath("tests/package/test_kvmtool/linux-kvm.fragment")
> +    rootfs_overlay = \
> +        infra.filepath("tests/package/test_kvmtool/rootfs-overlay")
> +    config = \
> +        f"""
> +        BR2_aarch64=y
> +        BR2_TOOLCHAIN_EXTERNAL=y
> +        BR2_LINUX_KERNEL=y
> +        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
> +        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.18.1"
> +        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
> +        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
> +        BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kern_frag}"
> +        BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
> +        BR2_PACKAGE_KVMTOOL=y
> +        BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
> +        BR2_TARGET_ROOTFS_CPIO=y
> +        # BR2_TARGET_ROOTFS_TAR is not set
> +        """
> +
> +    def test_run(self):
> +        img = os.path.join(self.builddir, "images", "rootfs.cpio")
> +        kern = os.path.join(self.builddir, "images", "Image")
> +        img_dir = os.path.join(self.builddir, "images")
> +        virtfs_tag = "br-imgs"
> +        virtfs_opts = [
> +            f"local,path={img_dir}",
> +            f"mount_tag={virtfs_tag}",
> +            "security_model=mapped-xattr",
> +            "readonly"
> +        ]
> +        qemu_opts = ["-M", "virt,gic-version=3,virtualization=on",
> +                     "-cpu", "cortex-a57",
> +                     "-smp", "4",
> +                     "-m", "1G",
> +                     "-virtfs", ','.join(virtfs_opts),
> +                     "-initrd", img]
> +        self.emulator.boot(arch="aarch64",
> +                           kernel=kern,
> +                           options=qemu_opts)
> +        self.emulator.login()
> +
> +        # Test the program can execute.
> +        self.assertRunOk("lkvm --version")
> +
> +        # We mount the virtfs to get the Kernel and initramfs from the
> +        # test host.
> +        self.assertRunOk(f"mount -t 9p {virtfs_tag} /mnt/")
> +
> +        # We define an arbitrary kernel command line argument that we
> +        # will use to detect we are in our virtual machine.
> +        kvm_karg = "br-kvm"
> +
> +        # The number of CPU of our virtual machine
> +        kvm_nproc = 2
> +
> +        # We run the KVM virtual machine
> +        cmd = "lkvm run"
> +        cmd += " --kernel /mnt/Image"
> +        cmd += " --initrd /mnt/rootfs.cpio"
> +        cmd += f" --cpus {kvm_nproc}"
> +        cmd += " --mem 320M"
> +        cmd += " --console virtio"
> +        cmd += " --irqchip gicv3"
> +        cmd += f" --params {kvm_karg}"
> +
> +        # We use qemu.sendline() to run the command because the
> +        # program will not return an exit code. The command "lkvm run"
> +        # will spawn the new virtual machine console. The login is
> +        # expected to be reached after the command is issued.
> +        self.emulator.qemu.sendline(cmd)
> +
> +        # We login in the virtual machine.
> +        self.emulator.login()
> +
> +        # We check we can see our kernel argument.
> +        out, ret = self.emulator.run("cat /proc/cmdline")
> +        self.assertEqual(ret, 0)
> +        self.assertIn(kvm_karg, out[0])
> +
> +        # We check the virtual machine has the expected number of CPU.
> +        out, ret = self.emulator.run("nproc")
> +        self.assertEqual(ret, 0)
> +        self.assertEqual(int(out[0]), kvm_nproc)
> diff --git a/support/testing/tests/package/test_kvmtool/linux-kvm.fragment b/support/testing/tests/package/test_kvmtool/linux-kvm.fragment
> new file mode 100644
> index 0000000000..8058ac41c3
> --- /dev/null
> +++ b/support/testing/tests/package/test_kvmtool/linux-kvm.fragment
> @@ -0,0 +1,6 @@
> +CONFIG_VIRTUALIZATION=y
> +CONFIG_KVM=y
> +CONFIG_NET_9P=y
> +CONFIG_NET_9P_VIRTIO=y
> +CONFIG_9P_FS=y
> +CONFIG_9P_FS_POSIX_ACL=y
> diff --git a/support/testing/tests/package/test_kvmtool/rootfs-overlay/etc/profile.d/stty-raw.sh b/support/testing/tests/package/test_kvmtool/rootfs-overlay/etc/profile.d/stty-raw.sh
> new file mode 100644
> index 0000000000..24d72995e6
> --- /dev/null
> +++ b/support/testing/tests/package/test_kvmtool/rootfs-overlay/etc/profile.d/stty-raw.sh
> @@ -0,0 +1,3 @@
> +# Avoid double-cooking the terminal, otherwise the test infrastructure
> +# would not be able to retrieve return codes properly.
> +grep -Fq br-kvm /proc/cmdline && stty raw
> -- 
> 2.52.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2026-01-07 17:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-16 23:14 [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS Julien Olivain via buildroot
2025-12-16 23:14 ` [Buildroot] [PATCH 2/3] package/kvmtool: bump to git version 7ad32e5514 Julien Olivain via buildroot
2025-12-16 23:14 ` [Buildroot] [PATCH 3/3] support/testing: new kvmtool runtime test Julien Olivain via buildroot
2026-01-07 17:49   ` Arnout Vandecappelle via buildroot
2025-12-28 22:23 ` [Buildroot] [PATCH 1/3] package/kvmtool: remove unneeded KVMTOOL_EXTRA_LDFLAGS Thomas Petazzoni via buildroot
2026-01-07 17:49 ` Arnout Vandecappelle via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox