From: Anthony PERARD <anthony@xenproject.org>
To: xen-devel@lists.xenproject.org
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Doug Goldstein" <cardoe@cardoe.com>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: [RFC XEN PATCH 03/13] pytest: Add fixture to prepare the tftp server
Date: Tue, 22 Sep 2026 12:08:50 +0200 [thread overview]
Message-ID: <20260922100900.29129-4-anthony@xenproject.org> (raw)
In-Reply-To: <20260922100900.29129-1-anthony@xenproject.org>
From: Anthony PERARD <anthony.perard@vates.tech>
Prepare the netboot config, and upload the necessary files.
Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
---
automation/pytest/lib/net_boot.py | 60 +++++++++++++++++++++++++++++++
automation/pytest/pyproject.toml | 2 ++
automation/pytest/test_boot.py | 11 ++++++
3 files changed, 73 insertions(+)
create mode 100644 automation/pytest/lib/net_boot.py
diff --git a/automation/pytest/lib/net_boot.py b/automation/pytest/lib/net_boot.py
new file mode 100644
index 000000000000..50d2cfaa5aaa
--- /dev/null
+++ b/automation/pytest/lib/net_boot.py
@@ -0,0 +1,60 @@
+import io
+import logging
+import os
+import paramiko
+from pathlib import Path
+import textwrap
+
+
+class NetBoot:
+ def grub_script(self) -> str:
+ http_pxe_path = os.environ['PXE_HTTP_PATH']
+ tftp_path = f"(http)/{http_pxe_path}"
+ console_opts = "console=vga,com1"
+
+ xen_cmdline_opts = [
+ console_opts,
+ "loglvl=all",
+ "guest_loglvl=all",
+ "dom0_mem=4G",
+ "console_timestamps=boot",
+ "watchdog",
+ "noreboot",
+ ]
+ xen_cmdline = " ".join(xen_cmdline_opts)
+ linux_cmdline = "console=hvc0 root=/dev/ram0 earlyprintk=xen"
+ script = textwrap.dedent(f"""\
+ echo \"Loading xen\"
+ multiboot2 {tftp_path}/xen {xen_cmdline}
+ echo \"Loading vmlinuz\"
+ module2 {tftp_path}/bzImage {linux_cmdline}
+ echo \"Loading initrd\"
+ module2 --nounzip {tftp_path}/pre-dom0-rootfs.cpio.gz
+ echo \"Booting\"
+ boot
+ """)
+
+ return script
+
+ def prepare_tftp(self, xenroot: Path, rootfss: list[Path]) -> None:
+ username = os.environ['PXE_SSH_USER']
+ hostname = os.environ['PXE_HOST']
+ remote_path = Path(os.environ['PXE_SSH_PATH'])
+
+ binaries_path = xenroot / "binaries"
+ binaries = []
+ for b1 in ["xen", "bzImage"]:
+ binaries.append(binaries_path / b1)
+ binaries += rootfss
+
+ ssh = paramiko.client.SSHClient()
+ ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+ ssh.connect(hostname, username=username)
+ with ssh.open_sftp() as sftp:
+ for b2 in binaries:
+ logging.debug(f" put {b2}, to {remote_path / b2.name}")
+ sftp.put(str(b2), str(remote_path / b2.name), confirm=True)
+ grub_script = io.BytesIO(self.grub_script().encode('utf-8'))
+ sftp.putfo(grub_script, str(remote_path / "grub.cfg"),
+ confirm=True)
+ ssh.close()
diff --git a/automation/pytest/pyproject.toml b/automation/pytest/pyproject.toml
index 3180b2555029..78f60c4f8e77 100644
--- a/automation/pytest/pyproject.toml
+++ b/automation/pytest/pyproject.toml
@@ -3,8 +3,10 @@ name = "xen-ci-intree"
version = "0.1.0"
requires-python = ">=3.14"
dependencies = [
+ "paramiko>=4.0.0",
"pip>=26.0.1",
"pytest>=9.0.2",
+ "types-paramiko>=4.0.0.20260322",
]
[dependency-groups]
dev = [
diff --git a/automation/pytest/test_boot.py b/automation/pytest/test_boot.py
index 230cee96d0ba..661c2a59e4fe 100644
--- a/automation/pytest/test_boot.py
+++ b/automation/pytest/test_boot.py
@@ -3,6 +3,7 @@ from pathlib import Path
import pytest
from lib.boot_binary import BootBinary
+from lib.net_boot import NetBoot
@pytest.fixture
@@ -30,3 +31,13 @@ def prepare_rootfs(tmp_path: Path,
static_ipv6=os.environ['HOST_IP6'],
boot_script=boot_script,
)
+
+
+@pytest.fixture
+def prepare_netboot(prepare_rootfs: BootBinary, xenroot_path: Path) -> None:
+ netboot = NetBoot()
+ rootfs_paths = [
+ prepare_rootfs.minimal(),
+ prepare_rootfs.dom0_tools(),
+ ]
+ netboot.prepare_tftp(xenroot_path, rootfs_paths)
--
Anthony PERARD
next prev parent reply other threads:[~2026-09-22 10:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 10:08 [RFC XEN PATCH 00/13] Running bare-metal tests with "pytest" Anthony PERARD
2026-09-22 10:08 ` [RFC XEN PATCH 01/13] pytest: Add fixture to prepare rootfs Anthony PERARD
2026-09-22 10:08 ` [RFC XEN PATCH 02/13] Creating new python project Anthony PERARD
2026-09-22 10:08 ` Anthony PERARD [this message]
2026-09-22 10:08 ` [RFC XEN PATCH 04/13] pytest: Add fixture that boot a machine Anthony PERARD
2026-09-22 10:08 ` [RFC XEN PATCH 05/13] pytest: Introduce reading the console, and add a test Anthony PERARD
2026-09-22 10:08 ` [RFC XEN PATCH 06/13] We need an older version of paramiko Anthony PERARD
2026-09-22 10:08 ` [RFC XEN PATCH 07/13] pytest: Add random string to look for in the logs Anthony PERARD
2026-09-22 10:08 ` [RFC XEN PATCH 08/13] pytest: Run run-tools-tests over ssh on the test machine Anthony PERARD
2026-09-22 10:08 ` [RFC XEN PATCH 09/13] pytest: Generate a rootfs for a guest Anthony PERARD
2026-09-22 10:08 ` [RFC XEN PATCH 10/13] pytest: Add guest test Anthony PERARD
2026-09-22 10:08 ` [RFC XEN PATCH 11/13] pytest: Add config to enable live log, and disable ssh/paramiko logging Anthony PERARD
2026-09-22 10:08 ` [RFC XEN PATCH 12/13] pytest: Add example .env for options for the tests Anthony PERARD
2026-09-22 10:09 ` [RFC XEN PATCH 13/13] gitlab-ci: Add job for moonshot with pytest Anthony PERARD
2026-09-22 11:01 ` [RFC XEN PATCH 00/13] Running bare-metal tests with "pytest" Marek Marczykowski-Górecki
2026-09-22 14:31 ` Baptiste Le Duc
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=20260922100900.29129-4-anthony@xenproject.org \
--to=anthony@xenproject.org \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=cardoe@cardoe.com \
--cc=marmarek@invisiblethingslab.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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.