From nobody Thu May 2 02:28:06 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561577921; cv=none; d=zoho.com; s=zohoarc; b=Y5is/poVTlvXtvVIhGa1rnOn2Hsts/bILY1EFdU68o5dJR954tNISNR3O2f9IlxPDhj7ikDnRcAMpv3Qyk+LDB4GylNlTnR4YYD3zqLBFxV2SZPC8VrfRgCfjiAWG2dl91hu+tuz1T5aZWg7Nxuf5nnvV+Fu54qEaIidKwaMgb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561577921; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=4Yv+MFAemMah012a3WQS+RrZZMe/thZunVZ60teHU0w=; b=cc4l8xB1XmHS5KUiJtHaBBxNIA4GlLcaIAH76rWSWufmOs0DAURfHE7OPBDPYTe1ryVlg+W6qkSVkMsGwjm9RENClH7EfooAkzVr5nFdXcqVmjkSA9femeBYy6v5mHooePUYkRRWNCYyz7hPRsLU+KHZPPeHdaWAXN17F9aCeeo= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561577921853527.7613721137153; Wed, 26 Jun 2019 12:38:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6F91C1EB205; Wed, 26 Jun 2019 19:38: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 BA727600CC; Wed, 26 Jun 2019 19:38: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 8444B206D3; Wed, 26 Jun 2019 19:38:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5QJaNoT012779 for ; Wed, 26 Jun 2019 15:36:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id D1E9E5D9D3; Wed, 26 Jun 2019 19:36:23 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CAD425D9C6; Wed, 26 Jun 2019 19:36:21 +0000 (UTC) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (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 C9DA63004426; Wed, 26 Jun 2019 19:36:12 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id p15so3731054qtl.3; Wed, 26 Jun 2019 12:36:12 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:18:805:41b2:608e:c97b:9c84:d48f]) by smtp.gmail.com with ESMTPSA id k40sm10706658qta.50.2019.06.26.12.36.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 12:36:11 -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 :mime-version:content-transfer-encoding; bh=Y5e1TKReRsqKl4SF06xAqP04vFodVWi+dT189zZZICo=; b=mpRvbPyJmLjuXDc8iIrq/xyrM7IxNfm8tse+qRrEsMjAXBtjtj5Cl+C8j+ryoD0thR cbZ6/KoJkE45jLiGHoow25rSOOWalt//oP8RZH/0W7WB7lLlTeJx20FsIDsA+PbwSMbx u7o70Z3O7Omq2lYb+ulAyRrtUcM6HAiEE5RmoLWxu80xuyi+RE0IFz2khTNoR4tuDkcM nUlcXOX78cnrBQvEHl06iLNFHRfPotjOPyKlHFNvL24XYX7rSS/7l6cYICsBVZ9R4Ea1 KEI6RFi7cf8k1v5h3VigzMZwCpV/uDagqjSXO/1IK1MOI4bUNIDu4k4wAhq/7p4VK/yO juSA== 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:mime-version:content-transfer-encoding; bh=Y5e1TKReRsqKl4SF06xAqP04vFodVWi+dT189zZZICo=; b=GwJXeOc1/eJdKgEt91trBE5YXfmKNZuSDa7Nuon1u59cBO3LKaTcA1aaEZZS8T6nQc 6DP54ilShxhzBlBcCIZht+N1TnxZVdAhoDCPRy/pa+oUMlHzAXfaC95v3D4Fthvl4Skr XzYv4D2tWr7I+MAh2CW37rqz0oLdvOPD5DggC6A2c6zY0+0Pavq5MdM6c/Duzynp4D7M ctMsU3rmXYWxO5sJhGv9OfY9o5w8xutXp4sC9jABg4SqsYN6tthHuUdLQnVERRN2zGP6 ZwgyAkNrKrojjtPb7sXcPorWo49QXyZy9UM0wXHxTVw+3S7MDUsXPVy1J8vA+pArrkdF EPEA== X-Gm-Message-State: APjAAAX0jx/FcqKgMXWgFtz7Dw/He/dUOtHDH0BByyGsAERxMDk+gZZh UYBrMsHDs0smXZ4xN8e+fOHrLK7mJU0= X-Google-Smtp-Source: APXvYqxXzzBz79LUWMMtN9GMrR6hvhy2PQsX+DZxLAaQTgQpcTQBIMVsVBm5Y5uMh1sojH33EPPz6w== X-Received: by 2002:a0c:b4ae:: with SMTP id c46mr5195231qve.230.1561577771983; Wed, 26 Jun 2019 12:36:11 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 16:35:50 -0300 Message-Id: <20190626193559.24431-2-danielhb413@gmail.com> In-Reply-To: <20190626193559.24431-1-danielhb413@gmail.com> References: <20190626193559.24431-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 26 Jun 2019 19:36:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 26 Jun 2019 19:36:13 +0000 (UTC) for IP:'209.85.160.193' DOMAIN:'mail-qt1-f193.google.com' HELO:'mail-qt1-f193.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.142 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.160.193 mail-qt1-f193.google.com 209.85.160.193 mail-qt1-f193.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, laine@laine.org Subject: [libvirt] [PATCH v1 01/10] virpcimock: Move actions checking one level up 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: , 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 26 Jun 2019 19:38:40 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Michal Privoznik The pci_driver_bind() and pci_driver_unbind() functions are "internal implementation", meaning other parts of the code should be able to call them and get the job done. Checking for actions (PCI_ACTION_BIND and PCI_ACTION_UNBIND) should be done in handlers (pci_driver_handle_bind() and pci_driver_handle_unbind()). Surprisingly, the other two actions (PCI_ACTION_NEW_ID and PCI_ACTION_REMOVE_ID) are checked already at this level. Signed-off-by: Michal Privoznik --- tests/virpcimock.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index beb5e1490d..6865f992dc 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -551,8 +551,8 @@ pci_driver_bind(struct pciDriver *driver, int ret =3D -1; char *devpath =3D NULL, *driverpath =3D NULL; =20 - if (dev->driver || PCI_ACTION_BIND & driver->fail) { - /* Device already bound or failing driver requested */ + if (dev->driver) { + /* Device already bound */ errno =3D ENODEV; return ret; } @@ -598,8 +598,8 @@ pci_driver_unbind(struct pciDriver *driver, int ret =3D -1; char *devpath =3D NULL, *driverpath =3D NULL; =20 - if (dev->driver !=3D driver || PCI_ACTION_UNBIND & driver->fail) { - /* Device not bound to the @driver or failing driver used */ + if (dev->driver !=3D driver) { + /* Device not bound to the @driver */ errno =3D ENODEV; return ret; } @@ -669,8 +669,8 @@ pci_driver_handle_bind(const char *path) struct pciDevice *dev =3D pci_device_find_by_content(path); struct pciDriver *driver =3D pci_driver_find_by_path(path); =20 - if (!driver || !dev) { - /* This should never happen (TM) */ + if (!driver || !dev || PCI_ACTION_BIND & driver->fail) { + /* No driver, no device or failing driver requested */ errno =3D ENODEV; goto cleanup; } @@ -686,8 +686,8 @@ pci_driver_handle_unbind(const char *path) int ret =3D -1; struct pciDevice *dev =3D pci_device_find_by_content(path); =20 - if (!dev || !dev->driver) { - /* This should never happen (TM) */ + if (!dev || !dev->driver || PCI_ACTION_UNBIND & dev->driver->fail) { + /* No device, device not binded or failing driver requested */ errno =3D ENODEV; goto cleanup; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:28:06 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561577874; cv=none; d=zoho.com; s=zohoarc; b=HqiKZ0wJvWrCPNepVJSE+ZoyxnvRherPF1QSb4Vz4U2kQyKELyPFKjyBsIM+sDWH6PfTokiaDHRpmSRMRhd/k3EmnriM2DU0SzgOdKS8AhzFkCZJATVgVCOfCg4p+59UpiK/l44grMRa4E2fGD8Fltgy5xiB3xiUxSPja0iTgUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561577874; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=dkS3ibT2/3uH/WuJ8MC35URBxg9nQv1+GF7z+3U/rLA=; b=M+cdljxKrudFAkxcg1/ig1rXYsYBT3uNnDG5qnSljVg106ksA1zwafxcHWpuVNGW96XWH7A3eyJZd14gEA/p8F3DaTf5PyFR3Mj/a5jmlVgz/f3dIrV5m/vfMH07/mIsKw475kohwUa4bL1//V6M93CD12YdIKekPUgiFo5VWac= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561577874368913.7665412444509; Wed, 26 Jun 2019 12:37:54 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 5F6573082B4D; Wed, 26 Jun 2019 19:37:52 +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 9CA105D717; Wed, 26 Jun 2019 19:37:47 +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 B5CA41806B0F; Wed, 26 Jun 2019 19:37:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5QJaMMb012735 for ; Wed, 26 Jun 2019 15:36:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 08EF55C226; Wed, 26 Jun 2019 19:36:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02CBC5C1B4; Wed, 26 Jun 2019 19:36:19 +0000 (UTC) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (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 47702C049E23; Wed, 26 Jun 2019 19:36:14 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id d17so3696819qtj.8; Wed, 26 Jun 2019 12:36:14 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:18:805:41b2:608e:c97b:9c84:d48f]) by smtp.gmail.com with ESMTPSA id k40sm10706658qta.50.2019.06.26.12.36.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 12:36:13 -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 :mime-version:content-transfer-encoding; bh=FjG5o1gGx/m6VCrpgtEklci257UVyvr9Z8GYHKyXznY=; b=gy8DRVT45+g47tnyM9jcb96ePB2otJnQwSAZXSITSM3GsT1GXAHaKXfOHx9HA4BiJB L36aEbq6FkYhPD2aXARrYkvr9fRmSgmfCFDusz62IJp0APHpmIpnnZcOQeI/VDSdQ9Le h3DiJRT9zPWGgireojejMdYDh3ROAPyvHiUU2G/cG+q/y9RiybpMx7d9JQW3dTclwwEl HVIfCKlOlCijwbRaelLy/yvCeTPqzy9P9H74bJNTeVmlYS3+e4jlt4rlydsVy3ug+RsG XNJj4MdFcuf9wJnZpKDKg9fbAHbIcRtAg/JXihh7tjNCBzf5KNGqo3d31LyoioRx2CGL HPHw== 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:mime-version:content-transfer-encoding; bh=FjG5o1gGx/m6VCrpgtEklci257UVyvr9Z8GYHKyXznY=; b=B75QZqIPJI2QvSXYXIsFUB/bm6Y5cgWqnYPhj0uphlS12PXLRNEk1OrZeXF4TY66iq YqwKxijT2kLY/0CEOoHzmHCu8zcb8wvFUygXj9/QeIYPg8OPgXgijtMTqAvMhJbMKFCH 9D7fLLEMUbW9wfX5+MGyRBoDDvYy6ZELDgx2xKk97Ew/UTZsP3OanzK8gO4G/wTHj9JD Gq/n8q3OyBX8PG9MKFIlf1HhJ6txVFHYMEwr8l4oUHXvkiLMT84wIPAiMDiVXDoovmZf UkIf5MfnN13n/pm/azC2O1fdvYE4xbfRDqY875KW/dt+8qyKxo0cA78Exp9+tycuGEjs /BVA== X-Gm-Message-State: APjAAAXO3B8ljwSdVSlaHuMJ21uZ6K8rbowxs/RBoyQKXVXE7OI5jF4Z /V2pKWyR1LMfc/oou2jdFa9F/aCqVQo= X-Google-Smtp-Source: APXvYqzxRgQWwK81+7/1j04APztg6/zO4nSzEtF4zrX532vA3bpKJ1RfvSGtZg66HODhIEQOWJIvVw== X-Received: by 2002:ac8:428f:: with SMTP id o15mr5155210qtl.210.1561577773453; Wed, 26 Jun 2019 12:36:13 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 16:35:51 -0300 Message-Id: <20190626193559.24431-3-danielhb413@gmail.com> In-Reply-To: <20190626193559.24431-1-danielhb413@gmail.com> References: <20190626193559.24431-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 26 Jun 2019 19:36:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 26 Jun 2019 19:36:14 +0000 (UTC) for IP:'209.85.160.193' DOMAIN:'mail-qt1-f193.google.com' HELO:'mail-qt1-f193.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.142 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.160.193 mail-qt1-f193.google.com 209.85.160.193 mail-qt1-f193.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, laine@laine.org Subject: [libvirt] [PATCH v1 02/10] Revert "virpcitest: Test virPCIDeviceDetach failure" 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 26 Jun 2019 19:37:53 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Michal Privoznik This reverts commit b70c093ffa00cd87c8d39d3652b798f033a81faf. In next commit the virpcimock is going to be extended and thus binding a PCI device to vfio-pci driver will finally succeed. Remove this test as it will no longer make sense. Signed-off-by: Michal Privoznik --- tests/virpcitest.c | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 961a7eff1a..9ecd1b7d27 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -256,36 +256,6 @@ testVirPCIDeviceDetachSingle(const void *opaque) return ret; } =20 -static int -testVirPCIDeviceDetachFail(const void *opaque) -{ - const struct testPCIDevData *data =3D opaque; - int ret =3D -1; - virPCIDevicePtr dev; - - dev =3D virPCIDeviceNew(data->domain, data->bus, data->slot, data->fun= ction); - if (!dev) - goto cleanup; - - virPCIDeviceSetStubDriver(dev, VIR_PCI_STUB_DRIVER_VFIO); - - if (virPCIDeviceDetach(dev, NULL, NULL) < 0) { - if (virTestGetVerbose() || virTestGetDebug()) - virDispatchError(NULL); - virResetLastError(); - ret =3D 0; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - "Attaching device %s to %s should have failed", - virPCIDeviceGetName(dev), - virPCIStubDriverTypeToString(VIR_PCI_STUB_DRIVER_VF= IO)); - } - - cleanup: - virPCIDeviceFree(dev); - return ret; -} - static int testVirPCIDeviceReattachSingle(const void *opaque) { @@ -421,8 +391,6 @@ mymain(void) DO_TEST_PCI(testVirPCIDeviceIsAssignable, 5, 0x90, 1, 0); DO_TEST_PCI(testVirPCIDeviceIsAssignable, 1, 1, 0, 0); =20 - DO_TEST_PCI(testVirPCIDeviceDetachFail, 0, 0x0a, 1, 0); - /* Reattach a device already bound to non-stub a driver */ DO_TEST_PCI_DRIVER(0, 0x0a, 1, 0, "i915"); DO_TEST_PCI(testVirPCIDeviceReattachSingle, 0, 0x0a, 1, 0); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:28:06 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561577870; cv=none; d=zoho.com; s=zohoarc; b=kzrjZ7OVlXBO19J+qbKAgAvSX3i3zI70GZD6NSCsuHCV+DczZDjMLmS6NcvNraHaNdSml3AB0OzKY0C4+s+09yYxaaTKBOZGhUwzeoXU4ABML4ykf0STXrSXHvL9GNKX9nQXRXl4u5zsSy3oivqr0WFJOhVJPCvBSPGedFRqNxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561577870; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=5ufqiMHDY1FDmqj6aDEYnlF/Ig3TXZ/+fbCZ51LLRYE=; b=mSDXcNtz+p0NpyNuMWjdqIqHuyGjAmvygw8ZCSrcU0UMcrVC1JPDaAM9UxbLzPs25ZOSBJ9mPYifYAWn9/WvcWw5VABE0oep9adJvQiQby2wjWOlfY/Ra2oEoxfIq++pstEV2R+xmdEqdDkRCNsouZqI4Sq94Vk2wmNs1xop7x8= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561577870471994.3348207583249; Wed, 26 Jun 2019 12:37:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A17F730832D3; Wed, 26 Jun 2019 19:37:17 +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 3C6566012E; Wed, 26 Jun 2019 19:37:00 +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 B6AE91806B0F; Wed, 26 Jun 2019 19:36:35 +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 x5QJaNEG012785 for ; Wed, 26 Jun 2019 15:36:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id E396660856; Wed, 26 Jun 2019 19:36:23 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC5B760852; Wed, 26 Jun 2019 19:36:21 +0000 (UTC) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (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 0DF3A3084039; Wed, 26 Jun 2019 19:36:16 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id m29so3748302qtu.1; Wed, 26 Jun 2019 12:36:16 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:18:805:41b2:608e:c97b:9c84:d48f]) by smtp.gmail.com with ESMTPSA id k40sm10706658qta.50.2019.06.26.12.36.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 12:36:14 -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 :mime-version:content-transfer-encoding; bh=/0vfn3QXCQJDCGELlTblDSCazonE6wQ9xH2yWA9WOec=; b=MDQAcVrgzYcSoupYSuaJN0akY14aNA90OAyCdfWFmgHsmGoczYoSrWMQ2akjVqCzGo DkLE1qtgZbcYmuWCDOHIAtjswkANma7bPUvRg5M8d0ECVd1yMr5jYnY1YzGAX0vOwjfk THLyUbxWYxJh1iflRyLRX45OR2yq+7Y/lFhhRCRWAwa3Q+hoO58EPRit3U3DW3S2OP2v I0iVOqOSYFU0G6c33y9A4h65zcok9IEwFTPyeYea5ZpbJZpuiGTeYr+D9WgtIrezPgeF lbAHzp08msLLJX69Q0wqgMO9kqbEMbpPLkaftH3TjEgl9bQJ1SaNsBAohiqn+TxjZBMp b90g== 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:mime-version:content-transfer-encoding; bh=/0vfn3QXCQJDCGELlTblDSCazonE6wQ9xH2yWA9WOec=; b=rcDJkl3VVpgFhjgfGm3qUa0nfDrLbHU5mDnX5FREf93NsL1EbxD5BYPs0PQWMO+df4 //7cGHW317s9/0cKg/PLSsgeRjV+uiAg8sWFQiVhxxYKHtQjLzCvWuRMdk3TMQV5p36S ShkLmszJOpdtSmkRIr0Y6toqbG2iK3ciD6RSuRIdv9VkZEh1AWX8vt6QuvTMQHM3WlsU BN2/iB1nrwf3hNNtlTlBgNbnhB7+iQq+i3Nu0RaMfgxuNKExkqtl1ibuNUkEUT/BnXwq mTnr90bNin6NaP25GDCPHgei16iN/B2fTUnwuoGnTo1fc+9OZmNCnc/TeT7FPjdsWEvE Rokw== X-Gm-Message-State: APjAAAVqw70BHzXzrAQWnY+/HsfHGwgjAKeRdW0wi/bE1iXPiKLDyj9V 7RDUArqVgMYhCBEqyYuSMF/ccHT+aes= X-Google-Smtp-Source: APXvYqyH5YhclSJP3DbPNf1mKj4AvgkgO/rGPEKj4yWVsH5RUxhGOGu4/19KlN+AGYV2xsN8I9808Q== X-Received: by 2002:a0c:9186:: with SMTP id n6mr5054868qvn.5.1561577775050; Wed, 26 Jun 2019 12:36:15 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 16:35:52 -0300 Message-Id: <20190626193559.24431-4-danielhb413@gmail.com> In-Reply-To: <20190626193559.24431-1-danielhb413@gmail.com> References: <20190626193559.24431-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 26 Jun 2019 19:36:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 26 Jun 2019 19:36:16 +0000 (UTC) for IP:'209.85.160.193' DOMAIN:'mail-qt1-f193.google.com' HELO:'mail-qt1-f193.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.143 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS) 209.85.160.193 mail-qt1-f193.google.com 209.85.160.193 mail-qt1-f193.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, laine@laine.org Subject: [libvirt] [PATCH v1 03/10] virpcimock: Create driver_override file in device dirs 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: , 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 26 Jun 2019 19:37:48 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Michal Privoznik Newer kernels (v3.16-rc1~29^2~6^4) have 'driver_override' file which simplifies way of binding a PCI device to desired driver. Libvirt has support for this for some time too (v2.3.0-rc1~236), but not our virpcimock. So far we did not care because our code is designed to deal with this situation. Except for one. hypothetical case: binding a device to the vfio-pci driver can be successful only via driver_override. Any attempt to bind a PCI device to vfio-pci driver using old method (new_id + unbind + bind) will fail because of b803b29c1a5. While on vanilla kernel I'm able to use the old method successfully, it's failing on RHEL kernels (not sure why). Signed-off-by: Michal Privoznik --- tests/virpcimock.c | 59 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 6865f992dc..5d55038a26 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -87,6 +87,11 @@ char *fakesysfspcidir; * Probe for a driver that handles the specified device. * Data in format "DDDD:BB:DD.F" (Domain:Bus:Device.Function). * + * /sys/bus/pci/devices//driver_override + * Name of a driver that overrides preferred driver can be written + * here. The device will be attached to it on drivers_probe event. + * Writing an empty string (or "\n") clears the override. + * * As a little hack, we are not mocking write to these files, but close() * instead. The advantage is we don't need any self growing array to hold = the * partial writes and construct them back. We can let all the writes finis= h, @@ -147,6 +152,7 @@ static struct pciDevice *pci_device_find_by_content(con= st char *path); static void pci_driver_new(const char *name, int fail, ...); static struct pciDriver *pci_driver_find_by_dev(struct pciDevice *dev); static struct pciDriver *pci_driver_find_by_path(const char *path); +static struct pciDriver *pci_driver_find_by_driver_override(struct pciDevi= ce *dev); static int pci_driver_bind(struct pciDriver *driver, struct pciDevice *dev= ); static int pci_driver_unbind(struct pciDriver *driver, struct pciDevice *d= ev); static int pci_driver_handle_change(int fd, const char *path); @@ -202,7 +208,8 @@ make_symlink(const char *path, static int pci_read_file(const char *path, char *buf, - size_t buf_size) + size_t buf_size, + bool truncate) { int ret =3D -1; int fd =3D -1; @@ -224,7 +231,8 @@ pci_read_file(const char *path, goto cleanup; } =20 - if (ftruncate(fd, 0) < 0) + if (truncate && + ftruncate(fd, 0) < 0) goto cleanup; =20 ret =3D 0; @@ -398,6 +406,8 @@ pci_device_new_from_stub(const struct pciDevice *data) ABORT("@tmp overflow"); make_file(devpath, "class", tmp, -1); =20 + make_file(devpath, "driver_override", NULL, -1); + if (snprintf(tmp, sizeof(tmp), "%s/../../../kernel/iommu_groups/%d", devpath, dev->iommuGroup) < 0) { @@ -441,7 +451,7 @@ pci_device_find_by_content(const char *path) { char tmp[32]; =20 - if (pci_read_file(path, tmp, sizeof(tmp)) < 0) + if (pci_read_file(path, tmp, sizeof(tmp), true) < 0) return NULL; =20 return pci_device_find_by_id(tmp); @@ -450,7 +460,10 @@ pci_device_find_by_content(const char *path) static int pci_device_autobind(struct pciDevice *dev) { - struct pciDriver *driver =3D pci_driver_find_by_dev(dev); + struct pciDriver *driver =3D pci_driver_find_by_driver_override(dev); + + if (!driver) + driver =3D pci_driver_find_by_dev(dev); =20 if (!driver) { /* No driver found. Nothing to do */ @@ -544,6 +557,36 @@ pci_driver_find_by_path(const char *path) return NULL; } =20 +static struct pciDriver * +pci_driver_find_by_driver_override(struct pciDevice *dev) +{ + struct pciDriver *ret =3D NULL; + char *path =3D NULL; + char tmp[32]; + size_t i; + + if (virAsprintfQuiet(&path, + SYSFS_PCI_PREFIX "devices/%s/driver_override", + dev->id) < 0) + return NULL; + + if (pci_read_file(path, tmp, sizeof(tmp), false) < 0) + goto cleanup; + + for (i =3D 0; i < nPCIDrivers; i++) { + struct pciDriver *driver =3D pciDrivers[i]; + + if (STREQ(tmp, driver->name)) { + ret =3D driver; + break; + } + } + + cleanup: + VIR_FREE(path); + return ret; +} + static int pci_driver_bind(struct pciDriver *driver, struct pciDevice *dev) @@ -644,7 +687,7 @@ pci_driver_handle_drivers_probe(const char *path) static int pci_driver_handle_change(int fd ATTRIBUTE_UNUSED, const char *path) { - int ret; + int ret =3D 0; const char *file =3D last_component(path); =20 if (STREQ(file, "bind")) @@ -657,6 +700,8 @@ pci_driver_handle_change(int fd ATTRIBUTE_UNUSED, const= char *path) ret =3D pci_driver_handle_remove_id(path); else if (STREQ(file, "drivers_probe")) ret =3D pci_driver_handle_drivers_probe(path); + else if (STREQ(file, "driver_override")) + ; /* nada */ else ABORT("Not handled write to: %s", path); return ret; @@ -711,7 +756,7 @@ pci_driver_handle_new_id(const char *path) goto cleanup; } =20 - if (pci_read_file(path, buf, sizeof(buf)) < 0) + if (pci_read_file(path, buf, sizeof(buf), true) < 0) goto cleanup; =20 if (sscanf(buf, "%x %x", &vendor, &device) < 2) { @@ -766,7 +811,7 @@ pci_driver_handle_remove_id(const char *path) goto cleanup; } =20 - if (pci_read_file(path, buf, sizeof(buf)) < 0) + if (pci_read_file(path, buf, sizeof(buf), true) < 0) goto cleanup; =20 if (sscanf(buf, "%x %x", &vendor, &device) < 2) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:28:06 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561577938; cv=none; d=zoho.com; s=zohoarc; b=jXRnQU/e2WfezLTg9FktUw/+HMfCCNuW8OB5QreszRlSuzb0Yse4UNIY1gSJqkncL940UeobogILVvCmuTWztY65FDq7+0P2JQb1g4JqDFppOX4m45yaPic2pzhDZDaXpqi6KKyBPbqAHnSPmrFVjxtYASIQ4ui+RRbKiVv3Dpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561577938; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=tdO4JbW9In30tEXoUkqsmf4UXpKZXpttM7iRLl8kI20=; b=N35E+ELbVGpY3dPeU0NMZ35C+21EmaIdftqxZ6CZ3RI2AV0IKZ4pSPJDRk5WAVqzbo5jwshOIhM57Gmx8GPELjzaSi3IWxXWrDQ5ZgybGOKhuzRfbgGtuhgL/zyRLWJXxEDQCNMAYTG/I7RSvo9QZhhOQqSSQXPiB/FqbuF77ik= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561577938799894.1274391237008; Wed, 26 Jun 2019 12:38:58 -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 E886E51026; Wed, 26 Jun 2019 19:38:56 +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 B4766608C1; Wed, 26 Jun 2019 19:38:56 +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 792391806B0F; Wed, 26 Jun 2019 19:38:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5QJaWWW013041 for ; Wed, 26 Jun 2019 15:36:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5F73019733; Wed, 26 Jun 2019 19:36:32 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57A7819C5B; Wed, 26 Jun 2019 19:36:30 +0000 (UTC) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (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 DF4C6307BA56; Wed, 26 Jun 2019 19:36:22 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id j19so3685639qtr.12; Wed, 26 Jun 2019 12:36:22 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:18:805:41b2:608e:c97b:9c84:d48f]) by smtp.gmail.com with ESMTPSA id k40sm10706658qta.50.2019.06.26.12.36.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 12:36:16 -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 :mime-version:content-transfer-encoding; bh=BvbU+DN31c0fwjYrFwCMTouce/06d3mT+qhmwO2WYOQ=; b=srI42h6Iv126wQpP/TRPbNkpdCG1kgjTEoyupZrrXoazBbyzi8xBuekI2XVzuGK9+x y8vV6QPVC+fWw1UBWbEfu0o5PeIa4Oy62ZDDwOpnfTqm/M7I08Tw42VBiAPso2EBldCM il7Cq1wcbICjTELrchr6SCqmzmIx0bVx2uldkZBHk4WQlCFNce+JRtv6ei7E15SebN1g txkMcm5xWGq6+G6VhkPbFUOvCStaDMDKfpGMadp2n9oCWrYX3YZQWx/T0fA3n3NG0K9g BwGOTXmT7gOJQ4Tmo9z1xDl82vo2bFXrQI4ZOQe6boCrw4Br5WxjDkbNyFsGAsvL1dn5 CFkQ== 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:mime-version:content-transfer-encoding; bh=BvbU+DN31c0fwjYrFwCMTouce/06d3mT+qhmwO2WYOQ=; b=kpkeswgS4R30Wn1hhLrjoHEazZaNXFA4rZgPuLQdR+gVnArn1rIaWCuC0rTuoOdCha udLGqRP/rX9NH440ZhMxcRM4tZVzWpvEEp88YC+ZGqIyjzG7arUVABp8W72x0zakT271 SRdefmweH/Y7LkhxaBJ6LXXjvawfoZfvisj2r8THpCN3j+33SIoWQSW8um5KoUNrSeY1 cCI9iulIi91JPFt22kT980NtNh+XLOeEbKbSSaxAowlr0S+7Z4CYf728b9G762RWXVIt 1Lwnl2Qa32gShaSz2d7/+PpM2md+B2MR+ZvBIoD4fn6MCa743xcWshviTT61L7voE1ax 5m4Q== X-Gm-Message-State: APjAAAWwHqNOyEgFg21zjioXhVvE5kB0YcPL7HcO8Pubn5itWVw8qq76 OWHRzQIqUERWSiGacs7Qt+lIeWLod68= X-Google-Smtp-Source: APXvYqzSF2crwgrdffdMHedwzbPmj1gwOl8/t0hXwFjxVOhnaptHTg7+0KBk4tNEJaglFrrwO0UtzA== X-Received: by 2002:a0c:ad7a:: with SMTP id v55mr4980459qvc.130.1561577777068; Wed, 26 Jun 2019 12:36:17 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 16:35:53 -0300 Message-Id: <20190626193559.24431-5-danielhb413@gmail.com> In-Reply-To: <20190626193559.24431-1-danielhb413@gmail.com> References: <20190626193559.24431-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 26 Jun 2019 19:36:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 26 Jun 2019 19:36:23 +0000 (UTC) for IP:'209.85.160.196' DOMAIN:'mail-qt1-f196.google.com' HELO:'mail-qt1-f196.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.143 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS) 209.85.160.196 mail-qt1-f196.google.com 209.85.160.196 mail-qt1-f196.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH v1 04/10] tests: Fix the iommu group path in mock pci 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: , 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.39]); Wed, 26 Jun 2019 19:38:57 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat The mocked path falls into /sys/bus/kernel/iommu_groups instead of /sys/kernel/iommu_groups. Needed for adding some new test cases. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- tests/virpcimock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 5d55038a26..acd7560f8b 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -409,7 +409,7 @@ pci_device_new_from_stub(const struct pciDevice *data) make_file(devpath, "driver_override", NULL, -1); =20 if (snprintf(tmp, sizeof(tmp), - "%s/../../../kernel/iommu_groups/%d", + "%s/../../../../kernel/iommu_groups/%d", devpath, dev->iommuGroup) < 0) { ABORT("@tmp overflow"); } @@ -417,7 +417,7 @@ pci_device_new_from_stub(const struct pciDevice *data) ABORT("Unable to create %s", tmp); =20 if (snprintf(tmp, sizeof(tmp), - "../../../kernel/iommu_groups/%d", dev->iommuGroup) < 0) { + "../../../../kernel/iommu_groups/%d", dev->iommuGroup) < = 0) { ABORT("@tmp overflow"); } make_symlink(devpath, "iommu_group", tmp); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:28:06 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561577947; cv=none; d=zoho.com; s=zohoarc; b=hMUlrtJ4GHH4FcYoFKn2dB3mjVJ2pltXhsD2aSZSp7Z/8p7LGn9LikNzlNPXupe+jOm6+h18cplG6f1DVG8b3qdgBxEexIvMB2vuXuxGej0QzsHzMTZG0GyVJZq65BjmfKWCwCgIGd5g2JUr+or50mmXsk35o3ETl1H9byZ/rP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561577947; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=Q6gO1azatnxhbSTOerXiZw9LzcaftBrek9dybp81hx8=; b=AdOynLrQUHmxJ872lWwRDSwTGi+BJKnQQ94tucl6uUwMBFYdbtQU/plBpJ/SuzmrU1RpQSbzYtphmZXJA96/u7K+TWH6DhzgO3nua1Mi/f9Hb9i/cSuM54VVWOpynzmLKpddJeaw7TqB8wH85/fqGmtbYPVOg8r4vn4FrCRa0mY= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561577947095383.10298193945357; Wed, 26 Jun 2019 12:39:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 25D6C81F1B; Wed, 26 Jun 2019 19:39:00 +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 F1D026012E; Wed, 26 Jun 2019 19:38:59 +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 B1CF31806B16; Wed, 26 Jun 2019 19:38:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5QJaVjG012954 for ; Wed, 26 Jun 2019 15:36:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id F17865D71B; Wed, 26 Jun 2019 19:36:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9B555D717; Wed, 26 Jun 2019 19:36:28 +0000 (UTC) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (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 DEDE7308213C; Wed, 26 Jun 2019 19:36:19 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id m29so3748526qtu.1; Wed, 26 Jun 2019 12:36:19 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:18:805:41b2:608e:c97b:9c84:d48f]) by smtp.gmail.com with ESMTPSA id k40sm10706658qta.50.2019.06.26.12.36.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 12:36:18 -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 :mime-version:content-transfer-encoding; bh=flBjUAzqYIc+GrwWM/2w8/+tBktmyWpnBIB9U6Im+U4=; b=L1WeyUcWt0LuPl22ufDPEsddWZhSlO3FFxv5JBiApnFWWqMI/yUwUIkbpgkS31jhgX j0REAdZMqqfQj4kGBv0J5hsXqGB8hGmlAFv4br8PQ8LmJH9vd2pwQDIHIquU/V8zpNWd CKPX5yGeZlYPeLGUtPxYPxH4WSbvvZkfVqzHHZCaox7c4LuY/GUaG7KKYFXG9em1nCQC UCJQTzumQ2PalEUqv2SgmSdV78rS5GNSNhCv/HLFRsN8zONKjv1EPLkFrtHr7J1ptA0Q l5VAQdW6wo/tLoPguyy1YVwdt08GfSVl6DoSFZBjLEF7EOJsR+unix0k/0+eM+YY/PRY BFcg== 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:mime-version:content-transfer-encoding; bh=flBjUAzqYIc+GrwWM/2w8/+tBktmyWpnBIB9U6Im+U4=; b=jTTJHx1s5sN2qlgiqEVm1I2NbaStEwpHqPh0vOwkWQU8bca6mTxWleBnf0dQUmN3ME UNQukYANjwHLLxcghRYBHKBwY6RAhlty7ZtK8bUPdUaNJCBU02p+XFMCK1fsW3/Nt58E EqTGVjJ69SO5Q54Esahf8Eq40zMQIA2J4+RQKjwon3MfBpnEoC9Z2HL0acSb8SU8+9Xk gAHTbE3DsyOapqPdNbyZrZ9yZviAkBORAIbi+gkdqioxIIFMqQQxhZyPbE7v8/SpFiET 1r1VSiW2se6yTUn9CdN5vHAx9ktSpYepcB4rVxbdr1xJKlUTZ0wnX6pJTcpF/FaN+3lU rTzg== X-Gm-Message-State: APjAAAXH04svt8AwpTVKWyJZJVuEF+xNaaH3evOoPsYsMFYednn5KfwO HSyfK9BinNvc8ftNPTdzZBqE+DEBWvw= X-Google-Smtp-Source: APXvYqzp3B53X5aotaY3UI2IJKpNL2zs+YT88fncqDCOSztP7qUFDL798H0fXWoAbQrz1XHjbnftvQ== X-Received: by 2002:a0c:d94e:: with SMTP id t14mr4961583qvj.18.1561577778882; Wed, 26 Jun 2019 12:36:18 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 16:35:54 -0300 Message-Id: <20190626193559.24431-6-danielhb413@gmail.com> In-Reply-To: <20190626193559.24431-1-danielhb413@gmail.com> References: <20190626193559.24431-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 26 Jun 2019 19:36:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 26 Jun 2019 19:36:20 +0000 (UTC) for IP:'209.85.160.196' DOMAIN:'mail-qt1-f196.google.com' HELO:'mail-qt1-f196.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.143 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS) 209.85.160.196 mail-qt1-f196.google.com 209.85.160.196 mail-qt1-f196.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH v1 05/10] tests: pci: Mock the iommu groups and vfio 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: , 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 26 Jun 2019 19:39:05 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat The iommu group, /dev/vfio/ behaviors of the host are mocked. This patch implements support for multifunction/multiple devices per iommu groups and emulates the /dev/vfio/ file correctly. This code helps adding necessary testcases for pci-hotplug code. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- tests/virpcimock.c | 177 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 162 insertions(+), 15 deletions(-) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index acd7560f8b..fc8cb92ebd 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -44,6 +44,8 @@ char *fakerootdir; char *fakesysfspcidir; =20 # define SYSFS_PCI_PREFIX "/sys/bus/pci/" +# define SYSFS_KERNEL_PREFIX "/sys/kernel/" + =20 # define STDERR(...) \ fprintf(stderr, "%s %zu: ", __FUNCTION__, (size_t) __LINE__); \ @@ -128,6 +130,11 @@ struct pciDevice { struct pciDriver *driver; /* Driver attached. NULL if attached to no= driver */ }; =20 +struct pciIommuGroup { + int iommu; + size_t nDevicesBoundToVFIO; /* Indicates the devices in the gro= up */ +}; + struct fdCallback { int fd; char *path; @@ -139,6 +146,9 @@ size_t nPCIDevices =3D 0; struct pciDriver **pciDrivers =3D NULL; size_t nPCIDrivers =3D 0; =20 +struct pciIommuGroup **pciIommuGroups =3D NULL; +size_t npciIommuGroups =3D 0; + struct fdCallback *callbacks =3D NULL; size_t nCallbacks =3D 0; =20 @@ -255,6 +265,13 @@ getrealpath(char **newpath, errno =3D ENOMEM; return -1; } + } else if (STRPREFIX(path, SYSFS_KERNEL_PREFIX)) { + if (virAsprintfQuiet(newpath, "%s/%s", + fakerootdir, + path) < 0) { + errno =3D ENOMEM; + return -1; + } } else { if (VIR_STRDUP_QUIET(*newpath, path) < 0) return -1; @@ -473,6 +490,101 @@ pci_device_autobind(struct pciDevice *dev) return pci_driver_bind(driver, dev); } =20 +static void +pci_iommu_new(int num) +{ + char *iommupath, *kerneldir; + struct pciIommuGroup *iommuGroup; + + if (VIR_ALLOC_QUIET(iommuGroup) < 0) + ABORT_OOM(); + + iommuGroup->iommu =3D num; + iommuGroup->nDevicesBoundToVFIO =3D 0; /* No device bound to vfio by d= efault */ + + if (virAsprintfQuiet(&kerneldir, "%s%s", + fakerootdir, SYSFS_KERNEL_PREFIX) < 0) + ABORT_OOM(); + + if (virAsprintfQuiet(&iommupath, "%s/iommu_groups/%d/devices", kerneld= ir, num) < 0) + ABORT_OOM(); + VIR_FREE(kerneldir); + + if (virFileMakePath(iommupath) < 0) + ABORT("Unable to create: %s", iommupath); + VIR_FREE(iommupath); + + if (VIR_APPEND_ELEMENT_QUIET(pciIommuGroups, npciIommuGroups, iommuGro= up) < 0) + ABORT_OOM(); +} + +static int +pci_vfio_release_iommu(struct pciDevice *device) +{ + char *vfiopath =3D NULL; + int ret =3D -1; + size_t i =3D 0; + + for (i =3D 0; i < npciIommuGroups; i++) { + if (pciIommuGroups[i]->iommu =3D=3D device->iommuGroup) + break; + } + + if (i !=3D npciIommuGroups) { + if (pciIommuGroups[i]->nDevicesBoundToVFIO =3D=3D 0) { + ret =3D 0; + goto cleanup; + } + pciIommuGroups[i]->nDevicesBoundToVFIO--; + if (!pciIommuGroups[i]->nDevicesBoundToVFIO) { + if (virAsprintfQuiet(&vfiopath, "%s/dev/vfio/%d", + fakesysfspcidir, device->iommuGroup) < 0) { + errno =3D ENOMEM; + goto cleanup; + } + if (unlink(vfiopath) < 0) + goto cleanup; + } + } + + ret =3D 0; + cleanup: + VIR_FREE(vfiopath); + return ret; +} + +static int +pci_vfio_lock_iommu(struct pciDevice *device) +{ + char *vfiopath =3D NULL; + int ret =3D -1; + size_t i =3D 0; + int fd =3D -1; + + for (i =3D 0; i < npciIommuGroups; i++) { + if (pciIommuGroups[i]->iommu =3D=3D device->iommuGroup) + break; + } + + if (i !=3D npciIommuGroups) { + if (!pciIommuGroups[i]->nDevicesBoundToVFIO) { + if (virAsprintfQuiet(&vfiopath, "%s/dev/vfio/%d", + fakesysfspcidir, device->iommuGroup) < 0) { + errno =3D ENOMEM; + goto cleanup; + } + if ((fd =3D real_open(vfiopath, O_CREAT)) < 0) + goto cleanup; + } + pciIommuGroups[i]->nDevicesBoundToVFIO++; + } + + ret =3D 0; + cleanup: + real_close(fd); + VIR_FREE(vfiopath); + return ret; +} =20 /* * PCI Driver functions @@ -626,6 +738,10 @@ pci_driver_bind(struct pciDriver *driver, if (symlink(devpath, driverpath) < 0) goto cleanup; =20 + if (STREQ(driver->name, "vfio-pci")) + if (pci_vfio_lock_iommu(dev) < 0) + goto cleanup; + dev->driver =3D driver; ret =3D 0; cleanup: @@ -660,6 +776,10 @@ pci_driver_unbind(struct pciDriver *driver, unlink(driverpath) < 0) goto cleanup; =20 + if (STREQ(driver->name, "vfio-pci")) + if (pci_vfio_release_iommu(dev) < 0) + goto cleanup; + dev->driver =3D NULL; ret =3D 0; cleanup: @@ -858,6 +978,8 @@ init_syms(void) static void init_env(void) { + char *devVFIO; + if (fakerootdir && fakesysfspcidir) return; =20 @@ -873,6 +995,29 @@ init_env(void) =20 make_file(fakesysfspcidir, "drivers_probe", NULL, -1); =20 + if (virAsprintfQuiet(&devVFIO, "%s/dev/vfio", fakesysfspcidir) < 0) + ABORT_OOM(); + + if (virFileMakePath(devVFIO) < 0) + ABORT("Unable to create: %s", devVFIO); + + /* Create /dev/vfio/vfio file */ + make_file(devVFIO, "vfio", NULL, -1); + VIR_FREE(devVFIO); + + pci_iommu_new(0); + pci_iommu_new(1); + pci_iommu_new(2); + pci_iommu_new(3); + pci_iommu_new(4); + pci_iommu_new(5); + pci_iommu_new(6); + pci_iommu_new(7); + pci_iommu_new(8); + pci_iommu_new(9); + pci_iommu_new(10); + pci_iommu_new(11); + # define MAKE_PCI_DRIVER(name, ...) \ pci_driver_new(name, 0, __VA_ARGS__, -1, -1) =20 @@ -888,20 +1033,21 @@ init_env(void) pci_device_new_from_stub(&dev); \ } while (0) =20 - MAKE_PCI_DEVICE("0000:00:00.0", 0x8086, 0x0044); - MAKE_PCI_DEVICE("0000:00:01.0", 0x8086, 0x0044); - MAKE_PCI_DEVICE("0000:00:02.0", 0x8086, 0x0046); - MAKE_PCI_DEVICE("0000:00:03.0", 0x8086, 0x0048); - MAKE_PCI_DEVICE("0001:00:00.0", 0x1014, 0x03b9, .klass =3D 0x060400); - MAKE_PCI_DEVICE("0001:01:00.0", 0x8086, 0x105e, .iommuGroup =3D 0); - MAKE_PCI_DEVICE("0001:01:00.1", 0x8086, 0x105e, .iommuGroup =3D 0); - MAKE_PCI_DEVICE("0005:80:00.0", 0x10b5, 0x8112, .klass =3D 0x060400); - MAKE_PCI_DEVICE("0005:90:01.0", 0x1033, 0x0035, .iommuGroup =3D 1); - MAKE_PCI_DEVICE("0005:90:01.1", 0x1033, 0x0035, .iommuGroup =3D 1); - MAKE_PCI_DEVICE("0005:90:01.2", 0x1033, 0x00e0, .iommuGroup =3D 1); - MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047); - MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048); - MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048); + MAKE_PCI_DEVICE("0000:00:00.0", 0x8086, 0x0044, .iommuGroup =3D 0); + MAKE_PCI_DEVICE("0000:00:01.0", 0x8086, 0x0044, .iommuGroup =3D 1); + MAKE_PCI_DEVICE("0000:00:02.0", 0x8086, 0x0046, .iommuGroup =3D 2); + MAKE_PCI_DEVICE("0000:00:03.0", 0x8086, 0x0048, .iommuGroup =3D 3); + MAKE_PCI_DEVICE("0001:00:00.0", 0x1014, 0x03b9, .klass =3D 0x060400, .= iommuGroup =3D 4); + MAKE_PCI_DEVICE("0001:01:00.0", 0x8086, 0x105e, .iommuGroup =3D 5); + MAKE_PCI_DEVICE("0001:01:00.1", 0x8086, 0x105e, .iommuGroup =3D 5); + MAKE_PCI_DEVICE("0005:80:00.0", 0x10b5, 0x8112, .klass =3D 0x060400, .= iommuGroup =3D 6); + MAKE_PCI_DEVICE("0005:90:01.0", 0x1033, 0x0035, .iommuGroup =3D 7); + MAKE_PCI_DEVICE("0005:90:01.1", 0x1033, 0x0035, .iommuGroup =3D 7); + MAKE_PCI_DEVICE("0005:90:01.2", 0x1033, 0x00e0, .iommuGroup =3D 7); + MAKE_PCI_DEVICE("0005:90:01.3", 0x1033, 0x00e0, .iommuGroup =3D 7); + MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047, .iommuGroup =3D 8); + MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048, .iommuGroup =3D 8); + MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048, .iommuGroup =3D 8); } =20 =20 @@ -985,7 +1131,8 @@ opendir(const char *path) =20 init_syms(); =20 - if (STRPREFIX(path, SYSFS_PCI_PREFIX) && + if ((STRPREFIX(path, SYSFS_PCI_PREFIX) || + STRPREFIX(path, SYSFS_KERNEL_PREFIX)) && getrealpath(&newpath, path) < 0) return NULL; =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:28:06 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561577952; cv=none; d=zoho.com; s=zohoarc; b=nR8dlCcktUCHZXwhjgeWB0cLAkkcVxPeRg+Awn6RaovVe7WlTJ4kzifg7SwAFjO640yqliE8pl1KWu51F30VPCxd6DhQkKq//J6jrjSRT1qlMsaxAuTiEU+Z0La08w/CtQJEDPGtSSYMftZ6SDqI147NoiVpb/pe+N3veVW7kAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561577952; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=F27awY90gc6WNM+Fvf3dKnx/iBztgemLcv1s+Brlws8=; b=a9hpwYjMCQf3GLqYgQ57ZDm8KAl8giMdY7VdjoWM2cuD5V/NtjYmDfC48tHwVWKj1kJg767aMNN4t8S31F+5IXi3KND0C6fzYZTNMX40jANGsqKGr0wM8fx1Zf+lBSPhTASmzGW8RWxYd1rxOq8JdouHfWlDV0T6QzQ5W+0DLdc= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561577952030731.076454629486; Wed, 26 Jun 2019 12:39:12 -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 E58DD66995; Wed, 26 Jun 2019 19:39:07 +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 B27D9608C1; Wed, 26 Jun 2019 19:39:06 +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 6D540206D2; Wed, 26 Jun 2019 19:39:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5QJaXtU013059 for ; Wed, 26 Jun 2019 15:36:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id F25765D9D6; Wed, 26 Jun 2019 19:36:32 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EAAEE5D9C6; Wed, 26 Jun 2019 19:36:32 +0000 (UTC) Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) (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 96FFD8830C; Wed, 26 Jun 2019 19:36:21 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id x47so3682833qtk.11; Wed, 26 Jun 2019 12:36:21 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:18:805:41b2:608e:c97b:9c84:d48f]) by smtp.gmail.com with ESMTPSA id k40sm10706658qta.50.2019.06.26.12.36.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 12:36:20 -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 :mime-version:content-transfer-encoding; bh=lncVBjV6lVg71V6AJRDhmReAL3GIHke3KXetA3IJ5Vg=; b=obOZzNtrEvvKptnc/C4LjbSUL1JdJ8Pax4nNKEj90bfu4iEvRzCc6LUw6imcMdvVz7 F026vN29hst8HX+4YbIUHb4pL1TsvqbvbMlTWL9H4dEtpFCPfWESoe/01ARshEq5Mj3K Y2eLCbcBzYweNFmTbiGRH6BhbXu+j3bmCgX379ncG/70afSSYubgfGep51p3RyZmpP3E NXUn/ILP/vXcCWbUxf/3qDPCaoaLy+Z7jApSNTHcucpw34OSLCZ4PlfeOlMpETAh3wng dgibwErIo+GCoi68YOCAAn+hTalD9C4ZmoonbryW05j2IhlQIbrqJRt/t8VEcppkIUFs rwSw== 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:mime-version:content-transfer-encoding; bh=lncVBjV6lVg71V6AJRDhmReAL3GIHke3KXetA3IJ5Vg=; b=ED74IkGSl1fW7S0ZB1Wka0SkP2FFWnzmQiRdbFeOKTkh92V8ZAxvtmr6OC03hZECbW la6IbYFl7UBNpq2ckQXEx8+uydrjG8G9FueVzoIqL3mHg4wmhMC5nYjos4dqnxNfyoUE xP0ogIDrA6UD38kzrEk7kNcVolUeYfrYSWvA4HFRMyE3Tz6gsJFBtDI0EcvLTNHwyW5K VOxpJK943LAWqeMLe6sxk2ju1rrcHYt6IbRhIIF7W8CTekXpNFvaFx42jRLzhUWMGV4/ imJJojEKFciLTlh+MbUzy6/lNrKGkNM2diGcPmeIJ/Hb3v54Hz4w3Lc9JEQVKZCsSo5o SVeA== X-Gm-Message-State: APjAAAVu/52sHApB8Uq8CRASFCW92dtAeFkC5hcd1aI86WyA9+a8uoH3 tKaINZFEL2R0f3zuH2oDuPyjds5miiE= X-Google-Smtp-Source: APXvYqwf11OU1FVpJU6kEUvJXvrla1OK5ZOkcbleecRxd/CXzWNIbzpfNqC2iqJRjGl1UFJrLv1Emg== X-Received: by 2002:a0c:b084:: with SMTP id o4mr5098474qvc.227.1561577780715; Wed, 26 Jun 2019 12:36:20 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 16:35:55 -0300 Message-Id: <20190626193559.24431-7-danielhb413@gmail.com> In-Reply-To: <20190626193559.24431-1-danielhb413@gmail.com> References: <20190626193559.24431-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 26 Jun 2019 19:36:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 26 Jun 2019 19:36:21 +0000 (UTC) for IP:'209.85.160.195' DOMAIN:'mail-qt1-f195.google.com' HELO:'mail-qt1-f195.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.141 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.160.195 mail-qt1-f195.google.com 209.85.160.195 mail-qt1-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH v1 06/10] util/virhostdev: enhance VFIO device is in use detection 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: , 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.38]); Wed, 26 Jun 2019 19:39:10 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The current virHostdevPreparePCIDevices code fails to detect an unmanaged VFIO device that is in the activePCIHostdevs, and active in the same domain name as dom_name, as a device in use. Considering a call to this function, when activePCIHostdevs has a VFIO deviceA in the list, and deviceA is active in domain 'dom_name', this is what happens: - At step 1, the code goes to the 'if (usesVFIO)' block. All devices in the same IOMMU group of deviceA are used as argument of virHostdevIsPCINodeDeviceUsed, via the IOMMUGroupIterate function; - Inside virHostdevIsPCINodeDeviceUsed, an 'usesVFIO' verification is made, following to an 'iommu_owner' jump that sets ret=3D0. This will happen to all devices of the IOMMU group that belongs to the same domain as dom_name, including deviceA; - Step 2 starts, thinking that all devices inside hostdevs are available, which is not the case. This error was detected when changing tests/virhostdev.c to use vfio-pci instead of pci-stub (a change that will follow this one). The side effect observed was a test failure in testVirHostdevPreparePCIHostdevs_unmanaged, result of the behavior mentioned above: Unexpected count of items in mgr->inactivePCIHostdevs: 1, expecting 0 This patch fixes virHostdevIsPCINodeDeviceUsed to consider the case of a VFIO device that is already active in the domain. First, check if the device is in the activePCIHostdev list and bail immediately if true. Otherwise, in case of VFIO, check for IOMMU group ownership of the domain. This is done by a new callback function for IOMMUGroupIterate. If the VFIO device isn't in the active list and its domain has ownership of the IOMMU, then it is unused. Signed-off-by: Daniel Henrique Barboza --- src/util/virhostdev.c | 74 +++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index a3647a6cf4..35be8fede1 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -55,6 +55,46 @@ struct virHostdevIsPCINodeDeviceUsedData { const bool usesVFIO; }; =20 + +static virPCIDevicePtr +virHostdevFindActivePCIDevWithAddr(virPCIDeviceAddressPtr devAddr, + virHostdevManagerPtr mgr) +{ + virPCIDevicePtr ret =3D NULL; + + ret =3D virPCIDeviceListFindByIDs(mgr->activePCIHostdevs, + devAddr->domain, devAddr->bus, + devAddr->slot, devAddr->function); + + return ret; +} + +/* Callback to be used inside virHostdevIsPCINodeDeviceUsed to check + * for IOMMU ownership of a domain given by helperData->domainName. */ +static int +virHostdevDomainHasIOMMUOwnershipCb(virPCIDeviceAddressPtr devAddr, void *= opaque) +{ + struct virHostdevIsPCINodeDeviceUsedData *helperData =3D opaque; + virPCIDevicePtr actual; + int ret =3D 0; + + actual =3D virHostdevFindActivePCIDevWithAddr(devAddr, helperData->mgr= ); + if (!actual) + return ret; + + if (helperData->usesVFIO) { + const char *actual_drvname =3D NULL; + const char *actual_domname =3D NULL; + virPCIDeviceGetUsedBy(actual, &actual_drvname, &actual_domname); + + if ((actual_domname && helperData->domainName) && + (STRNEQ(actual_domname, helperData->domainName))) + ret =3D -1; + } + + return ret; +} + /* This module makes heavy use of bookkeeping lists contained inside a * virHostdevManager instance to keep track of the devices' status. To make * it easy to spot potential ownership errors when moving devices from one @@ -82,19 +122,13 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceA= ddressPtr devAddr, void *o int ret =3D -1; struct virHostdevIsPCINodeDeviceUsedData *helperData =3D opaque; =20 - actual =3D virPCIDeviceListFindByIDs(helperData->mgr->activePCIHostdev= s, - devAddr->domain, devAddr->bus, - devAddr->slot, devAddr->function); + actual =3D virHostdevFindActivePCIDevWithAddr(devAddr, helperData->mgr= ); + if (actual) { const char *actual_drvname =3D NULL; const char *actual_domname =3D NULL; virPCIDeviceGetUsedBy(actual, &actual_drvname, &actual_domname); =20 - if (helperData->usesVFIO && - (actual_domname && helperData->domainName) && - (STREQ(actual_domname, helperData->domainName))) - goto iommu_owner; - if (actual_drvname && actual_domname) virReportError(VIR_ERR_OPERATION_INVALID, _("PCI device %s is in use by " @@ -105,9 +139,20 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceA= ddressPtr devAddr, void *o virReportError(VIR_ERR_OPERATION_INVALID, _("PCI device %s is in use"), virPCIDeviceGetName(actual)); + goto cleanup; } - iommu_owner: + + /* For VFIO devices, the domain helperData->domainName must have owner= ship + * of the IOMMU group that contains devAddr. Otherwise, even if the de= vAddr + * is not in use, another device of that IOMMU group is in use by anot= herdomain, + * forbidding devAddr to be used in helperData->domainName. */ + if (helperData->usesVFIO) + if (virPCIDeviceAddressIOMMUGroupIterate(devAddr, + virHostdevDomainHasIOMMUO= wnershipCb, + helperData) < 0) + goto cleanup; + ret =3D 0; cleanup: return ret; @@ -673,17 +718,12 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, /* The device is in use by other active domain if * the dev is in list activePCIHostdevs. VFIO devices * belonging to same iommu group can't be shared - * across guests. + * across guests. virHostdevIsPCINodeDeviceUsedData handles + * both cases. */ devAddr =3D virPCIDeviceGetAddress(pci); - if (usesVFIO) { - if (virPCIDeviceAddressIOMMUGroupIterate(devAddr, - virHostdevIsPCINodeDe= viceUsed, - &data) < 0) - goto cleanup; - } else if (virHostdevIsPCINodeDeviceUsed(devAddr, &data)) { + if (virHostdevIsPCINodeDeviceUsed(devAddr, &data)) goto cleanup; - } } =20 /* Step 1.5: For non-802.11Qbh SRIOV network devices, save the --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:28:06 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561577963; cv=none; d=zoho.com; s=zohoarc; b=NVCjfuMLTkBrjmh7owZSSJoKZuqNL5VMbYwhmW+wgILSkO/5YXy1C2kwudanPrFewWEnceAYG0QlLDLrD0rFxEVluFHDSHdcVK48IfLar/yWMq/gyk4c8TpO0JPBxL800WFnY8tt6Gt+Rq1PEq5+wlrIvYOZMEWzsRlHOMVOnUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561577963; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=gQLjkTYVTzrH/Ab7IIwrm0ZGB+D4qRavJeS+1dNsFI4=; b=HOWHodguyXs8zgxZdN6zZf5KWw73yZnG4MASJ/7UmEFLqccii0qhw02FN+PWoUPV09IlRL9ErEgRvdfBn6y6r11/c8ahoj0e3Cg0rgSJwAQtIgtEr2Ziy2A0vMiX2QSEWykvbvApWERIzp6i3HcsXR9EPmR+3q6kiTBjgIcP++0= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561577963725662.3729523813176; Wed, 26 Jun 2019 12:39:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8964930860A3; Wed, 26 Jun 2019 19:39:16 +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 617315D9D6; Wed, 26 Jun 2019 19:39:16 +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 224EF206D6; Wed, 26 Jun 2019 19:39:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5QJaawu013160 for ; Wed, 26 Jun 2019 15:36:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5558B5C226; Wed, 26 Jun 2019 19:36:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4DDC25C1B4; Wed, 26 Jun 2019 19:36:36 +0000 (UTC) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (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 435E781F35; Wed, 26 Jun 2019 19:36:27 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id x18so2660732qkn.13; Wed, 26 Jun 2019 12:36:27 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:18:805:41b2:608e:c97b:9c84:d48f]) by smtp.gmail.com with ESMTPSA id k40sm10706658qta.50.2019.06.26.12.36.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 12:36:22 -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 :mime-version:content-transfer-encoding; bh=eFZXi6mMgiYCXtgFxGmeqzKVFPOcBYc6L1P8XMBYRDY=; b=GjPcWfZRF6NpAbyv+UbEqtwN+RFG5HMDwH41ytic1yu3AtnkXJGy/DzBY8eX0eO9qC T5uEpsde8GVmYwLjxPGlg1maAiOawg7IugPTK4KKIqh9VcIwwGwdsK4+MN3MzNv/+TS4 PhzNPZn+wiljzcftNsdlHHODfY1iN0wm5PdRZdRAN63l2TSSiWMesE0FLR3YcRksBVJh wgxbeW75ZRZUwW8XieFndNMG6XlkjXUCSsN1cjAGPEjfoCLOXJ+X6vzLs4YLV9/VB5YE 3reX8tjGNR6FNUPd/rMt/H66C/Geehk5fghLQP2STit4sutwAVyVrtQmFY1zptRLM8fg MLvw== 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:mime-version:content-transfer-encoding; bh=eFZXi6mMgiYCXtgFxGmeqzKVFPOcBYc6L1P8XMBYRDY=; b=mxzGoCum/7ER0vl9C+PrM34OJZmKv+fyB1ahWMJ+6K1TUUlzwl72zO+gam8w4tukNG lNKgoiUAtdAPp9gVb7feX5M9q1U0I9vTAJY03xxjwS9Eo4c5sin2Fmaw5Ep//REonp/6 zzPboOdVOmv8x4lW4Vyticauv5biprxnLI9s7wzvhbkCOKaj+KIWb4ksyzBH6MjnIQY/ 1Ckzrd07hBzEFMmvCaA6rBZj2pgmCgytVkpnC41XmXtQgs8BI8W0jZqbCtJgvlQcie4+ ZvQLbp/vT60c0ErbJSJP8xOowVwUdVuEqkq1TB4wAcHR9R7bj/PzdpH5hwggFZp+Wbpy CH9Q== X-Gm-Message-State: APjAAAXFojI3cClaAWznDT31TqOybRQk9F2VuvXYRYiWn7raTMW0wZ+C mMXzFwoiCuxM8EHwdIpZDIuop0kbM6I= X-Google-Smtp-Source: APXvYqyYFTHn/UZN2PvS0ET1Hsh696X2KklfZsHt0EB3MMAGD6XATPkGekRBZcKd0H8VXRRqDpW0PQ== X-Received: by 2002:ae9:e41a:: with SMTP id q26mr5447623qkc.361.1561577782631; Wed, 26 Jun 2019 12:36:22 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 16:35:56 -0300 Message-Id: <20190626193559.24431-8-danielhb413@gmail.com> In-Reply-To: <20190626193559.24431-1-danielhb413@gmail.com> References: <20190626193559.24431-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 26 Jun 2019 19:36:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 26 Jun 2019 19:36:27 +0000 (UTC) for IP:'209.85.222.195' DOMAIN:'mail-qk1-f195.google.com' HELO:'mail-qk1-f195.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.14 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.222.195 mail-qk1-f195.google.com 209.85.222.195 mail-qk1-f195.google.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH v1 07/10] virpcitest: Change the stub driver to vfio from pci-stub 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: , 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 26 Jun 2019 19:39:22 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat The pci-stub is obsolete for a while now. Upcoming test cases try to test the VFIO hotplug/unplug cases. Change the default test driver to vfio-pci instead of pci-stub, and fail bind for pci-stub instead. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- tests/virhostdevtest.c | 4 ++-- tests/virpcimock.c | 4 ++-- tests/virpcitest.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index 20eaca82e0..99ee2d44ec 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -93,7 +93,7 @@ myInit(void) subsys.u.pci.addr.bus =3D 0; subsys.u.pci.addr.slot =3D i + 1; subsys.u.pci.addr.function =3D 0; - subsys.u.pci.backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM; + subsys.u.pci.backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; hostdevs[i]->source.subsys =3D subsys; } =20 @@ -101,7 +101,7 @@ myInit(void) if (!(dev[i] =3D virPCIDeviceNew(0, 0, i + 1, 0))) goto cleanup; =20 - virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_KVM); + virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO); } =20 if (VIR_ALLOC(mgr) < 0) diff --git a/tests/virpcimock.c b/tests/virpcimock.c index fc8cb92ebd..f9863b2b82 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -1023,8 +1023,8 @@ init_env(void) =20 MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044); MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047); - MAKE_PCI_DRIVER("pci-stub", -1, -1); - pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1); + pci_driver_new("pci-stub", PCI_ACTION_BIND, -1, -1); + MAKE_PCI_DRIVER("vfio-pci", -1, -1); =20 # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \ do { \ diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 9ecd1b7d27..3319ab3d6a 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -106,12 +106,12 @@ testVirPCIDeviceDetach(const void *opaque ATTRIBUTE_U= NUSED) if (!(dev[i] =3D virPCIDeviceNew(0, 0, i + 1, 0))) goto cleanup; =20 - virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_KVM); + virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO); =20 if (virPCIDeviceDetach(dev[i], activeDevs, inactiveDevs) < 0) goto cleanup; =20 - if (testVirPCIDeviceCheckDriver(dev[i], "pci-stub") < 0) + if (testVirPCIDeviceCheckDriver(dev[i], "vfio-pci") < 0) goto cleanup; =20 CHECK_LIST_COUNT(activeDevs, 0); @@ -245,7 +245,7 @@ testVirPCIDeviceDetachSingle(const void *opaque) if (!dev) goto cleanup; =20 - virPCIDeviceSetStubDriver(dev, VIR_PCI_STUB_DRIVER_KVM); + virPCIDeviceSetStubDriver(dev, VIR_PCI_STUB_DRIVER_VFIO); =20 if (virPCIDeviceDetach(dev, NULL, NULL) < 0) goto cleanup; @@ -405,7 +405,7 @@ mymain(void) /* Detach an unbound device */ DO_TEST_PCI_DRIVER(0, 0x0a, 2, 0, NULL); DO_TEST_PCI(testVirPCIDeviceDetachSingle, 0, 0x0a, 2, 0); - DO_TEST_PCI_DRIVER(0, 0x0a, 2, 0, "pci-stub"); + DO_TEST_PCI_DRIVER(0, 0x0a, 2, 0, "vfio-pci"); =20 /* Reattach an unknown unbound device */ DO_TEST_PCI_DRIVER(0, 0x0a, 3, 0, NULL); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:28:06 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561577967; cv=none; d=zoho.com; s=zohoarc; b=j3A6CPRLusO24er/8FGTHiGIU5tsJfKDjCpEDJoPfZDJvXc9taIs2dZ9hb8a+77ENSYaKeC4X/IOX5msAvblsKwSQVjb+3ia2ZSbMaU8KkCVYT/qSrwnkJehf+20gaefGvA2Y5C6l5BSY2NAnYrbhr1mANPMDvQAHPKZL60tMvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561577967; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=9nas+MhoTo8OYyBwuczdr6LU5cVLQQPWPStcFGlNcwc=; b=HhJxbobZYs2jpHHvawkWQ/5ReuD79eIt0A6IBE/JqosIUxahdiMLo2zKWvwsCUMyhD/QZjtLeJzL4kStaFrZ6rROcEtjiBS6NZfpL7ia32J5Q2ig9Eih+lUQwDiYdzHK4E1CjXc8YE2DadSdD+pPqbVE9FHV8OcyYbQAF6PxKVo= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561577967563591.3287445531397; Wed, 26 Jun 2019 12:39:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8562830821F4; Wed, 26 Jun 2019 19:39:25 +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 E35496012E; Wed, 26 Jun 2019 19:39:24 +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 ABE461806B12; Wed, 26 Jun 2019 19:39:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5QJafs1013416 for ; Wed, 26 Jun 2019 15:36:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E71B60BF3; Wed, 26 Jun 2019 19:36:41 +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 87E1960C4C; Wed, 26 Jun 2019 19:36:40 +0000 (UTC) Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (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 3F61F30917A8; Wed, 26 Jun 2019 19:36:29 +0000 (UTC) Received: by mail-qk1-f171.google.com with SMTP id b18so2674290qkc.9; Wed, 26 Jun 2019 12:36:29 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:18:805:41b2:608e:c97b:9c84:d48f]) by smtp.gmail.com with ESMTPSA id k40sm10706658qta.50.2019.06.26.12.36.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 12:36:24 -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 :mime-version:content-transfer-encoding; bh=irGXvd54SskiH99g7y6v2bWAbgQW0vr8r1BBL6PAVbQ=; b=VuJv9gqhtOpHzPEsFHBZ9aVTlXgg9iIvV7U9W6PxWTNBVbXcdn8oGj2gVX4cvcyLxR Wo9FWMSyBBc8PlsHx3ol9/HmPPvbjYhfvLIwF4JCjUHdN8gRc92Iwbj3cBzinLEh9qz0 2/eOlBnCaMe+iVh3PF951vOOe66Uuk9cZ4nuwlnyNVktt3wdv4Ppxws/4QfAjCT/196I yxUrctlEFw34AxFOtXTnc4rieJ9QV4DkJMQjPjyd7uZo2u1OkHbN/G9BEuZiDiTjPDyC EVstYu7BTWB5330oFW1ZlLJ8eeHcyfIMOdpA5HEJahRPYt6EvQNxMzcd1M6ZR/r/ywWv QA1w== 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:mime-version:content-transfer-encoding; bh=irGXvd54SskiH99g7y6v2bWAbgQW0vr8r1BBL6PAVbQ=; b=bD1uogbTcylVuGNHok5J0YeKaA+kv2SjSuP+4pxUo/HlqskuAfNKceZ+NMksL+n4pB EAuTaV0Tunr9mGCVzo1js6imMoLonQjHqr5AbmDi+EU38d5xto+74PnLiUa50jgRdpjK NDfvS2fmtc7kUAgP8tvgXpcm983yc6svJ4ikgwPdkjCLj4n1CuiIm0LWWNpICJrfay74 Wb+JdiXOzjPrAPR9z8sNjPYW2GPCbmXM4pdfENMSmvzKhUljWZVtH91NJA9eh+8A+4uG YvR/WrxSnl6m7XmmoW4ACv80Ghi72YzazrgUYU7ewgvvneIjykV6DIZsbNJp/yI+hfpL hKOg== X-Gm-Message-State: APjAAAXdJih0G3yDGw1C4fwswjZXam/xdPkmtYwHyX3bQsPV3Qztux2Z VYazl/alLAj+a5PqM4oX+I4AaYPod9E= X-Google-Smtp-Source: APXvYqzjJFplblTlNaUl+56YnICaOHRf5FT+cPRrMQXWQp/0C0/G/KLMcWFjRETi4rp1cvltwKIZYw== X-Received: by 2002:a37:6112:: with SMTP id v18mr5422243qkb.126.1561577784708; Wed, 26 Jun 2019 12:36:24 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 16:35:57 -0300 Message-Id: <20190626193559.24431-9-danielhb413@gmail.com> In-Reply-To: <20190626193559.24431-1-danielhb413@gmail.com> References: <20190626193559.24431-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 26 Jun 2019 19:36:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 26 Jun 2019 19:36:29 +0000 (UTC) for IP:'209.85.222.171' DOMAIN:'mail-qk1-f171.google.com' HELO:'mail-qk1-f171.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.141 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.222.171 mail-qk1-f171.google.com 209.85.222.171 mail-qk1-f171.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH v1 08/10] virpcimock: Mock the SRIOV Virtual functions 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: , 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 26 Jun 2019 19:39:26 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat The softlink to physfn is the way to know if the device is VF or not. So, the patch softlinks 'physfn' to the parent function. The multifunction PCI devices dont have 'physfn' softlinks. The patch adds few Virtual functions to the mock environment and changes the existing VFIO test xmls using the VFs to use the newly added VFs for their use case. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- .../hostdev-vfio-multidomain.args | 2 +- .../hostdev-vfio-multidomain.xml | 2 +- tests/qemuxml2argvdata/hostdev-vfio.args | 2 +- tests/qemuxml2argvdata/hostdev-vfio.xml | 2 +- tests/qemuxml2argvdata/net-hostdev-fail.xml | 2 +- tests/qemuxml2argvdata/net-hostdev-vfio.args | 2 +- tests/qemuxml2argvdata/net-hostdev-vfio.xml | 2 +- tests/qemuxml2xmloutdata/hostdev-vfio.xml | 2 +- tests/qemuxml2xmloutdata/net-hostdev-vfio.xml | 2 +- tests/virpcimock.c | 16 ++++++++++++++++ tests/virpcitestdata/0000-06-12.0.config | Bin 0 -> 256 bytes tests/virpcitestdata/0000-06-12.1.config | Bin 0 -> 256 bytes tests/virpcitestdata/0000-06-12.2.config | Bin 0 -> 256 bytes 13 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 tests/virpcitestdata/0000-06-12.0.config create mode 100644 tests/virpcitestdata/0000-06-12.1.config create mode 100644 tests/virpcitestdata/0000-06-12.2.config diff --git a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args b/tests/q= emuxml2argvdata/hostdev-vfio-multidomain.args index d098bff356..959d2a8888 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args +++ b/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args @@ -27,5 +27,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --device vfio-pci,host=3D55aa:20:0f.3,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D0021:de:1f.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml b/tests/qe= muxml2argvdata/hostdev-vfio-multidomain.xml index 832458125b..7c34b65c7f 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml @@ -25,7 +25,7 @@ -
+
diff --git a/tests/qemuxml2argvdata/hostdev-vfio.args b/tests/qemuxml2argvd= ata/hostdev-vfio.args index b86181e267..e7456d0e49 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio.args +++ b/tests/qemuxml2argvdata/hostdev-vfio.args @@ -27,5 +27,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --device vfio-pci,host=3D06:12.5,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D06:12.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/hostdev-vfio.xml b/tests/qemuxml2argvda= ta/hostdev-vfio.xml index 4d96b9f732..b2e6c62e7e 100644 --- a/tests/qemuxml2argvdata/hostdev-vfio.xml +++ b/tests/qemuxml2argvdata/hostdev-vfio.xml @@ -27,7 +27,7 @@ -
+
diff --git a/tests/qemuxml2argvdata/net-hostdev-fail.xml b/tests/qemuxml2ar= gvdata/net-hostdev-fail.xml index c815d68bd9..50b102c658 100644 --- a/tests/qemuxml2argvdata/net-hostdev-fail.xml +++ b/tests/qemuxml2argvdata/net-hostdev-fail.xml @@ -25,7 +25,7 @@ -
+
diff --git a/tests/qemuxml2argvdata/net-hostdev-vfio.args b/tests/qemuxml2a= rgvdata/net-hostdev-vfio.args index fcc8716fdf..a7fb5819ac 100644 --- a/tests/qemuxml2argvdata/net-hostdev-vfio.args +++ b/tests/qemuxml2argvdata/net-hostdev-vfio.args @@ -27,5 +27,5 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --device vfio-pci,host=3D03:07.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D06:12.1,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/net-hostdev-vfio.xml b/tests/qemuxml2ar= gvdata/net-hostdev-vfio.xml index 24034cad8b..aff681c0fb 100644 --- a/tests/qemuxml2argvdata/net-hostdev-vfio.xml +++ b/tests/qemuxml2argvdata/net-hostdev-vfio.xml @@ -26,7 +26,7 @@ -
+
diff --git a/tests/qemuxml2xmloutdata/hostdev-vfio.xml b/tests/qemuxml2xmlo= utdata/hostdev-vfio.xml index 77bd62a129..15a845f4d1 100644 --- a/tests/qemuxml2xmloutdata/hostdev-vfio.xml +++ b/tests/qemuxml2xmloutdata/hostdev-vfio.xml @@ -32,7 +32,7 @@ -
+
diff --git a/tests/qemuxml2xmloutdata/net-hostdev-vfio.xml b/tests/qemuxml2= xmloutdata/net-hostdev-vfio.xml index 0523cd8d3b..3f057a8249 100644 --- a/tests/qemuxml2xmloutdata/net-hostdev-vfio.xml +++ b/tests/qemuxml2xmloutdata/net-hostdev-vfio.xml @@ -31,7 +31,7 @@ -
+
diff --git a/tests/virpcimock.c b/tests/virpcimock.c index f9863b2b82..9a1776febf 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -127,6 +127,7 @@ struct pciDevice { int device; int klass; int iommuGroup; + const char *physfn; struct pciDriver *driver; /* Driver attached. NULL if attached to no= driver */ }; =20 @@ -439,6 +440,15 @@ pci_device_new_from_stub(const struct pciDevice *data) } make_symlink(devpath, "iommu_group", tmp); =20 + if (dev->physfn) { + if (snprintf(tmp, sizeof(tmp), + "%s/devices/%s", fakesysfspcidir, dev->physfn) < 0) { + ABORT("@tmp overflow"); + } + make_symlink(devpath, "physfn", tmp); + } + + if (pci_device_autobind(dev) < 0) ABORT("Unable to bind: %s", data->id); =20 @@ -1048,6 +1058,12 @@ init_env(void) MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047, .iommuGroup =3D 8); MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048, .iommuGroup =3D 8); MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048, .iommuGroup =3D 8); + MAKE_PCI_DEVICE("0000:06:12.0", 0x8086, 0x0047, .iommuGroup =3D 9); + MAKE_PCI_DEVICE("0000:06:12.1", 0x8086, 0x0047, .iommuGroup =3D 10, .p= hysfn =3D "0000:06:12.0"); /* Virtual Function */ + MAKE_PCI_DEVICE("0000:06:12.2", 0x8086, 0x0047, .iommuGroup =3D 11, .p= hysfn =3D "0000:06:12.0"); /* Virtual Function */ + MAKE_PCI_DEVICE("0021:de:1f.0", 0x8086, 0x0047, .iommuGroup =3D 12); + MAKE_PCI_DEVICE("0021:de:1f.1", 0x8086, 0x0047, .iommuGroup =3D 13, .p= hysfn =3D "0021:de:1f.0"); /* Virtual Function */ + } =20 =20 diff --git a/tests/virpcitestdata/0000-06-12.0.config b/tests/virpcitestdat= a/0000-06-12.0.config new file mode 100644 index 0000000000000000000000000000000000000000..beee76534041a7020c08ae9ac03= d9a349c6ea12e GIT binary patch literal 256 ycmXpOFlAt45MXi^VCG@qU|?VnU}yr8Sb;H6EeJS(Ng%<*sKv;@R0rb@MH&E<&;s)S literal 0 HcmV?d00001 diff --git a/tests/virpcitestdata/0000-06-12.1.config b/tests/virpcitestdat= a/0000-06-12.1.config new file mode 100644 index 0000000000000000000000000000000000000000..beee76534041a7020c08ae9ac03= d9a349c6ea12e GIT binary patch literal 256 ycmXpOFlAt45MXi^VCG@qU|?VnU}yr8Sb;H6EeJS(Ng%<*sKv;@R0rb@MH&E<&;s)S literal 0 HcmV?d00001 diff --git a/tests/virpcitestdata/0000-06-12.2.config b/tests/virpcitestdat= a/0000-06-12.2.config new file mode 100644 index 0000000000000000000000000000000000000000..beee76534041a7020c08ae9ac03= d9a349c6ea12e GIT binary patch literal 256 ycmXpOFlAt45MXi^VCG@qU|?VnU}yr8Sb;H6EeJS(Ng%<*sKv;@R0rb@MH&E<&;s)S literal 0 HcmV?d00001 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:28:06 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561577966; cv=none; d=zoho.com; s=zohoarc; b=CaqHOK49xXU7uARtaevvejZckslyePbAVIewSnZzt6hquKi+uRv5u6BoYKVK8ftafISSbGapar8h8o3GE74q4mpdGQu+oovz6mucwppJQfO3abzfbAyLMKv69Z+DiY/AlUybY1vmzS1NQbQ2183TQcC9hLxSLM7SETyd+WkYH4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561577966; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=aiVvUU5pPGgYa4vwxE30/iaiW0m/oVzYDTkhrvISxvk=; b=J3LHXWG2yEV84eIqV4pMqE+KRSoY8MWn82ZmTgtFzHna81Z/h8pO/lIaZ4HJuLXr4uwKIBbeBPPm6Xgl0rhj29WIJZjLOri3aiViy3VUvrFqMJMkecPlm7YftALy0PJZ2TQO97kcnYdX9YBtzdPYxneOEEbvucm+GpIIm4oY0FE= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561577966536122.94903924715743; Wed, 26 Jun 2019 12:39:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 79B91C059B9F; Wed, 26 Jun 2019 19:39:19 +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 5474E60143; Wed, 26 Jun 2019 19:39:18 +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 13055206D8; Wed, 26 Jun 2019 19:39:18 +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 x5QJal7Z013711 for ; Wed, 26 Jun 2019 15:36:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id D514C608C1; Wed, 26 Jun 2019 19:36:47 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CA2C060852; Wed, 26 Jun 2019 19:36:45 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (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 DF0DC36807; Wed, 26 Jun 2019 19:36:33 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id l128so2705444qke.2; Wed, 26 Jun 2019 12:36:33 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:18:805:41b2:608e:c97b:9c84:d48f]) by smtp.gmail.com with ESMTPSA id k40sm10706658qta.50.2019.06.26.12.36.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 12:36:26 -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 :mime-version:content-transfer-encoding; bh=zUeCjGrijxB7EouaIqNy3Ph/qyGofGxMYkiAsvft+sc=; b=P/audFzNIhflgxCjtbVFy2eboWU9dwq3Pk20ki8IXBQsFcHLw9cHnY6DzUpj5JkOLl HKlf5EZc9V6olmjDv7Fku9G+fpbPBb7q88BbitQeXa1u9vw76bgx5qekL4KSc3qlGIVp K5iWnDU4FjwCctSD5O/iUS65nGM9pyH81ko6Lh55DjnUf4RJNjdyGEaSQD6zwgmehE6K YLrvrLLBSgZNjS2McZizHmR5dt2oQ6nDEsTkQgLT4hQaGICFXRoTZowq92D+et4PaCX2 DJUMXeuA/B6Z51D742iWZ2ylNKniCoE8O30gKfkEOXouw+rc+zocGZcqab09Jxfot+UH Qabg== 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:mime-version:content-transfer-encoding; bh=zUeCjGrijxB7EouaIqNy3Ph/qyGofGxMYkiAsvft+sc=; b=FJS2grAnULClI8CB3xnKwlYVpPlv4+DUPErL3BIyR5SNyiMkH+1tZMEOU47r707/0s d9DHJc4BEdZNsXa1H0yeg7w9WrqvEBP/LU+82Uycrk9eipq6mMJupI7FtGz+l3nl8BNm AHlnVhaAgi6nWYZhsX9v1cKaiYK+vnz3K3s4ONlebCeVZkDtvvNCDCfqCjj2FTVt9hMn 6T8057EEGfOuupwWKAeYt4EzJcGG9e306x9JdA6n2IL6CyZ8xXMDxJBaC3G7PEcKPlSP cqjCzQ6Z5gSR1+0bKsz4GCBFttfNGrmB2aZvlHp+BcLEZ7Af8zs6rPxuVBpGNIMC2WbM gtjA== X-Gm-Message-State: APjAAAX6dYy4WsoFtEX1Z66booZRDllTkhhJzfmv6JMswvN6W2G2Tlr4 48UsolHHdFhyCDxo7MuftZTUKcWWiGU= X-Google-Smtp-Source: APXvYqwD5V+X1b8rxULCjRvBkSPyjgYPE4DfaiLKCMTpwDAToN5pw4MQSeRG4aLwhM/csv83mZaFpg== X-Received: by 2002:a37:668c:: with SMTP id a134mr5550147qkc.477.1561577786988; Wed, 26 Jun 2019 12:36:26 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 16:35:58 -0300 Message-Id: <20190626193559.24431-10-danielhb413@gmail.com> In-Reply-To: <20190626193559.24431-1-danielhb413@gmail.com> References: <20190626193559.24431-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 26 Jun 2019 19:36:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 26 Jun 2019 19:36:34 +0000 (UTC) for IP:'209.85.222.196' DOMAIN:'mail-qk1-f196.google.com' HELO:'mail-qk1-f196.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.15 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.222.196 mail-qk1-f196.google.com 209.85.222.196 mail-qk1-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH v1 09/10] tests: qemu: Add test case for pci-hostdev hotplug 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: , 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 26 Jun 2019 19:39:25 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- src/util/virprocess.h | 2 +- tests/Makefile.am | 7 +++ tests/qemuhotplugtest.c | 42 +++++++++++++- .../qemuhotplug-hostdev-pci.xml | 6 ++ .../qemuhotplug-base-live+hostdev-pci.xml | 58 +++++++++++++++++++ ...uhotplug-pseries-base-live+hostdev-pci.xml | 51 ++++++++++++++++ .../qemuhotplug-pseries-base-live.xml | 43 ++++++++++++++ tests/virprocessmock.c | 28 +++++++++ 8 files changed, 235 insertions(+), 2 deletions(-) create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-live+host= dev-pci.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-l= ive+hostdev-pci.xml create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-l= ive.xml create mode 100644 tests/virprocessmock.c diff --git a/src/util/virprocess.h b/src/util/virprocess.h index d7d191ec75..fddd216c93 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -75,7 +75,7 @@ int virProcessGetNamespaces(pid_t pid, int virProcessSetNamespaces(size_t nfdlist, int *fdlist); =20 -int virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes); +int virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes) ATTRIBUTE= _NOINLINE; int virProcessSetMaxProcesses(pid_t pid, unsigned int procs); int virProcessSetMaxFiles(pid_t pid, unsigned int files); int virProcessSetMaxCoreSize(pid_t pid, unsigned long long bytes); diff --git a/tests/Makefile.am b/tests/Makefile.am index 115afa1c1a..05a20483e4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -211,6 +211,7 @@ test_libraries =3D libshunload.la \ virpcimock.la \ virnetdevmock.la \ virrandommock.la \ + virprocessmock.la \ virhostcpumock.la \ domaincapsmock.la \ virfilecachemock.la \ @@ -1193,6 +1194,12 @@ virrandommock_la_SOURCES =3D \ virrandommock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) virrandommock_la_LIBADD =3D $(MOCKLIBS_LIBS) =20 +virprocessmock_la_SOURCES =3D \ + virprocessmock.c +virprocessmock_la_CFLAGS =3D $(AM_CFLAGS) +virprocessmock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) +virprocessmock_la_LIBADD =3D $(MOCKLIBS_LIBS) + virhostcpumock_la_SOURCES =3D \ virhostcpumock.c virhostcpumock_la_LDFLAGS =3D $(MOCKLIBS_LDFLAGS) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 354068d748..bf95bfb4a7 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -28,6 +28,7 @@ #include "testutils.h" #include "testutilsqemu.h" #include "testutilsqemuschema.h" +#include "virhostdev.h" #include "virerror.h" #include "virstring.h" #include "virthread.h" @@ -79,6 +80,8 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_PLAIN); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_SCSI_DISK_WWN); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI); + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); =20 if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0) goto cleanup; @@ -130,6 +133,9 @@ testQemuHotplugAttach(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_WATCHDOG: ret =3D qemuDomainAttachWatchdog(&driver, vm, dev->data.watchdog); break; + case VIR_DOMAIN_DEVICE_HOSTDEV: + ret =3D qemuDomainAttachHostDevice(&driver, vm, dev->data.hostdev); + break; default: VIR_TEST_VERBOSE("device type '%s' cannot be attached\n", virDomainDeviceTypeToString(dev->type)); @@ -151,6 +157,7 @@ testQemuHotplugDetach(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_WATCHDOG: + case VIR_DOMAIN_DEVICE_HOSTDEV: ret =3D qemuDomainDetachDeviceLive(vm, dev, &driver, async); break; default: @@ -578,6 +585,7 @@ testQemuHotplugCpuIndividual(const void *opaque) return ret; } =20 +#define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" =20 =20 static int @@ -587,6 +595,21 @@ mymain(void) int ret =3D 0; struct qemuHotplugTestData data =3D {0}; struct testQemuHotplugCpuParams cpudata; + char *fakerootdir; + + if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { + fprintf(stderr, "Out of memory\n"); + abort(); + } + + if (!mkdtemp(fakerootdir)) { + fprintf(stderr, "Cannot create fakerootdir"); + abort(); + } + + setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); + unsetenv("LD_PRELOAD"); + =20 #if !WITH_YAJL fputs("libvirt not compiled with JSON support, skipping this test\n", = stderr); @@ -621,6 +644,8 @@ mymain(void) if (!driver.lockManager) return EXIT_FAILURE; =20 + driver.hostdevMgr =3D virHostdevManagerGetDefault(); + /* wait only 100ms for DEVICE_DELETED event */ qemuDomainRemoveDeviceWaitTime =3D 100; =20 @@ -789,6 +814,15 @@ mymain(void) "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); =20 + DO_TEST_ATTACH("base-live", "hostdev-pci", false, true, + "device_add", QMP_OK); + DO_TEST_DETACH("base-live", "hostdev-pci", false, false, + "device_del", QMP_DEVICE_DELETED("hostdev0") QMP_OK); + DO_TEST_ATTACH("pseries-base-live", "hostdev-pci", false, true, + "device_add", QMP_OK); + DO_TEST_DETACH("pseries-base-live", "hostdev-pci", false, false, + "device_del", QMP_DEVICE_DELETED("hostdev0") QMP_OK); + DO_TEST_ATTACH("base-live", "watchdog", false, true, "watchdog-set-action", QMP_OK, "device_add", QMP_OK); @@ -846,9 +880,15 @@ mymain(void) DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "16-22", true, true,= true); DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "17", true, true, tr= ue); =20 + if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) + virFileDeleteTree(fakerootdir); + VIR_FREE(fakerootdir); + qemuTestDriverFree(&driver); virObjectUnref(data.vm); return (ret =3D=3D 0) ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, + abs_builddir "/.libs/virpcimock.so", + abs_builddir "/.libs/virprocessmock.so"); diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml b/tes= ts/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml new file mode 100644 index 0000000000..6f7c99c943 --- /dev/null +++ b/tests/qemuhotplugtestdevices/qemuhotplug-hostdev-pci.xml @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+hostdev-pci= .xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+hostdev-pci.xml new file mode 100644 index 0000000000..40dcc33595 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+hostdev-pci.xml @@ -0,0 +1,58 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + +
+ + + +
+ + + +
+ + + + + + +
+ + + + + + + + + + +
+ + +
+ + + + + diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live+hos= tdev-pci.xml b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live+h= ostdev-pci.xml new file mode 100644 index 0000000000..483cb5d8f0 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live+hostdev-pc= i.xml @@ -0,0 +1,51 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-ppc64 + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + +
+ + +
+ + + + + + diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live.xml= b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live.xml new file mode 100644 index 0000000000..1dcc35f626 --- /dev/null +++ b/tests/qemuhotplugtestdomains/qemuhotplug-pseries-base-live.xml @@ -0,0 +1,43 @@ + + hotplug + d091ea82-29e6-2e34-3005-f02617b36e87 + 4194304 + 4194304 + 4 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-ppc64 + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + + + diff --git a/tests/virprocessmock.c b/tests/virprocessmock.c new file mode 100644 index 0000000000..985562fee1 --- /dev/null +++ b/tests/virprocessmock.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 Red Hat, Inc. + * Copyright (C) 2018 IBM Corp. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +#include +#include "virprocess.h" + +int +virProcessSetMaxMemLock(pid_t pid ATTRIBUTE_UNUSED, unsigned long long byt= es ATTRIBUTE_UNUSED) +{ + return 0; +} --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:28:06 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561577951; cv=none; d=zoho.com; s=zohoarc; b=hPTIE4xTOcaxOys4KLz4/dPiSUD1RPUiSJPcQVi4peILyNw0paVe3lI7hyNBjWsX4YW6a2mIc5b7gaAdS7ZG1Pzy8ar8inwAliLsrQzjWmD58KR2Xz4o2z/3ZGYyCm0kWDYMG1YHIU0hWr7V1y1YgKYF6fGejgUqjcIePBYXQMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561577951; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=pSkovgUcCyOfi3wVWAJbVWKVyp8+Vimc4OSW3QAPZdU=; b=TQFeykCJT0pR2E5vhLnWGH0zVCe+n6Ai85XJ/o2xISwpDfoXiGRU9ezUEzL/I+BDuBmdAKQ0quvPhxeo5cUcrZzKaQZcicEI1SZnGxA/l5dP63RztawUYf079ZSJu8nH605TbMIdDl+Yl/M1GsektpDiSu8Xi08iyk4oel/nqdo= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561577951323603.3605808417699; Wed, 26 Jun 2019 12:39:11 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id A32583162908; Wed, 26 Jun 2019 19:39:09 +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 79EE719936; Wed, 26 Jun 2019 19:39:09 +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 3CFC81806B1B; Wed, 26 Jun 2019 19:39:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5QJabj4013224 for ; Wed, 26 Jun 2019 15:36:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8465760BF3; Wed, 26 Jun 2019 19:36:37 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7DD2060BE5; Wed, 26 Jun 2019 19:36:35 +0000 (UTC) Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 C0874C058CBD; Wed, 26 Jun 2019 19:36:29 +0000 (UTC) Received: by mail-qt1-f181.google.com with SMTP id i34so3713482qta.6; Wed, 26 Jun 2019 12:36:29 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:18:805:41b2:608e:c97b:9c84:d48f]) by smtp.gmail.com with ESMTPSA id k40sm10706658qta.50.2019.06.26.12.36.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 12:36:28 -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 :mime-version:content-transfer-encoding; bh=fP98ja4eTuaooMiKIssspH0UPxY0p+snfktvV1V544M=; b=GgJihRY7SfP6AI/OVb7dm41OxQrwZge5QJcA+zDveqpSMpGXWkcuZUQmjmS0Z0OfpP T6ITykx/bzzNtRENPSDDWR2Ck6XY2QR7mp/0EyPQHUGXW+XgnyMry85n/r7IBNdIPwP4 MRiU68bMKfbUDlE00aaLsKtmyZXktOdPMmCoyEN8ubWB2mM6fxx6eSvjO45/j/vBwEWJ VoQcLkbljM8Ut4g5AL11KnErCvURMnaQSFvC3Pb0OkAF/xGRzOYpFqI8w8SU9p5uDOKr A3BB/yECB6QpmBeVB02XtoYW7N3E+TOhgUpRfK3UlFs/t03JDi+jMKuF24b8FAOWA7Y6 xyuA== 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:mime-version:content-transfer-encoding; bh=fP98ja4eTuaooMiKIssspH0UPxY0p+snfktvV1V544M=; b=lF1U0nrPfZUH3OruFLF5LFUaBxWt+I0F2RJcd46OtxtC218eOT/QYFeutFI1YemFwH fZbdNCJR7nR8fWY3fYJ6JLQS0DriKmhnBG7v8eUJw55etz92B+p5qMTDQWfyRckXpSvg 4ScY6fjXY/7xqxWY1kn9VI5JHDAzimeqs4UMXb5QjfzOR3GYgKxCosbezd2MPTMd7gXA 2CmKftcVuHkp71z6HKl6Cy9vK5syl94ncW/PVoqvVtMZwUEWUCrbg4jul12uD/rudpFn iwK97G933uRXwSgM8VQ7Y0VVCkzP4AE7XVyKhesrZ3Ovd90ypTVHN8gjcqeRMDoMImRH bKQQ== X-Gm-Message-State: APjAAAUFpsS2zLhLJZboxSkL9G1QgCJcXOYuNjo+4wl7xhVAMgjl1K3f cGVlfSWgAAxanpi+2ZXP94Xbk6qNrq0= X-Google-Smtp-Source: APXvYqzPu2wOAkU/HmxNO7PPsJCR6BfFQ4CJJis2Mc3jAqMwn2w6FU/HE0tHuJ8fVG78VIR4Ml9rAA== X-Received: by 2002:a0c:9189:: with SMTP id n9mr5143407qvn.122.1561577788839; Wed, 26 Jun 2019 12:36:28 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Wed, 26 Jun 2019 16:35:59 -0300 Message-Id: <20190626193559.24431-11-danielhb413@gmail.com> In-Reply-To: <20190626193559.24431-1-danielhb413@gmail.com> References: <20190626193559.24431-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 26 Jun 2019 19:36:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 26 Jun 2019 19:36:30 +0000 (UTC) for IP:'209.85.160.181' DOMAIN:'mail-qt1-f181.google.com' HELO:'mail-qt1-f181.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.141 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.160.181 mail-qt1-f181.google.com 209.85.160.181 mail-qt1-f181.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Daniel Henrique Barboza , laine@laine.org Subject: [libvirt] [PATCH v1 10/10] tests: Add a baseline test for multifunction pci device use case 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 26 Jun 2019 19:39:10 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat There are already good number of test cases with hostdevices, few have multifunction devices but none having more than one than one multifunction cards. This patch adds a case where there are two multifunction cards and two Virtual functions part of the same XML. 0001:01:00.X & 0005:09:00.X - are Multifunction PCI cards. 0000:06:12.[5|6] - are SRIOV Virtual functions The next few commits improve on automatically detecting the multifunction cards and auto-assinging the addresses appropriately. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- .../hostdev-pci-multifunction.args | 35 ++++++++ .../hostdev-pci-multifunction.xml | 59 ++++++++++++++ tests/qemuxml2argvtest.c | 3 + .../hostdev-pci-multifunction.xml | 79 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 5 files changed, 177 insertions(+) create mode 100644 tests/qemuxml2argvdata/hostdev-pci-multifunction.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-multifunction.xml create mode 100644 tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction.args b/tests/= qemuxml2argvdata/hostdev-pci-multifunction.args new file mode 100644 index 0000000000..7747cca442 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction.args @@ -0,0 +1,35 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-delete \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-delete/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-delete/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-delete/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name delete \ +-S \ +-machine pc,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff \ +-m 256 \ +-realtime mlock=3Doff \ +-smp 4,sockets=3D4,cores=3D1,threads=3D1 \ +-uuid 583a8e8e-f0ce-4f53-89ab-092862148b25 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-delete/monitor.= sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-usb \ +-device vfio-pci,host=3D0005:90:01.0,id=3Dhostdev0,bus=3Dpci.0,addr=3D0x3 \ +-device vfio-pci,host=3D0001:01:00.1,id=3Dhostdev1,bus=3Dpci.0,addr=3D0x4 \ +-device vfio-pci,host=3D0001:01:00.0,id=3Dhostdev2,bus=3Dpci.0,addr=3D0x5 \ +-device vfio-pci,host=3D0005:90:01.2,id=3Dhostdev3,bus=3Dpci.0,addr=3D0x6 \ +-device vfio-pci,host=3D0005:90:01.3,id=3Dhostdev4,bus=3Dpci.0,addr=3D0x7 \ +-device vfio-pci,host=3D06:12.1,id=3Dhostdev5,bus=3Dpci.0,addr=3D0x8 \ +-device vfio-pci,host=3D06:12.2,id=3Dhostdev6,bus=3Dpci.0,addr=3D0x9 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0xa diff --git a/tests/qemuxml2argvdata/hostdev-pci-multifunction.xml b/tests/q= emuxml2argvdata/hostdev-pci-multifunction.xml new file mode 100644 index 0000000000..06c889c64d --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-multifunction.xml @@ -0,0 +1,59 @@ + + delete + 583a8e8e-f0ce-4f53-89ab-092862148b25 + 262144 + 4 + + hvm + + + /usr/bin/qemu-system-x86_64 + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 91ca35d469..51d7392730 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1291,6 +1291,9 @@ mymain(void) DO_TEST_FAILURE("net-hostdev-fail", QEMU_CAPS_DEVICE_VFIO_PCI); =20 + DO_TEST("hostdev-pci-multifunction", + QEMU_CAPS_KVM, + QEMU_CAPS_DEVICE_VFIO_PCI); =20 DO_TEST("serial-file-log", QEMU_CAPS_CHARDEV_FILE_APPEND, diff --git a/tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml b/tests= /qemuxml2xmloutdata/hostdev-pci-multifunction.xml new file mode 100644 index 0000000000..52ed86e305 --- /dev/null +++ b/tests/qemuxml2xmloutdata/hostdev-pci-multifunction.xml @@ -0,0 +1,79 @@ + + delete + 583a8e8e-f0ce-4f53-89ab-092862148b25 + 262144 + 262144 + 4 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index a64b17ac28..5f57bdac13 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -425,6 +425,7 @@ mymain(void) =20 DO_TEST("hostdev-usb-address", NONE); DO_TEST("hostdev-pci-address", NONE); + DO_TEST("hostdev-pci-multifunction", NONE); DO_TEST("hostdev-vfio", NONE); DO_TEST("hostdev-vfio-zpci", QEMU_CAPS_DEVICE_ZPCI, --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list