From nobody Sun Feb 8 17:37:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1648836528; cv=none; d=zohomail.com; s=zohoarc; b=h5KgzYYSEddJ6ZDkEv5bWFu4vYbrhhKr4ArA7hZ5RFPZGW3UNYWUF/I0lWh5ckKJy7GVPms7pm/ZEaTr+nhZvq7Cj0JrjYeVSEyeufJadQ7xycR7+txHjQ40LkQXHhcdaA9SWYZvNOvxSD5ghG4wx7ySJEUsjBJsKuv9tVypLmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648836528; 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=UM6oJGc+fyXd72brJihzOtS4ZPfMSK33Te1Y8M2x3HY=; b=KkuIUIGmHTcMFqdI7gp9OGNXR/S7z3hOEVrSpeNdzf1pMiVKiytF6EGTEDQDstuqw6on/Tmtgaaht76DjyFfxBcpX/bP2HvqjnLuj9X9Wlmgx9MgxecJy+N0r9aWY/nMI801BsI/H2X77VH7iJzB0NKrtxvmIGqO+xj3FAvbfkA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1648836528806386.9043140765441; Fri, 1 Apr 2022 11:08:48 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-197-afdRudnYOK6lowD0eiQJxw-1; Fri, 01 Apr 2022 14:08:44 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26B8F8117B0; Fri, 1 Apr 2022 18:08:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13BF3417EC9; Fri, 1 Apr 2022 18:08:42 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 616F81940363; Fri, 1 Apr 2022 18:08:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A0A5D194034F for ; Fri, 1 Apr 2022 18:08:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 93631111D7B5; Fri, 1 Apr 2022 18:08:39 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.193.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A2A9111D7B4 for ; Fri, 1 Apr 2022 18:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648836527; 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=UM6oJGc+fyXd72brJihzOtS4ZPfMSK33Te1Y8M2x3HY=; b=XzBQcuxcKpjr2mhoAB63skBgUlcNbzG0S+Lc2w0NCcbtggZMOnQeZxK+lR/cJYOFDrGEaH rNGvbXViB/h5tUpwCBQ7NhiMRL1rdto61zvCfg7kZ5SRan8AHwejCovOhrvDIoU463hdtx fHY5gVeuU4WGLznCeoslJ8NyvHD36DY= X-MC-Unique: afdRudnYOK6lowD0eiQJxw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 02/16] qemu: Tweak some code Date: Fri, 1 Apr 2022 20:08:21 +0200 Message-Id: <20220401180835.200444-3-abologna@redhat.com> In-Reply-To: <20220401180835.200444-1-abologna@redhat.com> References: <20220401180835.200444-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648837435151100001 The altered code is functionally equivalent to the previous one, but it's already laid down in a way that will make further changes easier and less messy. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 14 ++++++-------- src/qemu/qemu_domain_address.c | 23 ++++++++++++++++++++++- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f7f55b20ef..9180d5c317 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6428,15 +6428,14 @@ qemuBuildIOMMUCommandLine(virCommand *cmd, const virDomainDef *def, virQEMUCaps *qemuCaps) { + g_autoptr(virJSONValue) props =3D NULL; const virDomainIOMMUDef *iommu =3D def->iommu; =20 if (!iommu) return 0; =20 switch (iommu->model) { - case VIR_DOMAIN_IOMMU_MODEL_INTEL: { - g_autoptr(virJSONValue) props =3D NULL; - + case VIR_DOMAIN_IOMMU_MODEL_INTEL: if (virJSONValueObjectAdd(&props, "s:driver", "intel-iommu", "S:intremap", qemuOnOffAuto(iommu->intre= map), @@ -6451,7 +6450,6 @@ qemuBuildIOMMUCommandLine(virCommand *cmd, return -1; =20 return 0; - } =20 case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: /* There is no -device for SMMUv3, so nothing to be done here */ @@ -7034,14 +7032,14 @@ qemuBuildMachineCommandLine(virCommand *cmd, =20 if (def->iommu) { switch (def->iommu->model) { - case VIR_DOMAIN_IOMMU_MODEL_INTEL: - /* The 'intel' IOMMu is formatted in qemuBuildIOMMUCommandLine= */ - break; - case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: virBufferAddLit(&buf, ",iommu=3Dsmmuv3"); break; =20 + case VIR_DOMAIN_IOMMU_MODEL_INTEL: + /* These IOMMUs are formatted in qemuBuildIOMMUCommandLine */ + break; + case VIR_DOMAIN_IOMMU_MODEL_LAST: default: virReportEnumRangeError(virDomainIOMMUModel, def->iommu->model= ); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index dd0680f57f..6ca6fa54a3 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1002,6 +1002,16 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDe= viceDef *dev, } break; =20 + case VIR_DOMAIN_DEVICE_IOMMU: + switch ((virDomainIOMMUModel) dev->data.iommu->model) { + case VIR_DOMAIN_IOMMU_MODEL_INTEL: + case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: + case VIR_DOMAIN_IOMMU_MODEL_LAST: + /* These are not PCI devices */ + return 0; + } + break; + case VIR_DOMAIN_DEVICE_VSOCK: switch ((virDomainVsockModel) dev->data.vsock->model) { case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL: @@ -1041,7 +1051,6 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDev= iceDef *dev, /* These devices don't even have a DeviceInfo */ case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_GRAPHICS: - case VIR_DOMAIN_DEVICE_IOMMU: case VIR_DOMAIN_DEVICE_AUDIO: case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_NONE: @@ -2369,6 +2378,18 @@ qemuDomainAssignDevicePCISlots(virDomainDef *def, /* Nada - none are PCI based (yet) */ } =20 + if (def->iommu) { + virDomainIOMMUDef *iommu =3D def->iommu; + + switch ((virDomainIOMMUModel) iommu->model) { + case VIR_DOMAIN_IOMMU_MODEL_INTEL: + case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: + case VIR_DOMAIN_IOMMU_MODEL_LAST: + /* These are not PCI devices */ + break; + } + } + if (def->vsock && virDeviceInfoPCIAddressIsWanted(&def->vsock->info)) { =20 --=20 2.35.1