From nobody Sat Feb 7 08:13:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1594749665; cv=none; d=zohomail.com; s=zohoarc; b=HKbjGywnItyDiwCYdDeSu4BGEyQazZTjG2SpEn5E2QiCBS9a14DS8hrtVe4vompT8yJiD+scowPv4wV0SIAvQBu36YEWa7ScqIhA1qOB++OyjNxg/a/4mvCT8Tn0DSKF98Rg6nXF5gD8XmCYkU4o443ezFeCt6rOJz2B3kRvST8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594749665; 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=DOVh3055zB3kpGQFZ2PvTEdVdIvglRi/Xlyw5B3MKOM=; b=IMfumvoV7tENMgd1k7jAxvX9TfwnaTEITYjPCAoDDAL8vQ1a7tkskGD5qc3O7wF9Fz+KYVDgJIqcB2/f7unAKUAWDkO4jelWEWBbsLO/4slfzjW0eY6Xg3lOONGZ/jUkUTyWJEqYP4aQd8wC+DXwdZaF6tXvuDepPnGgVnSPRuw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594749665739303.793549688791; Tue, 14 Jul 2020 11:01:05 -0700 (PDT) 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-24-lPWsgyaeOzC4xe_Vy1y_5g-1; Tue, 14 Jul 2020 14:01:01 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE0EE803CED; Tue, 14 Jul 2020 18:00: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 A004F61483; Tue, 14 Jul 2020 18:00: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 648CB1809563; Tue, 14 Jul 2020 18:00:25 +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 06EI0MvP023947 for ; Tue, 14 Jul 2020 14:00:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2B414765AB; Tue, 14 Jul 2020 18:00:22 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5207865970 for ; Tue, 14 Jul 2020 18:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594749664; 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=DOVh3055zB3kpGQFZ2PvTEdVdIvglRi/Xlyw5B3MKOM=; b=Lxe4GjbLJOVsRf4xDWv7/1iiNsf+hAsO22b+SqtzH2sdpS1OVQ4xaRFIIZdXqDsWDoqigG H+S4YGIjUD6VA4Wy+fDyC1MQNrgudlok9xXVnjfFDropbEqCefgPRYX0saBgyY7nUCI7hA unlYYzhFbWRe5VHHwk64eFk8T2ckp4c= X-MC-Unique: lPWsgyaeOzC4xe_Vy1y_5g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/11] virDomainHostdevDefFormatSubsys: Split out formatting of PCI subsystem Date: Tue, 14 Jul 2020 20:00:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Similarly to previous commit split out formatting of the PCI subsystem related stuff. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 74 ++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7718a59c66..d4a2aa7623 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26057,6 +26057,50 @@ virDomainHostdevDefFormatSubsysUSB(virBufferPtr bu= f, } +static int +virDomainHostdevDefFormatSubsysPCI(virBufferPtr buf, + virDomainHostdevDefPtr def, + unsigned int flags, + bool includeTypeInAddr) +{ + g_auto(virBuffer) sourceAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) sourceChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) origstatesChildBuf =3D VIR_BUFFER_INIT_CHILD(&source= ChildBuf); + virDomainHostdevSubsysPCIPtr pcisrc =3D &def->source.subsys.u.pci; + + if (pcisrc->backend !=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) { + const char *backend =3D virDomainHostdevSubsysPCIBackendTypeToStri= ng(pcisrc->backend); + + if (!backend) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected pci hostdev driver name type %d"), + pcisrc->backend); + return -1; + } + + virBufferAsprintf(buf, "\n", backend); + } + + virPCIDeviceAddressFormat(&sourceChildBuf, pcisrc->addr, includeTypeIn= Addr); + + if ((flags & VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES)) { + if (def->origstates.states.pci.unbind_from_stub) + virBufferAddLit(&origstatesChildBuf, "\n"); + + if (def->origstates.states.pci.remove_slot) + virBufferAddLit(&origstatesChildBuf, "\n"); + + if (def->origstates.states.pci.reprobe) + virBufferAddLit(&origstatesChildBuf, "\n"); + + virXMLFormatElement(&sourceChildBuf, "origstates", NULL, &origstat= esChildBuf); + } + + virXMLFormatElement(buf, "source", &sourceAttrBuf, &sourceChildBuf); + return 0; +} + + static int virDomainHostdevDefFormatSubsys(virBufferPtr buf, virDomainHostdevDefPtr def, @@ -26066,8 +26110,6 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, { g_auto(virBuffer) sourceAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) sourceChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); - g_auto(virBuffer) origstatesChildBuf =3D VIR_BUFFER_INIT_CHILD(&source= ChildBuf); - virDomainHostdevSubsysPCIPtr pcisrc =3D &def->source.subsys.u.pci; virDomainHostdevSubsysSCSIPtr scsisrc =3D &def->source.subsys.u.scsi; virDomainHostdevSubsysSCSIVHostPtr hostsrc =3D &def->source.subsys.u.s= csi_host; virDomainHostdevSubsysMediatedDevPtr mdevsrc =3D &def->source.subsys.u= .mdev; @@ -26080,6 +26122,8 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, return 0; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: + return virDomainHostdevDefFormatSubsysPCI(buf, def, flags, include= TypeInAddr); + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: @@ -26091,20 +26135,6 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, return -1; } - if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI = && - pcisrc->backend !=3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) { - const char *backend =3D - virDomainHostdevSubsysPCIBackendTypeToString(pcisrc->backend); - - if (!backend) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected pci hostdev driver name type %d"), - pcisrc->backend); - return -1; - } - virBufferAsprintf(buf, "\n", backend); - } - if (def->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI= && scsisrc->protocol =3D=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISC= SI) { @@ -26127,18 +26157,6 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - virPCIDeviceAddressFormat(&sourceChildBuf, pcisrc->addr, - includeTypeInAddr); - - if ((flags & VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES)) { - if (def->origstates.states.pci.unbind_from_stub) - virBufferAddLit(&origstatesChildBuf, "\n"); - if (def->origstates.states.pci.remove_slot) - virBufferAddLit(&origstatesChildBuf, "\n"); - if (def->origstates.states.pci.reprobe) - virBufferAddLit(&origstatesChildBuf, "\n"); - virXMLFormatElement(&sourceChildBuf, "origstates", NULL, &orig= statesChildBuf); - } break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: if (scsisrc->protocol =3D=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE= _ISCSI) { --=20 2.26.2