Skip to contentSkip to conversation

qemu-helper: depend on unfs3 and pseudo directly

PATCH Superseded Alexander Kanavin 2 participants 6 messages Nov 25, 2022 – Nov 28, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 qemu-helper: depend on unfs3 and pseudo directly

Dependencies of runqemu belong in qemu-helper; in particular there is no reason to scatter unfs3 all over the place, and then require separate steps to make it available (e.g. 'meta-ide-support').

With this, startng runqemu with a nfs mount starts to 'just work' after building an image.

---
 meta/recipes-core/meta/meta-extsdk-toolchain.bb           | 2 +-
 meta/recipes-core/meta/meta-ide-support.bb                | 2 +-
 .../packagegroups/nativesdk-packagegroup-sdk-host.bb      | 1 -
 meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb   | 2 +-
 meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb      | 2 +-
 scripts/runqemu-export-rootfs                             | 8 ++------
 scripts/runqemu-extract-sdk                               | 2 +-
 7 files changed, 7 insertions(+), 12 deletions(-)
meta/recipes-core/meta/meta-extsdk-toolchain.bb +1 -1
index 0df681ac73..618b596e4d 100644
@@ -2,7 +2,7 @@ SUMMARY = "Extensible SDK toolchain meta-recipe"
 DESCRIPTION = "Meta-recipe for ensuring the build directory contains all appropriate toolchain packages for using an IDE"
 LICENSE = "MIT"
 
-DEPENDS = "virtual/libc gdb-cross-${TARGET_ARCH} qemu-native qemu-helper-native unfs3-native"
+DEPENDS = "virtual/libc gdb-cross-${TARGET_ARCH} qemu-native qemu-helper-native"
 
 do_populate_sysroot[deptask] = "do_populate_sysroot"
 
meta/recipes-core/meta/meta-ide-support.bb +1 -1
index 7f349f673d..dd11b5673c 100644
@@ -2,7 +2,7 @@ SUMMARY = "Integrated Development Environment support"
 DESCRIPTION = "Meta package for ensuring the build directory contains all appropriate toolchain packages for using an IDE"
 LICENSE = "MIT"
 
-DEPENDS = "virtual/libc gdb-cross-${TARGET_ARCH} qemu-native qemu-helper-native unfs3-native cmake-native autoconf-native automake-native meson-native intltool-native pkgconfig-native"
+DEPENDS = "virtual/libc gdb-cross-${TARGET_ARCH} qemu-native qemu-helper-native cmake-native autoconf-native automake-native meson-native intltool-native pkgconfig-native"
 PR = "r3"
 RM_WORK_EXCLUDE += "${PN}"
 
meta/recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bb +0 -1
index 9166a0851f..84ee1e3fa1 100644
@@ -16,7 +16,6 @@ RDEPENDS:${PN} = "\
     nativesdk-qemu \
     nativesdk-qemu-helper \
     nativesdk-pseudo \
-    nativesdk-unfs3 \
     nativesdk-opkg \
     nativesdk-libtool \
     nativesdk-autoconf \
meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb +1 -1
index abba7fe159..2a5bcfb909 100644
@@ -1,6 +1,6 @@
 SUMMARY = "Qemu helper scripts"
 LICENSE = "GPL-2.0-only"
-RDEPENDS:${PN} = "nativesdk-qemu \
+RDEPENDS:${PN} = "nativesdk-qemu nativesdk-unfs3 nativesdk-pseudo \
                   nativesdk-python3-shell nativesdk-python3-fcntl nativesdk-python3-logging \
                 "
 
meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb +1 -1
index e297586bbb..6053b71717 100644
@@ -25,5 +25,5 @@ do_install() {
 	install qemu-oe-bridge-helper ${D}${bindir}/
 }
 
-DEPENDS += "qemu-system-native"
+DEPENDS += "qemu-system-native unfs3-native pseudo-native"
 addtask addto_recipe_sysroot after do_populate_sysroot before do_build
scripts/runqemu-export-rootfs +2 -6
index c1fff7fcb3..6a8acd0d5a 100755
@@ -34,16 +34,12 @@ if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then
 	echo "Did you forget to source your build environment setup script?"
 	exit 1
 fi
-. $SYSROOT_SETUP_SCRIPT meta-ide-support
+. $SYSROOT_SETUP_SCRIPT qemu-helper-native
 
 if [ ! -e "$OECORE_NATIVE_SYSROOT/usr/bin/unfsd" ]; then
 	echo "Error: Unable to find unfsd binary in $OECORE_NATIVE_SYSROOT/usr/bin/"
 
-	if [ "x$OECORE_DISTRO_VERSION" = "x" ]; then
-		echo "Have you run 'bitbake meta-ide-support'?"
-	else
-		echo "This shouldn't happen - something is missing from your toolchain installation"
-	fi
+	echo "This shouldn't happen - something is missing from your toolchain installation"
 	exit 1
 fi
 
scripts/runqemu-extract-sdk +1 -1
index 9bc0c07fb8..db05da25f2 100755
@@ -25,7 +25,7 @@ if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then
 	echo "Did you forget to source your build system environment setup script?"
 	exit 1
 fi
-. $SYSROOT_SETUP_SCRIPT meta-ide-support
+. $SYSROOT_SETUP_SCRIPT qemu-helper-native
 PSEUDO_OPTS="-P $OECORE_NATIVE_SYSROOT/usr"
 
 ROOTFS_TARBALL=$1
Signature · 1 line
2.30.2
#1 lore raw

PATCH 2/3 runqemu: do not hardcode the ip address of the nfs server when using tap

Rather, set it similarly to the overall network config.

---
 scripts/runqemu | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/runqemu +2 -1
index 7bd9465593..04728673de 100755
@@ -999,7 +999,7 @@ class BaseConfig(object):
             if self.slirp_enabled:
                 self.nfs_server = '10.0.2.2'
             else:
-                self.nfs_server = '192.168.7.1'
+                self.nfs_server = '192.168.7.@GATEWAY@'
 
         # Figure out a new nfs_instance to allow multiple qemus running.
         ps = subprocess.check_output(("ps", "auxww")).decode('utf-8')
@@ -1187,6 +1187,7 @@ class BaseConfig(object):
         netconf = " " + self.cmdline_ip_tap
         netconf = netconf.replace('@CLIENT@', str(client))
         netconf = netconf.replace('@GATEWAY@', str(gateway))
+        self.nfs_server = self.nfs_server.replace('@GATEWAY@', str(gateway))
         logger.info("Network configuration:%s", netconf)
         self.kernel_cmdline_script += netconf
         mac = "%s%02x" % (self.mac_tap, client)
Signature · 1 line
2.30.2
#2 lore raw

PATCH 3/3 selftest/runqemu: reenable the nfs rootfs test

In reply to Alexander Kanavin

With the previous fixes the test can be run again, and it doesn't need all those extra steps. Runqemu takes care of everything automatically now.

---
 meta/lib/oeqa/selftest/cases/runqemu.py | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
meta/lib/oeqa/selftest/cases/runqemu.py +2 -12
index 58a4526df6..c2c3fbc924 100644
@@ -199,22 +199,12 @@ class QemuTest(OESelftestTestCase):
             qemu_shutdown_succeeded = self._start_qemu_shutdown_check_if_shutdown_succeeded(qemu, shutdown_timeout)
             self.assertTrue(qemu_shutdown_succeeded, 'Failed: %s does not shutdown within timeout(%s)' % (self.machine, shutdown_timeout))
 
-    # Need to have portmap/rpcbind running to allow this test to work and
-    # current autobuilder setup does not have this.
-    def disabled_test_qemu_can_boot_nfs_and_shutdown(self):
-        self.assertExists(self.qemuboot_conf)
-        bitbake('meta-ide-support')
+    def test_qemu_can_boot_nfs_and_shutdown(self):
         rootfs_tar = "%s-%s.tar.bz2" % (self.recipe, self.machine)
         rootfs_tar = os.path.join(self.deploy_dir_image, rootfs_tar)
         self.assertExists(rootfs_tar)
-        tmpdir = tempfile.mkdtemp(prefix='qemu_nfs')
-        tmpdir_nfs = os.path.join(tmpdir, 'nfs')
-        cmd_extract_nfs = 'runqemu-extract-sdk %s %s' % (rootfs_tar, tmpdir_nfs)
-        result = runCmd(cmd_extract_nfs)
-        self.assertEqual(0, result.status, "runqemu-extract-sdk didn't run as expected. %s" % result.output)
-        cmd = "%s nfs %s %s" % (self.cmd_common, self.qemuboot_conf, tmpdir_nfs)
+        cmd = "%s %s" % (self.cmd_common, rootfs_tar)
         shutdown_timeout = 120
         with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
             qemu_shutdown_succeeded = self._start_qemu_shutdown_check_if_shutdown_succeeded(qemu, shutdown_timeout)
             self.assertTrue(qemu_shutdown_succeeded, 'Failed: %s does not shutdown within timeout(%s)' % (self.machine, shutdown_timeout))
-        runCmd('rm -rf %s' % tmpdir)
Signature · 1 line
2.30.2
#3 lore raw
In reply to Alexander Kanavin
Quoted 3 lines · Alexander Kanavin

Dependencies of runqemu belong in qemu-helper; in particular there is no reason to scatter unfs3 all over the place, and then require separate steps to make it available (e.g. 'meta-ide-support').

NFS isn't really a dependency of qemu though. The thinking here was that you could boot a real board onto an NFS mount from your local system for development purposes. That is why it was being included as an SDK tool.

Perhaps we should just add it to qemu helper as well to simplify the runqemu case?

Cheers,

Richard

#4 lore raw
Quoted 7 lines · Richard Purdie

NFS isn't really a dependency of qemu though. The thinking here was that you could boot a real board onto an NFS mount from your local system for development purposes. That is why it was being included as an SDK tool.

Perhaps we should just add it to qemu helper as well to simplify the runqemu case?

I'm fine with that, just want to point out that commit history does not have this justification - meta-* additions of nfs server dependency specifically talk about qemu only, and sdk packagegroup commit [1] does not describe the use case. I don't think there's a BSP where this way of booting is officially supported and documented.

[1] https://git.yoctoproject.org/poky/commit/?h=master-next&id=b5b3825ce6df45b16e1f3e15001da213bc8b0a55

Alex

#5 lore raw
Quoted 7 lines · Alexander Kanavin
Quoted 5 lines · Richard Purdie

NFS isn't really a dependency of qemu though. The thinking here was that you could boot a real board onto an NFS mount from your local system for development purposes. That is why it was being included as an SDK tool.

Quoted 7 lines
Quoted 2 lines

Perhaps we should just add it to qemu helper as well to simplify the runqemu case?

I'm fine with that, just want to point out that commit history does not have this justification - meta-* additions of nfs server dependency specifically talk about qemu only, and sdk packagegroup commit [1] does not describe the use case.

Some of our older commits don't have the right information in sadly, it is something we've had to work on and still don't always get right. I did think I was likely going to be at fault until I looked! :) That is partly why I'm adding some context around it.

Quoted 2 lines

I don't think there's a BSP
where this way of booting is officially supported and documented.

Maybe not but I have done it myself before, admittedly a long time ago. The key question is whether it is a useful capability and worth maintaining. I'd say that yes, in this case it is, particularly if we can raise the profile of the feature and make sure it continues to work (which the tests you're enabling help massively with).

Cheers,

Richard