From nobody Wed May 14 06:12:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1527770413912217.28471865744746; Thu, 31 May 2018 05:40:13 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C932026AC52; Thu, 31 May 2018 12:40:11 +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 5857B5F7C0; Thu, 31 May 2018 12:40:11 +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 B7D3C180BA81; Thu, 31 May 2018 12:40:10 +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 w4VCe8t7016501 for ; Thu, 31 May 2018 08:40:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2283F60181; Thu, 31 May 2018 12:40:08 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1534460177 for ; Thu, 31 May 2018 12:40:02 +0000 (UTC) Received: from mail-wr0-f174.google.com (mail-wr0-f174.google.com [209.85.128.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B9A1316EB6B for ; Thu, 31 May 2018 12:39:51 +0000 (UTC) Received: by mail-wr0-f174.google.com with SMTP id d8-v6so1661024wro.4 for ; Thu, 31 May 2018 05:39:51 -0700 (PDT) Received: from filip.redhat.com ([213.175.37.12]) by smtp.googlemail.com with ESMTPSA id l5-v6sm19444452wrn.92.2018.05.31.05.39.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 05:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Pkq6/2kNg4OPSRhPv7Ih4fSKSZAoZv9jy0wd1UOc3To=; b=jPUXW5Y1VswbY+pszOsOGWZoW8h/z3Shp/a3c2DVg2JE4UnmhU8mI3zwbwl551DutD soj9ZKyKEWi+GcBKriy28adT9hYVf3Adj0AeXA/dGIuLmbcgTDvkhBuxFrM2B7KQsQh+ 9gIKsoA/0y0aHzcQ/e/WRCMf0iQkkSia8FdMEf+vClPUT8eijllhZM0gNPOEz/Oxudkj L+DDQHiqSlvyAbgiIqm24dej0auGVJWJ5EFiAa0qyG49ia9S5GNqZ7vkNyuYIgJZIeoj e+RCCd5lQJzSjpkcQ+eR36AW8FY3oBqzeNeNyMWqE2vQicrTKDZUwinnFDbwEqppch8n uUYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Pkq6/2kNg4OPSRhPv7Ih4fSKSZAoZv9jy0wd1UOc3To=; b=q1dJ7iGvzQHRZ3zceQdouSm88jqp8abo4HaC/dVC0o8mK3kSIyDDXxWtJqsqjueArW UPi48hUk27O/xHjC57i+C7z5eyIfI1YhJ2VfuPeASiqX2kQAH23F1mp2djHEuYXSATy0 SpTG4hUoksclU+LbkcEzTgopVQS6spcn7mJf/YmJslqXXTkBystth/hJHN11Xgi5RAt2 0nv6AN5LsDOL7qvXc9l/VOHWKFc9nNFfooNvRVo37ZFUXd9w0Olx/dVwuIvort4A5jJz Z6hWUkbNrACl04RI8h/aYLkOVEXI7E1cM8IvlURCqvFX2wQ3E+Jz0gfUkUwV03ncawas clKg== X-Gm-Message-State: ALKqPwegZsTzfKHFYPXkFMH5H4blZpLWv0rdv3phnBx4zXtcfsg6dZ2x QLsO70BbScJLxotPavlQDl9fOw== X-Google-Smtp-Source: ADUXVKI9CGTK7AnnUIi8pAuTfFlltbM+vqGEC6oArw5Z+6XinMxYrAH+rTE4X+jU24TKURQtGIhVMA== X-Received: by 2002:adf:a925:: with SMTP id u34-v6mr5825746wrc.248.1527770389791; Thu, 31 May 2018 05:39:49 -0700 (PDT) From: Filip Alac To: libvir-list@redhat.com Date: Thu, 31 May 2018 14:30:52 +0200 Message-Id: <20180531123054.13831-3-filipalac@gmail.com> In-Reply-To: <20180531123054.13831-1-filipalac@gmail.com> References: <20180531123054.13831-1-filipalac@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 31 May 2018 12:39:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 31 May 2018 12:39:51 +0000 (UTC) for IP:'209.85.128.174' DOMAIN:'mail-wr0-f174.google.com' HELO:'mail-wr0-f174.google.com' FROM:'filipalac@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.396 (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.128.174 mail-wr0-f174.google.com 209.85.128.174 mail-wr0-f174.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Filip Alac Subject: [libvirt] [PATCH v3 2/4] qemu: hostdev: Refactor code 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 31 May 2018 12:40:12 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make qemuHostdevHostSupportsPassthroughVFIO use virHostHasIOMMU. --- src/libvirt_private.syms | 2 ++ src/qemu/qemu_hostdev.c | 29 ++++------------------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6001635916..99a14ab460 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -58,6 +58,7 @@ virCapabilitiesFreeMachines; virCapabilitiesFreeNUMAInfo; virCapabilitiesGetCpusForNodemask; virCapabilitiesGetNodeInfo; +virCapabilitiesHostInitIOMMU; virCapabilitiesHostSecModelAddBaseLabel; virCapabilitiesInitCaches; virCapabilitiesInitNUMA; @@ -3073,6 +3074,7 @@ virGetUserName; virGetUserRuntimeDirectory; virGetUserShell; virHexToBin; +virHostHasIOMMU; virIndexToDiskName; virIsDevMapperDevice; virIsSUID; diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 955b5df1a3..25e2dcf868 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -23,7 +23,6 @@ =20 #include =20 -#include #include #include #include @@ -124,33 +123,13 @@ qemuHostdevUpdateActiveDomainDevices(virQEMUDriverPtr= driver, bool qemuHostdevHostSupportsPassthroughVFIO(void) { - DIR *iommuDir =3D NULL; - struct dirent *iommuGroup =3D NULL; - bool ret =3D false; - int direrr; - - /* condition 1 - /sys/kernel/iommu_groups/ contains entries */ - if (virDirOpenQuiet(&iommuDir, "/sys/kernel/iommu_groups/") < 0) - goto cleanup; - - while ((direrr =3D virDirRead(iommuDir, &iommuGroup, NULL)) > 0) { - /* assume we found a group */ - break; - } - - if (direrr < 0 || !iommuGroup) - goto cleanup; - /* okay, iommu is on and recognizes groups */ + if (!virHostHasIOMMU()) + return false; =20 - /* condition 2 - /dev/vfio/vfio exists */ if (!virFileExists("/dev/vfio/vfio")) - goto cleanup; - - ret =3D true; + return false; =20 - cleanup: - VIR_DIR_CLOSE(iommuDir); - return ret; + return true; } =20 =20 --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list