From nobody Sun Dec 14 06:38:51 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=1750867292; cv=none; d=zohomail.com; s=zohoarc; b=Kx1NY37i/azyCGthGpPxFi5kq+2NI7vdizTH2z0gRmUSfHb1UAOgjn62nseHSK34+MK1goMSUmiTRp8InleHvw1xp9ZQc8xKViT+LWwtZ5zYOf0eZ7/egAhUWdkwpZY1iGl2BGu6tn7fTXSg2hxVDg1VGdkRI+ECJUKtgsUWPB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750867292; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=kQFys4e/VLZxALDoaFe2OSW1F7ZwPNwJOfM+tXe+XF8=; b=UH76BCU9ubhDmi49SvuQIQRHoln4mvbcc79RBzXlBgDYAW+PaVoqXYxwKWXcRhVQNr+Jvs6LgO2tuTrvGrAjVPPcbwCZddK4doKVvA+5n2DxPhp0ByfFDrMY68d6nnXy3qowXy5scL4A1fPWIBDjY/2c9yHv6WweApTUa3X9ZQc= 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 1750867292619155.76983506122997; Wed, 25 Jun 2025 09:01:32 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B03BD151E; Wed, 25 Jun 2025 12:01:31 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 846251527; Wed, 25 Jun 2025 11:57:22 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E427814DD; Wed, 25 Jun 2025 11:57:19 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 80843118 for ; Wed, 25 Jun 2025 11:57:15 -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-575-jkwoqASgMni0yrWocJ1WYQ-1; Wed, 25 Jun 2025 11:57:10 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 0171F193D2A0; Wed, 25 Jun 2025 15:56:44 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.5]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B72FA18003FC; Wed, 25 Jun 2025 15:56:42 +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=1750867035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AsZtldfaH9gpqEIkNZbrRkzq5oGEF2ePeffK3ZeEDvo=; b=bUR/gLzfn7os2bZjz78hkBPpNjaUUuZ8KXer6Tx7WKAcllf086rZxcwvn03ktZUfUoP6a6 s1sGhH6zOoz3N15sYZx53lbPUAY/w4k/dhD+Ouw9Gh7Ag+ymr6m0g3n3IhrGv7UKOMBsLj QCKsXr72Fz/p7EDAgUMfsDyk0Gl7xnU= X-MC-Unique: jkwoqASgMni0yrWocJ1WYQ-1 X-Mimecast-MFC-AGG-ID: jkwoqASgMni0yrWocJ1WYQ_1750867029 To: devel@lists.libvirt.org Subject: [PATCH 1/4] conf: Turn 'protocol' field of virStorageSource into proper enum type Date: Wed, 25 Jun 2025 17:56:34 +0200 Message-ID: <9656a6567b7aaf14519083b0dbbbca9d88936092.1750866876.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: SvgN9l8hCnXC2D-_kcSX9odauzC40PZLAb9TqTf-4qk_1750867029 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MJOJ23HI66ME7SMBN2UVL7TOK6GBAV4C X-Message-ID-Hash: MJOJ23HI66ME7SMBN2UVL7TOK6GBAV4C 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 CC: Rodrigo Prieto , Peter Krempa 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: 1750867383553116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Convert the member to the appropriate type, fix few offending parse calls and remove explicit typecasts in switch(). Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 5 +---- src/conf/domain_validate.c | 2 +- src/conf/storage_source_conf.h | 2 +- src/libxl/libxl_conf.c | 2 +- src/libxl/xen_xl.c | 2 +- src/qemu/qemu_block.c | 7 +++---- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_snapshot.c | 4 ++-- .../storage_source_backingstore.c | 21 ++++++++++++------- 9 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1e24e41a48..f1057b406c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7368,15 +7368,12 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, virStorageSource *src, unsigned int flags) { - virStorageNetProtocol protocol; xmlNodePtr tmpnode; if (virXMLPropEnum(node, "protocol", virStorageNetProtocolTypeFromStri= ng, - VIR_XML_PROP_REQUIRED, &protocol) < 0) + VIR_XML_PROP_REQUIRED, &src->protocol) < 0) return -1; - src->protocol =3D protocol; - if (!(src->path =3D virXMLPropString(node, "name")) && src->protocol !=3D VIR_STORAGE_NET_PROTOCOL_NBD) { virReportError(VIR_ERR_XML_ERROR, "%s", diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index b28af7fa56..87fbefe4f1 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -494,7 +494,7 @@ virDomainDiskDefValidateSourceChainOne(const virStorage= Source *src) return -1; } - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_ISCSI: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index ebddf28cd6..362897f058 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -301,7 +301,7 @@ struct _virStorageSource { virStorageType type; char *path; char *fdgroup; /* name of group of file descriptors the user wishes to= use instead of 'path' */ - int protocol; /* virStorageNetProtocol */ + virStorageNetProtocol protocol; char *volume; /* volume name for remote storage */ char *snapshot; /* for storage systems supporting internal snapshots */ char *configFile; /* some storage systems use config file as part of diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index bdd30dd65a..36fba4a555 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1068,7 +1068,7 @@ libxlMakeNetworkDiskSrcStr(virStorageSource *src, g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index ec8de30c01..b83ed45c46 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1448,7 +1448,7 @@ xenFormatXLDiskSrcNet(virStorageSource *src) g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 32568d4ae6..a59c0a0a03 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1046,14 +1046,13 @@ qemuBlockStorageSourceGetBackendProps(virStorageSou= rce *src, break; } - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_GLUSTER: driver =3D "gluster"; if (!(fileprops =3D qemuBlockStorageSourceGetGlusterProps(src,= onlytarget))) return NULL; break; - case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: case VIR_STORAGE_NET_PROTOCOL_FTP: @@ -1969,7 +1968,7 @@ qemuBlockGetBackingStoreString(virStorageSource *src, src->readahead =3D=3D 0 && src->reconnectDelay =3D=3D 0) { - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: @@ -2352,7 +2351,7 @@ qemuBlockStorageSourceCreateGetStorageProps(virStorag= eSource *src, break; case VIR_STORAGE_TYPE_NETWORK: - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_GLUSTER: driver =3D "gluster"; if (!(location =3D qemuBlockStorageSourceGetGlusterProps(src, = false))) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0d2548d8d4..cf5083de34 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8943,7 +8943,7 @@ qemuDomainPrepareStorageSourceTLS(virStorageSource *s= rc, if (virStorageSourceGetActualType(src) !=3D VIR_STORAGE_TYPE_NETWORK) return 0; - switch ((virStorageNetProtocol) src->protocol) { + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_VXHS: /* vxhs is no longer supported */ break; diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 8128154749..764aafda4d 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -658,7 +658,7 @@ qemuSnapshotPrepareDiskExternalInactive(virDomainSnapsh= otDiskDef *snapdisk, break; case VIR_STORAGE_TYPE_NETWORK: - switch ((virStorageNetProtocol) domdisk->src->protocol) { + switch (domdisk->src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_RBD: @@ -883,7 +883,7 @@ qemuSnapshotPrepareDiskInternal(virDomainDiskDef *disk, return 0; case VIR_STORAGE_TYPE_NETWORK: - switch ((virStorageNetProtocol) disk->src->protocol) { + switch (disk->src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_RBD: diff --git a/src/storage_file/storage_source_backingstore.c b/src/storage_f= ile/storage_source_backingstore.c index 80681924ea..4a273fe46c 100644 --- a/src/storage_file/storage_source_backingstore.c +++ b/src/storage_file/storage_source_backingstore.c @@ -44,6 +44,7 @@ virStorageSourceParseBackingURI(virStorageSource *src, const char *path =3D NULL; int transport =3D 0; g_auto(GStrv) scheme =3D NULL; + int protocol; if (!(uri =3D virURIParse(uristr))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -59,12 +60,13 @@ virStorageSourceParseBackingURI(virStorageSource *src, return -1; if (!scheme[0] || - (src->protocol =3D virStorageNetProtocolTypeFromString(scheme[0]))= < 0) { + (protocol =3D virStorageNetProtocolTypeFromString(scheme[0])) < 0)= { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid backing protocol '%1$s'"), NULLSTR(scheme[0])); return -1; } + src->protocol =3D protocol; if (scheme[1]) { if ((transport =3D virStorageNetHostTransportTypeFromString(scheme= [1])) < 0) { @@ -370,7 +372,8 @@ virStorageSourceParseBackingColon(virStorageSource *src, const char *path) { const char *p; - g_autofree char *protocol =3D NULL; + g_autofree char *protocol_str =3D NULL; + int protocol; if (!(p =3D strchr(path, ':'))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -379,16 +382,18 @@ virStorageSourceParseBackingColon(virStorageSource *s= rc, return -1; } - protocol =3D g_strndup(path, p - path); + protocol_str =3D g_strndup(path, p - path); - if ((src->protocol =3D virStorageNetProtocolTypeFromString(protocol)) = < 0) { + if ((protocol =3D virStorageNetProtocolTypeFromString(protocol_str)) <= 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid backing protocol '%1$s'"), - protocol); + protocol_str); return -1; } - switch ((virStorageNetProtocol) src->protocol) { + src->protocol =3D protocol; + + switch (src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NBD: if (virStorageSourceParseNBDColonString(path, src) < 0) return -1; @@ -404,7 +409,7 @@ virStorageSourceParseBackingColon(virStorageSource *src, case VIR_STORAGE_NET_PROTOCOL_NONE: virReportError(VIR_ERR_INTERNAL_ERROR, _("backing store parser is not implemented for prot= ocol %1$s"), - protocol); + protocol_str); return -1; case VIR_STORAGE_NET_PROTOCOL_HTTP: @@ -419,7 +424,7 @@ virStorageSourceParseBackingColon(virStorageSource *src, case VIR_STORAGE_NET_PROTOCOL_NFS: virReportError(VIR_ERR_INTERNAL_ERROR, _("malformed backing store path for protocol %1$s"), - protocol); + protocol_str); return -1; } --=20 2.49.0