From nobody Sun May 5 10:05:35 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1597846381; cv=none; d=zohomail.com; s=zohoarc; b=Do2fbTXWomxpA2oOQsa+BqqvNtCUgtFlQQjRR7oas2fRAHYeFzLaZXofex8aNYRuUZL65ZVwWa/XBS0CYmfYO+gS87j2z7X1iXwJQXXEPPH0JIqYk+V4S33CKni1gIU/50tOnhgTcqIrGAV81oMQ8il7fGinBcFfaDIH8Tmfspk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597846381; 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=cUULyjjsanUPeMdn+sjJBXthOBBu0CgiD68YD+Tr/Ew=; b=MMLgxO0321BTXl2LJKXuSBAoPvnvkknfYtg2EZ5Y+drsMiL57f0rCsQFIgQnGU19vjEXaI5O5/3RtMiL6VSBt740rcAwxrlnJXT3utzGqKqmGocmzIHHO7SLSWjp7YGqCcVy43Rf/pBlFiVTcCdQAGBJzcVOfWKZvdNJLZEA9hM= 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; dmarc=pass header.from= (p=none dis=none) header.from= 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 1597846381761729.1109301708162; Wed, 19 Aug 2020 07:13:01 -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-499-IO7cFh0MOiChRPDYKVQXzg-1; Wed, 19 Aug 2020 10:12:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B24F801AAE; Wed, 19 Aug 2020 14:12:49 +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 6B7DD7A427; Wed, 19 Aug 2020 14:12:48 +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 7D63560370; Wed, 19 Aug 2020 14:12:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07JE78Nr026554 for ; Wed, 19 Aug 2020 10:07:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 666657A421; Wed, 19 Aug 2020 14:07:08 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA1E7709DC for ; Wed, 19 Aug 2020 14:07:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597846380; 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=cUULyjjsanUPeMdn+sjJBXthOBBu0CgiD68YD+Tr/Ew=; b=ZJ70lt+y/lxaIBHTpsYTcmSEEs5sQxZKzzsou4RpxLTSnh9rjDtPSeLuvt+SrYBXvW37mU 14hxc3taPAI8c3NzsC2ymzQ9uV0P/tKXvBgji9AZAvbGs7qDMc01U/DdVoFQ5wShMPu5ew nT9Rir1wutTxWFJ9RQvoPsZWS2bHjgM= X-MC-Unique: IO7cFh0MOiChRPDYKVQXzg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virdevmapper: Ignore all errors when opening /dev/mapper/control Date: Wed, 19 Aug 2020 16:07:01 +0200 Message-Id: <75667298306f8ac6b12ed9b1df86a38cbd4bfc8b.1597846021.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" So far, only ENOENT is ignored (to deal with kernels without devmapper). However, as reported on the list, under certain scenarios a different error can occur. For instance, when libvirt is running inside a container which doesn't have permissions to talk to the devmapper. If this is the case, then open() returns -1 and sets errno=3DEPERM. Assuming that multipath devices are fairly narrow use case and using them in a restricted container is even more narrow the best fix seems to be to ignore all open errors BUT produce a warning on failure. To avoid flooding logs with warnings on kernels without devmapper the level is reduced to a plain debug message. Reported-by: Christian Ehrhardt Signed-off-by: Michal Privoznik Reviewed-by: Christian Ehrhardt --- src/util/virdevmapper.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index 3cc399f382..7c89c2a952 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -35,9 +35,12 @@ # include "viralloc.h" # include "virstring.h" # include "virfile.h" +# include "virlog.h" =20 # define VIR_FROM_THIS VIR_FROM_STORAGE =20 +VIR_LOG_INIT("util.virdevmapper"); + # define PROC_DEVICES "/proc/devices" # define DM_NAME "device-mapper" # define DEV_DM_DIR "/dev/" DM_DIR @@ -130,11 +133,15 @@ virDMOpen(void) memset(&dm, 0, sizeof(dm)); =20 if ((controlFD =3D open(CONTROL_PATH, O_RDWR)) < 0) { - if (errno =3D=3D ENOENT) - return -2; - - virReportSystemError(errno, _("Unable to open %s"), CONTROL_PATH); - return -1; + /* We can't talk to devmapper. Produce a warning and let + * the caller decide what to do next. */ + if (errno =3D=3D ENOENT) { + VIR_DEBUG("device mapper not available"); + } else { + VIR_WARN("unable to open %s: %s", + CONTROL_PATH, g_strerror(errno)); + } + return -2; } =20 if (!virDMIoctl(controlFD, DM_VERSION, &dm, &tmp)) { @@ -309,9 +316,9 @@ virDevMapperGetTargets(const char *path, =20 if ((controlFD =3D virDMOpen()) < 0) { if (controlFD =3D=3D -2) { - /* The CONTROL_PATH doesn't exist. Probably the - * module isn't loaded, yet. Don't error out, just - * exit. */ + /* The CONTROL_PATH doesn't exist or is unusable. + * Probably the module isn't loaded, yet. Don't error + * out, just exit. */ return 0; } =20 --=20 2.26.2