From nobody Sun Feb 8 15:25:34 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 207.211.31.120 is neither permitted nor denied by domain of redhat.com) 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=none (zohomail.com: 207.211.31.120 is neither permitted nor denied by domain of redhat.com) 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=1597743050; cv=none; d=zohomail.com; s=zohoarc; b=HrVRq0UQJqkwNqp+G0+l6oVnFZesBnNayZcs/yBZkQsysZChUDQs6PvLl4VNKvw2dNjyGkpBnpnvJijYdoNUxh6Hv6vFVZZz3x+/8syoOBe2NSQrNOwMvUxykLalkUwE/YRT34s5y2OBTPnX3EavPbyM3hXwOGI70K26MkIpk+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597743050; 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=ZR3o/oWfhX29irznkQ9QNyyFHHhmQx0pxIbEyrSW9N4=; b=dWd5mWhturzo4QnFSL8hAv1uaVobl0DKjNynmPsll4Nwn4mFHFSNJvxTLuo1COFo8sjhX8k/OT7vuGEvT+aPsn5ekrg6nKWUejMpXtwbRFWv6p03dIKAjtRJaDXpNdCkdjjS8CF+3iXLEjS2rC50DQkTsSPxGkGYSjS2Iwgr7KI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=none (zohomail.com: 207.211.31.120 is neither permitted nor denied by domain of redhat.com) 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 1597743050185981.385886881039; Tue, 18 Aug 2020 02:30:50 -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-319-MWKBnke0M6Cl5i4UcRrDrw-1; Tue, 18 Aug 2020 05:30:46 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C58891005E5F; Tue, 18 Aug 2020 09:30:40 +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 A222D19C4F; Tue, 18 Aug 2020 09:30:40 +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 3FBDA181A06E; Tue, 18 Aug 2020 09:30:40 +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 07I9UYnW002106 for ; Tue, 18 Aug 2020 05:30:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 854A27A1E6; Tue, 18 Aug 2020 09:30:34 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02A027849A for ; Tue, 18 Aug 2020 09:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597743049; 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=ZR3o/oWfhX29irznkQ9QNyyFHHhmQx0pxIbEyrSW9N4=; b=EKdH9yVxJpNoJRAzWBkKbJQiDoew3OJv0aCK+zwA95jMD4fiSjWXyW3Bb9UrZbp/RFxtWQ 0pBc/IFrjhkFn8wcH3rE7QZCv0iG5qxquilBzVRW9xSfyQmlx3qN/cTd/Z28jzw6FZNN5q pa6xMAzV0fCl3ofvKZxU0wLrM4vSnsU= X-MC-Unique: MWKBnke0M6Cl5i4UcRrDrw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 2/2] virdevmapper: Handle kernel without device-mapper support Date: Tue, 18 Aug 2020 11:30:25 +0200 Message-Id: <0c2805af80a131d364fdab81d63da45b30c6cc29.1597742945.git.mprivozn@redhat.com> In-Reply-To: References: 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.84 on 10.5.11.23 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" In one of my latest patch (v6.6.0~30) I was trying to remove libdevmapper use in favor of our own implementation. However, the code did not take into account that device mapper can be not compiled into the kernel (e.g. be a separate module that's not loaded) in which case /proc/devices won't have the device-mapper major number and thus virDevMapperGetTargets() and/or virIsDevMapperDevice() fails. Fixes: 22494556542c676d1b9e7f1c1f2ea13ac17e1e3e Reported-by: Andrea Bolognani Reported-by: Christian Ehrhardt Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/util/virdevmapper.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index b24d9377f8..3cc399f382 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -54,6 +54,9 @@ virDevMapperGetMajor(unsigned int *major) VIR_AUTOSTRINGLIST lines =3D NULL; size_t i; =20 + if (!virFileExists(CONTROL_PATH)) + return -2; + if (virFileReadAll(PROC_DEVICES, BUF_SIZE, &buf) < 0) return -1; =20 @@ -126,8 +129,13 @@ virDMOpen(void) =20 memset(&dm, 0, sizeof(dm)); =20 - if ((controlFD =3D open(CONTROL_PATH, O_RDWR)) < 0) + 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; + } =20 if (!virDMIoctl(controlFD, DM_VERSION, &dm, &tmp)) { virReportSystemError(errno, "%s", @@ -299,8 +307,16 @@ virDevMapperGetTargets(const char *path, * consist of devices or yet another targets. If that's the * case, we have to stop recursion somewhere. */ =20 - if ((controlFD =3D virDMOpen()) < 0) + 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. */ + return 0; + } + return -1; + } =20 return virDevMapperGetTargetsImpl(controlFD, path, devPaths, ttl); } --=20 2.26.2