From nobody Thu Nov 13 23:29:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=canonical.com ARC-Seal: i=1; a=rsa-sha256; t=1583854756; cv=none; d=zohomail.com; s=zohoarc; b=FQPwUMmLmlioGJdpOi386OUgP0p1hHpE5UJvQvc3QsM3+aJbzSMzTiumMPfbMe5BeyyaXdWKWD/haDJPQJUEYvgFoMqz4CiBabwVffLF8lLx51sAx39UTAQygPIMyAcJEF/w0pqDYlMQV5RLNWyQBqADq2fVzB4Fkuv8gOjDUC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583854756; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1Sf7y5LiTnXTREn336xSpL/ukVhqjaBNgQjFb+WUHzg=; b=E26MoFwx5vt/zx9cV1vlg5CIdxSI4Z14bW9AusE8ffWFMJdTQrHYQrh4kdAycRqXDZobo19HLqcWH4pOvwqP+LCA2TFU5bgCGxId1pwFSRLpkFVh6re2kxvXqJZtmPo9tqQ3we8WwEAvLerkZ9ToVHZshk87oTPUD3Ej0Ez9SOQ= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583854756775407.177698144392; Tue, 10 Mar 2020 08:39:16 -0700 (PDT) Received: from localhost ([::1]:35236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBgZ0-00021p-BT for importer@patchew.org; Tue, 10 Mar 2020 11:12:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38599) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBgKk-0004j4-Vi for qemu-devel@nongnu.org; Tue, 10 Mar 2020 10:58:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBgKj-0001Sf-H0 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 10:58:14 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:56881) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jBgKj-0001RB-B1 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 10:58:13 -0400 Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jBgKi-0004kR-EK; Tue, 10 Mar 2020 14:58:12 +0000 From: Christian Ehrhardt To: qemu-devel@nongnu.org Subject: [PATCH v2 1/1] modules: load modules from versioned /var/run dir Date: Tue, 10 Mar 2020 15:58:06 +0100 Message-Id: <20200310145806.18335-2-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310145806.18335-1-christian.ehrhardt@canonical.com> References: <20200310145806.18335-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 91.189.89.112 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Christian Ehrhardt , pkg-qemu-devel@lists.alioth.debian.org, Cole Robinson , Paolo Bonzini , Miroslav Rezanina Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" On upgrades the old .so files usually are replaced. But on the other hand since a qemu process represents a guest instance it is usually kept around. That makes late addition of dynamic features e.g. 'hot-attach of a ceph disk' fail by trying to load a new version of e.f. block-rbd.so into an old still running qemu binary. This adds a fallback to also load modules from a versioned directory in the temporary /var/run path. That way qemu is providing a way for packaging to store modules of an upgraded qemu package as needed until the next reboo= t. An example how that can then be used in packaging can be seen in: https://git.launchpad.net/~paelzer/ubuntu/+source/qemu/log/?h=3Dbug-1847361= -miss-old-so-on-upgrade-UBUNTU Fixes: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1847361 Signed-off-by: Christian Ehrhardt Reviewed-by: Daniel P. Berrang=C3=A9 --- configure | 15 +++++++++++++++ util/module.c | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/configure b/configure index cbf864bff1..5911bf1a82 100755 --- a/configure +++ b/configure @@ -405,6 +405,7 @@ EXESUF=3D"" DSOSUF=3D".so" LDFLAGS_SHARED=3D"-shared" modules=3D"no" +module_upgrades=3D"no" prefix=3D"/usr/local" mandir=3D"\${prefix}/share/man" datadir=3D"\${prefix}/share" @@ -1032,6 +1033,10 @@ for opt do --disable-modules) modules=3D"no" ;; + --disable-module-upgrades) module_upgrades=3D"no" + ;; + --enable-module-upgrades) module_upgrades=3D"yes" + ;; --cpu=3D*) ;; --target-list=3D*) target_list=3D"$optarg" @@ -1786,6 +1791,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: guest-agent-msi build guest agent Windows MSI installation package pie Position Independent Executables modules modules support (non-Windows) + module-upgrades try to load modules from alternate paths for upgrades debug-tcg TCG debugging (default is disabled) debug-info debugging information sparse sparse checker @@ -2049,6 +2055,11 @@ if test "$modules" =3D "yes" && test "$mingw32" =3D = "yes" ; then error_exit "Modules are not available for Windows" fi =20 +# module_upgrades is only reasonable if modules are enabled +if test "$modules" =3D "no" && test "$module_upgrades" =3D "yes" ; then + error_exit "Can't enable module-upgrades as Modules are not enabled" +fi + # Static linking is not possible with modules or PIE if test "$static" =3D "yes" ; then if test "$modules" =3D "yes" ; then @@ -6584,6 +6595,7 @@ if test "$slirp" !=3D "no" ; then echo "smbd $smbd" fi echo "module support $modules" +echo "alt path mod load $module_upgrades" echo "host CPU $cpu" echo "host big endian $bigendian" echo "target list $target_list" @@ -6937,6 +6949,9 @@ if test "$modules" =3D "yes"; then echo "CONFIG_STAMP=3D_$( (echo $qemu_version; echo $pkgversion; cat $0) = | $shacmd - | cut -f1 -d\ )" >> $config_host_mak echo "CONFIG_MODULES=3Dy" >> $config_host_mak fi +if test "$module_upgrades" =3D "yes"; then + echo "CONFIG_MODULE_UPGRADES=3Dy" >> $config_host_mak +fi if test "$have_x11" =3D "yes" && test "$need_x11" =3D "yes"; then echo "CONFIG_X11=3Dy" >> $config_host_mak echo "X11_CFLAGS=3D$x11_cflags" >> $config_host_mak diff --git a/util/module.c b/util/module.c index 236a7bb52a..5f7896870a 100644 --- a/util/module.c +++ b/util/module.c @@ -19,6 +19,9 @@ #endif #include "qemu/queue.h" #include "qemu/module.h" +#ifdef CONFIG_MODULE_UPGRADES +#include "qemu-version.h" +#endif =20 typedef struct ModuleEntry { @@ -170,6 +173,9 @@ bool module_load_one(const char *prefix, const char *li= b_name) #ifdef CONFIG_MODULES char *fname =3D NULL; char *exec_dir; +#ifdef CONFIG_MODULE_UPGRADES + char *version_dir; +#endif const char *search_dir; char *dirs[4]; char *module_name; @@ -201,6 +207,14 @@ bool module_load_one(const char *prefix, const char *l= ib_name) dirs[n_dirs++] =3D g_strdup_printf("%s", CONFIG_QEMU_MODDIR); dirs[n_dirs++] =3D g_strdup_printf("%s/..", exec_dir ? : ""); dirs[n_dirs++] =3D g_strdup_printf("%s", exec_dir ? : ""); + +#ifdef CONFIG_MODULE_UPGRADES + version_dir =3D g_strcanon(g_strdup(QEMU_PKGVERSION), + G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "+-.~= ", + '_'); + dirs[n_dirs++] =3D g_strdup_printf("/var/run/qemu/%s", version_dir); +#endif + assert(n_dirs <=3D ARRAY_SIZE(dirs)); =20 g_free(exec_dir); --=20 2.25.1