Skip to contentSkip to conversation

qemu-helper: depend on unfs3 and pseudo directly

PATCH New Alexander Kanavin 1 participant 3 messages Nov 28, 2022

lore
Share & tools
lore
#0 lore raw

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

The eliminates having to do extra steps (e.g. meta-ide-support) when booting an image with a nfs mount as rootfs - startng runqemu with a nfs mount starts to 'just work' after building an image.

---
 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 +-
 4 files changed, 5 insertions(+), 9 deletions(-)
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 v2 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 v2 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