From nobody Mon Nov 25 22:28:34 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=1591875948; cv=none; d=zohomail.com; s=zohoarc; b=dZ9p/sAd0HJxVfnzpm8+Zrc8Z0Q18yP6SOcMLlfnWn2g+WAEThszIXwmLaLIvakvbpTDp+W2l3vhFl96rDgls+BJpZMUqq58cwt9QQPb9MiVutE9pxd84V1UqQCl4d7oer2DYek77FMk6qkSJcNVa8xYelnqGQlCo5+5CGlXgbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591875948; 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=mQe+81cbSBkPKW6HILFGeGw1GXJZbyK7KNKP0d5MNHs=; b=PHlNVfTqg3eSSzvU0vUrAKOcx+2DBrKFCwvXmYRadavwh0yfZIjGIZid6kC2LnzPdWhIfUhOWB/sLHGInvNW4RtRx0p8ZDgrekm6rmkqkfA5yPaNf6OVqJJLQgradimVxDDyRgFbN8t8Nq+V5/IDI8i5GaWhJdFB8VN0rBt/F04= 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 1591875948321311.9401597595205; Thu, 11 Jun 2020 04:45:48 -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-9-h5NmMgAzOqK-vd8Mrdr6Uw-1; Thu, 11 Jun 2020 07:45:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 644E9193F561; Thu, 11 Jun 2020 11:45:39 +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 4214F60BF4; Thu, 11 Jun 2020 11:45:39 +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 1241F10480C; Thu, 11 Jun 2020 11:45:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05BBjH4X013564 for ; Thu, 11 Jun 2020 07:45:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id EDD0A512FE; Thu, 11 Jun 2020 11:45:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EFDC9CA0 for ; Thu, 11 Jun 2020 11:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591875947; 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=mQe+81cbSBkPKW6HILFGeGw1GXJZbyK7KNKP0d5MNHs=; b=SYBfIADiViqXYherZfFw81dfzOLS6DJ+eKchGBn2wk/b8aWTQHZ+gE+FK8apat3ShVYU89 sV7STYPf/nM/K3MrIehIYrG9XZ4XGEMGbN+O63+y0rTH3Ug/lSy4Ki8RThkUiCojJiuzD8 abMSkew5B+3IBDnMzaeb7lle14SquKk= X-MC-Unique: h5NmMgAzOqK-vd8Mrdr6Uw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] virDevMapperGetTargetsImpl: Check for dm major properly Date: Thu, 11 Jun 2020 13:44:48 +0200 Message-Id: <73faec9f055848df4b370d31ca97b63ef831e610.1591875846.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.12 X-Mimecast-Spam-Score: 0 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 v6.4.0-rc1~143 I've introduced a check that is supposed to return from the function early, if given path is not a dm target. While the idea is still valid, the implementation had a flaw. It calls stat() over given path and the uses major(sb.st_dev) to learn the major of the device. This is then passed to dm_is_dm_major() which returns true or false depending whether the device is under devmapper's control or not. The problem with this approach is in how the major of the device is obtained - paths managed by devmapper are special files and thus we want to be using st_rdev instead of st_dev to obtain the major number. Well, that's what virIsDevMapperDevice() does already so might as well us that. Fixes: 01626c668ecfbe465d18799ac4628e6127ea1d47 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1839992 Signed-off-by: Michal Privoznik --- src/util/virdevmapper.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index 600e1f6322..40a82285f9 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -64,7 +64,6 @@ virDevMapperGetTargetsImpl(const char *path, char ***devPaths_ret, unsigned int ttl) { - struct stat sb; struct dm_task *dmt =3D NULL; struct dm_deps *deps; struct dm_info info; @@ -83,13 +82,7 @@ virDevMapperGetTargetsImpl(const char *path, return ret; } =20 - if (stat(path, &sb) < 0) { - if (errno =3D=3D ENOENT) - return 0; - return -1; - } - - if (!dm_is_dm_major(major(sb.st_dev))) + if (!virIsDevMapperDevice(path)) return 0; =20 if (!(dmt =3D dm_task_create(DM_DEVICE_DEPS))) { --=20 2.26.2