From nobody Mon Feb 9 04:29:11 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=1563480640; cv=none; d=zoho.com; s=zohoarc; b=O25knE6Uj8DLAjjrcgF61/Ix2pK3sNtEQT7pYqI+DLbyQmmq/jPsiWI1tXdUBPU6qdZQU2xeuj/62vYnknfO5mY1yEWtr9V0wzS/QLWkyQTkHZkcC96YU8gnOPRZVlUvEDzFMr9UdRpGIXitLglNAeMpVT7HqvWsp+O8kuq8Uk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563480640; 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=X7P2fwo3mcNyULgZ+AtiwGnQqJCsuGErJXDzk2ieQ+8=; b=OxIrBqbk4QfsvFl3enwlNyquHRD5QASUr/gXlzPr2Ir4ako5eRbIHZLZv5XMhr7vu3SR2l4qZJPqR7Z1lIwjdVsa1qm+WkwA5UXfMYCN2l9cdHUJPDXud/iVxyGq4HljxaPMBdmDQeIICsQ/W5Ws6e4JfJ+JiloWK3GVBwxvsAg= 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 1563480640443609.3802068963323; Thu, 18 Jul 2019 13:10:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC6233162913; Thu, 18 Jul 2019 20:10:38 +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 A676C5C22F; Thu, 18 Jul 2019 20:10:38 +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 6B672180020A; Thu, 18 Jul 2019 20:10:38 +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 x6IKALsv013514 for ; Thu, 18 Jul 2019 16:10:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 034C1607A1; Thu, 18 Jul 2019 20:10:21 +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 F19E85D9D6 for ; Thu, 18 Jul 2019 20:10:18 +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 D9B21285AE for ; Thu, 18 Jul 2019 20:10:17 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id h18so28574635qtm.9 for ; Thu, 18 Jul 2019 13:10:17 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:94cf:6a36:8ff2:a855:c9e6]) by smtp.gmail.com with ESMTPSA id h26sm17586605qta.58.2019.07.18.13.10.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Jul 2019 13:10: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=laDRoW3qt6Z2qXzPUxX8H6Q3p/vpvg4jBs1y0PBhWWA=; b=trKCc44X6PYA+LWAOk9Ek6hTBrHRGdd3sTXqpmIkdU2THgABIhP75JPiOqOgFDniYx ZVlm/e7UiA67ucoO5RcJY5nJ9Nf54ZGIn/ZLh2k8lMa4Zs4IXFsgi6hWgMNwuD+Aeti3 2y7374k3F3PLxjSXLSKl/o6JLu0vx4Cgfp1kGX9B79TKjVZeO3ewUaeCF9QCum5ll8tz K/1qPsTWs1oQukZ4dfKASFZZeVr7XKyT2V8Mxf8Yqx88m0ucF6380sXF/RndTibOxjCO 5zqGqaZuf/xFCg/7xsYvmymRvgKz8oipy/+HGPOhMVIcJiWsHnDuICid8jnRu8RhRguB t2iw== 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=laDRoW3qt6Z2qXzPUxX8H6Q3p/vpvg4jBs1y0PBhWWA=; b=CtFJwownpezs+vCg01k0uB55mnd2eM322MjRYAEqxZVUKUcyciAuTtDHLbzTmtP7mk E29rqAlUFv+bR7C6QLacGRI+3WHXKbkguYmB3CzFsjPTPLLiAUPh4pYW7+9xfZtU3bf2 vgomxl6J5nn7NKm46J/kjRWT9jANEoQW8rcDXhAd4vwFmXvroWigE7/Ww72sv2T6DiRB /dbgtKgcqsH/nDA1JY0CVYzv6qW9pqvQUzyOswuKddGrutkxufRCLmg/HTRFRiwPF4Sl Nrtl7VdI8scE1KMqym6tkLxM7eElpp3cp1V1fo89yq+VRUhRUkcFSf9tV0ISzeqxSpOH dJog== X-Gm-Message-State: APjAAAVrCYjY8gXPNG/bz/iY5VPlGQIAnKdzxZ6gLhHMPgGknRDUpZ5R gPDqIDCLSq+iZcqLdx2Te1taYKoV X-Google-Smtp-Source: APXvYqx8WKZYkKIUzL+M4vsKCIvleusRpIrIP8gLgxVPuF8kpjSsAgehlWGRf2m3bTjhRrQDBD7sJQ== X-Received: by 2002:aed:220e:: with SMTP id n14mr34277224qtc.388.1563480617035; Thu, 18 Jul 2019 13:10:17 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Thu, 18 Jul 2019 17:10:05 -0300 Message-Id: <20190718201007.28571-2-danielhb413@gmail.com> In-Reply-To: <20190718201007.28571-1-danielhb413@gmail.com> References: <20190718201007.28571-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]); Thu, 18 Jul 2019 20:10:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 18 Jul 2019 20:10:18 +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.153 (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.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza Subject: [libvirt] [PATCH v1 1/3] virhostdev: introduce virHostdevResetAllPCIDevices 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 18 Jul 2019 20:10:39 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This code that executes virPCIDeviceReset in all virPCIDevicePtr objects of a given virPCIDeviceListPtr list is replicated twice in the code. Putting it in a helper function helps with readability. Signed-off-by: Daniel Henrique Barboza --- src/util/virhostdev.c | 54 +++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index a3647a6cf4..7cb0beb545 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -613,6 +613,32 @@ virHostdevRestoreNetConfig(virDomainHostdevDefPtr host= dev, } } =20 +static int +virHostdevResetAllPCIDevices(virPCIDeviceListPtr pcidevs, + virHostdevManagerPtr mgr) +{ + int ret =3D 0; + size_t i; + + for (i =3D 0; i < virPCIDeviceListCount(pcidevs); i++) { + virPCIDevicePtr pci =3D virPCIDeviceListGet(pcidevs, i); + + /* We can avoid looking up the actual device here, because perform= ing + * a PCI reset on a device doesn't require any information other t= han + * the address, which 'pci' already contains */ + VIR_DEBUG("Resetting PCI device %s", virPCIDeviceGetName(pci)); + if (virPCIDeviceReset(pci, mgr->activePCIHostdevs, + mgr->inactivePCIHostdevs) < 0) { + VIR_ERROR(_("Failed to reset PCI device: %s"), + virGetLastErrorMessage()); + virResetLastError(); + ret =3D -1; + } + } + + return ret; +} + int virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, const char *drv_name, @@ -765,17 +791,8 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, =20 /* Step 3: Now that all the PCI hostdevs have been detached, we * can safely reset them */ - for (i =3D 0; i < virPCIDeviceListCount(pcidevs); i++) { - virPCIDevicePtr pci =3D virPCIDeviceListGet(pcidevs, i); - - /* We can avoid looking up the actual device here, because perform= ing - * a PCI reset on a device doesn't require any information other t= han - * the address, which 'pci' already contains */ - VIR_DEBUG("Resetting PCI device %s", virPCIDeviceGetName(pci)); - if (virPCIDeviceReset(pci, mgr->activePCIHostdevs, - mgr->inactivePCIHostdevs) < 0) - goto reattachdevs; - } + if (virHostdevResetAllPCIDevices(pcidevs, mgr) < 0) + goto reattachdevs; =20 /* Step 4: For SRIOV network devices, Now that we have detached the * the network device, set the new netdev config */ @@ -1046,20 +1063,7 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mg= r, } =20 /* Step 4: perform a PCI Reset on all devices */ - for (i =3D 0; i < virPCIDeviceListCount(pcidevs); i++) { - virPCIDevicePtr pci =3D virPCIDeviceListGet(pcidevs, i); - - /* We can avoid looking up the actual device here, because perform= ing - * a PCI reset on a device doesn't require any information other t= han - * the address, which 'pci' already contains */ - VIR_DEBUG("Resetting PCI device %s", virPCIDeviceGetName(pci)); - if (virPCIDeviceReset(pci, mgr->activePCIHostdevs, - mgr->inactivePCIHostdevs) < 0) { - VIR_ERROR(_("Failed to reset PCI device: %s"), - virGetLastErrorMessage()); - virResetLastError(); - } - } + virHostdevResetAllPCIDevices(pcidevs, mgr); =20 /* Step 5: Reattach managed devices to their host drivers; unmanaged * devices don't need to be processed further */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list