From nobody Mon Feb 9 04:18:00 2026 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=1626274089; cv=none; d=zohomail.com; s=zohoarc; b=SGZHnCmblztlDDyejM68qIUjo81ZBd8GQ3bhXUkBg5WVVF20nztbkR3mpLwTI6HgCS0Pqw9eb4aiLY4/x4YcrkbHuVhSE4nA6dstOd55bU6pml6J/Px2hFvinVd9mgk5IxF5iLeyB5hn0naYD3oTm8SBYaeXj54Dn5/sVM9+2gE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626274089; 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=PSlry0vR+k5rCND8sLRrQpDswEQXhy7xaBfECOcfdx4=; b=XYe+FnQr17dGj2IJGgxdix+ZWnblc5oog8o6aK1OtSB86z6OtygQJmDbMW0But7eLdx/q0QBqAZHRXqBhUmYdhATnU49w4Zk46mlKNhx8GxAOo0Wa1V0tliKw8oZ6tu+TbJGC7UHez02MnZzg2tam/LZMVrHtE7YScEFdiLPLjA= 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 1626274089545793.892127329142; Wed, 14 Jul 2021 07:48:09 -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-37-Vvwb80hBOUqfFM0vwEW6JA-1; Wed, 14 Jul 2021 10:47:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0BA54102C87E; Wed, 14 Jul 2021 14:47:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64EEA69327; Wed, 14 Jul 2021 14:47:22 +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 F23A64EA37; Wed, 14 Jul 2021 14:47:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16EElEQT007364 for ; Wed, 14 Jul 2021 10:47:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id ED01578DE1; Wed, 14 Jul 2021 14:47:13 +0000 (UTC) Received: from 48-A4-72-0B-E8-25.redhat.com (unknown [10.40.195.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2F487B014 for ; Wed, 14 Jul 2021 14:47:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626274088; 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=PSlry0vR+k5rCND8sLRrQpDswEQXhy7xaBfECOcfdx4=; b=VCpQg0QPm612OUGABEuetnWkpnUghHbj5kohm5AahovuxVWJIQ9Qeibxv7iO9XPuyxJ+KV 3CnCEfdzIkvn94ZSKHmh7OotaPu0f7AQTc2C4rBhOA/dxqxS206IA37lnx+UO6LzjlVcmM kIfcYyKf2R8nJ0ycnZNGG3lRJBKa4/4= X-MC-Unique: Vvwb80hBOUqfFM0vwEW6JA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 1/3] qemu: Check for existing file in namespace Date: Wed, 14 Jul 2021 16:46:52 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1626274090605100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- src/qemu/qemu_namespace.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 98495e8ef8..eb048a2faa 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -929,6 +929,10 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data) bool isDev =3D S_ISCHR(data->sb.st_mode) || S_ISBLK(data->sb.st_mode); bool isReg =3D S_ISREG(data->sb.st_mode) || S_ISFIFO(data->sb.st_mode)= || S_ISSOCK(data->sb.st_mode); bool isDir =3D S_ISDIR(data->sb.st_mode); + bool exists =3D false; + + if (virFileExists(data->file)) + exists =3D true; =20 if (virFileMakeParentPath(data->file) < 0) { virReportSystemError(errno, @@ -1039,7 +1043,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data) virFileMoveMount(data->target, data->file) < 0) goto cleanup; =20 - ret =3D 0; + ret =3D exists ? 1 : 0; cleanup: if (ret < 0 && delDevice) { if (isDir) @@ -1069,15 +1073,21 @@ qemuNamespaceMknodHelper(pid_t pid G_GNUC_UNUSED, qemuNamespaceMknodData *data =3D opaque; size_t i; int ret =3D -1; + bool exists =3D false; =20 qemuSecurityPostFork(data->driver->securityManager); =20 for (i =3D 0; i < data->nitems; i++) { - if (qemuNamespaceMknodOne(&data->items[i]) < 0) + int rc =3D 0; + + if ((rc =3D qemuNamespaceMknodOne(&data->items[i])) < 0) goto cleanup; + + if (rc > 0) + exists =3D true; } =20 - ret =3D 0; + ret =3D exists ? 1 : 0; cleanup: qemuNamespaceMknodDataClear(data); return ret; --=20 2.31.1