From nobody Sat May 18 02:20:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1688139943; cv=none; d=zohomail.com; s=zohoarc; b=UY40KYvJv4cVbjovTd7I/itXD76wGK/hr6c4EQEdnggb2S6BMsmlkGGNz1hmaRK2q2I0252hu1ZQ9Cjl5sDZ3J5IMgOfEOvy9+7D6nZp04gWZCxYQ0iVVr+kkhV78FkdZnapCSQ/an5OoG3j3R7Vp51kkIeGb0c4BeD0puzRuWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688139943; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=293+caOO7e5fwn6C7K3hNwCowRJjBQyN68cLugxco4k=; b=fDk7yuLmY7qaMEshhH4bppVCTJ3fzRifg4AwiqjkxUAMpePsaIxvdRame8F1RkwsGZFlbZIZkbEVvhLNS613iyZF/Bd1zIRuzLh4ej71pgxxfG6sUa/WfEqgLWIeu6uvh4pGKzLKBw8RqeCdlL+eqfjRt+xQ/b9vcXlYbNn34H8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1688139943401736.4569193479815; Fri, 30 Jun 2023 08:45:43 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-338-HERbeA3gP_-7FOutOnRZLw-1; Fri, 30 Jun 2023 11:45:40 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 87AE9800CB4; Fri, 30 Jun 2023 15:45:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 018F5C00049; Fri, 30 Jun 2023 15:45:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B23941946A46; Fri, 30 Jun 2023 15:45:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0EB4619465B6 for ; Fri, 30 Jun 2023 15:01:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B0BB84CD0C0; Fri, 30 Jun 2023 15:01:39 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1CA6492C13; Fri, 30 Jun 2023 15:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688139942; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=293+caOO7e5fwn6C7K3hNwCowRJjBQyN68cLugxco4k=; b=Wn8lzKwyTL89PQxnhb605ZCN3FOSL8qtd2i/wbaHY9KtdG9SjKBFduhuBU9rzCRjkRRzU9 m5N0muOwled2f60Z+Twf/g1dN1YuIBRp9CyrBesTPUk7OxbGiYWIUijSSbuXb/pWac6vXn Y7PLp052V/DYgS4w34NyD+SNC/4cme0= X-MC-Unique: HERbeA3gP_-7FOutOnRZLw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Thomas Huth To: qemu-devel@nongnu.org, Paolo Bonzini Subject: [PATCH] os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option Date: Fri, 30 Jun 2023 17:01:12 +0200 Message-Id: <20230630150112.435874-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libvir-list@redhat.com, Claudio Imbrenda , Markus Armbruster Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1688139945161100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We recently introduced "-run-with" for options that influence the runtime behavior of QEMU. This option has the big advantage that it can group related options (so that it is easier for the users to spot them) and that the options become introspectable via QMP this way. So let's start moving more switches into this option group, starting with "-chroot" now. Signed-off-by: Thomas Huth Reviewed-by: Claudio Imbrenda Reviewed-by: J=C3=A1n Tomko Reviewed-by: Michael Tokarev --- docs/about/deprecated.rst | 5 +++++ os-posix.c | 35 ++++++++++++++++++++++++++++++++++- util/async-teardown.c | 21 --------------------- qemu-options.hx | 18 +++++++++++++----- 4 files changed, 52 insertions(+), 27 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 0743459862..1cf53b86ce 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -116,6 +116,11 @@ Use "whpx" (on Windows) or "hvf" (on macOS) instead. =20 Use ``-run-with async-teardown=3Don`` instead. =20 +``-chroot`` (since 8.1) +''''''''''''''''''''''' + +Use ``-run-with chroot=3Ddir`` instead. + ``-singlestep`` (since 8.1) ''''''''''''''''''''''''''' =20 diff --git a/os-posix.c b/os-posix.c index 90ea71725f..0ae1fb2347 100644 --- a/os-posix.c +++ b/os-posix.c @@ -38,6 +38,7 @@ #include "qemu/cutils.h" #include "qemu/config-file.h" #include "qemu/option.h" +#include "qemu/module.h" =20 #ifdef CONFIG_LINUX #include @@ -148,6 +149,7 @@ int os_parse_cmd_args(int index, const char *optarg) } break; case QEMU_OPTION_chroot: + warn_report("option is deprecated, use '-run-with chroot=3D...' in= stead"); chroot_dir =3D optarg; break; case QEMU_OPTION_daemonize: @@ -158,18 +160,25 @@ int os_parse_cmd_args(int index, const char *optarg) case QEMU_OPTION_asyncteardown: init_async_teardown(); break; +#endif case QEMU_OPTION_run_with: { + const char *str; QemuOpts *opts =3D qemu_opts_parse_noisily(qemu_find_opts("run-wit= h"), optarg, false); if (!opts) { exit(1); } +#if defined(CONFIG_LINUX) if (qemu_opt_get_bool(opts, "async-teardown", false)) { init_async_teardown(); } +#endif + str =3D qemu_opt_get(opts, "chroot"); + if (str) { + chroot_dir =3D str; + } break; } -#endif default: return -1; } @@ -348,3 +357,27 @@ int os_mlock(void) return -ENOSYS; #endif } + +static QemuOptsList qemu_run_with_opts =3D { + .name =3D "run-with", + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_run_with_opts.head), + .desc =3D { +#if defined(CONFIG_LINUX) + { + .name =3D "async-teardown", + .type =3D QEMU_OPT_BOOL, + }, +#endif + { + .name =3D "chroot", + .type =3D QEMU_OPT_STRING, + }, + { /* end of list */ } + }, +}; + +static void register_teardown(void) +{ + qemu_add_opts(&qemu_run_with_opts); +} +opts_init(register_teardown); diff --git a/util/async-teardown.c b/util/async-teardown.c index 3ab19c8740..62cdeb0f20 100644 --- a/util/async-teardown.c +++ b/util/async-teardown.c @@ -12,9 +12,6 @@ */ =20 #include "qemu/osdep.h" -#include "qemu/config-file.h" -#include "qemu/option.h" -#include "qemu/module.h" #include #include #include @@ -147,21 +144,3 @@ void init_async_teardown(void) clone(async_teardown_fn, new_stack_for_clone(), CLONE_VM, NULL); sigprocmask(SIG_SETMASK, &old_signals, NULL); } - -static QemuOptsList qemu_run_with_opts =3D { - .name =3D "run-with", - .head =3D QTAILQ_HEAD_INITIALIZER(qemu_run_with_opts.head), - .desc =3D { - { - .name =3D "async-teardown", - .type =3D QEMU_OPT_BOOL, - }, - { /* end of list */ } - }, -}; - -static void register_teardown(void) -{ - qemu_add_opts(&qemu_run_with_opts); -} -opts_init(register_teardown); diff --git a/qemu-options.hx b/qemu-options.hx index b57489d7ca..f49d4c0e3c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4670,11 +4670,12 @@ ERST =20 #ifndef _WIN32 DEF("chroot", HAS_ARG, QEMU_OPTION_chroot, \ - "-chroot dir chroot to dir just before starting the VM\n", + "-chroot dir chroot to dir just before starting the VM (deprecated= )\n", QEMU_ARCH_ALL) #endif SRST ``-chroot dir`` + Deprecated, use '-run-with chroot=3D...' instead. Immediately before starting guest execution, chroot to the specified directory. Especially useful in combination with -runas. ERST @@ -4861,13 +4862,16 @@ SRST This option is deprecated and should no longer be used. The new option ``-run-with async-teardown=3Don`` is a replacement. ERST +#endif +#ifdef CONFIG_POSIX DEF("run-with", HAS_ARG, QEMU_OPTION_run_with, - "-run-with async-teardown[=3Don|off]\n" - " misc QEMU process lifecycle options\n" - " async-teardown=3Don enables asynchronous teardown\n", + "-run-with [async-teardown=3Don|off][,chroot=3Ddir]\n" + " Set miscellaneous QEMU process lifecycle options:\n" + " async-teardown=3Don enables asynchronous teardown (Li= nux only)\n" + " chroot=3Ddir chroot to dir just before starting the V= M\n", QEMU_ARCH_ALL) SRST -``-run-with`` +``-run-with [async-teardown=3Don|off][,chroot=3Ddir]`` Set QEMU process lifecycle options. =20 ``async-teardown=3Don`` enables asynchronous teardown. A new process c= alled @@ -4880,6 +4884,10 @@ SRST performed correctly. This only works if the cleanup process is not forcefully killed with SIGKILL before the main QEMU process has terminated completely. + + ``chroot=3Ddir`` can be used for doing a chroot to the specified direc= tory + immediately before starting the guest execution. This is especially us= eful + in combination with -runas. ERST #endif =20 --=20 2.39.3