From nobody Sat Dec 21 14:27:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 171811734115794.7498135749621; Tue, 11 Jun 2024 07:49:01 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 22A8EC59; Tue, 11 Jun 2024 10:49:00 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2FA9ACF8; Tue, 11 Jun 2024 10:48:27 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B860BBAC; Tue, 11 Jun 2024 10:48:21 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5730ABA6 for ; Tue, 11 Jun 2024 10:48:21 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-206-9B-a0Pe_N--7mjPVFsrdtg-1; Tue, 11 Jun 2024 10:48:18 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7BFE919560B9 for ; Tue, 11 Jun 2024 14:48:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.20]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A1E9730000C4 for ; Tue, 11 Jun 2024 14:48:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: *** X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718117301; h=from:from: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; bh=hCyFjPjxQcwuWqakFzm9In19z8Rdw7CXGKXgqYCDPL8=; b=cpu/1mT3/IUAiyW9lByRfX8Y2czBBXmMsj0qxTdyvUheelcwyfU7eVTpGHAbuRqWx5iU7Y ToxthDNJdod5UOJ7rfEZZDxfsp07N+zGGnlOGqohrymj1xz5lin0uHr+HMJFG4NgFqsGEf zJyj1BpHsRar40gT0PHZm8ZPeqDbQL8= X-MC-Unique: 9B-a0Pe_N--7mjPVFsrdtg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 1/3] qemuValidateDomainDeviceDefDiskFrontend: Refactor validation of Date: Tue, 11 Jun 2024 16:48:11 +0200 Message-ID: <9d6a464bda1cc91f1519cec18e19619b19eba469.1718117248.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YPXCS4WIWQRIMSNXLLD3DI7CK7DAWKLD X-Message-ID-Hash: YPXCS4WIWQRIMSNXLLD3DI7CK7DAWKLD X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1718117341554100001 Content-Type: text/plain; charset="utf-8" Use a switch statement for checks based on the disk bus. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_validate.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 95af93d606..fe190cea36 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2901,23 +2901,34 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDo= mainDiskDef *disk, } if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { - /* make sure that both the bus supports type=3D'lun' (SG_IO). */ - if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO && - disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI) { + + switch (disk->bus) { + case VIR_DOMAIN_DISK_BUS_SCSI: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_BLOCK)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support scsi-block for= lun passthrough")); + return -1; + } + break; + + case VIR_DOMAIN_DISK_BUS_VIRTIO: + break; + + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SATA: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk device=3D'lun' is not supported for bus= =3D'%1$s'"), virDomainDiskBusTypeToString(disk->bus)); return -1; } - if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_BLOCK)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU doesn't support scsi-block for lun= passthrough")); - return -1; - } - - if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("copy_on_read is not compatible with 'lun' di= sk '%1$s'"), --=20 2.45.2