Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package virtme for openSUSE:Factory checked in at 2021-11-17 01:13:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/virtme (Old) and /work/SRC/openSUSE:Factory/.virtme.new.1890 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "virtme" Wed Nov 17 01:13:45 2021 rev:3 rq:931598 version:0.1.1 Changes: -------- --- /work/SRC/openSUSE:Factory/virtme/virtme.changes 2019-10-25 18:43:01.375948334 +0200 +++ /work/SRC/openSUSE:Factory/.virtme.new.1890/virtme.changes 2021-11-17 01:14:43.690182778 +0100 @@ -1,0 +2,33 @@ +Thu Nov 12 08:24:10 UTC 2020 - Matthias Brugger <[email protected]> + +- Update patch for aarch64 support. Does not break full emulation case. + +------------------------------------------------------------------- +Fri Oct 30 11:09:02 UTC 2020 - Matthias Brugger <[email protected]> + +- Add patch to fix aarch64 native support. + * aarch64-Fix-aarch64-support.patch + +------------------------------------------------------------------- +Wed Jul 22 01:14:28 UTC 2020 - Marcos de Souza <[email protected]> + +- Add patches to include some fixes and the new --blk-disk feature + * 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 +- Drop outdated patch: + * 0001-mkinitramfs.py-Search-for-busybox-.-static-first.patch + +------------------------------------------------------------------- Old: ---- 0001-mkinitramfs.py-Search-for-busybox-.-static-first.patch New: ---- 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 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ virtme.spec ++++++ --- /var/tmp/diff_new_pack.kDWgQ2/_old 2021-11-17 01:14:44.250182987 +0100 +++ /var/tmp/diff_new_pack.kDWgQ2/_new 2021-11-17 01:14:44.254182989 +0100 @@ -1,7 +1,7 @@ # -# spec file for package virtme +# spec file # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -26,11 +26,26 @@ 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 +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-mkinitramfs.py-Search-for-busybox-.-static-first.patch +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 BuildRequires: %{python_module setuptools} -BuildRequires: python-rpm-macros +#BuildRequires: python-rpm-macros Requires: busybox-static Requires: qemu BuildArch: noarch @@ -52,8 +67,7 @@ find . -name __pycache__ -type d -exec rm -fr {} + %install -export PYTHONDONTWRITEBYTECODE=1 -%py3_install +export PYTHONDONTWRITEBYTECODE=1 %py3_install %files %{_bindir}/virtme-configkernel ++++++ 0001-Add-save-initramfs-to-save-the-actual-generated-init.patch ++++++ >From d2438fe1ba0c379a50bcd01bd310c7a310242ca6 Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Wed, 16 Oct 2019 10:39:18 -0700 Subject: [PATCH 1/9] Add --save-initramfs to save the actual generated initramfs Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/commands/run.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 78782ca..7526dea 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -106,6 +106,8 @@ def make_parser() -> argparse.ArgumentParser: 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') @@ -518,14 +520,23 @@ def do_it() -> int: 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() + 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. -- 2.26.2 ++++++ 0001-configkernel-Add-CONFIG_INOTIFY_USER-y.patch ++++++ >From 6f355aab0ddb7edc5fedbd3fd06935827ba2dc6e Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Sun, 19 Jul 2020 10:13:08 -0700 Subject: [PATCH 1/6] configkernel: Add CONFIG_INOTIFY_USER=y Per #34, this fixes udev. Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/commands/configkernel.py | 1 + 1 file changed, 1 insertion(+) diff --git a/virtme/commands/configkernel.py b/virtme/commands/configkernel.py index 8199294..043e720 100644 --- a/virtme/commands/configkernel.py +++ b/virtme/commands/configkernel.py @@ -72,6 +72,7 @@ _GENERIC_CONFIG = [ 'CONFIG_VT=y', 'CONFIG_UNIX98_PTYS=y', 'CONFIG_EARLY_PRINTK=y', + 'CONFIG_INOTIFY_USER=y', '', '# virtio-scsi support', 'CONFIG_BLOCK=y', -- 2.27.0 ++++++ 0002-Make-save-initramfs-show-command-output-more-useful.patch ++++++ >From 8a914171ac633ad4b88ac704b6a5693c2e2e6164 Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Wed, 16 Oct 2019 12:25:36 -0700 Subject: [PATCH 2/9] Make --save-initramfs --show-command output more useful Now --save-initramfs uses the actual filesystem path for QEMU's -initrd. Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/commands/run.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 7526dea..4c354a1 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -529,8 +529,11 @@ def do_it() -> int: initramfsfile = os.fdopen(initramfsfd, 'r+b') mkinitramfs.mkinitramfs(initramfsfile, config) initramfsfile.flush() - fcntl.fcntl(initramfsfd, fcntl.F_SETFD, 0) - initrdpath = '/proc/self/fd/%d' % initramfsfd + 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', -- 2.26.2 ++++++ 0002-Use-fsdev-multidevs-remap-on-QEMU-4.2.patch ++++++ >From 5e80c9310ca2280db20ff984046251da88c0095f Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Sun, 19 Jul 2020 11:05:29 -0700 Subject: [PATCH 2/6] Use -fsdev multidevs=remap on QEMU 4.2+ Apparently having a virtfs export that spans multiple host filesystems can cause problems in the guest. QEMU 4.2+ will warn about this and supports a workaround: multidevs=remap. Probe for new enough QEMU and pass multidevs=remap on 4.2+. See #60. Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/commands/run.py | 9 ++++++--- virtme/qemu_helpers.py | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 5d9b96b..46cf312 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -236,13 +236,16 @@ def find_kernel_and_mods(arch, args) -> Kernel: 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' 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: diff --git a/virtme/qemu_helpers.py b/virtme/qemu_helpers.py index 8ddc3dd..6ba0c03 100644 --- a/virtme/qemu_helpers.py +++ b/virtme/qemu_helpers.py @@ -30,6 +30,10 @@ class Qemu(object): self.cannot_overmount_virtfs = ( re.search(r'version 1\.[012345]', self.version) is not None) + # 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): """Quote an argument to an option.""" return a.replace(',', ',,') -- 2.27.0 ++++++ 0003-Add-more-typing-annotations.patch ++++++ >From 21b44d23bb81b933c2c0c11f8d32548dc5b4c9d0 Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Sun, 19 Jul 2020 11:21:40 -0700 Subject: [PATCH 3/6] Add more typing annotations Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/architectures.py | 23 ++++++++++++----------- virtme/commands/run.py | 2 +- virtme/qemu_helpers.py | 10 +++++++--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/virtme/architectures.py b/virtme/architectures.py index 35bd338..c284416 100644 --- a/virtme/architectures.py +++ b/virtme/architectures.py @@ -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,40 @@ class Arch(object): 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 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): @@ -294,7 +295,7 @@ ARCHES = {arch.virtmename: arch for arch in [ Arch_s390x(), ]} -def get(arch): +def get(arch: str) -> Arch: if arch in ARCHES: return ARCHES[arch] else: diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 46cf312..ec8fc28 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -418,7 +418,7 @@ def do_it() -> int: 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') diff --git a/virtme/qemu_helpers.py b/virtme/qemu_helpers.py index 6ba0c03..96ed693 100644 --- a/virtme/qemu_helpers.py +++ b/virtme/qemu_helpers.py @@ -9,9 +9,13 @@ import os 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, arch) -> None: self.arch = arch qemubin = shutil.which('qemu-system-%s' % arch) @@ -23,7 +27,7 @@ class Qemu(object): 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') @@ -34,7 +38,7 @@ class Qemu(object): self.has_multidevs = ( re.search(r'version (?:1\.|2\.|3\.|4\.[01][^\d])', self.version) is None) - def quote_optarg(self, a): + def quote_optarg(self, a: str) -> str: """Quote an argument to an option.""" return a.replace(',', ',,') -- 2.27.0 ++++++ 0003-Fix-the-error-message-for-mods-misuse.patch ++++++ >From 5876e8a594c0636438a9b57c3c1e9b0585cffa8d Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Wed, 16 Oct 2019 12:34:22 -0700 Subject: [PATCH 3/9] Fix the error message for --mods misuse Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/commands/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 4c354a1..50c670a 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -225,7 +225,7 @@ def find_kernel_and_mods(arch, args) -> Kernel: 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") + arg_fail("--mods must be used together with --kdir or --installed-kernel") elif args.kimg is not None: kernel.kimg = args.kimg kernel.modfiles = [] -- 2.26.2 ++++++ 0004-Fix-the-mods-error-even-better.patch ++++++ >From 9c7b668bdf792ca885154d4fd57984280a7a5c17 Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Wed, 16 Oct 2019 12:49:23 -0700 Subject: [PATCH 4/9] Fix the --mods error even better. Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/commands/run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 50c670a..722d18a 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -224,13 +224,13 @@ def find_kernel_and_mods(arch, args) -> Kernel: 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 or --installed-kernel") 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.') -- 2.26.2 ++++++ 0004-run.py-Extract-path-file-sanitizing-into-a-new-funct.patch ++++++ >From ada9f8cb90408c673a4980c63277e91df0582611 Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza <[email protected]> Date: Mon, 20 Jul 2020 19:47:05 -0300 Subject: [PATCH 4/6] run.py: Extract path=file sanitizing into a new function This function will be used in the next patch. Signed-off-by: Marcos Paulo de Souza <[email protected]> --- virtme/commands/run.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 5d9b96b..2734848 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -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 @@ -254,6 +254,19 @@ def quote_karg(arg: str) -> str: 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))?$' % @@ -401,15 +414,8 @@ def do_it() -> int: 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)]) -- 2.27.0 ++++++ 0001-mkinitramfs.py-Search-for-busybox-.-static-first.patch -> 0005-mkinitramfs.py-Search-for-busybox-.-static-first.patch ++++++ --- /work/SRC/openSUSE:Factory/virtme/0001-mkinitramfs.py-Search-for-busybox-.-static-first.patch 2019-10-25 18:43:01.343948303 +0200 +++ /work/SRC/openSUSE:Factory/.virtme.new.1890/0005-mkinitramfs.py-Search-for-busybox-.-static-first.patch 2021-11-17 01:14:43.590182740 +0100 @@ -1,7 +1,7 @@ From f2b13f805a203b7aaa5e4ba09cceb06396903e6c Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza <[email protected]> Date: Wed, 16 Oct 2019 23:01:56 -0300 -Subject: [PATCH] mkinitramfs.py: Search for busybox{.,-}static first +Subject: [PATCH 5/9] mkinitramfs.py: Search for busybox{.,-}static first In currentl Tumbleweed, using busybox dynamic linked does not work. For now let's check if we have busybox static first. @@ -27,5 +27,5 @@ if os.path.isfile(path): return path -- -2.23.0 +2.26.2 ++++++ 0005-run.py-Introduce-blk-disk-argument.patch ++++++ >From 80b31bb76560df894fc72b08a9957cd8c9058828 Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza <[email protected]> Date: Mon, 20 Jul 2020 19:48:22 -0300 Subject: [PATCH 5/6] run.py: Introduce --blk-disk argument This new argument will create a new virtio-blk device, instead of the scsi-blk that can be created by using --disk argument, accepting the same argument of --disk. By using --disk-blk "disk2=file1" will create /dev/disk/by-id/virtio-disk. Signed-off-by: Marcos Paulo de Souza <[email protected]> --- virtme/commands/run.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 2734848..d4c3233 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -71,6 +71,8 @@ def make_parser() -> argparse.ArgumentParser: 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('--name', action='store', default=None, @@ -410,6 +412,13 @@ def do_it() -> int: if args.memory: qemuargs.extend(['-m', args.memory]) + 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')]) -- 2.27.0 ++++++ 0006-Minor-sanitize_disk_args-cleanup.patch ++++++ >From 88cd30f073714bd097d83bc7a6b028c0e4bf7a2b Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Mon, 20 Jul 2020 16:32:14 -0700 Subject: [PATCH 6/6] Minor sanitize_disk_args() cleanup 'foo %s bar' % (baz) doesn't need parentheses. Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/commands/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtme/commands/run.py b/virtme/commands/run.py index d900b41..f9ee4dd 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -263,7 +263,7 @@ def quote_karg(arg: str) -> str: 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)) + arg_fail('invalid argument to %s' % func) name, fn = namefile if '=' in fn or ',' in fn: arg_fail("%s filenames cannot contain '=' or ','" % (func)) -- 2.27.0 ++++++ 0006-mkinitramfs-Improve-the-find_busybox-algorithm.patch ++++++ >From 0c733ddb1ef4952bda0614cc68ce80f1c8433ffc Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Fri, 18 Oct 2019 11:03:31 -0700 Subject: [PATCH 6/9] mkinitramfs: Improve the find_busybox algorithm Now the algorithm prefers the 'static' versions regardless of path, and it searches PATH first (for native) as advertised. See issue #52. Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/mkinitramfs.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/virtme/mkinitramfs.py b/virtme/mkinitramfs.py index 193f510..98c7528 100644 --- a/virtme/mkinitramfs.py +++ b/virtme/mkinitramfs.py @@ -167,16 +167,22 @@ def mkinitramfs(out, config) -> None: 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') + names = ['busybox-static', 'busybox.static', 'busybox'] + dirs = [os.path.join(*i) for i in itertools.product( + ['usr/local', 'usr', ''], + ['bin', 'sbin'])] + + for n in names: + if is_native: + # 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 -- 2.26.2 ++++++ 0007-Add-util.find_binary-to-find-binaries.patch ++++++ >From 73bb57a4e1b08e61bc290c282c787d8e0719135e Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Wed, 13 Nov 2019 13:06:48 -0800 Subject: [PATCH 7/9] Add util.find_binary() to find binaries This factors the logic out from find_busybox() Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/mkinitramfs.py | 22 +++------------------- virtme/util.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 virtme/util.py diff --git a/virtme/mkinitramfs.py b/virtme/mkinitramfs.py index 98c7528..1a21c9b 100644 --- a/virtme/mkinitramfs.py +++ b/virtme/mkinitramfs.py @@ -13,6 +13,7 @@ import os.path 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,22 +168,5 @@ def mkinitramfs(out, config) -> None: cw.write_trailer() def find_busybox(root, is_native) -> Optional[str]: - names = ['busybox-static', 'busybox.static', 'busybox'] - dirs = [os.path.join(*i) for i in itertools.product( - ['usr/local', 'usr', ''], - ['bin', 'sbin'])] - - for n in names: - if is_native: - # 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 + return util.find_binary(['busybox-static', 'busybox.static', 'busybox'], + root=root, use_path=is_native) diff --git a/virtme/util.py b/virtme/util.py new file mode 100644 index 0000000..16b7ef7 --- /dev/null +++ b/virtme/util.py @@ -0,0 +1,33 @@ +# -*- 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 -- 2.26.2 ++++++ 0008-modfinder-Use-find_binary_or_raise-to-find-modprobe.patch ++++++ >From 7a5257bc978bc26637c7d6a8fa75851beba0bd80 Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Wed, 13 Nov 2019 13:10:23 -0800 Subject: [PATCH 8/9] modfinder: Use find_binary_or_raise() to find modprobe This should fix #53. Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/modfinder.py | 6 +++--- virtme/util.py | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/virtme/modfinder.py b/virtme/modfinder.py index d0269b0..88f7df57 100644 --- a/virtme/modfinder.py +++ b/virtme/modfinder.py @@ -14,16 +14,16 @@ everything. The idea is to require very few modules. 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 --git a/virtme/util.py b/virtme/util.py index 16b7ef7..cc1787b 100644 --- a/virtme/util.py +++ b/virtme/util.py @@ -31,3 +31,10 @@ def find_binary(names: Sequence[str], root: str = '/', # 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 -- 2.26.2 ++++++ 0009-Enable-the-Xen-console-when-using-xen.patch ++++++ >From 23ca7b2c27185d1a8640583a3b45d98db46db6cd Mon Sep 17 00:00:00 2001 From: Andy Lutomirski <[email protected]> Date: Thu, 25 Jun 2020 15:44:41 -0700 Subject: [PATCH 9/9] Enable the Xen console when using --xen This causes Xen's console output to be visible. It's a horrible layering violation. Signed-off-by: Andy Lutomirski <[email protected]> --- virtme/commands/run.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/virtme/commands/run.py b/virtme/commands/run.py index 722d18a..5d9b96b 100644 --- a/virtme/commands/run.py +++ b/virtme/commands/run.py @@ -279,6 +279,7 @@ def do_it() -> int: qemuargs: List[str] = [qemu.qemubin] kernelargs = [] + xenargs = [] # Put the '-name' flag first so it's easily visible in ps, top, etc. if args.name: @@ -362,9 +363,15 @@ def do_it() -> int: 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']) @@ -574,9 +581,15 @@ def do_it() -> int: 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), -- 2.26.2 ++++++ aarch64-Fix-aarch64-support.patch ++++++ >From beb85146cd91de37ae455eccb6ab67c393e6e290 Mon Sep 17 00:00:00 2001 From: Matthias Brugger <[email protected]> Date: Fri, 16 Oct 2020 13:20:09 +0200 Subject: [PATCH] aarch64: Fix aarch64 support When running virtme natively on a aarch64 host, we should use the same version of GIC as the host. We also don't need to emulate a CPU. Instead we can run on the host one. Signed-off-by: Matthias Brugger <[email protected]> --- virtme/architectures.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/virtme/architectures.py b/virtme/architectures.py index c284416..ba16138 100644 --- a/virtme/architectures.py +++ b/virtme/architectures.py @@ -165,12 +165,17 @@ class Arch_aarch64(Arch): 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 -- 2.28.0
