From nobody Wed May 8 02:32:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1592362095; cv=none; d=zohomail.com; s=zohoarc; b=DQq5QAciLYY08Ss9pvYneJ4Dc/T0BVvvWdO75J0ZOE0xp96/1KMCIuLQwtI9WymE4J05f5wi4swtrk6Jca0S7P6luiZlSy8ck0tRAIGs0NZtwBLRPj265yTTwyuz2L/c+3lmkrF5bavPOzS4nQQ0vn0YL7Q4c+/RLiGSFmfHki0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592362095; 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=CO5kTloka9eddOExXt2+tgGN1NE0Zr5iZ5cLBBD7UiQ=; b=eNmoETm7mu5rsd+wcPmZ3X1qQVhFRSWt0BxL93MB/+A6vFK5vlbOWlQxWx6aBTYSwDHjiEVC61hKzKyanNtfLqXnOg/QwW+HXxiYayBTpdmSoruvW6imwKkSb05aj4BY72if5z/kV/ubynKOk9mp8e41uWEFvKN90gR4qHzgtZU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1592362095558633.5069671725798; Tue, 16 Jun 2020 19:48:15 -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-369-VTrg3vxnPd2WOU9bUSeT2g-1; Tue, 16 Jun 2020 22:48:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A62D83DE70; Wed, 17 Jun 2020 02:48:06 +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 24E1C1944D; Wed, 17 Jun 2020 02:48:04 +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 A7FC6833CC; Wed, 17 Jun 2020 02:48:01 +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 05H2lxgp011496 for ; Tue, 16 Jun 2020 22:48:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id C6BEA2029F62; Wed, 17 Jun 2020 02:47:59 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C29D12026D5D for ; Wed, 17 Jun 2020 02:47:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 3476985A5A3 for ; Wed, 17 Jun 2020 02:47:57 +0000 (UTC) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-Wtt94PdGM8m6qA3Tn-1mGQ-1; Tue, 16 Jun 2020 22:47:54 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2B5825F3B19E6F49C291 for ; Wed, 17 Jun 2020 10:47:50 +0800 (CST) Received: from [10.173.222.155] (10.173.222.155) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Wed, 17 Jun 2020 10:47:44 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592362094; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CO5kTloka9eddOExXt2+tgGN1NE0Zr5iZ5cLBBD7UiQ=; b=MZqrpm4ACeW3/PO+YogQNBL35uvso8vJp03SZNTUejQAEkwq2CasZMeisir3EZlJNAbY0D poeORTHZVEuSaBTK/64g+qEfShTVzkSkOS8NjjnuicbIpXZIK2bDZBIeqEuUuyzTDEXFQY TlyKugP8rD/we1TonCrf8UXTIAJyo1s= X-MC-Unique: VTrg3vxnPd2WOU9bUSeT2g-1 X-MC-Unique: Wtt94PdGM8m6qA3Tn-1mGQ-1 To: , , , , From: Bihong Yu Subject: [PATCH] utils: check flags and errno before reporting errno Message-ID: <40766c03-8e17-13f1-b2a5-0cf3db50936c@huawei.com> Date: Wed, 17 Jun 2020 10:47:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [10.173.222.155] X-CFilter-Loop: Reflected X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) >From 099707463944faeae75da640b0d1d780cb675406 Mon Sep 17 00:00:00 2001 From: Bihong Yu Date: Tue, 16 Jun 2020 22:08:55 +0800 Subject: [PATCH] utils: check flags and errno before reporting errno There are races condiction to make '/run/libvirt/qemu/dbus' directory in virDirCreateNoFork() while concurrent start VMs, and get "failed to create directory '/run/libvirt/qemu/dbus': File exists" error message. Check flags= and errno before reporting errno after mkdir(). Signed-off-by:Bihong Yu Reviewed-by:Chuan Zheng Reviewed-by:alexchen --- src/util/virfile.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 20260a2..96ac4e5 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -2614,12 +2614,15 @@ virDirCreateNoFork(const char *path, if (!((flags & VIR_DIR_CREATE_ALLOW_EXIST) && virFileExists(path))) { if (mkdir(path, mode) < 0) { - ret =3D -errno; - virReportSystemError(errno, _("failed to create directory '%s'= "), - path); - goto error; + if (!((flags & VIR_DIR_CREATE_ALLOW_EXIST) && errno =3D=3D EEX= IST)) { + ret =3D -errno; + virReportSystemError(errno, _("failed to create directory = '%s'"), + path); + goto error; + } + } else { + created =3D true; } - created =3D true; } if (stat(path, &st) =3D=3D -1) { --=20 1.8.3.1