Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] support/testing: test_xen: add networking
@ 2025-10-10  7:29 Vincent Stehlé
  2025-10-11 20:35 ` Julien Olivain via buildroot
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Stehlé @ 2025-10-10  7:29 UTC (permalink / raw)
  To: buildroot; +Cc: Titouan Christophe, Alistair Francis, Vincent Stehlé

Enhance the Xen python tests to exercise networking:

- Add the networking support we need to the Linux kernel configurations.
- Add a virtual network interface to the Xen dom1 configurations.
- Update the test in the following way:
  * Start the emulator with restricted networking.
  * Create a network bridge in dom0.
  * Check that networking is functional in both domains by ping'ing the
    gateway.
  (Refer also to the diagram in the python script.)
- While at it, bump Linux kernel to 6.17.1 and U-Boot to 2025.07.
  We also need to adjust the DTB address in the Arm 32b U-Boot script to
  accommodate the new U-Boot version, which does not have enough free space
  around the control DTB anymore.

Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
---
 support/testing/tests/package/test_xen.py     | 48 ++++++++++++++++++-
 .../package/test_xen/aarch64/linux.config     | 43 ++---------------
 .../test_xen/aarch64/overlay/etc/xen/dom1.cfg |  1 +
 .../tests/package/test_xen/arm/boot.cmd       |  4 +-
 .../tests/package/test_xen/arm/linux.config   |  5 +-
 .../test_xen/arm/overlay/etc/xen/dom1.cfg     |  1 +
 6 files changed, 58 insertions(+), 44 deletions(-)

diff --git a/support/testing/tests/package/test_xen.py b/support/testing/tests/package/test_xen.py
index 881327b9b9..511363be40 100644
--- a/support/testing/tests/package/test_xen.py
+++ b/support/testing/tests/package/test_xen.py
@@ -14,9 +14,10 @@ class TestXenBase(infra.basetest.BRTest):
         BR2_ROOTFS_POST_BUILD_SCRIPT="support/testing/tests/package/test_xen/common/post-build.sh"
         BR2_LINUX_KERNEL=y
         BR2_LINUX_KERNEL_CUSTOM_VERSION=y
-        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.12.9"
+        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.17.1"
         BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
         BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+        BR2_PACKAGE_BRIDGE_UTILS=y
         BR2_PACKAGE_XEN=y
         BR2_PACKAGE_XEN_HYPERVISOR=y
         BR2_PACKAGE_XEN_TOOLS=y
@@ -25,7 +26,7 @@ class TestXenBase(infra.basetest.BRTest):
         BR2_TARGET_UBOOT=y
         BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
         BR2_TARGET_UBOOT_CUSTOM_VERSION=y
-        BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2025.01"
+        BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2025.07"
         BR2_TARGET_UBOOT_NEEDS_OPENSSL=y
         BR2_TARGET_UBOOT_NEEDS_GNUTLS=y
         BR2_PACKAGE_HOST_DOSFSTOOLS=y
@@ -47,6 +48,20 @@ class TestXenBase(infra.basetest.BRTest):
     def run_xen_test(self, arch: str, options: list[str]) -> None:
         """This functions tests Xen for multiple architectures.
         The arch and options parameters are passed to the emulator.
+
+        Here is the network setup we use in the test:
+
+                    :         dom0        :   dom1   :
+                    :                     :          :
+                    :        br0          :          :
+                    :      10.0.2.x       :          :
+             gw     :         |           :          :
+          10.0.2.2 -:- eth0 --+-- vif1.0 -:-- eth0   :
+                    :                     : 10.0.2.y :
+
+        The VMs get their IP addresses with DHCP.
+        We create a bridge in dom0, which allows dom1 to reach the gateway.
+        vif1.0 is added to the bridge automatically when dom1 is created.
         """
 
         # Boot the emulator.
@@ -65,6 +80,20 @@ class TestXenBase(infra.basetest.BRTest):
         # Check that we have one VM running.
         self.assertNumVM(1)
 
+        # Create a network bridge.
+        self.assertRunOk("brctl addbr br0")
+        self.assertRunOk("brctl addif br0 eth0")
+        self.assertRunOk("brctl show")
+
+        # Bring up the network in the dom0.
+        self.assertRunOk("ifconfig eth0 up")
+        self.assertRunOk("ifconfig br0 up")
+        self.assertRunOk("udhcpc -i br0")
+        self.assertRunOk("ifconfig -a")
+
+        # Verify that we can ping the gateway.
+        self.assertRunOk("ping -c 3 -A 10.0.2.2")
+
         # Create dom1 with console attached and login.
         self.emulator.qemu.sendline("xl create -c /etc/xen/dom1.cfg")
         self.emulator.login()
@@ -73,6 +102,14 @@ class TestXenBase(infra.basetest.BRTest):
         uuid = self.get_dom_uuid()
         self.assertNotEqual(uuid, dom0_uuid, "Unexpected dom0 UUID")
 
+        # Bring up the network in the dom1.
+        self.assertRunOk("ifconfig eth0 up")
+        self.assertRunOk("udhcpc -i eth0")
+        self.assertRunOk("ifconfig -a")
+
+        # Verify that we can ping the gateway.
+        self.assertRunOk("ping -c 3 -A 10.0.2.2")
+
         # Detach from dom1's console with CTRL-].
         # dom1 is still running in the background after that.
         self.emulator.qemu.send(chr(0x1d))
@@ -88,6 +125,9 @@ class TestXenBase(infra.basetest.BRTest):
         # Check that we have two VMs running.
         self.assertNumVM(2)
 
+        # Print the bridge setup for debugging.
+        self.assertRunOk("brctl show")
+
 
 class TestXenAarch64(TestXenBase):
     # Test Xen on 64b Arm.
@@ -117,8 +157,10 @@ class TestXenAarch64(TestXenBase):
             "-bios", uboot_bin,
             "-cpu", "cortex-a53",
             "-device", "virtio-blk-device,drive=hd0",
+            "-device", "virtio-net-device,netdev=eth0",
             "-drive", f"file={disk_img},if=none,format=raw,id=hd0",
             "-m", "1G",
+            "-netdev", "user,id=eth0,restrict=yes",
             "-machine", "virt,gic-version=3,virtualization=on,acpi=off",
             "-smp", "2"
         ]
@@ -158,9 +200,11 @@ class TestXenArmv7(TestXenBase):
             "-bios", uboot_bin,
             "-cpu", "cortex-a15",
             "-device", "virtio-blk-device,drive=hd0",
+            "-device", "virtio-net-device,netdev=eth0",
             "-drive", f"file={disk_img},if=none,format=raw,id=hd0",
             "-m", "1G",
             "-machine", "virt,virtualization=on,acpi=off",
+            "-netdev", "user,id=eth0,restrict=yes",
             "-smp", "2"
         ]
 
diff --git a/support/testing/tests/package/test_xen/aarch64/linux.config b/support/testing/tests/package/test_xen/aarch64/linux.config
index 4afab3c171..eca6d871ec 100644
--- a/support/testing/tests/package/test_xen/aarch64/linux.config
+++ b/support/testing/tests/package/test_xen/aarch64/linux.config
@@ -44,7 +44,6 @@ CONFIG_ARCH_VEXPRESS=y
 CONFIG_SCHED_MC=y
 CONFIG_XEN=y
 # CONFIG_ARM64_HW_AFDBM is not set
-# CONFIG_ARM64_PAN is not set
 # CONFIG_ARM64_USE_LSE_ATOMICS is not set
 # CONFIG_ARM64_RAS_EXTN is not set
 # CONFIG_ARM64_CNP is not set
@@ -60,7 +59,6 @@ CONFIG_RANDOMIZE_BASE=y
 CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y
 CONFIG_CPU_IDLE=y
 CONFIG_ARM_PSCI_CPUIDLE=y
-CONFIG_JUMP_LABEL=y
 CONFIG_COMPAT_32BIT_TIME=y
 # CONFIG_GCC_PLUGINS is not set
 CONFIG_MODULES=y
@@ -72,8 +70,10 @@ CONFIG_IOSCHED_BFQ=y
 # CONFIG_COMPAT_BRK is not set
 CONFIG_KSM=y
 CONFIG_NET=y
+CONFIG_PACKET=y
 CONFIG_UNIX=y
 CONFIG_INET=y
+CONFIG_BRIDGE=m
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_FW_LOADER_USER_HELPER=y
@@ -84,6 +84,9 @@ CONFIG_SCSI=y
 # CONFIG_SCSI_PROC_FS is not set
 CONFIG_BLK_DEV_SD=y
 CONFIG_SCSI_SAS_LIBSAS=y
+CONFIG_NETDEVICES=y
+CONFIG_VIRTIO_NET=y
+CONFIG_XEN_NETDEV_BACKEND=y
 CONFIG_INPUT_FF_MEMLESS=y
 CONFIG_INPUT_MATRIXKMAP=y
 CONFIG_INPUT_EVDEV=y
@@ -149,43 +152,8 @@ CONFIG_NLS_ISO8859_1=y
 CONFIG_SECURITY=y
 CONFIG_SECURITYFS=y
 # CONFIG_INTEGRITY is not set
-CONFIG_CR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FS=y
-# CONFIG_SCHED_DEBUG is not set
 # CONFIG_FTRACE is not set
 CONFIG_CORESIGHT=m
 CONFIG_CORESIGHT_LINK_AND_SINK_TMC=m
diff --git a/support/testing/tests/package/test_xen/aarch64/overlay/etc/xen/dom1.cfg b/support/testing/tests/package/test_xen/aarch64/overlay/etc/xen/dom1.cfg
index 869c12beb8..651b8de919 100644
--- a/support/testing/tests/package/test_xen/aarch64/overlay/etc/xen/dom1.cfg
+++ b/support/testing/tests/package/test_xen/aarch64/overlay/etc/xen/dom1.cfg
@@ -3,3 +3,4 @@ kernel="/mnt/Image"
 ramdisk="/mnt/rootfs.cpio"
 memory=256
 cmdline="console=hvc0"
+vif=['bridge=br0']
diff --git a/support/testing/tests/package/test_xen/arm/boot.cmd b/support/testing/tests/package/test_xen/arm/boot.cmd
index 698e055e56..859dc661c8 100644
--- a/support/testing/tests/package/test_xen/arm/boot.cmd
+++ b/support/testing/tests/package/test_xen/arm/boot.cmd
@@ -1,4 +1,4 @@
-fdt addr ${fdtcontroladdr}
+fdt addr ${fdt_addr}
 fdt resize
 
 fdt set /chosen \#address-cells <1>
@@ -20,4 +20,4 @@ load ${devtype} ${devnum} ${loadaddr} xen
 fdt set /chosen xen,dom0-bootargs "console=hvc0"
 fdt set /chosen xen,xen-bootargs "dom0_mem=256M loglvl=all guest_loglvl=all"
 fdt print /chosen
-bootz ${loadaddr} - ${fdtcontroladdr}
+bootz ${loadaddr} - ${fdt_addr}
diff --git a/support/testing/tests/package/test_xen/arm/linux.config b/support/testing/tests/package/test_xen/arm/linux.config
index aedd9bf0a2..69c795199b 100644
--- a/support/testing/tests/package/test_xen/arm/linux.config
+++ b/support/testing/tests/package/test_xen/arm/linux.config
@@ -23,6 +23,7 @@ CONFIG_VFP=y
 CONFIG_NEON=y
 CONFIG_KERNEL_MODE_NEON=y
 # CONFIG_SUSPEND is not set
+# CONFIG_GCC_PLUGINS is not set
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 CONFIG_PARTITION_ADVANCED=y
@@ -38,6 +39,7 @@ CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
 CONFIG_IP_PNP_BOOTP=y
 CONFIG_IP_PNP_RARP=y
+CONFIG_BRIDGE=y
 CONFIG_QRTR=m
 CONFIG_PAGE_POOL_STATS=y
 CONFIG_DEVTMPFS=y
@@ -69,6 +71,7 @@ CONFIG_DWMAC_DWC_QOS_ETH=y
 CONFIG_MDIO_BITBANG=y
 CONFIG_MDIO_MSCC_MIIM=m
 # CONFIG_WLAN is not set
+CONFIG_XEN_NETDEV_BACKEND=y
 CONFIG_INPUT_EVDEV=y
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_GPIO_DECODER=m
@@ -153,11 +156,9 @@ CONFIG_TMPFS_POSIX_ACL=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ISO8859_1=y
 CONFIG_NLS_UTF8=y
-CONFIG_CRC_CCITT=m
 CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
 CONFIG_DEBUG_INFO_REDUCED=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_FS=y
-# CONFIG_SCHED_DEBUG is not set
 # CONFIG_FTRACE is not set
diff --git a/support/testing/tests/package/test_xen/arm/overlay/etc/xen/dom1.cfg b/support/testing/tests/package/test_xen/arm/overlay/etc/xen/dom1.cfg
index 0a4ae24a16..3c75a0cfb7 100644
--- a/support/testing/tests/package/test_xen/arm/overlay/etc/xen/dom1.cfg
+++ b/support/testing/tests/package/test_xen/arm/overlay/etc/xen/dom1.cfg
@@ -3,3 +3,4 @@ kernel="/mnt/zImage"
 ramdisk="/mnt/rootfs.cpio"
 memory=256
 cmdline="console=hvc0"
+vif=['bridge=br0']
-- 
2.51.0

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

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

* Re: [Buildroot] [PATCH] support/testing: test_xen: add networking
  2025-10-10  7:29 [Buildroot] [PATCH] support/testing: test_xen: add networking Vincent Stehlé
@ 2025-10-11 20:35 ` Julien Olivain via buildroot
  2025-10-14 14:19   ` Vincent Stehlé
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Olivain via buildroot @ 2025-10-11 20:35 UTC (permalink / raw)
  To: Vincent Stehlé; +Cc: buildroot, Titouan Christophe, Alistair Francis

Hi Vincent,

Thanks for the patch.

On 10/10/2025 09:29, Vincent Stehlé wrote:
> Enhance the Xen python tests to exercise networking:
> 
> - Add the networking support we need to the Linux kernel 
> configurations.
> - Add a virtual network interface to the Xen dom1 configurations.
> - Update the test in the following way:
>   * Start the emulator with restricted networking.
>   * Create a network bridge in dom0.
>   * Check that networking is functional in both domains by ping'ing the
>     gateway.
>   (Refer also to the diagram in the python script.)
> - While at it, bump Linux kernel to 6.17.1 and U-Boot to 2025.07.
>   We also need to adjust the DTB address in the Arm 32b U-Boot script 
> to
>   accommodate the new U-Boot version, which does not have enough free 
> space
>   around the control DTB anymore.
> 
> Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>

For some reason, the TestXenArmv7 runtime test is failing in the
reference Buildroot Docker image. I tested with the command:

     utils/docker-run support/testing/run-tests \
         -k -d dl -o output_folder \
         tests.package.test_xen

The file output_folder/TestXenArmv7-run.log ends with:

	[BRTEST# udhcpc -i eth0
	udhcpc: started, v1.37.0
	udhcpc: broadcasting discover
	udhcpc: broadcasting discover

Strangely, the TestXenAarch64 is passing in the Build Docker image.

I initially thought it was a timing issue, but I tested several times
and I consistently got the same result.

Both tests are passing on a Fedora 42 host with qemu 9.2.4.

The Buildroot Docker image has an "old" qemu 7.2.15. See the command:

     utils/docker-run qemu-system-arm --version

which output:

     QEMU emulator version 7.2.15 (Debian 1:7.2+dfsg-7+deb12u12)

I tested by adding in the test config:

     BR2_PACKAGE_HOST_QEMU=y
     BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y

in order to compile a more recent qemu 10.1.0. This seems to
solve or workaround the issue.

For the moment, I cannot tell if it's a network emulation bug in
the old qemu (which in that case the test needs to compile the newer
qemu), or if it's a timing issue in the test (i.e. the test
might need to wait a bit somewhere to let the bridge settle).

Could you have a look please and send an updated patch addressing
this issue, please?

Best regards,

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

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

* Re: [Buildroot] [PATCH] support/testing: test_xen: add networking
  2025-10-11 20:35 ` Julien Olivain via buildroot
@ 2025-10-14 14:19   ` Vincent Stehlé
  0 siblings, 0 replies; 3+ messages in thread
From: Vincent Stehlé @ 2025-10-14 14:19 UTC (permalink / raw)
  To: Julien Olivain; +Cc: buildroot, Titouan Christophe, Alistair Francis

On Sat, Oct 11, 2025 at 10:35:07PM +0200, Julien Olivain wrote:
> Hi Vincent,
> 
> Thanks for the patch.
> 
> On 10/10/2025 09:29, Vincent Stehlé wrote:
> > Enhance the Xen python tests to exercise networking:
> > 
> > - Add the networking support we need to the Linux kernel configurations.
> > - Add a virtual network interface to the Xen dom1 configurations.
> > - Update the test in the following way:
> >   * Start the emulator with restricted networking.
> >   * Create a network bridge in dom0.
> >   * Check that networking is functional in both domains by ping'ing the
> >     gateway.
> >   (Refer also to the diagram in the python script.)
> > - While at it, bump Linux kernel to 6.17.1 and U-Boot to 2025.07.
> >   We also need to adjust the DTB address in the Arm 32b U-Boot script to
> >   accommodate the new U-Boot version, which does not have enough free
> > space
> >   around the control DTB anymore.
> > 
> > Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
> 
> For some reason, the TestXenArmv7 runtime test is failing in the
> reference Buildroot Docker image. I tested with the command:
> 
>     utils/docker-run support/testing/run-tests \
>         -k -d dl -o output_folder \
>         tests.package.test_xen
> 
> The file output_folder/TestXenArmv7-run.log ends with:
> 
> 	[BRTEST# udhcpc -i eth0
> 	udhcpc: started, v1.37.0
> 	udhcpc: broadcasting discover
> 	udhcpc: broadcasting discover

Hi Julien,

Good catch! I thought I did test this, but maybe not the last version with guest
ping, sorry :(

> 
> Strangely, the TestXenAarch64 is passing in the Build Docker image.
> 
> I initially thought it was a timing issue, but I tested several times
> and I consistently got the same result.
> 
> Both tests are passing on a Fedora 42 host with qemu 9.2.4.
> 
> The Buildroot Docker image has an "old" qemu 7.2.15. See the command:
> 
>     utils/docker-run qemu-system-arm --version
> 
> which output:
> 
>     QEMU emulator version 7.2.15 (Debian 1:7.2+dfsg-7+deb12u12)

It seems that Qemu versions <= 9.0.4 break the test, and >= 9.1.0 repair it.
Whatever the reason, I will try to make the test pass on gitlab and send a v2.

Best regards,
Vincent.

> 
> I tested by adding in the test config:
> 
>     BR2_PACKAGE_HOST_QEMU=y
>     BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
> 
> in order to compile a more recent qemu 10.1.0. This seems to
> solve or workaround the issue.
> 
> For the moment, I cannot tell if it's a network emulation bug in
> the old qemu (which in that case the test needs to compile the newer
> qemu), or if it's a timing issue in the test (i.e. the test
> might need to wait a bit somewhere to let the bridge settle).
> 
> Could you have a look please and send an updated patch addressing
> this issue, please?
> 
> Best regards,
> 
> Julien.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2025-10-14 14:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-10  7:29 [Buildroot] [PATCH] support/testing: test_xen: add networking Vincent Stehlé
2025-10-11 20:35 ` Julien Olivain via buildroot
2025-10-14 14:19   ` Vincent Stehlé

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