From nobody Mon Feb 9 05:01:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1667231644; cv=none; d=zohomail.com; s=zohoarc; b=bEp7rrT2/KqG170jgT3rAabrUfL7P951/COIJ0AuKuF5HQk/qB/XeyA2x0QLhpgJe7+hDOVNcewSG7GC3zBsTtFdmMSIlbcMQB89zv1cZSuTnXyx6tgn+V8ygrTjIybG0kjNvvzgcyjK3SvqxZgqu6Drmu0sqwsomoUoiPO2qUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667231644; h=Content-Type:Content-Transfer-Encoding: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=WhatyQ55+iDEdD+Sr3CAQ/8BF7QeKe7crZLNnonWTIE=; b=dCpHTKo0NhE+QeQnj6OlvDUez0k9zHD9Z9ikptRhaVhwWja5VXVsgVvqplyYuq/xqfAKASbiZCA3nssNUC2Nb4cNvP1+fRSAd+cy4a18haNenD8HRM3iKsTWHUuVz2MGTnqLGprjlk2wrXyM0lr4GqxCxpQmQfAFXC0YNznbHOI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1667231644981684.6936207133725; Mon, 31 Oct 2022 08:54:04 -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-478-UPCp8ApVP46bM8m6vCoMCQ-1; Mon, 31 Oct 2022 11:53:14 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 35E0C101E9B7; Mon, 31 Oct 2022 15:53:12 +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 1B0C740C845E; Mon, 31 Oct 2022 15:53:12 +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 D229A1946A4F; Mon, 31 Oct 2022 15:53:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A270C194658C for ; Mon, 31 Oct 2022 15:53:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CC15440C94CF; Mon, 31 Oct 2022 15:53:03 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7134740C6EC6 for ; Mon, 31 Oct 2022 15:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667231643; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WhatyQ55+iDEdD+Sr3CAQ/8BF7QeKe7crZLNnonWTIE=; b=MsyHSLd61teDf4t24dzzH9YC7d52rUxfvhkRnuCfxIQRXNvd3mZ0SpDYTVdwFoqllF0bt+ dvet+fqOvVrfFKVHsE0RzIkVlveDT1PjsL2HW6KC0pJX8mqorfTkzhaxeh3cG2sn7o/sAv ayjsZKE875QeJnRMd6rObtNjzchHHac= X-MC-Unique: UPCp8ApVP46bM8m6vCoMCQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] qemu_namespace: Make qemuDomainGetPreservedMounts() more robust wrt running VMs Date: Mon, 31 Oct 2022 16:53:00 +0100 Message-Id: <229163002645cf7b30f3ebeb7378031aa7d3a02e.1667231427.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: 1667231646627100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The aim of qemuDomainGetPreservedMounts() is to get a list of filesystems mounted under /dev and optionally generate a path for each one where they are moved temporarily when building the namespace. And if given domain is also running it looks into its mount table rather than at the host one. But if it did look at the domain's private mount table, it find /dev mounted twice: the first time by udev, the second time the tmpfs mounted by us. Now, later in the function there's a "sorting" algorithm that tries to reduce number of mount points needing preservation, by identifying nested mount points. And if we keep the second occurrence of /dev on the list, well, after the "sorting" we are left with nothing but "/dev" because all other mount points are nested. Fixes: 46b03819ae8d833b11c2aaccb2c2a0361727f51b Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_namespace.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 9fed6871e8..8189cc37ba 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -154,6 +154,17 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfig *cfg, for (i =3D 1; i < nmounts; i++) { size_t j =3D i + 1; =20 + /* If we looked into mount table of already running VM, + * we might have found /dev twice. Remove the other + * occurrence as it would jeopardize the rest of the prune + * algorithm. + */ + if (STREQ(mounts[i], "/dev")) { + VIR_FREE(mounts[i]); + VIR_DELETE_ELEMENT_INPLACE(mounts, i, nmounts); + continue; + } + while (j < nmounts) { char *c =3D STRSKIP(mounts[j], mounts[i]); =20 --=20 2.37.4