From nobody Sun Feb 8 01:34:15 2026 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