Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package virtme for openSUSE:Factory checked in at 2023-04-22 22:03:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/virtme (Old) and /work/SRC/openSUSE:Factory/.virtme.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "virtme" Sat Apr 22 22:03:21 2023 rev:5 rq:1082143 version:0.1.2 Changes: -------- --- /work/SRC/openSUSE:Factory/virtme/virtme.changes 2021-12-28 12:27:12.716510947 +0100 +++ /work/SRC/openSUSE:Factory/.virtme.new.1533/virtme.changes 2023-04-22 22:03:57.898473589 +0200 @@ -1,0 +2,23 @@ +Fri Apr 21 10:21:46 UTC 2023 - Michal Suchanek <[email protected]> + +- Update project URL: https://github.com/arighi/virtme +- Update to version 0.1.2 + - Remove upstreamed patches + - 0001-Add-save-initramfs-to-save-the-actual-generated-init.patch + - 0002-Make-save-initramfs-show-command-output-more-useful.patch + - 0003-Fix-the-error-message-for-mods-misuse.patch + - 0004-Fix-the-mods-error-even-better.patch + - 0005-mkinitramfs.py-Search-for-busybox-.-static-first.patch + - 0006-mkinitramfs-Improve-the-find_busybox-algorithm.patch + - 0007-Add-util.find_binary-to-find-binaries.patch + - 0008-modfinder-Use-find_binary_or_raise-to-find-modprobe.patch + - 0009-Enable-the-Xen-console-when-using-xen.patch + - 0001-configkernel-Add-CONFIG_INOTIFY_USER-y.patch + - 0002-Use-fsdev-multidevs-remap-on-QEMU-4.2.patch + - 0003-Add-more-typing-annotations.patch + - 0004-run.py-Extract-path-file-sanitizing-into-a-new-funct.patch + - 0005-run.py-Introduce-blk-disk-argument.patch + - 0006-Minor-sanitize_disk_args-cleanup.patch + - aarch64-Fix-aarch64-support.patch + +------------------------------------------------------------------- Old: ---- 0001-Add-save-initramfs-to-save-the-actual-generated-init.patch 0001-configkernel-Add-CONFIG_INOTIFY_USER-y.patch 0002-Make-save-initramfs-show-command-output-more-useful.patch 0002-Use-fsdev-multidevs-remap-on-QEMU-4.2.patch 0003-Add-more-typing-annotations.patch 0003-Fix-the-error-message-for-mods-misuse.patch 0004-Fix-the-mods-error-even-better.patch 0004-run.py-Extract-path-file-sanitizing-into-a-new-funct.patch 0005-mkinitramfs.py-Search-for-busybox-.-static-first.patch 0005-run.py-Introduce-blk-disk-argument.patch 0006-Minor-sanitize_disk_args-cleanup.patch 0006-mkinitramfs-Improve-the-find_busybox-algorithm.patch 0007-Add-util.find_binary-to-find-binaries.patch 0008-modfinder-Use-find_binary_or_raise-to-find-modprobe.patch 0009-Enable-the-Xen-console-when-using-xen.patch aarch64-Fix-aarch64-support.patch virtme-0.1.1.tar.gz New: ---- virtme-0.1.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ virtme.spec ++++++ --- /var/tmp/diff_new_pack.vVrnKG/_old 2023-04-22 22:03:58.502477200 +0200 +++ /var/tmp/diff_new_pack.vVrnKG/_new 2023-04-22 22:03:58.502477200 +0200 @@ -1,7 +1,7 @@ # # spec file # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ %define name virtme -%define version 0.1.1 +%define version 0.1.2 %define skip_python2 1 Name: %{name} @@ -26,24 +26,8 @@ Summary: Tools for virtualize the running distro or a rootfs License: GPL-2.0-only Group: Development/Tools/Other -URL: https://git.kernel.org/cgit/utils/kernel/virtme/virtme.git -Source0: https://git.kernel.org/pub/scm/utils/kernel/virtme/virtme.git/snapshot/%{name}-%{version}.tar.gz -Patch1: 0001-Add-save-initramfs-to-save-the-actual-generated-init.patch -Patch2: 0002-Make-save-initramfs-show-command-output-more-useful.patch -Patch3: 0003-Fix-the-error-message-for-mods-misuse.patch -Patch4: 0004-Fix-the-mods-error-even-better.patch -Patch5: 0005-mkinitramfs.py-Search-for-busybox-.-static-first.patch -Patch6: 0006-mkinitramfs-Improve-the-find_busybox-algorithm.patch -Patch7: 0007-Add-util.find_binary-to-find-binaries.patch -Patch8: 0008-modfinder-Use-find_binary_or_raise-to-find-modprobe.patch -Patch9: 0009-Enable-the-Xen-console-when-using-xen.patch -Patch10: 0001-configkernel-Add-CONFIG_INOTIFY_USER-y.patch -Patch11: 0002-Use-fsdev-multidevs-remap-on-QEMU-4.2.patch -Patch12: 0003-Add-more-typing-annotations.patch -Patch13: 0004-run.py-Extract-path-file-sanitizing-into-a-new-funct.patch -Patch14: 0005-run.py-Introduce-blk-disk-argument.patch -Patch15: 0006-Minor-sanitize_disk_args-cleanup.patch -Patch16: aarch64-Fix-aarch64-support.patch +URL: https://github.com/arighi/virtme +Source0: https://github.com/arighi/virtme/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz BuildRequires: %{python_module setuptools} BuildRequires: python-rpm-macros Requires: busybox-static ++++++ virtme-0.1.1.tar.gz -> virtme-0.1.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/README.md new/virtme-0.1.2/README.md --- old/virtme-0.1.1/README.md 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/README.md 2023-04-13 12:09:53.000000000 +0200 @@ -35,6 +35,8 @@ For disk support, you need CONFIG_SCSI_VIRTIO. +For --overlay-rwdir support, you need CONFIG_OVERLAY_FS. + That kernel needs to be sane. Your kernel is probably sane, but allmodconfig and allyesconfig generate insane kernels. Sanity includes: CONFIG_CMDLINE_OVERRIDE=n @@ -56,7 +58,7 @@ Your host system will need to satisfy some prerequisites: -* You need Python 3.3 or higher. +* You need Python 3.8 or higher. * QEMU 1.6 or higher is recommended. QEMU 1.4 and 1.5 are partially supported using a rather ugly kludge. * You will have a much better experience if KVM is enabled. That means that you should be on bare metal with hardware virtualization (VT-x or SVM) enabled or in a VM that supports nested virtualization. On some Linux distributions, you may need to be a member of the "kvm" group. Using VirtualBox or most VPS providers will fall back to emulation. * Depending on the options you use, you may need a statically linked `busybox` binary somewhere in your path. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/bin/virtme-prep-kdir-mods new/virtme-0.1.2/bin/virtme-prep-kdir-mods --- old/virtme-0.1.1/bin/virtme-prep-kdir-mods 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/bin/virtme-prep-kdir-mods 2023-04-13 12:09:53.000000000 +0200 @@ -1,12 +1,6 @@ #!/bin/sh # This is still a bit of an experiment. - -if ! [ -f modules.order ]; then - echo 'virtme-prep-kdir-mods must be run from a kernel build directory' >&2 - exit 1 -fi - FAKEVER=0.0.0 MODDIR=".virtme_mods/lib/modules/$FAKEVER" @@ -15,7 +9,34 @@ # (depmod, etc.). PATH=$PATH:/sbin:/usr/sbin +COPY_MODULES=${COPY_MODULES:-"false"} + +print_help() { + script_name=$(basename "$0") + echo "usage: ${script_name} [-h | --help] [-c | --copy-modules]" + echo "" + echo "optional arguments:" + echo " -h, --help show this help message and exit" + echo " -c, --copy-modules copy kernel instead of linking" +} + +while ":"; do + case "$1" in + -h | --help) + print_help + exit 0 + ;; + -c | --copy-modules) + COPY_MODULES="true" + shift + ;; + *) + break + esac +done + if ! [ -f "modules.order" ]; then + echo 'virtme-prep-kdir-mods must be run from a kernel build directory' >&2 echo "modules.order is missing. Your kernel may be too old or you didn't make modules." >&2 exit 1 fi @@ -29,12 +50,16 @@ # Remove all preexisting symlinks and add symlinks to all modules that belong # to the build kenrnel. find "$MODDIR/kernel" -type l -print0 |xargs -0 rm -f -- -while read -r i; do +# from v6.2, modules.order lists .o files, we need the .ko ones +sed 's:\.o$:.ko:' modules.order | while read -r i; do [ ! -e "$i" ] && i=$(echo "$i" | sed s:^kernel/::) mkdir -p "$MODDIR/kernel/$(dirname "$i")" - ln -sr "$i" "$MODDIR/kernel/$i" -done < modules.order - + if [ "$COPY_MODULES" = "true" ]; then + cp "$i" "$MODDIR/kernel/$i" + else + ln -sr "$i" "$MODDIR/kernel/$i" + fi +done # Link in the files that make modules_install would copy ln -srf modules.builtin modules.builtin.modinfo modules.order "$MODDIR/" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/debian/changelog new/virtme-0.1.2/debian/changelog --- old/virtme-0.1.1/debian/changelog 1970-01-01 01:00:00.000000000 +0100 +++ new/virtme-0.1.2/debian/changelog 2023-04-13 12:09:53.000000000 +0200 @@ -0,0 +1,154 @@ +virtme (0.1.2-1ubuntu1) lunar; urgency=medium + + * Bump minimum python version to 3.8 + * virtme-init: allow root to run sudo + * virtme-configkernel: enable BLK_DEV_INITRD as optional + * virtme-prep-kdir-mods: shellcheck: Remove bashisms + * virtme-prep-kdir-mods: Add --copy-modules argument + * virtme/architectures.py: Fix ppc64le support + * allow user to specify custom qemu binary to run + * virtme-init: exclude /root from systemd-tmpfiles + + -- Andrea Righi <[email protected]> Thu, 13 Apr 2023 07:44:09 +0200 + +virtme (0.1.1-1ubuntu11) lunar; urgency=medium + + * virtme-prep-kdir-mods: support new modules.order format + + -- Andrea Righi <[email protected]> Tue, 28 Mar 2023 08:53:26 +0200 + +virtme (0.1.1-1ubuntu10) lunar; urgency=medium + + * drop .git from source package + + -- Andrea Righi <[email protected]> Wed, 22 Feb 2023 09:07:37 +0100 + +virtme (0.1.1-1ubuntu9) lunar; urgency=medium + + * virtme-configkernel: allow to specify --custom multiple times + + -- Andrea Righi <[email protected]> Wed, 22 Feb 2023 09:03:46 +0100 + +virtme (0.1.1-1ubuntu8) kinetic; urgency=medium + + * virtme-configkernel: fix: set propagated makefile arguments as optional + + -- Andrea Righi <[email protected]> Fri, 10 Feb 2023 12:12:27 +0100 + +virtme (0.1.1-1ubuntu7) kinetic; urgency=medium + + * virtme-configkernel: allow to propagate makefile variable definitions + + -- Andrea Righi <[email protected]> Fri, 10 Feb 2023 09:08:56 +0100 + +virtme (0.1.1-1ubuntu6) kinetic; urgency=medium + + * virtme-configkernel: split mandatory configs vs optional configs + + -- Andrea Righi <[email protected]> Sat, 07 Jan 2023 15:47:22 +0100 + +virtme (0.1.1-1ubuntu5) kinetic; urgency=medium + + * virtme-init: fix resolv.conf symlink path + + -- Andrea Righi <[email protected]> Wed, 14 Dec 2022 09:15:57 +0100 + +virtme (0.1.1-1ubuntu4) kinetic; urgency=medium + + * virtme-init: don't report errors when dirs don't exist in the guest + + -- Andrea Righi <[email protected]> Tue, 13 Dec 2022 14:40:49 +0100 + +virtme (0.1.1-1ubuntu3) kinetic; urgency=medium + + * virtme-configkernel: disable mouse and input interfaces by default + + -- Andrea Righi <[email protected]> Wed, 07 Dec 2022 14:20:12 +0100 + +virtme (0.1.1-1ubuntu2) kinetic; urgency=medium + + * virtme-run: allow to specify --user with --cwd or --pwd + + -- Andrea Righi <[email protected]> Tue, 06 Dec 2022 16:03:12 +0100 + +virtme (0.1.1-1ubuntu1) kinetic; urgency=medium + + * No change, fix version (upstream is 0.1.1) + + -- Andrea Righi <[email protected]> Fri, 02 Dec 2022 13:12:35 +0100 + +virtme (0.0.1-2ubuntu7) kinetic; urgency=medium + + * virtme-run: properly forward stdin with --script-sh + + -- Andrea Righi <[email protected]> Fri, 02 Dec 2022 10:06:57 +0100 + +virtme (0.0.1-2ubuntu6) kinetic; urgency=medium + + * avoid printing kernel.moddir to stdout + + -- Andrea Righi <[email protected]> Thu, 01 Dec 2022 11:33:07 +0100 + +virtme (0.0.1-2ubuntu5) kinetic; urgency=medium + + * architecture: x86: fix qemu watchdog warning + + -- Andrea Righi <[email protected]> Wed, 30 Nov 2022 10:14:06 +0100 + +virtme (0.0.1-2ubuntu4) kinetic; urgency=medium + + * Tunings/improvements for KernelCraft: + - better support for ppc64el and s390x + - try to strip the kernel even more (drop some unnecessary config options) + + -- Andrea Righi <[email protected]> Fri, 25 Nov 2022 15:39:08 +0100 + +virtme (0.0.1-2ubuntu3) kinetic; urgency=medium + + * virtme-configkernel: prioritize having BTF rather than Rust support + + -- Andrea Righi <[email protected]> Thu, 24 Nov 2022 11:30:15 +0100 + +virtme (0.0.1-2ubuntu2) kinetic; urgency=medium + + * Custom features required by kernelcraft: + - virtme-configkernel: re-enable USB support by default + - virtme-configkernel: disable CONFIG_LOCALVERSION_AUTO + - virtme-init: do not break kernel modules setup inside the guest + - virtme-init: allow to use rw overlays without breaking systemd and apt + - virtme-init: connect /root with /tmp/roothome + - virtme-init: allow to use --cwd when --user is not used + - virtme-init: fix always true condition + - virtme-configkernel: introduce option --custom FILE + - virtme-configkernel: disable audit + - virtme-configkernel: disable cpufreq support + - virtme-configkernel: disable security models completely + - virtme-configkernel: make sure BPF is properly supported + + -- Andrea Righi <[email protected]> Wed, 09 Nov 2022 08:34:46 +0100 + +virtme (0.0.1-2ubuntu1) kinetic; urgency=medium + + * Add custom features required by kernelcraft: + - virtme-init: use overlayfs to make /home write-able (as a live snapshot) + - virtme-init: make additional directories required by systemd write-able + - virtme-configkernel: enable Rust support when possible + - virtme-configkernel: enable overlayfs + - virtme-configkernel: drop configs that are not usually required + - virtme-configkernel: make sure debuginfo are available + - virtme-init: make /var/tmp write-able + - virtme-init: add /usr/local/bin to $PATH + + -- Andrea Righi <[email protected]> Sun, 06 Nov 2022 16:46:51 +0100 + +virtme (0.0.1-2) kinetic; urgency=medium + + * Add python3-setuptools dependency + + -- Andrea Righi <[email protected]> Sun, 06 Nov 2022 11:05:47 +0100 + +virtme (0.0.1-1) kinetic; urgency=low + + * Initial build + + -- Andrea Righi <[email protected]> Sat, 05 Nov 2022 10:53:33 +0100 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/debian/compat new/virtme-0.1.2/debian/compat --- old/virtme-0.1.1/debian/compat 1970-01-01 01:00:00.000000000 +0100 +++ new/virtme-0.1.2/debian/compat 2023-04-13 12:09:53.000000000 +0200 @@ -0,0 +1 @@ +11 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/debian/control new/virtme-0.1.2/debian/control --- old/virtme-0.1.1/debian/control 1970-01-01 01:00:00.000000000 +0100 +++ new/virtme-0.1.2/debian/control 2023-04-13 12:09:53.000000000 +0200 @@ -0,0 +1,16 @@ +Source: virtme +Section: misc +Priority: optional +Maintainer: Andrea Righi <[email protected]> +Build-Depends: debhelper (>= 11) +Build-Depends-Indep: dh-python, python3, python3-six, python3-setuptools +Homepage: https://git.kernel.org/cgit/utils/kernel/virtme/virtme.git +Vcs-Git: https://git.kernel.org/cgit/utils/kernel/virtme/virtme.git + +Package: virtme +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, qemu-kvm +Description: Virtualize the running distro or a simple rootfs + Virtme is a set of simple tools to run a virtualized Linux kernel that + uses the host Linux distribution or a simple rootfs instead of a whole + disk image. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/debian/copyright new/virtme-0.1.2/debian/copyright --- old/virtme-0.1.1/debian/copyright 1970-01-01 01:00:00.000000000 +0100 +++ new/virtme-0.1.2/debian/copyright 2023-04-13 12:09:53.000000000 +0200 @@ -0,0 +1,11 @@ +This package was debianized by Andrea Righi <[email protected]> on +Sat, 05 Nov 2022 10:53:33 +0100. + +It was downloaded from https://git.kernel.org/cgit/utils/kernel/virtme/virtme.git + +Upstream Author: Andy Lutomirski <[email protected]> + +Files: * +Copyright: Andy Lutomirski <[email protected]> +License: GPL-2 +Homepage: https://git.kernel.org/cgit/utils/kernel/virtme/virtme.git diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/debian/dirs new/virtme-0.1.2/debian/dirs --- old/virtme-0.1.1/debian/dirs 1970-01-01 01:00:00.000000000 +0100 +++ new/virtme-0.1.2/debian/dirs 2023-04-13 12:09:53.000000000 +0200 @@ -0,0 +1 @@ +usr/bin diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/debian/rules new/virtme-0.1.2/debian/rules --- old/virtme-0.1.1/debian/rules 1970-01-01 01:00:00.000000000 +0100 +++ new/virtme-0.1.2/debian/rules 2023-04-13 12:09:53.000000000 +0200 @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ --with python3 --buildsystem=pybuild diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/setup.py new/virtme-0.1.2/setup.py --- old/virtme-0.1.1/setup.py 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/setup.py 2023-04-13 12:09:53.000000000 +0200 @@ -4,11 +4,11 @@ import sys from setuptools import setup -if sys.version_info < (3,3): - print('virtme requires Python 3.3 or higher') +if sys.version_info < (3,8): + print('virtme requires Python 3.8 or higher') sys.exit(1) -_VERSION = '0.1.1' +_VERSION = '0.1.2' setup( name='virtme', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme/architectures.py new/virtme-0.1.2/virtme/architectures.py --- old/virtme-0.1.1/virtme/architectures.py 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/virtme/architectures.py 2023-04-13 12:09:53.000000000 +0200 @@ -6,9 +6,10 @@ # 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 import os +from typing import List, Optional class Arch(object): - def __init__(self, name): + def __init__(self, name) -> None: self.virtmename = name self.qemuname = name self.linuxname = name @@ -17,40 +18,46 @@ defconfig_target = 'defconfig' @staticmethod - def serial_dev_name(index): + def serial_dev_name(index) -> str: return 'ttyS%d' % index @staticmethod - def qemuargs(is_native): + def qemuargs(is_native) -> List[str]: return [] @staticmethod - def virtio_dev_type(virtiotype): + def virtio_dev_type(virtiotype) -> str: # Return a full name for a virtio device. It would be # nice if QEMU abstracted this away, but it doesn't. return 'virtio-%s-pci' % virtiotype @staticmethod - def earlyconsole_args(): + def earlyconsole_args() -> List[str]: return [] @staticmethod - def serial_console_args(): + def serial_console_args() -> List[str]: return [] @staticmethod - def qemu_nodisplay_args(): + def qemu_nodisplay_args() -> List[str]: return ['-vga', 'none', '-display', 'none'] @staticmethod - def config_base(): + def qemu_serial_console_args() -> List[str]: + # We should be using the new-style -device serialdev,chardev=xyz, + # but many architecture-specific serial devices don't support that. + return ['-serial', 'chardev:console'] + + @staticmethod + def config_base() -> List[str]: return [] - def kimg_path(self): + def kimg_path(self) -> str: return 'arch/%s/boot/bzImage' % self.linuxname @staticmethod - def dtb_path(): + def dtb_path() -> Optional[str]: return None class Arch_unknown(Arch): @@ -70,7 +77,7 @@ ret = Arch.qemuargs(is_native) # Add a watchdog. This is useful for testing. - ret.extend(['-watchdog', 'i6300esb']) + ret.extend(['-device', 'i6300esb,id=watchdog0']) if is_native and os.access('/dev/kvm', os.R_OK): # If we're likely to use KVM, request a full-featured CPU. @@ -164,12 +171,17 @@ def qemuargs(is_native): ret = Arch.qemuargs(is_native) - # Emulate a fully virtual system. - ret.extend(['-M', 'virt']) + if is_native: + ret.extend(['-M', 'virt,gic-version=host']) + ret.extend(['-cpu', 'host']) + else: + # Emulate a fully virtual system. + ret.extend(['-M', 'virt']) + + # Despite being called qemu-system-aarch64, QEMU defaults to + # emulating a 32-bit CPU. Override it. + ret.extend(['-cpu', 'cortex-a57']) - # Despite being called qemu-system-aarch64, QEMU defaults to - # emulating a 32-bit CPU. Override it. - ret.extend(['-cpu', 'cortex-a57']) return ret @@ -188,14 +200,14 @@ def kimg_path(self): return 'arch/arm64/boot/Image' -class Arch_ppc64(Arch): - def __init__(self): - Arch.__init__(self, 'ppc64') +class Arch_ppc(Arch): + def __init__(self, name): + Arch.__init__(self, name) - self.defconfig_target = 'ppc64_defconfig' + self.defconfig_target = 'ppc64e_defconfig' self.qemuname = 'ppc64' self.linuxname = 'powerpc' - self.gccname = 'ppc64' + self.gccname = 'powerpc64le' def qemuargs(self, is_native): ret = Arch.qemuargs(is_native) @@ -204,6 +216,54 @@ return ret + @staticmethod + def config_base(): + return ['CONFIG_PPC64=y', + 'CONFIG_PPC_BOOK3S_64=y', + 'CONFIG_GENERIC_CPU=y', + 'CONFIG_PPC_BOOK3S=y', + 'CONFIG_PPC_FPU_REGS=y', + 'CONFIG_PPC_FPU=y', + 'CONFIG_ALTIVEC=y', + 'CONFIG_VSX=y', + 'CONFIG_PPC_64S_HASH_MMU=y', + 'CONFIG_PPC_RADIX_MMU=y', + 'CONFIG_PPC_RADIX_MMU_DEFAULT=y', + 'CONFIG_PPC_KUEP=y', + 'CONFIG_PPC_KUAP=y', + 'CONFIG_PPC_HAVE_PMU_SUPPORT=y', + 'CONFIG_PPC_PERF_CTRS=y', + 'CONFIG_FORCE_SMP=y', + 'CONFIG_SMP=y', + 'CONFIG_PPC_DOORBELL=y', + 'CONFIG_VDSO32=y', + 'CONFIG_CPU_LITTLE_ENDIAN=y', + 'CONFIG_PPC64_ELF_ABI_V2=y', + 'CONFIG_PPC64_BOOT_WRAPPER=y', + 'CONFIG_64BIT=y', + 'CONFIG_PPC_64K_PAGES=y', + 'CONFIG_PPC_SMLPAR=y', + 'CONFIG_PPC_SUBPAGE_PROT=y', + 'CONFIG_PPC_SVM=y', + 'CONFIG_PPC_TRANSACTIONAL_MEM=y', + 'CONFIG_PPC_UV=y', + 'CONFIG_PPC_WATCHDOG=y', + 'CONFIG_PPC_MEMTRACE=y', + 'CONFIG_PPC_UV=y', + 'CONFIG_PPC_WATCHDOG=y', + 'CONFIG_MEMORY_HOTPLUG=y', + 'CONFIG_VIRTUALIZATION=y', + 'CONFIG_KVM_BOOK3S_64=y', + 'CONFIG_KVM_BOOK3S_64_HV=y', + 'CONFIG_MEMORY_HOTREMOVE=y', + 'CONFIG_ZONE_DEVICE=y', + 'CONFIG_DEVICE_PRIVATE=y', + 'CONFIG_HARDLOCKUP_DETECTOR=y', + 'CONFIG_CRYPTO_MD5_PPC=m', + 'CONFIG_CRYPTO_SHA1_PPC=m', + 'CONFIG_HVC_CONSOLE=y', + ] + def kimg_path(self): # Apparently SLOF (QEMU's bundled firmware?) can't boot a zImage. return 'vmlinux' @@ -275,26 +335,29 @@ # default console ret.extend(['-nodefaults']) - ret.extend(['-device', 'sclpconsole,chardev=console']) - return ret @staticmethod def config_base(): return ['CONFIG_MARCH_Z900=y'] + @staticmethod + def qemu_serial_console_args(): + return ['-device', 'sclpconsole,chardev=console'] + ARCHES = {arch.virtmename: arch for arch in [ Arch_x86('x86_64'), Arch_x86('i386'), Arch_arm(), Arch_aarch64(), - Arch_ppc64(), + Arch_ppc('ppc64'), + Arch_ppc('ppc64le'), Arch_riscv64(), Arch_sparc64(), Arch_s390x(), ]} -def get(arch): +def get(arch: str) -> Arch: if arch in ARCHES: return ARCHES[arch] else: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme/commands/configkernel.py new/virtme-0.1.2/virtme/commands/configkernel.py --- old/virtme-0.1.1/virtme/commands/configkernel.py 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/virtme/commands/configkernel.py 2023-04-13 12:09:53.000000000 +0200 @@ -26,6 +26,9 @@ default=uname.machine, help='Target architecture') + parser.add_argument('--custom', action='append', metavar='CUSTOM', + help='Use a custom config snippet file to override specific config options') + g = parser.add_argument_group(title='Mode').add_mutually_exclusive_group() g.add_argument('--allnoconfig', action='store_true', @@ -37,6 +40,9 @@ g.add_argument('--update', action='store_true', help='Update existing config for virtme') + parser.add_argument('envs', metavar='envs', type=str, nargs='*', + help='Additional Makefile variables') + return parser _ARGPARSER = make_parser() @@ -72,6 +78,7 @@ 'CONFIG_VT=y', 'CONFIG_UNIX98_PTYS=y', 'CONFIG_EARLY_PRINTK=y', + 'CONFIG_INOTIFY_USER=y', '', '# virtio-scsi support', 'CONFIG_BLOCK=y', @@ -87,6 +94,73 @@ 'CONFIG_WATCHDOG=y', 'CONFIG_WATCHDOG_CORE=y', 'CONFIG_I6300ESB_WDT=y', + + '# Make sure debuginfo are available', + 'CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y', + + '# Enable overlayfs', + 'CONFIG_OVERLAY_FS=y', +] + +_GENERIC_CONFIG_OPTIONAL = [ + '# initramfs support', + 'BLK_DEV_INITRD=y', + + '# Provide USB support as module', + 'CONFIG_USB=m' + + '# BPF stuff', + 'CONFIG_BPF=y', + 'CONFIG_BPF_SYSCALL=y', + 'CONFIG_BPF_JIT=y', + 'CONFIG_HAVE_EBPF_JIT=y', + 'CONFIG_BPF_EVENTS=y', + 'CONFIG_FTRACE_SYSCALLS=y', + 'CONFIG_FUNCTION_TRACER=y', + 'CONFIG_HAVE_DYNAMIC_FTRACE=y', + 'CONFIG_DYNAMIC_FTRACE=y', + 'CONFIG_HAVE_KPROBES=y', + 'CONFIG_KPROBES=y', + 'CONFIG_KPROBE_EVENTS=y', + 'CONFIG_ARCH_SUPPORTS_UPROBES=y', + 'CONFIG_UPROBES=y', + 'CONFIG_UPROBE_EVENTS=y', + 'CONFIG_DEBUG_FS=y', + 'CONFIG_DEBUG_INFO_BTF=y', + + '# Useful debugging features', + 'CONFIG_PROVE_LOCKING=y', + + '# Unnecessary configs', + '# CONFIG_LOCALVERSION_AUTO is not set', + '# CONFIG_DRM is not set', + '# CONFIG_SOUND is not set', + '# CONFIG_I2C is not set', + '# CONFIG_INPUT_MOUSE is not set', + '# CONFIG_MOUSE_PS2 is not set', + '# CONFIG_USB_HID is not set', + '# CONFIG_HID is not set', + '# CONFIG_MLX4_EN is not set', + '# CONFIG_MLX5_CORE is not set', + '# CONFIG_NFS_FS is not set', + '# CONFIG_IPV6 is not set', + '# CONFIG_AUDIT is not set', + '# CONFIG_SECURITY is not set', + '# CONFIG_WIRELESS is not set', + '# CONFIG_WLAN is not set', + '# CONFIG_SCHED_MC is not set', + '# CONFIG_CPU_FREQ is not set', + '# CONFIG_INFINIBAND is not set', + '# CONFIG_PPP is not set', + '# CONFIG_PPPOE is not set', + '# CONFIG_EXT2_FS is not set', + '# CONFIG_REISERFS_FS not set', + '# CONFIG_JFS_FS is not set', + '# CONFIG_XFS_FS is not set', + '# CONFIG_BTRFS_FS is not set', + '# CONFIG_HFS_FS is not set', + '# CONFIG_HFSPLUS_FS is not set', + ] def main(): @@ -99,9 +173,17 @@ arch = architectures.get(args.arch) - conf = (_GENERIC_CONFIG + + custom_conf = [] + if args.custom: + for conf_chunk in args.custom: + with open(conf_chunk) as fd: + custom_conf += fd.readlines() + + conf = (_GENERIC_CONFIG_OPTIONAL + ['# Arch-specific options'] + - arch.config_base()) + arch.config_base() + + custom_conf + + _GENERIC_CONFIG) archargs = ['ARCH=%s' % shlex.quote(arch.linuxname)] @@ -112,7 +194,7 @@ if args.allnoconfig: maketarget = 'allnoconfig' - updatetarget = 'silentoldconfig' + updatetarget = 'syncconfig' elif args.defconfig: maketarget = arch.defconfig_target updatetarget = 'olddefconfig' @@ -138,6 +220,10 @@ with open(config, 'ab') as conffile: conffile.write('\n'.join(conf).encode('utf-8')) + # Propagate additional Makefile variables + for var in args.envs: + archargs.append(shlex.quote(var)) + subprocess.check_call(['make'] + archargs + [updatetarget]) print("Configured. Build with 'make %s -j%d'" % diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme/commands/run.py new/virtme-0.1.2/virtme/commands/run.py --- old/virtme-0.1.1/virtme/commands/run.py 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/virtme/commands/run.py 2023-04-13 12:09:53.000000000 +0200 @@ -5,7 +5,7 @@ # as a file called LICENSE with SHA-256 hash: # 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 -from typing import Any, Optional, List, NoReturn, Dict +from typing import Any, Optional, List, NoReturn, Dict, Tuple import argparse import tempfile @@ -71,10 +71,16 @@ help='Allow the host to ask the guest to release memory.') g.add_argument('--disk', action='append', default=[], metavar='NAME=PATH', help='Add a read/write virtio-scsi disk. The device node will be /dev/disk/by-id/scsi-0virtme_disk_NAME.') + g.add_argument('--blk-disk', action='append', default=[], metavar='NAME=PATH', + help='Add a read/write virtio-blk disk. The device nodes will be /dev/disk/by-id/virtio-virtme_disk_blk_NAME.') g.add_argument('--memory', action='store', default=None, help='Set guest memory and qemu -m flag.') + g.add_argument('--cpus', action='store', default=None, + help='Set guest cpu and qemu -smp flag.') g.add_argument('--name', action='store', default=None, help='Set guest hostname and qemu -name flag.') + g.add_argument('--user', action='store', + help='Change guest user') g = parser.add_argument_group( title='Scripting', @@ -94,6 +100,8 @@ help='Use the specified busybox binary.') g = parser.add_argument_group(title='Virtualizer settings') + g.add_argument('--qemu-bin', action='store', default=None, + help="Use specified QEMU binary.") g.add_argument('-q', '--qemu-opt', action='append', default=[], help="Add a single QEMU argument. Use this when --qemu-opts's greedy behavior is problematic.'") g.add_argument('--qemu-opts', action='store', nargs=argparse.REMAINDER, @@ -106,10 +114,12 @@ help="Initialize everything but don't run the guest") g.add_argument('--show-command', action='store_true', help='Show the VM command line') + g.add_argument('--save-initramfs', action='store', + help='Save the generated initramfs to the specified path') g.add_argument('--show-boot-console', action='store_true', help='Show the boot console when running scripts') - g = parser.add_argument_group(title='Guest userspace configuration') + g = parser.add_argument_group(title='Guest userspace configuration').add_mutually_exclusive_group() g.add_argument('--pwd', action='store_true', help='Propagate current working directory to the guest') g.add_argument('--cwd', action='store', @@ -121,6 +131,9 @@ g.add_argument('--rodir', action='append', default=[], help="Supply a read-only directory to the guest. Use --rodir=path or --rodir=guestpath=hostpath.") + g.add_argument('--overlay-rwdir', action='append', default=[], + help="Supply a directory that is r/w to the guest but read-only in the host. Use --overlay-rwdir=path.") + return parser _ARGPARSER = make_parser() @@ -213,7 +226,6 @@ kernel.moddir = os.path.join(virtme_mods, 'lib/modules', '0.0.0') kernel.modfiles = modfinder.find_modules_from_install( virtmods.MODALIASES, root=virtme_mods, kver='0.0.0') - print(kernel.moddir) else: arg_fail("invalid argument '%s', please use --mods=none|use|auto" % args.mods) @@ -222,25 +234,28 @@ kernel.dtb = None else: kernel.dtb = os.path.join(args.kdir, dtb_path) - elif args.mods is not None: - arg_fail("--mods must be used together with --kdir") elif args.kimg is not None: kernel.kimg = args.kimg kernel.modfiles = [] kernel.moddir = None kernel.dtb = None # TODO: fix this + if args.mods != 'use': + arg_fail("--mods is not currently supported properly with --kimg") else: arg_fail('You must specify a kernel to use.') return kernel -def export_virtfs(qemu, arch, qemuargs, path, mount_tag, security_model='none', readonly=True) -> None: +def export_virtfs(qemu: qemu_helpers.Qemu, arch: architectures.Arch, + qemuargs: List[str], path: str, + mount_tag: str, security_model='none', readonly=True) -> None: # NB: We can't use -virtfs for this, because it can't handle a mount_tag # that isn't a valid QEMU identifier. fsid = 'virtfs%d' % len(qemuargs) - qemuargs.extend(['-fsdev', 'local,id=%s,path=%s,security_model=%s%s' % + qemuargs.extend(['-fsdev', 'local,id=%s,path=%s,security_model=%s%s%s' % (fsid, qemu.quote_optarg(path), - security_model, ',readonly' if readonly else '')]) + security_model, ',readonly=on' if readonly else '', + ',multidevs=remap' if qemu.has_multidevs else '')]) qemuargs.extend(['-device', '%s,fsdev=%s,mount_tag=%s' % (arch.virtio_dev_type('9p'), fsid, qemu.quote_optarg(mount_tag))]) def quote_karg(arg: str) -> str: @@ -252,6 +267,19 @@ else: return arg +# Validate name=path arguments from --disk and --blk-disk +def sanitize_disk_args(func: str, arg: str) -> Tuple[str, str]: + namefile = arg.split('=', 1) + if len(namefile) != 2: + arg_fail('invalid argument to %s' % func) + name, fn = namefile + if '=' in fn or ',' in fn: + arg_fail("%s filenames cannot contain '=' or ','" % (func)) + if '=' in name or ',' in name: + arg_fail("%s device names cannot contain '=' or ','" % (func)) + + return name, fn + # Allowed characters in mount paths. We can extend this over time if needed. _SAFE_PATH_PATTERN = '[a-zA-Z0-9_+ /.-]+' _RWDIR_RE = re.compile('^(%s)(?:=(%s))?$' % @@ -263,13 +291,16 @@ arch = architectures.get(args.arch) is_native = (args.arch == uname.machine) - qemu = qemu_helpers.Qemu(arch.qemuname) + qemu = qemu_helpers.Qemu(args.qemu_bin, arch.qemuname) qemu.probe() need_initramfs = args.force_initramfs or qemu.cannot_overmount_virtfs config = mkinitramfs.Config() + if len(args.overlay_rwdir) > 0: + virtmods.MODALIASES.append('overlay') + kernel = find_kernel_and_mods(arch, args) config.modfiles = kernel.modfiles if config.modfiles: @@ -277,6 +308,7 @@ qemuargs: List[str] = [qemu.qemubin] kernelargs = [] + xenargs = [] # Put the '-name' flag first so it's easily visible in ps, top, etc. if args.name: @@ -334,6 +366,9 @@ export_virtfs(qemu, arch, qemuargs, hostpath, tag, readonly=(dirtype != 'rwdir')) kernelargs.append('virtme_initmount%d=%s' % (idx, guestpath)) + for i, d in enumerate(args.overlay_rwdir): + kernelargs.append('virtme_rw_overlay%d=%s' % (i, d)) + # Turn on KVM if available if is_native: qemuargs.extend(['-machine', 'accel=kvm:tcg']) @@ -353,16 +388,20 @@ qemuargs.extend(['-serial', 'none']) qemuargs.extend(['-chardev', 'stdio,id=console,signal=off,mux=on']) - # We should be using the new-style -device serialdev,chardev=xyz, - # but many architecture-specific serial devices don't support that. - qemuargs.extend(['-serial', 'chardev:console']) + qemuargs.extend(arch.qemu_serial_console_args()) qemuargs.extend(['-mon', 'chardev=console']) kernelargs.extend(arch.earlyconsole_args()) - kernelargs.extend(arch.serial_console_args()) qemuargs.extend(arch.qemu_nodisplay_args()) + if not args.xen: + kernelargs.extend(arch.serial_console_args()) + else: + # Horrible special case + xenargs.extend(['console=com1']) + kernelargs.extend(['xencons=hvc', 'console=hvc0']) + # PS/2 probing is slow; give the kernel a hint to speed it up. kernelargs.extend(['psmouse.proto=exps']) @@ -388,25 +427,28 @@ if args.memory: qemuargs.extend(['-m', args.memory]) + if args.cpus: + qemuargs.extend(['-smp', args.cpus]) + + if args.blk_disk: + for i,d in enumerate(args.blk_disk): + driveid = 'blk-disk%d' % i + name, fn = sanitize_disk_args('--blk-disk', d) + qemuargs.extend(['-drive', 'if=none,id=%s,file=%s' % (driveid, fn), + '-device', 'virtio-blk-pci,drive=%s,serial=%s' % (driveid, name)]) + if args.disk: qemuargs.extend(['-device', '%s,id=scsi' % arch.virtio_dev_type('scsi')]) for i,d in enumerate(args.disk): - namefile = d.split('=', 1) - if len(namefile) != 2: - arg_fail('invalid argument to --disk') - name,fn = namefile - if '=' in fn or ',' in fn: - arg_fail("--disk filenames cannot contain '=' or ','") - if '=' in name or ',' in name: - arg_fail("--disk device names cannot contain '=' or ','") driveid = 'disk%d' % i + name, fn = sanitize_disk_args('--disk', d) qemuargs.extend(['-drive', 'if=none,id=%s,file=%s' % (driveid, fn), '-device', 'scsi-hd,drive=%s,vendor=virtme,product=disk,serial=%s' % (driveid, name)]) has_script = False - def do_script(shellcmd, use_exec=False, show_boot_console=False): + def do_script(shellcmd: str, use_exec=False, show_boot_console=False) -> None: if args.graphics: arg_fail('scripts and --graphics are mutually exclusive') @@ -434,9 +476,13 @@ 'earlyprintk=serial,%s,115200' % serdev]) # Set up a virtserialport for script I/O - qemuargs.extend(['-chardev', 'stdio,id=stdio,signal=on,mux=off']) + qemuargs.extend(['-chardev', 'stdio,id=stdin,signal=on,mux=off']) + qemuargs.extend(['-device', arch.virtio_dev_type('serial')]) + qemuargs.extend(['-device', 'virtserialport,name=virtme.stdin,chardev=stdin']) + + qemuargs.extend(['-chardev', 'file,id=stdout,path=/proc/self/fd/1']) qemuargs.extend(['-device', arch.virtio_dev_type('serial')]) - qemuargs.extend(['-device', 'virtserialport,name=virtme.scriptio,chardev=stdio']) + qemuargs.extend(['-device', 'virtserialport,name=virtme.stdout,chardev=stdout']) # Scripts shouldn't reboot qemuargs.extend(['-no-reboot']) @@ -501,6 +547,9 @@ return 1 kernelargs.append('virtme_chdir=%s' % rel_cwd) + if args.user: + kernelargs.append('virtme_user=%s' % args.user) + initrdpath: Optional[str] if need_initramfs: @@ -518,14 +567,26 @@ config.access = 'rw' # Set up the initramfs (warning: hack ahead) - tmpfd,tmpname = tempfile.mkstemp('irfs') - os.unlink(tmpname) - tmpfile = os.fdopen(tmpfd, 'r+b') - mkinitramfs.mkinitramfs(tmpfile, config) - tmpfile.flush() - fcntl.fcntl(tmpfd, fcntl.F_SETFD, 0) - initrdpath = '/proc/self/fd/%d' % tmpfile.fileno() + if args.save_initramfs is not None: + initramfsfile = open(args.save_initramfs, 'xb') + initramfsfd = initramfsfile.fileno() + else: + initramfsfd,tmpname = tempfile.mkstemp('irfs') + os.unlink(tmpname) + initramfsfile = os.fdopen(initramfsfd, 'r+b') + mkinitramfs.mkinitramfs(initramfsfile, config) + initramfsfile.flush() + if args.save_initramfs is not None: + initrdpath = args.save_initramfs + else: + fcntl.fcntl(initramfsfd, fcntl.F_SETFD, 0) + initrdpath = '/proc/self/fd/%d' % initramfsfd else: + if args.save_initramfs is not None: + print('--save_initramfs specified but initramfs is not used', + file=sys.stderr) + return 1 + # No initramfs! Warning: this is slower than using an initramfs # because the kernel will wait for device probing to finish. # Sigh. @@ -560,9 +621,15 @@ qemuargs.extend(['-initrd', initrdpath]) if kernel.dtb is not None: qemuargs.extend(['-dtb', kernel.dtb]) + + if xenargs: + raise ValueError("Can't pass Xen any arguments if we're not using Xen") else: # Use multiboot syntax to load Xen qemuargs.extend(['-kernel', args.xen]) + if xenargs: + qemuargs.extend(['-append', + ' '.join(quote_karg(a) for a in xenargs)]) qemuargs.extend(['-initrd', '%s %s%s' % ( kernel.kimg, ' '.join(quote_karg(a).replace(',', ',,') for a in kernelargs), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme/guest/virtme-init new/virtme-0.1.2/virtme/guest/virtme-init --- old/virtme-0.1.1/virtme/guest/virtme-init 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/virtme/guest/virtme-init 2023-04-13 12:09:53.000000000 +0200 @@ -5,7 +5,7 @@ # as a file called LICENSE with SHA-256 hash: # 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 -export PATH=/bin:/sbin:/usr/bin:/usr/sbin +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin log() { if [[ -e /dev/kmsg ]]; then @@ -25,6 +25,20 @@ mount_tags["`sed '$s/\x00$//;' "$i"`"]=1 done +# Setup rw filesystem overlays +mount -t tmpfs tmpfs /tmp/ + +for tag in "${!virtme_rw_overlay@}"; do + td=`mktemp -d` + dir="${!tag}" + mount -t tmpfs none "$td" + mkdir "$td/cow" "$td/work" + mount -t overlay -o "lowerdir=$dir,upperdir=$td/cow,workdir=$td/work" cow "$dir" + umount "$td" + rmdir "$td" +done + +# Setup kernel modules kver="`uname -r`" if [[ -n "$virtme_root_mods" ]]; then @@ -38,14 +52,33 @@ mount -n -t tmpfs -o ro,mode=0000 disallow_modules "/lib/modules/$kver" fi -mount -t tmpfs tmpfs /tmp/ -[[ -w /var/log ]] || mount -t tmpfs tmpfs /var/log/ +# Setup rw tmpfs directories +[ -e /var/log ] && mount -t tmpfs tmpfs /var/log/ +[ -e /var/tmp ] && mount -t tmpfs tmpfs /var/tmp/ + +# Additional rw dirs used by systemd +[ -e /var/spool/rsyslog ] && mount -t tmpfs tmpfs /var/spool/rsyslog +[ -e /var/lib/portables ] && mount -t tmpfs tmpfs /var/lib/portables +[ -e /var/lib/machines ] && mount -t tmpfs tmpfs /var/lib/machines +[ -e /var/lib/private ] && mount -t tmpfs tmpfs /var/lib/private +[ -e /var/cache/private ] && mount -t tmpfs tmpfs /var/cache/private + +# Additional rw dirs required by apt +[ -e /var/lib/apt ] && mount -t tmpfs tmpfs /var/lib/apt +[ -e /var/cache ] && mount -t tmpfs tmpfs /var/cache # Fix up /etc a little bit touch /tmp/fstab mount --bind /tmp/fstab /etc/fstab rm /tmp/fstab +# Populate dummy entries in /etc/shadow to allow switching to any user defined +# in the system +(umask 0644 && touch /tmp/shadow) +sed -e 's/^\([^:]\+\).*/\1:!:::::::/' < /etc/passwd > /tmp/shadow +mount --bind /tmp/shadow /etc/shadow +rm /tmp/shadow + # Find udevd if [[ -x /usr/lib/systemd/systemd-udevd ]]; then udevd=/usr/lib/systemd/systemd-udevd @@ -86,7 +119,7 @@ mount -t 9p -o version=9p2000.L,trans=virtio,access=any "virtme.initmount${tag:16}" "${!tag}" || exit 1 done -if [[ -n "virtme_chdir" ]]; then +if [[ -n "${virtme_chdir}" ]]; then cd -- "${virtme_chdir}" fi @@ -97,7 +130,7 @@ # Does the system use systemd-tmpfiles? tmpfiles=`which systemd-tmpfiles 2>/dev/null` && { log "running systemd-tmpfiles" - systemd-tmpfiles --create --boot --exclude-prefix="/dev" + systemd-tmpfiles --create --boot --exclude-prefix="/dev" --exclude-prefix="/root" } # Make dbus work (if tmpfiles wasn't there or didn't create the directory). @@ -156,10 +189,20 @@ # Bring up networking ip link set dev lo up +if [[ -n "virtme_user" ]]; then + real_sudoers=/etc/sudoers + tmpfile="`mktemp --tmpdir=/tmp`" + echo "root ALL = (ALL) NOPASSWD: ALL" > $tmpfile + echo "${virtme_user} ALL = (ALL) NOPASSWD: ALL" >> $tmpfile + chmod 440 "$tmpfile" + mount --bind "$tmpfile" "$real_sudoers" + rm "$tmpfile" +fi + if cat /proc/cmdline |grep -q -E '(^| )virtme.dhcp($| )'; then real_resolv_conf=/etc/resolv.conf if [[ -L "$real_resolv_conf" ]]; then - real_resolv_conf="`readlink /etc/resolv.conf`" + real_resolv_conf="/`readlink /etc/resolv.conf`" if [[ ! -e $real_resolv_conf ]]; then mkdir -p "`dirname $real_resolv_conf`" touch $real_resolv_conf @@ -178,14 +221,14 @@ fi if [[ -x /run/virtme/data/script ]]; then - if [[ ! -e "/dev/virtio-ports/virtme.scriptio" ]]; then - echo "virtme-init: cannot find script I/O port; make sure virtio-serial is available" + if [[ ! -e "/dev/virtio-ports/virtme.stdin" || ! -e "/dev/virtio-ports/virtme.stdout" ]]; then + echo "virtme-init: cannot find script I/O ports; make sure virtio-serial is available" poweroff -f exit 1 fi log 'starting script' - setsid /run/virtme/data/script <>/dev/virtio-ports/virtme.scriptio 1>&0 2>&0 + setsid /run/virtme/data/script </dev/virtio-ports/virtme.stdin >/dev/virtio-ports/virtme.stdout 2>&1 log "script returned $?" # Hmm. We should expose the return value somehow. @@ -225,6 +268,7 @@ # Set up a basic environment install -d -m 0755 /tmp/roothome export HOME=/tmp/roothome +mount --bind /tmp/roothome /root # Bring up a functioning shell on the console. This is a bit magical: # We have no controlling terminal because we're attached to a fake @@ -237,8 +281,11 @@ if [[ -n "${virtme_stty_con}" ]]; then stty ${virtme_stty_con} <"/dev/$consdev" fi - - setsid bash 0<>"/dev/$consdev" 1>&0 2>&0 + if [[ -n "${virtme_user}" ]]; then + setsid bash -c "su ${virtme_user}" 0<>"/dev/$consdev" 1>&0 2>&0 + else + setsid bash 0<>"/dev/$consdev" 1>&0 2>&0 + fi echo "Shell died. Will respawn." sleep 0.5 done diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme/mkinitramfs.py new/virtme-0.1.2/virtme/mkinitramfs.py --- old/virtme-0.1.1/virtme/mkinitramfs.py 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/virtme/mkinitramfs.py 2023-04-13 12:09:53.000000000 +0200 @@ -13,6 +13,7 @@ import shlex import itertools from . import cpiowriter +from . import util def make_base_layout(cw): for dir in (b'lib', b'bin', b'var', b'etc', b'newroot', b'dev', b'proc', @@ -167,16 +168,5 @@ cw.write_trailer() def find_busybox(root, is_native) -> Optional[str]: - for p in itertools.product(['usr/local', 'usr', ''], - ['bin', 'sbin'], - ['', '-static', '.static']): - path = os.path.join(root, p[0], p[1], 'busybox' + p[2]) - if os.path.isfile(path): - return path - - if is_native: - # Try the host's busybox, if any - return shutil.which('busybox') - - # We give up. - return None + return util.find_binary(['busybox-static', 'busybox.static', 'busybox'], + root=root, use_path=is_native) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme/modfinder.py new/virtme-0.1.2/virtme/modfinder.py --- old/virtme-0.1.1/virtme/modfinder.py 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/virtme/modfinder.py 2023-04-13 12:09:53.000000000 +0200 @@ -14,16 +14,16 @@ from typing import List import re -import shutil import subprocess -import os, os.path +import os import itertools +from . import util _INSMOD_RE = re.compile('insmod (.*[^ ]) *$') def resolve_dep(modalias, root=None, kver=None, moddir=None): # /usr/sbin might not be in the path, and modprobe is usually in /usr/sbin - modprobe = shutil.which('modprobe') or '/usr/sbin/modprobe' + modprobe = util.find_binary_or_raise(['modprobe']) args = [modprobe, '--show-depends'] args += ['-C', '/var/empty'] if root is not None: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme/qemu_helpers.py new/virtme-0.1.2/virtme/qemu_helpers.py --- old/virtme-0.1.1/virtme/qemu_helpers.py 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/virtme/qemu_helpers.py 2023-04-13 12:09:53.000000000 +0200 @@ -9,28 +9,42 @@ import re import shutil import subprocess +from typing import Optional class Qemu(object): - def __init__(self, arch): + qemubin: str + version: Optional[str] + + def __init__(self, qemubin, arch) -> None: self.arch = arch - qemubin = shutil.which('qemu-system-%s' % arch) - if qemubin is None and arch == os.uname().machine: - qemubin = shutil.which('qemu-kvm') - if qemubin is None: - raise ValueError('cannot find qemu for %s' % arch) + if not qemubin: + qemubin = shutil.which('qemu-system-%s' % arch) + if qemubin is None and arch == os.uname().machine: + qemubin = shutil.which('qemu-kvm') + if qemubin is None: + raise ValueError('cannot find qemu for %s' % arch) + else: + if not os.path.isfile(qemubin): + raise ValueError('specified qemu binary "%s" does not exist' % qemubin) + if not os.access(qemubin, os.X_OK): + raise ValueError('specified qemu binary "%s" is not executable' % qemubin) self.qemubin = qemubin self.version = None - def probe(self): + def probe(self) -> None: if self.version is None: self.version = subprocess.check_output([self.qemubin, '--version'])\ .decode('utf-8') self.cannot_overmount_virtfs = ( re.search(r'version 1\.[012345]', self.version) is not None) - def quote_optarg(self, a): + # QEMU 4.2+ supports -fsdev multidevs=remap + self.has_multidevs = ( + re.search(r'version (?:1\.|2\.|3\.|4\.[01][^\d])', self.version) is None) + + def quote_optarg(self, a: str) -> str: """Quote an argument to an option.""" return a.replace(',', ',,') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme/util.py new/virtme-0.1.2/virtme/util.py --- old/virtme-0.1.1/virtme/util.py 1970-01-01 01:00:00.000000000 +0100 +++ new/virtme-0.1.2/virtme/util.py 2023-04-13 12:09:53.000000000 +0200 @@ -0,0 +1,40 @@ +# -*- mode: python -*- +# util.py: Misc helpers +# Copyright © 2014-2019 Andy Lutomirski +# Licensed under the GPLv2, which is available in the virtme distribution +# as a file called LICENSE with SHA-256 hash: +# 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 + +from typing import Optional, Sequence + +import os +import shutil +import itertools + +def find_binary(names: Sequence[str], root: str = '/', + use_path: bool = True) -> Optional[str]: + dirs = [os.path.join(*i) for i in itertools.product( + ['usr/local', 'usr', ''], + ['bin', 'sbin'])] + + for n in names: + if use_path: + # Search PATH first + path = shutil.which(n) + if path is not None: + return path + + for d in dirs: + path = os.path.join(root, d, n) + if os.path.isfile(path): + return path + + # We give up. + return None + +def find_binary_or_raise(names: Sequence[str], root: str = '/', + use_path: bool = True) -> str: + ret = find_binary(names, root=root, use_path=use_path) + if ret is None: + raise RuntimeError('Could not find %r' % names) + return ret diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme-configkernel new/virtme-0.1.2/virtme-configkernel --- old/virtme-0.1.1/virtme-configkernel 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/virtme-configkernel 2023-04-13 12:09:53.000000000 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- mode: python -*- # virtme-configkernel: Configure a kernel for virtme # Copyright © 2014 Andy Lutomirski @@ -10,8 +10,8 @@ # a source distribution. import sys -if sys.version_info < (3,3): - print('virtme requires Python 3.3 or higher') +if sys.version_info < (3,8): + print('virtme requires Python 3.8 or higher') sys.exit(1) from virtme.commands import configkernel diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme-mkinitramfs new/virtme-0.1.2/virtme-mkinitramfs --- old/virtme-0.1.1/virtme-mkinitramfs 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/virtme-mkinitramfs 2023-04-13 12:09:53.000000000 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- mode: python -*- # virtme-mkinitramfs: Generate an initramfs image for virtme # Copyright © 2019 Marcos Paulo de Souza @@ -7,8 +7,8 @@ # 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 import sys -if sys.version_info < (3,3): - print('virtme requires Python 3.3 or higher') +if sys.version_info < (3,8): + print('virtme requires Python 3.8 or higher') sys.exit(1) from virtme.commands import mkinitramfs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virtme-0.1.1/virtme-run new/virtme-0.1.2/virtme-run --- old/virtme-0.1.1/virtme-run 2019-10-10 19:38:21.000000000 +0200 +++ new/virtme-0.1.2/virtme-run 2023-04-13 12:09:53.000000000 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- mode: python -*- # virtme-run: The main command-line virtme frontend # Copyright © 2014 Andy Lutomirski @@ -10,8 +10,8 @@ # a source distribution. import sys -if sys.version_info < (3,3): - print('virtme requires Python 3.3 or higher') +if sys.version_info < (3,8): + print('virtme requires Python 3.8 or higher') sys.exit(1) from virtme.commands import run
