From nobody Fri Apr 19 17:26:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1575296856; cv=none; d=zohomail.com; s=zohoarc; b=f5/Xp+aED2CbYqomH7bGfg/8Mh74Y3bpF8Odo3m33xUpOC9jRzueIyQS8e/2lf8yydAPu9sqVWSi1rLM6VUgYA3aMEFl7Wq8ZtWDf3U/Mm4XhW24VL7gPuLOdeKfewMI8ottiK+GbdsAPbyEQ7gsWih1ub2QF4AsinNwJssGELQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575296856; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IX7qrP/vxbLNH02bT7ksgiYDb6KZ84ywsPamAoz/gvw=; b=S4Lcs4s9FcYVsG+yLgM46Pq8DdVBS72dypTbizj49jrDPdvKPx6KdBvfrv+iXo+AKXwZHrHxCM6tvh3zQH57uaAnDD/QduKXFUyZsxTryF0cu9s4+evplq9kYGT/hTJHgMp7euuzPQQKbsgY2F0u6YjbrTGlHD0WL5Y5gN7h3ZM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1575296856619741.6420963912824; Mon, 2 Dec 2019 06:27:36 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-p6D8qNDAOwKw0wE6YU9ufQ-1; Mon, 02 Dec 2019 09:27:33 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A61668048E9; Mon, 2 Dec 2019 14:27:25 +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 737C35D6A7; Mon, 2 Dec 2019 14:27:25 +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 1A12A4EDB1; Mon, 2 Dec 2019 14:27:25 +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 xB2ER6ni027317 for ; Mon, 2 Dec 2019 09:27:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8255B6764D; Mon, 2 Dec 2019 14:27:06 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BCE767662 for ; Mon, 2 Dec 2019 14:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575296855; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IX7qrP/vxbLNH02bT7ksgiYDb6KZ84ywsPamAoz/gvw=; b=aTbsiLX/Qhx2NbeI6oarCGsjoQktBXjQpvDzZLt9IJ9YsLGR+uCQBiwmbrmJVSVGIGwzvf NnGEz1YNC1mkXgdDzOhnEfx8cMY3AsVe3fOuEiOcgUX5O+mKbiRy4qne4ZifrP8MB6DDZC epQg2FtcZOzUtdEeykkpJyhtDri0Pl8= From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 2 Dec 2019 15:26:30 +0100 Message-Id: <3c143522acd9224ce40de2588fb40d6fb23479d1.1575296392.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 07/30] virHostdevReAttachPCIDevices: Separate out function body X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: p6D8qNDAOwKw0wE6YU9ufQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In near future we will have a list of PCI devices we want to re-attach to the host (held in virPCIDeviceListPtr) but we don't have virDomainHostdevDefPtr. That's okay because virHostdevReAttachPCIDevices() works with virPCIDeviceListPtr mostly anyway. And in very few places where it needs virDomainHostdevDefPtr are not interesting for our case. Signed-off-by: Michal Privoznik ACKed-by: Peter Krempa Reviewed-by: Cole Robinson --- src/util/virhostdev.c | 58 +++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index b8e6e2bc36..94a0185597 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -1002,30 +1002,17 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mg= r, } =20 =20 -/* @oldStateDir: - * For upgrade purpose: see virHostdevRestoreNetConfig - */ -void -virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr, - const char *drv_name, - const char *dom_name, - virDomainHostdevDefPtr *hostdevs, - int nhostdevs, - const char *oldStateDir) +static void +virHostdevReAttachPCIDevicesImpl(virHostdevManagerPtr mgr, + const char *drv_name, + const char *dom_name, + virPCIDeviceListPtr pcidevs, + virDomainHostdevDefPtr *hostdevs, + int nhostdevs, + const char *oldStateDir) { - g_autoptr(virPCIDeviceList) pcidevs =3D NULL; size_t i; =20 - if (!nhostdevs) - return; - - if (!(pcidevs =3D virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))= ) { - VIR_ERROR(_("Failed to allocate PCI device list: %s"), - virGetLastErrorMessage()); - virResetLastError(); - return; - } - virObjectLock(mgr->activePCIHostdevs); virObjectLock(mgr->inactivePCIHostdevs); =20 @@ -1121,6 +1108,35 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mg= r, virObjectUnlock(mgr->inactivePCIHostdevs); } =20 + +/* @oldStateDir: + * For upgrade purpose: see virHostdevRestoreNetConfig + */ +void +virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr, + const char *drv_name, + const char *dom_name, + virDomainHostdevDefPtr *hostdevs, + int nhostdevs, + const char *oldStateDir) +{ + g_autoptr(virPCIDeviceList) pcidevs =3D NULL; + + if (!nhostdevs) + return; + + if (!(pcidevs =3D virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))= ) { + VIR_ERROR(_("Failed to allocate PCI device list: %s"), + virGetLastErrorMessage()); + virResetLastError(); + return; + } + + virHostdevReAttachPCIDevicesImpl(mgr, drv_name, dom_name, pcidevs, + hostdevs, nhostdevs, oldStateDir); +} + + int virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr, virDomainHostdevDefPtr *hostdevs, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list