From nobody Tue Sep 9 03:16:12 2025 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1748332204; cv=none; d=zohomail.com; s=zohoarc; b=OQQ1XhB22b9j9tg2wJe/jznjzMmnoiOLasJKdKjB7djkdEgZt9aWsvQRWcYiHCLo0kMd9G10eDhONhAypupPHshPuUukxdrwkgfkfLKe+ibWQhW1rKhUKRkU6tGokrVMYfEo6WuF8c+ZE2Kax8h66dXRIjehAoM4Vq3Z5NG5gFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748332204; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=3s6QO0mY48i6XTB3e/kfM5LTZQ0FPhunKot4PNxQk1I=; b=BjlVf23vP3nC1Vs45ac4+SQuM0IhSxFTMYHILDIgb+6nE2tTfEs7ABS0vqaJXFMHVlFzrQh2x1tiG9TnVNTYE6343nXsSrcV3Ru6G4RZGb0QBoAbEYAcRRgA2OpLb8FGAJPkzeLv/xuebVX/Os6788DqWRfj0Vvor8Aqd9k+uN8= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1748332204277503.39108605134925; Tue, 27 May 2025 00:50:04 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 64D011825; Tue, 27 May 2025 03:50:03 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5626E1648; Tue, 27 May 2025 03:49:16 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 54DE7B15; Tue, 27 May 2025 03:49:12 -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 D49C3B0E for ; Tue, 27 May 2025 03:49:11 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-620-H0h2BbHVOouraon9JFBH9w-1; Tue, 27 May 2025 03:49:10 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2ED34180036E for ; Tue, 27 May 2025 07:49:09 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.3]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 458ED180047F for ; Tue, 27 May 2025 07:49:08 +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=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748332151; 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=Qt2cQtv8Mgld8Txqo0pnrz3o/y/bR3rrB38gjuVoj98=; b=C5GSvQ9vrbtGgXVWLqKkGhb3wstz6d6PEwf2GBGGM4ZINRxQnZ0UlTGHxSy33kDFRxA08R asA2qB13VQyOcIhz+xbkiKlGLNZqVquwKvhQUM+K2y9Mp+tDC6enASDqVyrvOVPFkZlAJA 6cyuHIjwwiZiu/ouOW+OFEpsza+ZYXw= X-MC-Unique: H0h2BbHVOouraon9JFBH9w-1 X-Mimecast-MFC-AGG-ID: H0h2BbHVOouraon9JFBH9w_1748332149 To: devel@lists.libvirt.org Subject: [PATCH 1/9] qemuDomainValidateStorageSource: Rework protocol validation into a switch statement Date: Tue, 27 May 2025 09:48:57 +0200 Message-ID: <5ad4b637798a60fac4898c79a8d8809fcb0fe3ca.1748332058.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 1qhmWsM4QJvsGhYcBsU3k2to0vKbRXwktyxUbiXI4fM_1748332149 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Z2JYIFBQDWZRZWKROAEPWIDMFQ5T65SV X-Message-ID-Hash: Z2JYIFBQDWZRZWKROAEPWIDMFQ5T65SV 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: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1748332205072116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Move the validation of TFTP and NFS into a new switch statement which will be used for validating also other protocol config in the future. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 68 +++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index cc3ab0a298..11f08b8ded 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4525,34 +4525,54 @@ qemuDomainValidateStorageSource(virStorageSource *s= rc, return -1; } - /* TFTP protocol is not supported since QEMU 2.8.0 */ - if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && - src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_TFTP) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'tftp' protocol is not supported with this QEMU = binary")); - return -1; - } + if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK) { + switch ((virStorageNetProtocol) src->protocol) { + case VIR_STORAGE_NET_PROTOCOL_GLUSTER: + case VIR_STORAGE_NET_PROTOCOL_VXHS: + case VIR_STORAGE_NET_PROTOCOL_HTTP: + case VIR_STORAGE_NET_PROTOCOL_HTTPS: + case VIR_STORAGE_NET_PROTOCOL_FTP: + case VIR_STORAGE_NET_PROTOCOL_FTPS: + case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_NBD: + case VIR_STORAGE_NET_PROTOCOL_RBD: + case VIR_STORAGE_NET_PROTOCOL_SSH: + case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: + break; - if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && - src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_NFS) { - /* NFS protocol must have exactly one host */ - if (src->nhosts !=3D 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'nfs' protocol requires the usage of exactly= one host")); - return -1; - } + case VIR_STORAGE_NET_PROTOCOL_NFS: + /* NFS protocol must have exactly one host */ + if (src->nhosts !=3D 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'nfs' protocol requires the usage of exa= ctly one host")); + return -1; + } - /* NFS can only use a TCP protocol */ - if (src->hosts[0].transport !=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'nfs' host must use TCP protocol")); + /* NFS can only use a TCP protocol */ + if (src->hosts[0].transport !=3D VIR_STORAGE_NET_HOST_TRANS_TC= P) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'nfs' host must use TCP protocol")); + return -1; + } + + /* NFS host cannot have a port */ + if (src->hosts[0].port !=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("port cannot be specified in 'nfs' protoc= ol host")); + return -1; + } + break; + + /* TFTP protocol is not supported since QEMU 2.8.0 */ + case VIR_STORAGE_NET_PROTOCOL_TFTP: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("storage protocol '%1$s' is not supported by = this QEMU"), + virStorageNetProtocolTypeToString(src->protocol= )); return -1; - } - /* NFS host cannot have a port */ - if (src->hosts[0].port !=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("port cannot be specified in 'nfs' protocol h= ost")); + case VIR_STORAGE_NET_PROTOCOL_NONE: + case VIR_STORAGE_NET_PROTOCOL_LAST: + virReportEnumRangeError(virStorageNetProtocol, src->protocol); return -1; } } --=20 2.49.0