From nobody Mon Apr 29 19:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688480724495.34331180646586; Mon, 10 Jul 2017 05:08:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E58E95BED8; Mon, 10 Jul 2017 12:07:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ABBAE17A97; Mon, 10 Jul 2017 12:07:55 +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 2CD581853E3A; Mon, 10 Jul 2017 12:07:55 +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 v6AC7h3Z018555 for ; Mon, 10 Jul 2017 08:07:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id DAA25182EC; Mon, 10 Jul 2017 12:07:43 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 196BC182F6; Mon, 10 Jul 2017 12:07:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E58E95BED8 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E58E95BED8 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:33 +0200 Message-Id: <7341aadaba8f725cb7cd67c83620a641630a78eb.1499688409.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 01/10] qemu: command: Set port number only for TCP transport 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 10 Jul 2017 12:07:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Setting port number for protocols using UNIX transport does not make sense. Move the setter code to the appropriate block. --- src/qemu/qemu_command.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3fe291863..f77ae91c3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -949,6 +949,10 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src, goto cleanup; if (src->hosts->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { + if ((uri->port =3D qemuNetworkDriveGetPort(src->protocol, + src->hosts->port)) < 0) + goto cleanup; + if (VIR_STRDUP(uri->scheme, virStorageNetProtocolTypeToString(src->protocol)) <= 0) goto cleanup; @@ -959,10 +963,6 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src, goto cleanup; } - if ((uri->port =3D qemuNetworkDriveGetPort(src->protocol, - src->hosts->port)) < 0) - goto cleanup; - if (src->path) { if (src->volume) { if (virAsprintf(&uri->path, "/%s%s", --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688472425770.3759902838177; Mon, 10 Jul 2017 05:07:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62AB5C062CE7; Mon, 10 Jul 2017 12:07:47 +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 34E747D4F6; Mon, 10 Jul 2017 12:07:47 +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 B34DB157C2; Mon, 10 Jul 2017 12:07:46 +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 v6AC7ijh018562 for ; Mon, 10 Jul 2017 08:07:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id D4898182F6; Mon, 10 Jul 2017 12:07:44 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 330F6182E0; Mon, 10 Jul 2017 12:07:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 62AB5C062CE7 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 62AB5C062CE7 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:34 +0200 Message-Id: <0d939d9b9ccea56c2f2df416aa5812b64008baaf.1499688409.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 02/10] util: Extract helper to retrieve default port for network protocol 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 10 Jul 2017 12:07:48 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make the stuff hardcoded in qemu a global helper so that other parts of the code can determine the default port too. --- src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 55 ++++++++-----------------------------------= ---- src/util/virstoragefile.c | 43 ++++++++++++++++++++++++++++++++++++ src/util/virstoragefile.h | 3 +++ 4 files changed, 56 insertions(+), 46 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 888412ac7..44b5dc1e0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2614,6 +2614,7 @@ virStorageSourceIsBlockLocal; virStorageSourceIsEmpty; virStorageSourceIsLocalStorage; virStorageSourceIsRelative; +virStorageSourceNetworkDefaultPort; virStorageSourceNewFromBacking; virStorageSourceNewFromBackingAbsolute; virStorageSourceParseRBDColonString; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f77ae91c3..e5f4bdab7 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -482,55 +482,18 @@ qemuNetworkDriveGetPort(int protocol, { int ret =3D 0; - if (port) { - if (virStrToLong_i(port, NULL, 10, &ret) < 0 || ret < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to parse port number '%s'"), - port); - return -1; - } - - return ret; - } - - switch ((virStorageNetProtocol) protocol) { - case VIR_STORAGE_NET_PROTOCOL_HTTP: - return 80; - - case VIR_STORAGE_NET_PROTOCOL_HTTPS: - return 443; - - case VIR_STORAGE_NET_PROTOCOL_FTP: - return 21; - - case VIR_STORAGE_NET_PROTOCOL_FTPS: - return 990; - - case VIR_STORAGE_NET_PROTOCOL_TFTP: - return 69; - - case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: - return 7000; - - case VIR_STORAGE_NET_PROTOCOL_NBD: - return 10809; - - case VIR_STORAGE_NET_PROTOCOL_SSH: - return 22; - - case VIR_STORAGE_NET_PROTOCOL_ISCSI: - case VIR_STORAGE_NET_PROTOCOL_GLUSTER: - /* no default port specified */ - return 0; + if (!port && + !(port =3D virStorageSourceNetworkDefaultPort(protocol))) + return -1; - case VIR_STORAGE_NET_PROTOCOL_RBD: - case VIR_STORAGE_NET_PROTOCOL_LAST: - case VIR_STORAGE_NET_PROTOCOL_NONE: - /* not applicable */ - return -1; + if (virStrToLong_i(port, NULL, 10, &ret) < 0 || ret < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to parse port number '%s'"), + port); + return -1; } - return -1; + return ret; } diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index f0ed5c6bd..cae20eccc 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4018,3 +4018,46 @@ virStorageSourceFindByNodeName(virStorageSourcePtr t= op, *idx =3D 0; return NULL; } + + +const char * +virStorageSourceNetworkDefaultPort(virStorageNetProtocol protocol) +{ + switch (protocol) { + case VIR_STORAGE_NET_PROTOCOL_HTTP: + return "80"; + + case VIR_STORAGE_NET_PROTOCOL_HTTPS: + return "443"; + + case VIR_STORAGE_NET_PROTOCOL_FTP: + return "21"; + + case VIR_STORAGE_NET_PROTOCOL_FTPS: + return "990"; + + case VIR_STORAGE_NET_PROTOCOL_TFTP: + return "69"; + + case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: + return "7000"; + + case VIR_STORAGE_NET_PROTOCOL_NBD: + return "10809"; + + case VIR_STORAGE_NET_PROTOCOL_SSH: + return "22"; + + case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_GLUSTER: + /* no default port specified */ + return "0"; + + case VIR_STORAGE_NET_PROTOCOL_RBD: + case VIR_STORAGE_NET_PROTOCOL_LAST: + case VIR_STORAGE_NET_PROTOCOL_NONE: + return NULL; + } + + return NULL; +} diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 0bff8671f..877c3af4d 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -406,4 +406,7 @@ virStorageSourceFindByNodeName(virStorageSourcePtr top, unsigned int *index) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +const char * +virStorageSourceNetworkDefaultPort(virStorageNetProtocol protocol); + #endif /* __VIR_STORAGE_FILE_H__ */ --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688488404794.9744078513339; Mon, 10 Jul 2017 05:08:08 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3C6DC04D28D; Mon, 10 Jul 2017 12:08: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 88F0E7EBED; Mon, 10 Jul 2017 12:08:02 +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 7DD0D157C4; Mon, 10 Jul 2017 12:08:01 +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 v6AC7j7x018572 for ; Mon, 10 Jul 2017 08:07:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD35D182F6; Mon, 10 Jul 2017 12:07:45 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CA27182EC; Mon, 10 Jul 2017 12:07:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E3C6DC04D28D Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E3C6DC04D28D From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:35 +0200 Message-Id: <2e25f183a5669f497ba2369011a08749ba07b6f0.1499688409.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 03/10] util: storage: Fill in default ports for gluster and iscsi 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 10 Jul 2017 12:08:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Our documentation provides them, so the helper should return them. --- src/util/virstoragefile.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index cae20eccc..0c215e1b6 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4049,11 +4049,15 @@ virStorageSourceNetworkDefaultPort(virStorageNetPro= tocol protocol) return "22"; case VIR_STORAGE_NET_PROTOCOL_ISCSI: + return "3260"; + case VIR_STORAGE_NET_PROTOCOL_GLUSTER: - /* no default port specified */ - return "0"; + return "24007"; case VIR_STORAGE_NET_PROTOCOL_RBD: + /* we don't provide a default for RBD */ + return NULL; + case VIR_STORAGE_NET_PROTOCOL_LAST: case VIR_STORAGE_NET_PROTOCOL_NONE: return NULL; --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688475915235.39934078182125; Mon, 10 Jul 2017 05:07:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17215C04B940; Mon, 10 Jul 2017 12:07:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E30B219E02; Mon, 10 Jul 2017 12:07:49 +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 7BD091841C41; Mon, 10 Jul 2017 12:07:49 +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 v6AC7ll9018587 for ; Mon, 10 Jul 2017 08:07:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id A333A182EC; Mon, 10 Jul 2017 12:07:47 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 845E4182FA; Mon, 10 Jul 2017 12:07:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 17215C04B940 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 17215C04B940 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:36 +0200 Message-Id: <38ac1913170e7f80eb5a1ee2bc76d4bf7371be7b.1499688409.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 04/10] conf: Pre-fill default ports when parsing network disk sources 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 10 Jul 2017 12:07:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fill them in right away rather than having to figure out at runtime whether they are necessary or not. virStorageSourceNetworkDefaultPort does not need to be exported any more. --- src/conf/domain_conf.c | 3 +++ src/libvirt_private.syms | 2 +- src/qemu/qemu_command.c | 10 ++-------- src/util/virstoragefile.c | 20 ++++++++++++++++= +++- src/util/virstoragefile.h | 5 +++-- .../generic-disk-network-http.xml | 4 ++-- .../qemuxml2xmlout-disk-drive-network-gluster.xml | 2 +- 7 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c3149f976..bc4b10d60 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7807,6 +7807,9 @@ virDomainDiskSourceParse(xmlNodePtr node, if (virDomainStorageHostParse(node, &src->hosts, &src->nhosts) < 0) goto cleanup; + + if (virStorageSourceNetworkAssignDefaultPorts(src) < 0) + goto cleanup; break; case VIR_STORAGE_TYPE_VOLUME: if (virDomainDiskSourcePoolDefParse(node, &src->srcpool) < 0) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 44b5dc1e0..ae8d3483c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2614,7 +2614,7 @@ virStorageSourceIsBlockLocal; virStorageSourceIsEmpty; virStorageSourceIsLocalStorage; virStorageSourceIsRelative; -virStorageSourceNetworkDefaultPort; +virStorageSourceNetworkAssignDefaultPorts; virStorageSourceNewFromBacking; virStorageSourceNewFromBackingAbsolute; virStorageSourceParseRBDColonString; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e5f4bdab7..285167145 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -477,15 +477,10 @@ qemuSafeSerialParamValue(const char *value) static int -qemuNetworkDriveGetPort(int protocol, - const char *port) +qemuNetworkDriveGetPort(const char *port) { int ret =3D 0; - if (!port && - !(port =3D virStorageSourceNetworkDefaultPort(protocol))) - return -1; - if (virStrToLong_i(port, NULL, 10, &ret) < 0 || ret < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse port number '%s'"), @@ -912,8 +907,7 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src, goto cleanup; if (src->hosts->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { - if ((uri->port =3D qemuNetworkDriveGetPort(src->protocol, - src->hosts->port)) < 0) + if ((uri->port =3D qemuNetworkDriveGetPort(src->hosts->port)) < 0) goto cleanup; if (VIR_STRDUP(uri->scheme, diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 0c215e1b6..6c2516d34 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4020,7 +4020,7 @@ virStorageSourceFindByNodeName(virStorageSourcePtr to= p, } -const char * +static const char * virStorageSourceNetworkDefaultPort(virStorageNetProtocol protocol) { switch (protocol) { @@ -4065,3 +4065,21 @@ virStorageSourceNetworkDefaultPort(virStorageNetProt= ocol protocol) return NULL; } + + +int +virStorageSourceNetworkAssignDefaultPorts(virStorageSourcePtr src) +{ + size_t i; + + for (i =3D 0; i < src->nhosts; i++) { + if (src->hosts[i].transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP = && + src->hosts[i].port =3D=3D NULL) { + if (VIR_STRDUP(src->hosts[i].port, + virStorageSourceNetworkDefaultPort(src->protoco= l)) < 0) + return -1; + } + } + + return 0; +} diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 877c3af4d..98992e04a 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -406,7 +406,8 @@ virStorageSourceFindByNodeName(virStorageSourcePtr top, unsigned int *index) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -const char * -virStorageSourceNetworkDefaultPort(virStorageNetProtocol protocol); +int +virStorageSourceNetworkAssignDefaultPorts(virStorageSourcePtr src) + ATTRIBUTE_NONNULL(1); #endif /* __VIR_STORAGE_FILE_H__ */ diff --git a/tests/genericxml2xmlindata/generic-disk-network-http.xml b/tes= ts/genericxml2xmlindata/generic-disk-network-http.xml index 51c779502..ec4520c7b 100644 --- a/tests/genericxml2xmlindata/generic-disk-network-http.xml +++ b/tests/genericxml2xmlindata/generic-disk-network-http.xml @@ -17,14 +17,14 @@ - + - + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-glu= ster.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-glust= er.xml index 66a84750a..2c7c46b01 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-gluster.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-network-gluster.xml @@ -34,7 +34,7 @@ - + --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688492507667.5209095368915; Mon, 10 Jul 2017 05:08:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC4663D966; Mon, 10 Jul 2017 12:08:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7CE6117AD9; Mon, 10 Jul 2017 12:08:08 +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 312E81853E36; Mon, 10 Jul 2017 12:08:08 +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 v6AC7mNc018592 for ; Mon, 10 Jul 2017 08:07:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id CFDF0182F6; Mon, 10 Jul 2017 12:07:48 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0030D182EC; Mon, 10 Jul 2017 12:07:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AC4663D966 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AC4663D966 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:37 +0200 Message-Id: <44ddc8f54056b06c971159e132ed5d15a4228953.1499688409.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 05/10] qemu: command: Remove default port numbers for NBD and GLUSTER 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 10 Jul 2017 12:08:09 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The command line generators for the protocols above hardcoded a default port number. Since we now always assign it when parsing the source definition, this ad-hoc code is not required any more. --- src/qemu/qemu_command.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 285167145..10c2dea93 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -792,9 +792,6 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd, } -#define QEMU_DEFAULT_NBD_PORT "10809" -#define QEMU_DEFAULT_GLUSTER_PORT "24007" - /* builds the hosts array */ static virJSONValuePtr qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src) @@ -804,7 +801,6 @@ qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src) virJSONValuePtr ret =3D NULL; virStorageNetHostDefPtr host; const char *transport; - const char *portstr; size_t i; if (!(servers =3D virJSONValueNewArray())) @@ -813,19 +809,15 @@ qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr sr= c) for (i =3D 0; i < src->nhosts; i++) { host =3D src->hosts + i; transport =3D virStorageNetHostTransportTypeToString(host->transpo= rt); - portstr =3D host->port; if (virJSONValueObjectCreate(&server, "s:type", transport, NULL) <= 0) goto cleanup; - if (!portstr) - portstr =3D QEMU_DEFAULT_GLUSTER_PORT; - switch ((virStorageNetHostTransport) host->transport) { case VIR_STORAGE_NET_HOST_TRANS_TCP: if (virJSONValueObjectAdd(server, "s:host", host->name, - "s:port", portstr, + "s:port", host->port, NULL) < 0) goto cleanup; break; @@ -979,10 +971,8 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src, switch (src->hosts->transport) { case VIR_STORAGE_NET_HOST_TRANS_TCP: - virBufferStrcat(&buf, src->hosts->name, NULL); - virBufferAsprintf(&buf, ":%s", - src->hosts->port ? src->hosts->port : - QEMU_DEFAULT_NBD_PORT); + virBufferStrcat(&buf, src->hosts->name, ":", + src->hosts->port, NULL); break; case VIR_STORAGE_NET_HOST_TRANS_UNIX: --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688481810229.15475433146992; Mon, 10 Jul 2017 05:08:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D52407EBDA; Mon, 10 Jul 2017 12:07:57 +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 856187ED83; Mon, 10 Jul 2017 12:07:57 +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 11441157C4; Mon, 10 Jul 2017 12:07:57 +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 v6AC7nM3018604 for ; Mon, 10 Jul 2017 08:07:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id DED55182E0; Mon, 10 Jul 2017 12:07:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C70F7DFD1; Mon, 10 Jul 2017 12:07:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D52407EBDA Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D52407EBDA From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:38 +0200 Message-Id: <7c12ca4c82d15bdbbcef55c85b9bc430a3a31668.1499688409.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 06/10] qemu: command: Call qemuGetDriveSourceProps only if necessary 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 10 Jul 2017 12:07:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add logic which will call qemuGetDriveSourceProps only in cases where we need the JSON representation. This will allow qemuGetDriveSourceProps to generate the JSON representation for all possible disk sources. --- src/qemu/qemu_command.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 10c2dea93..376082320 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1436,6 +1436,28 @@ qemuDiskBusNeedsDeviceArg(int bus) } +/** + * qemuDiskSourceNeedsProps: + * @src: disk source + * + * Returns true, if the disk source needs to be generated from the JSON + * representation. Otherwise, the disk source should be represented using + * the legacy representation. + */ +static bool +qemuDiskSourceNeedsProps(virStorageSourcePtr src) +{ + int actualType =3D virStorageSourceGetActualType(src); + + if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && + src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && + src->nhosts > 1) + return true; + + return false; +} + + static int qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, virQEMUDriverConfigPtr cfg, @@ -1450,7 +1472,8 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, char *source =3D NULL; int ret =3D -1; - if (qemuGetDriveSourceProps(disk->src, &srcprops) < 0) + if (qemuDiskSourceNeedsProps(disk->src) && + qemuGetDriveSourceProps(disk->src, &srcprops) < 0) goto cleanup; if (!srcprops && --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688497264894.2642547826767; Mon, 10 Jul 2017 05:08:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C81767F3FC; Mon, 10 Jul 2017 12:08:12 +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 86A8D17269; Mon, 10 Jul 2017 12:08:12 +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 21C4A157CB; Mon, 10 Jul 2017 12:08:12 +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 v6AC7pSb018609 for ; Mon, 10 Jul 2017 08:07:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4046E182EB; Mon, 10 Jul 2017 12:07:51 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BD15182E7; Mon, 10 Jul 2017 12:07:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C81767F3FC Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C81767F3FC From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:39 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 07/10] qemu: Move qemuGetDriveSourceProps to qemu_block 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 10 Jul 2017 12:08:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Pure code movement except for the tweaks necessary for cross-usage. --- po/POTFILES.in | 1 + src/qemu/qemu_block.c | 126 ++++++++++++++++++++++++++++++++++++++++++++= +++ src/qemu/qemu_block.h | 5 ++ src/qemu/qemu_command.c | 127 +-------------------------------------------= ---- 4 files changed, 133 insertions(+), 126 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 275df1f29..b5e99e084 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -129,6 +129,7 @@ src/openvz/openvz_util.c src/phyp/phyp_driver.c src/qemu/qemu_agent.c src/qemu/qemu_alias.c +src/qemu/qemu_block.c src/qemu/qemu_capabilities.c src/qemu/qemu_cgroup.c src/qemu/qemu_command.c diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 29b5c4756..e6b909015 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -428,3 +428,129 @@ qemuBlockGetNodeData(virJSONValuePtr data) virHashFree(ret); return NULL; } + + +/* builds the hosts array */ +static virJSONValuePtr +qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src) +{ + virJSONValuePtr servers =3D NULL; + virJSONValuePtr server =3D NULL; + virJSONValuePtr ret =3D NULL; + virStorageNetHostDefPtr host; + const char *transport; + size_t i; + + if (!(servers =3D virJSONValueNewArray())) + goto cleanup; + + for (i =3D 0; i < src->nhosts; i++) { + host =3D src->hosts + i; + transport =3D virStorageNetHostTransportTypeToString(host->transpo= rt); + + if (virJSONValueObjectCreate(&server, "s:type", transport, NULL) <= 0) + goto cleanup; + + switch ((virStorageNetHostTransport) host->transport) { + case VIR_STORAGE_NET_HOST_TRANS_TCP: + if (virJSONValueObjectAdd(server, + "s:host", host->name, + "s:port", host->port, + NULL) < 0) + goto cleanup; + break; + + case VIR_STORAGE_NET_HOST_TRANS_UNIX: + if (virJSONValueObjectAdd(server, + "s:socket", host->socket, + NULL) < 0) + goto cleanup; + break; + + case VIR_STORAGE_NET_HOST_TRANS_RDMA: + case VIR_STORAGE_NET_HOST_TRANS_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("transport protocol '%s' is not yet supported= "), + transport); + goto cleanup; + } + + if (virJSONValueArrayAppend(servers, server) < 0) + goto cleanup; + + server =3D NULL; + } + + ret =3D servers; + servers =3D NULL; + + cleanup: + virJSONValueFree(servers); + virJSONValueFree(server); + + return ret; +} + + +static virJSONValuePtr +qemuBuildGlusterDriveJSON(virStorageSourcePtr src) +{ + const char *protocol =3D virStorageNetProtocolTypeToString(src->protoc= ol); + virJSONValuePtr servers =3D NULL; + virJSONValuePtr ret =3D NULL; + + if (!(servers =3D qemuBuildGlusterDriveJSONHosts(src))) + return NULL; + + /* { driver:"gluster", + * volume:"testvol", + * path:"/a.img", + * server :[{type:"tcp", host:"1.2.3.4", port:24007}, + * {type:"unix", socket:"/tmp/glusterd.socket"}, ...]} + */ + if (virJSONValueObjectCreate(&ret, + "s:driver", protocol, + "s:volume", src->volume, + "s:path", src->path, + "a:server", servers, NULL) < 0) + virJSONValueFree(servers); + + return ret; +} + + +int +qemuGetDriveSourceProps(virStorageSourcePtr src, + virJSONValuePtr *props) +{ + int actualType =3D virStorageSourceGetActualType(src); + virJSONValuePtr fileprops =3D NULL; + + *props =3D NULL; + + switch ((virStorageType) actualType) { + case VIR_STORAGE_TYPE_BLOCK: + case VIR_STORAGE_TYPE_FILE: + case VIR_STORAGE_TYPE_DIR: + case VIR_STORAGE_TYPE_VOLUME: + case VIR_STORAGE_TYPE_NONE: + case VIR_STORAGE_TYPE_LAST: + break; + + case VIR_STORAGE_TYPE_NETWORK: + if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && + src->nhosts > 1) { + if (!(fileprops =3D qemuBuildGlusterDriveJSON(src))) + return -1; + } + break; + } + + if (fileprops && + virJSONValueObjectCreate(props, "a:file", fileprops, NULL) < 0) { + virJSONValueFree(fileprops); + return -1; + } + + return 0; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 2af15a65a..3a8950b13 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -53,4 +53,9 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver, virHashTablePtr qemuBlockGetNodeData(virJSONValuePtr data); + +int +qemuGetDriveSourceProps(virStorageSourcePtr src, + virJSONValuePtr *props); + #endif /* __QEMU_BLOCK_H__ */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 376082320..963224335 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -29,6 +29,7 @@ #include "qemu_interface.h" #include "qemu_alias.h" #include "qemu_security.h" +#include "qemu_block.h" #include "cpu/cpu.h" #include "dirname.h" #include "viralloc.h" @@ -792,95 +793,6 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd, } -/* builds the hosts array */ -static virJSONValuePtr -qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src) -{ - virJSONValuePtr servers =3D NULL; - virJSONValuePtr server =3D NULL; - virJSONValuePtr ret =3D NULL; - virStorageNetHostDefPtr host; - const char *transport; - size_t i; - - if (!(servers =3D virJSONValueNewArray())) - goto cleanup; - - for (i =3D 0; i < src->nhosts; i++) { - host =3D src->hosts + i; - transport =3D virStorageNetHostTransportTypeToString(host->transpo= rt); - - if (virJSONValueObjectCreate(&server, "s:type", transport, NULL) <= 0) - goto cleanup; - - switch ((virStorageNetHostTransport) host->transport) { - case VIR_STORAGE_NET_HOST_TRANS_TCP: - if (virJSONValueObjectAdd(server, - "s:host", host->name, - "s:port", host->port, - NULL) < 0) - goto cleanup; - break; - - case VIR_STORAGE_NET_HOST_TRANS_UNIX: - if (virJSONValueObjectAdd(server, - "s:socket", host->socket, - NULL) < 0) - goto cleanup; - break; - - case VIR_STORAGE_NET_HOST_TRANS_RDMA: - case VIR_STORAGE_NET_HOST_TRANS_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("transport protocol '%s' is not yet supported= "), - transport); - goto cleanup; - } - - if (virJSONValueArrayAppend(servers, server) < 0) - goto cleanup; - - server =3D NULL; - } - - ret =3D servers; - servers =3D NULL; - - cleanup: - virJSONValueFree(servers); - virJSONValueFree(server); - - return ret; -} - - -static virJSONValuePtr -qemuBuildGlusterDriveJSON(virStorageSourcePtr src) -{ - const char *protocol =3D virStorageNetProtocolTypeToString(src->protoc= ol); - virJSONValuePtr servers =3D NULL; - virJSONValuePtr ret =3D NULL; - - if (!(servers =3D qemuBuildGlusterDriveJSONHosts(src))) - return NULL; - - /* { driver:"gluster", - * volume:"testvol", - * path:"/a.img", - * server :[{type:"tcp", host:"1.2.3.4", port:24007}, - * {type:"unix", socket:"/tmp/glusterd.socket"}, ...]} - */ - if (virJSONValueObjectCreate(&ret, - "s:driver", protocol, - "s:volume", src->volume, - "s:path", src->path, - "a:server", servers, NULL) < 0) - virJSONValueFree(servers); - - return ret; -} - - static char * qemuBuildNetworkDriveURI(virStorageSourcePtr src, qemuDomainSecretInfoPtr secinfo) @@ -1103,43 +1015,6 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src, } -static int -qemuGetDriveSourceProps(virStorageSourcePtr src, - virJSONValuePtr *props) -{ - int actualType =3D virStorageSourceGetActualType(src); - virJSONValuePtr fileprops =3D NULL; - - *props =3D NULL; - - switch ((virStorageType) actualType) { - case VIR_STORAGE_TYPE_BLOCK: - case VIR_STORAGE_TYPE_FILE: - case VIR_STORAGE_TYPE_DIR: - case VIR_STORAGE_TYPE_VOLUME: - case VIR_STORAGE_TYPE_NONE: - case VIR_STORAGE_TYPE_LAST: - break; - - case VIR_STORAGE_TYPE_NETWORK: - if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && - src->nhosts > 1) { - if (!(fileprops =3D qemuBuildGlusterDriveJSON(src))) - return -1; - } - break; - } - - if (fileprops && - virJSONValueObjectCreate(props, "a:file", fileprops, NULL) < 0) { - virJSONValueFree(fileprops); - return -1; - } - - return 0; -} - - int qemuGetDriveSourceString(virStorageSourcePtr src, qemuDomainSecretInfoPtr secinfo, --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688489711754.698413509713; Mon, 10 Jul 2017 05:08:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BBDA158AB0; Mon, 10 Jul 2017 12:08:03 +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 ABE6D182FA; Mon, 10 Jul 2017 12:08:02 +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 28098157C7; Mon, 10 Jul 2017 12:08:02 +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 v6AC7qoV018622 for ; Mon, 10 Jul 2017 08:07:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 33EF662930; Mon, 10 Jul 2017 12:07:52 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8776F182E0; Mon, 10 Jul 2017 12:07:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0BBDA158AB0 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0BBDA158AB0 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:40 +0200 Message-Id: <3524b77c94e39d49073af1289830f7f342f32bdd.1499688409.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 08/10] qemu: block: Refactor and rename qemuGetDriveSourceProps 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 10 Jul 2017 12:08:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rename it to qemuBlockStorageSourceGetBackendProps and refactor it to return the JSON object instead of filling a pointer since now it's always expected to return data. --- src/qemu/qemu_block.c | 49 +++++++++++++++++++++++++++++++++++----------= ---- src/qemu/qemu_block.h | 6 ++---- src/qemu/qemu_command.c | 2 +- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index e6b909015..3dbb5586d 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -519,14 +519,19 @@ qemuBuildGlusterDriveJSON(virStorageSourcePtr src) } -int -qemuGetDriveSourceProps(virStorageSourcePtr src, - virJSONValuePtr *props) +/** + * qemuBlockStorageSourceGetBackendProps: + * @src: disk source + * + * Creates a JSON object describing the underlying storage or protocol of a + * storage source. Returns NULL on error and reports an appropriate error = message. + */ +virJSONValuePtr +qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src) { int actualType =3D virStorageSourceGetActualType(src); virJSONValuePtr fileprops =3D NULL; - - *props =3D NULL; + virJSONValuePtr ret =3D NULL; switch ((virStorageType) actualType) { case VIR_STORAGE_TYPE_BLOCK: @@ -538,19 +543,35 @@ qemuGetDriveSourceProps(virStorageSourcePtr src, break; case VIR_STORAGE_TYPE_NETWORK: - if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && - src->nhosts > 1) { + switch ((virStorageNetProtocol) src->protocol) { + case VIR_STORAGE_NET_PROTOCOL_GLUSTER: if (!(fileprops =3D qemuBuildGlusterDriveJSON(src))) - return -1; + goto cleanup; + break; + + case VIR_STORAGE_NET_PROTOCOL_NBD: + case VIR_STORAGE_NET_PROTOCOL_RBD: + case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: + case VIR_STORAGE_NET_PROTOCOL_ISCSI: + 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_TFTP: + case VIR_STORAGE_NET_PROTOCOL_SSH: + case VIR_STORAGE_NET_PROTOCOL_NONE: + case VIR_STORAGE_NET_PROTOCOL_LAST: + break; } break; } - if (fileprops && - virJSONValueObjectCreate(props, "a:file", fileprops, NULL) < 0) { - virJSONValueFree(fileprops); - return -1; - } + if (virJSONValueObjectCreate(&ret, "a:file", fileprops, NULL) < 0) + goto cleanup; - return 0; + fileprops =3D NULL; + + cleanup: + virJSONValueFree(fileprops); + return ret; } diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 3a8950b13..17dec799f 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -53,9 +53,7 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver, virHashTablePtr qemuBlockGetNodeData(virJSONValuePtr data); - -int -qemuGetDriveSourceProps(virStorageSourcePtr src, - virJSONValuePtr *props); +virJSONValuePtr +qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src); #endif /* __QEMU_BLOCK_H__ */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 963224335..c20dd64dc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1348,7 +1348,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, int ret =3D -1; if (qemuDiskSourceNeedsProps(disk->src) && - qemuGetDriveSourceProps(disk->src, &srcprops) < 0) + !(srcprops =3D qemuBlockStorageSourceGetBackendProps(disk->src))) goto cleanup; if (!srcprops && --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688491588225.0006247239828; Mon, 10 Jul 2017 05:08:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEC6F8E753; Mon, 10 Jul 2017 12:08:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C18117AD3; Mon, 10 Jul 2017 12:08:07 +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 129FF1853E31; Mon, 10 Jul 2017 12:08:07 +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 v6AC7rpL018630 for ; Mon, 10 Jul 2017 08:07:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6EADC182FD; Mon, 10 Jul 2017 12:07:53 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE722182EB; Mon, 10 Jul 2017 12:07:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BEC6F8E753 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BEC6F8E753 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:41 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 09/10] qemu: block: refactor and rename qemuBuildGlusterDriveJSONHosts 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 10 Jul 2017 12:08:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" New name is qemuBlockStorageSourceBuildHostsJSONSocketAddress since it formats the JSON object in accordance with qemu's SocketAddress type. Since the new naming in qemu uses 'inet' instead of 'tcp' add a compatibility layer for gluster which uses the old name. --- src/qemu/qemu_block.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 3dbb5586d..73f209060 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -430,9 +430,17 @@ qemuBlockGetNodeData(virJSONValuePtr data) } -/* builds the hosts array */ +/** + * qemuBlockStorageSourceBuildHostsJSONSocketAddress: + * @src: disk storage source + * @legacy: use 'tcp' instead of 'inet' for compatibility reasons + * + * Formats src->hosts into a json object conforming to the 'SocketAddress'= type + * in qemu. + */ static virJSONValuePtr -qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src) +qemuBlockStorageSourceBuildHostsJSONSocketAddress(virStorageSourcePtr src, + bool legacy) { virJSONValuePtr servers =3D NULL; virJSONValuePtr server =3D NULL; @@ -446,24 +454,27 @@ qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr sr= c) for (i =3D 0; i < src->nhosts; i++) { host =3D src->hosts + i; - transport =3D virStorageNetHostTransportTypeToString(host->transpo= rt); - - if (virJSONValueObjectCreate(&server, "s:type", transport, NULL) <= 0) - goto cleanup; switch ((virStorageNetHostTransport) host->transport) { case VIR_STORAGE_NET_HOST_TRANS_TCP: - if (virJSONValueObjectAdd(server, - "s:host", host->name, - "s:port", host->port, - NULL) < 0) + if (legacy) + transport =3D "tcp"; + else + transport =3D "inet"; + + if (virJSONValueObjectCreate(&server, + "s:type", transport, + "s:host", host->name, + "s:port", host->port, + NULL) < 0) goto cleanup; break; case VIR_STORAGE_NET_HOST_TRANS_UNIX: - if (virJSONValueObjectAdd(server, - "s:socket", host->socket, - NULL) < 0) + if (virJSONValueObjectCreate(&server, + "s:type", "unix", + "s:socket", host->socket, + NULL) < 0) goto cleanup; break; @@ -481,8 +492,7 @@ qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src) server =3D NULL; } - ret =3D servers; - servers =3D NULL; + VIR_STEAL_PTR(ret, servers); cleanup: virJSONValueFree(servers); @@ -499,7 +509,7 @@ qemuBuildGlusterDriveJSON(virStorageSourcePtr src) virJSONValuePtr servers =3D NULL; virJSONValuePtr ret =3D NULL; - if (!(servers =3D qemuBuildGlusterDriveJSONHosts(src))) + if (!(servers =3D qemuBlockStorageSourceBuildHostsJSONSocketAddress(sr= c, true))) return NULL; /* { driver:"gluster", --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499688495040444.72614891882995; Mon, 10 Jul 2017 05:08:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 934C6158A93; Mon, 10 Jul 2017 12:08:11 +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 65AB017A8D; Mon, 10 Jul 2017 12:08:11 +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 18BE3157C9; Mon, 10 Jul 2017 12:08:11 +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 v6AC7sxY018644 for ; Mon, 10 Jul 2017 08:07:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id B3829182E0; Mon, 10 Jul 2017 12:07:54 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7FC462930; Mon, 10 Jul 2017 12:07:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 934C6158A93 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 934C6158A93 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 14:07:42 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 10/10] qemu: block: rename and refactor qemuBuildGlusterDriveJSON 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 10 Jul 2017 12:08:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" New name is qemuBlockStorageSourceGetGlusterProps and also hardcode the protocol name rather than calling the ToString function, since this function can't be made universal. --- src/qemu/qemu_block.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 73f209060..ccaf32611 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -503,9 +503,8 @@ qemuBlockStorageSourceBuildHostsJSONSocketAddress(virSt= orageSourcePtr src, static virJSONValuePtr -qemuBuildGlusterDriveJSON(virStorageSourcePtr src) +qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src) { - const char *protocol =3D virStorageNetProtocolTypeToString(src->protoc= ol); virJSONValuePtr servers =3D NULL; virJSONValuePtr ret =3D NULL; @@ -519,7 +518,7 @@ qemuBuildGlusterDriveJSON(virStorageSourcePtr src) * {type:"unix", socket:"/tmp/glusterd.socket"}, ...]} */ if (virJSONValueObjectCreate(&ret, - "s:driver", protocol, + "s:driver", "gluster", "s:volume", src->volume, "s:path", src->path, "a:server", servers, NULL) < 0) @@ -555,7 +554,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourceP= tr src) case VIR_STORAGE_TYPE_NETWORK: switch ((virStorageNetProtocol) src->protocol) { case VIR_STORAGE_NET_PROTOCOL_GLUSTER: - if (!(fileprops =3D qemuBuildGlusterDriveJSON(src))) + if (!(fileprops =3D qemuBlockStorageSourceGetGlusterProps(src)= )) goto cleanup; break; --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list