From nobody Mon Feb 9 09:15:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1633622566; cv=none; d=zohomail.com; s=zohoarc; b=CeYwx/s+2NVmW8tak304c0Ax+Iww8/DrlEfQB3bq0ejB1f2Dh5fGvLQCw9dQpBOpJ+mKsV68DshCPMYjKi+IbH/TSlRgC1ajsd04sJh34xBFNbauDAQffIGVdJxeKlNPrKSl0PI17AprTI+sXbMUqjbxQ2auevnTDbZPYu8dwQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633622566; 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=GhUSAwbXMw099bWVw8Is2eC+XwPwLID+UXOKojnaIKg=; b=dPmhX0vSkea1I7gT38S2IlEHNaBvv5jDnaQcnNHeYvdfPTYfhYoV/l2VqKvd/76QL98SlNaioQzPmTXcEqdnMv+L/MMHKiWeeQq0IArNfdCq1NpIdpk7wAj/TPlT/7DqikKFkWy/H5E5R6lQ7U5Zx4Vc0mkLN5MbCaDPgdRUrDs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1633622566384783.4246779709681; Thu, 7 Oct 2021 09:02:46 -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-593-C2kNouLzObasE759h405og-1; Thu, 07 Oct 2021 12:02:39 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A84FC158CE37; Thu, 7 Oct 2021 15:45:02 +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 785DA10A66B5; Thu, 7 Oct 2021 15:44:34 +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 3B8844EA2F; Thu, 7 Oct 2021 15:44:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 197FJA1N023836 for ; Thu, 7 Oct 2021 11:19:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1372E5D6D5; Thu, 7 Oct 2021 15:19:10 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C1F15D6BA for ; Thu, 7 Oct 2021 15:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633622565; 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=GhUSAwbXMw099bWVw8Is2eC+XwPwLID+UXOKojnaIKg=; b=MuYA7JKHPJ/OZS+dz+OK9Klh9fTOf81KCu9SQW0EgR1ey1wvY+GI6L3BMqF03rvmPuF4VC QIN6qC+Ol4sTkqVHrX2BwS19dldTs2GND+6qwUrNaNaSEEyn37ist3AU+IedEksEwFTHNy 7a869JpwIgU+ypNseF/nJaqqX/QMYJU= X-MC-Unique: C2kNouLzObasE759h405og-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 034/103] qemuBuildVirtioDevStr: Don't return early Date: Thu, 7 Oct 2021 17:17:22 +0200 Message-Id: <27b22dec4213dbef4774357daa070fd82d6a1329.1633619630.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1633622567615100003 Content-Type: text/plain; charset="utf-8" To simplify upcoming refactors change the logic such that we don't return early for device types which can't be transitional. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 90 ++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 565b1970dc..5104af3731 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -608,7 +608,8 @@ qemuBuildVirtioDevStr(virBuffer *buf, const char *implName =3D NULL; virDomainDeviceDef device =3D { .type =3D devtype }; virDomainDeviceInfo *info; - bool has_tmodel, has_ntmodel; + bool has_tmodel =3D false; + bool has_ntmodel =3D false; virDomainDeviceSetData(&device, devdata); info =3D virDomainDeviceGetInfo(&device); @@ -660,10 +661,10 @@ qemuBuildVirtioDevStr(virBuffer *buf, break; case VIR_DOMAIN_DEVICE_HOSTDEV: - if (device.data.hostdev->source.subsys.type !=3D VIR_DOMAIN_HO= STDEV_SUBSYS_TYPE_SCSI_HOST) - return 0; - has_tmodel =3D device.data.hostdev->source.subsys.u.scsi_host.= model =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSIT= IONAL; - has_ntmodel =3D device.data.hostdev->source.subsys.u.scsi_host= .model =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TR= ANSITIONAL; + if (device.data.hostdev->source.subsys.type =3D=3D VIR_DOMAIN_= HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { + has_tmodel =3D device.data.hostdev->source.subsys.u.scsi_h= ost.model =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRA= NSITIONAL; + has_ntmodel =3D device.data.hostdev->source.subsys.u.scsi_= host.model =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NO= N_TRANSITIONAL; + } break; case VIR_DOMAIN_DEVICE_RNG: @@ -687,10 +688,10 @@ qemuBuildVirtioDevStr(virBuffer *buf, break; case VIR_DOMAIN_DEVICE_INPUT: - if (device.data.input->type !=3D VIR_DOMAIN_INPUT_TYPE_PASSTHR= OUGH) - return 0; - has_tmodel =3D device.data.input->model =3D=3D VIR_DOMAIN_INPU= T_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel =3D device.data.input->model =3D=3D VIR_DOMAIN_INP= UT_MODEL_VIRTIO_NON_TRANSITIONAL; + if (device.data.input->type =3D=3D VIR_DOMAIN_INPUT_TYPE_PASST= HROUGH) { + has_tmodel =3D device.data.input->model =3D=3D VIR_DOMAIN_= INPUT_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel =3D device.data.input->model =3D=3D VIR_DOMAIN= _INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; + } break; case VIR_DOMAIN_DEVICE_CONTROLLER: @@ -700,8 +701,6 @@ qemuBuildVirtioDevStr(virBuffer *buf, } else if (device.data.controller->type =3D=3D VIR_DOMAIN_CONT= ROLLER_TYPE_SCSI) { has_tmodel =3D device.data.controller->model =3D=3D VIR_DO= MAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; has_ntmodel =3D device.data.controller->model =3D=3D VIR_D= OMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; - } else { - return 0; } break; @@ -724,44 +723,45 @@ qemuBuildVirtioDevStr(virBuffer *buf, case VIR_DOMAIN_DEVICE_AUDIO: case VIR_DOMAIN_DEVICE_LAST: default: - return 0; - } - - if (info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && - (has_tmodel || has_ntmodel)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("virtio (non-)transitional models are not " - "supported for address type=3D%s"), - virDomainDeviceAddressTypeToString(info->type)); - return -1; + break; } - if (has_tmodel) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { - virBufferAddLit(buf, "-transitional"); - } else if (virQEMUCapsGet(qemuCaps, - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { - virBufferAddLit(buf, ",disable-legacy=3Doff,disable-modern=3Do= ff"); - } - /* No error if -transitional is not supported: our address - * allocation will force the device into plain PCI bus, which - * is functionally identical to standard 'virtio-XXX' behavior - */ - } else if (has_ntmodel) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { - virBufferAddLit(buf, "-non-transitional"); - } else if (virQEMUCapsGet(qemuCaps, - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { - /* Even if the QEMU binary doesn't support the non-transitional - * device, we can still make it work by manually disabling leg= acy - * VirtIO and enabling modern VirtIO */ - virBufferAddLit(buf, ",disable-legacy=3Don,disable-modern=3Dof= f"); - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtio non-transitional model not supported " - "for this qemu")); + if (has_tmodel || has_ntmodel) { + if (info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("virtio (non-)transitional models are not " + "supported for address type=3D%s"), + virDomainDeviceAddressTypeToString(info->type)); return -1; } + + if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL= )) { + virBufferAddLit(buf, "-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)= ) { + virBufferAddLit(buf, ",disable-legacy=3Doff,disable-modern= =3Doff"); + } + /* No error if -transitional is not supported: our address + * allocation will force the device into plain PCI bus, which + * is functionally identical to standard 'virtio-XXX' behavior + */ + } else if (has_ntmodel) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL= )) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)= ) { + /* Even if the QEMU binary doesn't support the non-transit= ional + * device, we can still make it work by manually disabling= legacy + * VirtIO and enabling modern VirtIO */ + virBufferAddLit(buf, ",disable-legacy=3Don,disable-modern= =3Doff"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not suppor= ted " + "for this qemu")); + return -1; + } + } } return 0; --=20 2.31.1