From nobody Sun May 19 00:47:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1597964669; cv=none; d=zohomail.com; s=zohoarc; b=Qkw0R7zjZHkeRyD1Ry1O7FmstYE/C/ySDXQRCY5aiFcLD2ITaNWsb/f79vG6Df3wwocPYW5tEVrxdbQ72MigiezE4l/LY4gh9UEnwq+o8drSt+YEtaxKCHP8iak1DguUeJzgO354tN95SaAQfdMlJEx7jwJcj13r6S1Q2SSWCGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597964669; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=LpD2FxdQwR7hmZ/AQf3ImAky1DXkAuVSNIxBdVbBYuI=; b=DpFz+KnJpfvpS80X4oKJrHYqr44ULwmNLjchunSWfLD095cwzd3bbHjtEwQVXE1CJuQOm39wrPrAJWiMAE3UEJPGDs6zamQuqIjNDnRJXBuEtplbUzE6QGleGE0wGtNg8+qiR3zEPz2dMRrXGaXZc/chpvqb/pCZtwYF4+EB89M= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1597964669818892.1945691527984; Thu, 20 Aug 2020 16:04:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-102-2oir0zwxPBeeXkjTU__E2A-1; Thu, 20 Aug 2020 19:04:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A78EE801AE8; Thu, 20 Aug 2020 23:04:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DBC291001281; Thu, 20 Aug 2020 23:04:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CEF1E183D020; Thu, 20 Aug 2020 23:04:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07KN4CgI031834 for ; Thu, 20 Aug 2020 19:04:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F1B4203B853; Thu, 20 Aug 2020 23:04:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 217F0203B864 for ; Thu, 20 Aug 2020 23:04:10 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 03421101AA40 for ; Thu, 20 Aug 2020 23:04:10 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [62.140.7.102]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-jzWLgawgPA21xISN9YBowg-1; Thu, 20 Aug 2020 19:04:07 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2177.outbound.protection.outlook.com [104.47.17.177]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-8-NAzZn_t_NfuEi0c-QPUZ5A-1; Fri, 21 Aug 2020 01:04:05 +0200 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) by VI1PR0401MB2430.eurprd04.prod.outlook.com (2603:10a6:800:2b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25; Thu, 20 Aug 2020 23:04:02 +0000 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::a0ba:4965:e484:d014]) by VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::a0ba:4965:e484:d014%9]) with mapi id 15.20.3305.025; Thu, 20 Aug 2020 23:04:02 +0000 Received: from linux-tbji.devlab.prv.suse.com (192.150.153.236) by AM3PR07CA0055.eurprd07.prod.outlook.com (2603:10a6:207:4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.10 via Frontend Transport; Thu, 20 Aug 2020 23:04:01 +0000 X-MC-Unique: 2oir0zwxPBeeXkjTU__E2A-1 X-MC-Unique: jzWLgawgPA21xISN9YBowg-1 X-MC-Unique: NAzZn_t_NfuEi0c-QPUZ5A-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [RFC] qemu: Check for changes in qemu modules directory Date: Thu, 20 Aug 2020 17:03:44 -0600 Message-ID: <20200820230344.11546-1-jfehlig@suse.com> X-ClientProxiedBy: AM3PR07CA0055.eurprd07.prod.outlook.com (2603:10a6:207:4::13) To VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Originating-IP: [192.150.153.236] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0a5ae1a9-20c6-4418-52fd-08d8455d544c X-MS-TrafficTypeDiagnostic: VI1PR0401MB2430: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jpOJsJa7V1egFQqJR8Kg3+Ctuk/urVhVPdc0SO61hdFUHUF9jzw3huRg9v+pqAL80d0+6cCsiluhH4sc9RS/s6iqlQbqvQFhGkN9vcM4/JYRgshqV8GcEFrAQ3OSAQtYEksAuBr7PoRuaJ4VAFoBAV3CXm81kFrqLLm8lw7j1hkd0KKt8rxbgthcAo08TOmPqjs8LcafnjhSHoRkPC22fYO5khrJk7/t9q/b8bDfbh2ucYAs1PUa00rVzq2tiMMfZTqPd3rnhAm6+UOOGwqFzRjwtrLpQND2ULCT4a37pAEJaUcXhCLNK/vogUtQPowmzVMnsasCdnmUpuBc0IAf9dvVaGKd+c1opYD9KNqFTP9tKJLNJU0FLoCQgquZ7XapG7A9py0EfyXlG7/MlsRCjg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0401MB2429.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(376002)(39860400002)(396003)(366004)(136003)(966005)(316002)(86362001)(16526019)(107886003)(6666004)(8676002)(186003)(26005)(8936002)(83380400001)(6916009)(66946007)(66476007)(6486002)(478600001)(2906002)(36756003)(66556008)(5660300002)(4326008)(2616005)(52116002)(1076003)(956004)(7696005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PiR7pNrvXBSAsiWBprHSvp4lLMdY7oHh9kCd/BlhrfNzmIsuGgBZ0mZZ9LD7QqvOBOy/vD8v7Z34XMn42Zx5RGmVs3cAQGWXyCY75DLq3m+5cEeuYlHb8KKrdM9Y3oVnItPJJW1KZ15s+GDO9KpU4cyq1hT6Z+2rkcOntBNfKqT/FRuVHKNNyOFaWCcstz6uU2egEQnff8vyyTwofkcuGX8Yxgpy6QBiFUgDmBW8ZCZnAe/ztqY9oCnTxvJ8MZtwvSl4tpVzvjl5fM9C9D0LAoe8BVmZ2M000+eR/IcsW8WdaUl5ZXHQb6quzi8lPPmDiIXEMYmWThtVZW6BdCNXmBE8zvU4zfZGk1YXn8DZlJRIOqT3eqw8GD6825QflErbc01Ff9goT+PcgVVfNMqCCKPOzU8p/0FPIeyGn0hDC0tOWDudCWv17CRdk4uLTvw41wYfNmsqyqMG4Z9/SMt+GMH5R4bQCE9vynJMhRyD6br8vaw0MLrSSN3lF9FyAFcrtVL51LqfS/EKCCKmcMJK0TyuLKp1xtgGcLyQJb6+knsJCzBg81reg3rTA7lnSjg0lBcVmtNS3TEXgn2a4CPz/8+vh7YbQCppjygfEUMzHWANk0kHK0TJRc47S4T18ij+8ZQyDsvKpooEZdBfkBcP+g== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a5ae1a9-20c6-4418-52fd-08d8455d544c X-MS-Exchange-CrossTenant-AuthSource: VI1PR0401MB2429.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2020 23:04:02.6776 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Qz/cVSqqTj37QKvVVUAiMJywUsqFyKtwNHa2FAGZ8PJ1xCFG/mExjFH5L2DfvVRczkXb94sITXeWZ7XQ/X625g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2430 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 07KN4CgI031834 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a configuration option for specifying location of the qemu modules directory, defaulting to /usr/lib64/qemu. Then use this location to check for changes in the directory, indicating that a qemu module has changed and capabilities need to be reprobed. Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrang=C3=A9 --- This is a mildly tested impl of the idea discussed here (and elsewhere in the thread) https://www.redhat.com/archives/libvir-list/2020-August/msg00684.html I've checked that both system and session caches are updated when a qemu modules package is updated. I'll do some more testing but wanted to send the patch for early comments. Testing in other environments would be much appreciated. Thanks! meson.build | 6 ++++++ meson_options.txt | 1 + src/qemu/qemu_capabilities.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/meson.build b/meson.build index a72d0c0e85..16928482aa 100644 --- a/meson.build +++ b/meson.build @@ -1745,6 +1745,12 @@ if not get_option('driver_qemu').disabled() if use_qemu conf.set('WITH_QEMU', 1) =20 + qemu_moddir =3D get_option('qemu_moddir') + if qemu_moddir =3D=3D '' + qemu_moddir =3D '/usr/lib64/qemu' + endif + conf.set_quoted('QEMU_MODDIR', qemu_moddir) + if host_machine.system() in ['freebsd', 'darwin'] default_qemu_user =3D 'root' default_qemu_group =3D 'wheel' diff --git a/meson_options.txt b/meson_options.txt index c538d323c1..cedbd79491 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -59,6 +59,7 @@ option('driver_openvz', type: 'feature', value: 'auto', d= escription: 'OpenVZ dri option('driver_qemu', type: 'feature', value: 'auto', description: 'QEMU/K= VM driver') option('qemu_user', type: 'string', value: '', description: 'username to r= un QEMU system instance as') option('qemu_group', type: 'string', value: '', description: 'groupname to= run QEMU system instance as') +option('qemu_moddir', type: 'string', value: '', description: 'set the dir= ectory where QEMU modules are located') option('driver_remote', type: 'feature', value: 'enabled', description: 'r= emote driver') option('remote_default_mode', type: 'combo', choices: ['legacy', 'direct']= , value: 'legacy', description: 'remote driver default mode') option('driver_secrets', type: 'feature', value: 'auto', description: 'loc= al secrets management driver') diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ff6ba8c9e9..a00853c753 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -677,6 +677,7 @@ struct _virQEMUCaps { char *binary; time_t ctime; time_t libvirtCtime; + time_t modDirMtime; bool invalidation; =20 virBitmapPtr flags; @@ -4194,6 +4195,7 @@ virQEMUCapsParseSEVInfo(virQEMUCapsPtr qemuCaps, xmlX= PathContextPtr ctxt) * * /some/path * 234235253 + * 234235253 * 234235253 * 1002016 * @@ -4283,6 +4285,9 @@ virQEMUCapsLoadCache(virArch hostArch, } qemuCaps->ctime =3D (time_t)l; =20 + if (virXPathLongLong("string(./qemumoddirmtime)", ctxt, &l) =3D=3D 0) + qemuCaps->modDirMtime =3D (time_t)l; + if ((n =3D virXPathNodeSet("./flag", ctxt, &nodes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse qemu capabilities flags")); @@ -4615,6 +4620,10 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps) qemuCaps->binary); virBufferAsprintf(&buf, "%llu\n", (long long)qemuCaps->ctime); + if (qemuCaps->modDirMtime > 0) { + virBufferAsprintf(&buf, "%llu\n= ", + (long long)qemuCaps->modDirMtime); + } virBufferAsprintf(&buf, "%llu\n", (long long)qemuCaps->libvirtCtime); virBufferAsprintf(&buf, "%lu\n", @@ -4881,6 +4890,23 @@ virQEMUCapsIsValid(void *data, if (!qemuCaps->binary) return true; =20 + if (virFileExists(QEMU_MODDIR)) { + if (stat(QEMU_MODDIR, &sb) < 0) { + VIR_DEBUG("Failed to stat QEMU module directory '%s': %s", + QEMU_MODDIR, + g_strerror(errno)); + return false; + } + + if (sb.st_mtime !=3D qemuCaps->modDirMtime) { + VIR_DEBUG("Outdated capabilities for '%s': QEMU modules " + "directory '%s' changed (%lld vs %lld)", + qemuCaps->binary, QEMU_MODDIR, + (long long)sb.st_mtime, (long long)qemuCaps->modDirM= time); + return false; + } + } + if (qemuCaps->libvirtCtime !=3D virGetSelfLastChanged() || qemuCaps->libvirtVersion !=3D LIBVIR_VERSION_NUMBER) { VIR_DEBUG("Outdated capabilities for '%s': libvirt changed " @@ -5463,6 +5489,15 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, goto error; } =20 + if (virFileExists(QEMU_MODDIR)) { + if (stat(QEMU_MODDIR, &sb) < 0) { + virReportSystemError(errno, _("Cannot check QEMU module direct= ory %s"), + QEMU_MODDIR); + goto error; + } + qemuCaps->modDirMtime =3D sb.st_mtime; + } + if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid) < 0) goto error; =20 --=20 2.28.0