From nobody Thu Apr 25 10:08:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580910217369231.10973629172622; Wed, 5 Feb 2020 05:43:37 -0800 (PST) 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-185-bzOiYYl8PhCmooi3gTzr6w-1; Wed, 05 Feb 2020 08:43:34 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24ED28010FC; Wed, 5 Feb 2020 13:43:28 +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 019FB5C541; Wed, 5 Feb 2020 13:43:28 +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 B15B718089D0; Wed, 5 Feb 2020 13:43:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015Df5H1008388 for ; Wed, 5 Feb 2020 08:41:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 924E11001B09; Wed, 5 Feb 2020 13:41:05 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A8281001B05 for ; Wed, 5 Feb 2020 13:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910216; 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=W5at56XpC0j4vb0xQ5LKIdXqyPULS/kqwKqSpJQOMAg=; b=EsCCwAuzt7O03lZfbdUmBn0YX/uOQ39TD8ojWDgppQOLSLzKZnRkTKFJ/NRwm6AzhC7CdN TVsFfd21uNEOjv0y9zxNVkSsBnMFVZP4BgmvaWnsdMfgObuqL1cRD9hx1PcDv7vBXazBPP ot8BnQyOkt9IVjKvrUtVQ00JRM9mVV4= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/9] virDomainDiskAddISCSIPoolSourceHost: Sanitize handling of string list Date: Wed, 5 Feb 2020 14:40:52 +0100 Message-Id: <885ac66befa22aa8a5ec1d95c90e138a908a4411.1580909976.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.79 on 10.5.11.16 X-MC-Unique: bzOiYYl8PhCmooi3gTzr6w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use virStringSplitCount instead of virStringSplit so that we can drop the call to virStringListLength and use VIR_AUTOSTRINGLIST to declare it and allow removal of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c95bd34fb5..6124c7520c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31327,7 +31327,8 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDe= fPtr def, virStoragePoolDefPtr pooldef) { int ret =3D -1; - char **tokens =3D NULL; + VIR_AUTOSTRINGLIST tokens =3D NULL; + size_t ntokens; /* Only support one host */ if (pooldef->source.nhost !=3D 1) { @@ -31348,10 +31349,10 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDisk= DefPtr def, pooldef->source.hosts[0].port : 3260; /* iscsi volume has name like "unit:0:0:1" */ - if (!(tokens =3D virStringSplit(def->src->srcpool->volume, ":", 0))) + if (!(tokens =3D virStringSplitCount(def->src->srcpool->volume, ":", 0= , &ntokens))) goto cleanup; - if (virStringListLength((const char * const *)tokens) !=3D 4) { + if (ntokens !=3D 4) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected iscsi volume name '%s'"), def->src->srcpool->volume); @@ -31373,7 +31374,6 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDe= fPtr def, ret =3D 0; cleanup: - virStringListFree(tokens); return ret; } --=20 2.24.1 From nobody Thu Apr 25 10:08:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580910112637641.0118643517532; Wed, 5 Feb 2020 05:41:52 -0800 (PST) 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-39-DfwQp8OIOVGSyJiiqDFjzQ-1; Wed, 05 Feb 2020 08:41:49 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC056DB65; Wed, 5 Feb 2020 13:41:43 +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 9F7CE857BA; Wed, 5 Feb 2020 13:41:42 +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 8132781744; Wed, 5 Feb 2020 13:41:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015Df6cI008394 for ; Wed, 5 Feb 2020 08:41:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6250B10018FF; Wed, 5 Feb 2020 13:41:06 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id E00211001B05 for ; Wed, 5 Feb 2020 13:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910111; 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=b0XdnmPXrEgAHo2B/jGHlRUCfGH23ztEPMpP5pKi83A=; b=GUx8BD73ehMCHhDXKdmV0aDGC7PVR3lgN8vDtbL89p5iaQvMN9hzh8MhPj0HMZtuPjltIJ fDtj0KT+UiznKk2d3VZvNJyzqp7WgHDEDBlnMA+2EZdINBdOa0qr0kJePHmQMJDuah16xK CIzY9NdLSl/2AbJG4DLahTk5D1CsA94= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/9] virDomainDiskAddISCSIPoolSourceHost: use g_new0 instead of VIR_ALLOC_N Date: Wed, 5 Feb 2020 14:40:53 +0100 Message-Id: <7bf09aeb1fba0e4ca0911c4602ad39e19eeb28de.1580909976.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.79 on 10.5.11.11 X-MC-Unique: DfwQp8OIOVGSyJiiqDFjzQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6124c7520c..7cf555596f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31339,9 +31339,7 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDe= fPtr def, /* iscsi pool only supports one host */ def->src->nhosts =3D 1; - - if (VIR_ALLOC_N(def->src->hosts, def->src->nhosts) < 0) - goto cleanup; + def->src->hosts =3D g_new0(virStorageNetHostDef, 1); def->src->hosts[0].name =3D g_strdup(pooldef->source.hosts[0].name); --=20 2.24.1 From nobody Thu Apr 25 10:08:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580910125595124.37320833035938; Wed, 5 Feb 2020 05:42:05 -0800 (PST) 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-32-aT2ieefuNimlRR6Uu5wUVA-1; Wed, 05 Feb 2020 08:42:00 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B233CDB66; Wed, 5 Feb 2020 13:41: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 8FD6B5C545; Wed, 5 Feb 2020 13:41: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 4E7EE18089CD; Wed, 5 Feb 2020 13:41:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015Df7M8008408 for ; Wed, 5 Feb 2020 08:41:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 354A61001B09; Wed, 5 Feb 2020 13:41:07 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id B174210018FF for ; Wed, 5 Feb 2020 13:41:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910123; 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=/Cp2b8HaEtAx3eMPKzAb7eMzTjSl3ukOF6DsExCph1Y=; b=cGDppv2U7EpSnzFz+wI0sO90JQGxm2HUyGelggtlkrlUythCgPT0a3XuNBDFFvpvNWUbPT 6zIuN0HfpBylDibR9gdfun4ABHC4PDSvcra9AIlsTPf/rDtS5oLJ4ww2shdvajLX0Wb5hF ddLGEaXGpjqptoBy6V9KnRGKMWF1GXE= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/9] virDomainDiskAddISCSIPoolSourceHost: Remove 'cleanup' label Date: Wed, 5 Feb 2020 14:40:54 +0100 Message-Id: <9131cf7a8cf4c27530659839930a2461d5c98a2a.1580909976.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.79 on 10.5.11.16 X-MC-Unique: aT2ieefuNimlRR6Uu5wUVA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7cf555596f..1c52d7f347 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31326,7 +31326,6 @@ static int virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDefPtr def, virStoragePoolDefPtr pooldef) { - int ret =3D -1; VIR_AUTOSTRINGLIST tokens =3D NULL; size_t ntokens; @@ -31334,7 +31333,7 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDe= fPtr def, if (pooldef->source.nhost !=3D 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Expected exactly 1 host for the storage pool")); - goto cleanup; + return -1; } /* iscsi pool only supports one host */ @@ -31348,13 +31347,13 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDisk= DefPtr def, /* iscsi volume has name like "unit:0:0:1" */ if (!(tokens =3D virStringSplitCount(def->src->srcpool->volume, ":", 0= , &ntokens))) - goto cleanup; + return -1; if (ntokens !=3D 4) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected iscsi volume name '%s'"), def->src->srcpool->volume); - goto cleanup; + return -1; } /* iscsi pool has only one source device path */ @@ -31369,10 +31368,7 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskD= efPtr def, def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; - ret =3D 0; - - cleanup: - return ret; + return 0; } --=20 2.24.1 From nobody Thu Apr 25 10:08:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580910186796940.3544659955649; Wed, 5 Feb 2020 05:43:06 -0800 (PST) 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-376-TnRlTXF_PB2zA9aEAn9uyw-1; Wed, 05 Feb 2020 08:42:04 -0500 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 36E87DB6E; Wed, 5 Feb 2020 13:41:59 +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 0F06E1001B09; Wed, 5 Feb 2020 13:41:59 +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 BC15A38A1; Wed, 5 Feb 2020 13:41:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015Df848008413 for ; Wed, 5 Feb 2020 08:41:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0751D1001B09; Wed, 5 Feb 2020 13:41:08 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8315510018FF for ; Wed, 5 Feb 2020 13:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910185; 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=UOLw4ibItOVQpb4u3RR8zavb4Y4qGyBnRgw4pGrLYu8=; b=bT9typZRWNm9qx3dfBGRMQKlXGaHtTOo29lBbi0n+bVRymS0ub3PXp4K8QkN/x0R84MvnR N254VbJg5EQiWzHO3Ae46sCxf2sikmXTFE8uy9ZFCcDLYpMOJcuT/SEzzUZpOkCb3SSjrF Pi2M3bIcEtXVHciakTGopG0sKLJx8w0= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/9] virDomainDiskAddISCSIPoolSourceHost: Remove ternary operator Date: Wed, 5 Feb 2020 14:40:55 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 X-MC-Unique: TnRlTXF_PB2zA9aEAn9uyw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1c52d7f347..5ef12c7ee7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31342,8 +31342,10 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskD= efPtr def, def->src->hosts[0].name =3D g_strdup(pooldef->source.hosts[0].name); - def->src->hosts[0].port =3D pooldef->source.hosts[0].port ? - pooldef->source.hosts[0].port : 3260; + if (pooldef->source.hosts[0].port !=3D 0) + def->src->hosts[0].port =3D pooldef->source.hosts[0].port; + else + def->src->hosts[0].port =3D 3260; /* iscsi volume has name like "unit:0:0:1" */ if (!(tokens =3D virStringSplitCount(def->src->srcpool->volume, ":", 0= , &ntokens))) --=20 2.24.1 From nobody Thu Apr 25 10:08:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580910112531741.8246720359214; Wed, 5 Feb 2020 05:41:52 -0800 (PST) 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-249-i4LTw3sTMtKy1fb7PbBJsQ-1; Wed, 05 Feb 2020 08:41:49 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 224E3802566; Wed, 5 Feb 2020 13:41:44 +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 D425460C05; Wed, 5 Feb 2020 13:41:43 +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 DE1658175A; Wed, 5 Feb 2020 13:41:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015Df8bG008418 for ; Wed, 5 Feb 2020 08:41:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id CC1151001DC2; Wed, 5 Feb 2020 13:41:08 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54C441001B05 for ; Wed, 5 Feb 2020 13:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910111; 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=BDfcqc6+F6KzHud1FCSWNXLmb+R8J7Z48KZEEqY4u7E=; b=FUo1W1Xatei45BZqBTMrkNh+B9sPw+9/SM1lTbMPXWjQgdivKDiy/ZlgIpIHGqLGj5EQFB BVaCKoW0pjfXxyqlC++c778i+qimmyg2TUSZ/v50qpvr1clF5QZxrZiAs4wK64AUu5Irbq 8COO6FPwe+FUWvC/ijEBW3haXB92Ou0= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/9] virDomainDiskAddISCSIPoolSourceHost: Take virStorageSourcePtr instead of virDomainDiskDefPtr Date: Wed, 5 Feb 2020 14:40:56 +0100 Message-Id: <67141bc05602cca3b6bbb261cc03fdb02c07a7e8.1580909976.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.79 on 10.5.11.12 X-MC-Unique: i4LTw3sTMtKy1fb7PbBJsQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Only 'def->src' was ever used in this function. Use the source directly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5ef12c7ee7..bcb17dcc6e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31323,7 +31323,7 @@ virDomainNetResolveActualType(virDomainNetDefPtr if= ace) static int -virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDefPtr def, +virDomainDiskAddISCSIPoolSourceHost(virStorageSourcePtr src, virStoragePoolDefPtr pooldef) { VIR_AUTOSTRINGLIST tokens =3D NULL; @@ -31337,38 +31337,38 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDisk= DefPtr def, } /* iscsi pool only supports one host */ - def->src->nhosts =3D 1; - def->src->hosts =3D g_new0(virStorageNetHostDef, 1); + src->nhosts =3D 1; + src->hosts =3D g_new0(virStorageNetHostDef, 1); - def->src->hosts[0].name =3D g_strdup(pooldef->source.hosts[0].name); + src->hosts[0].name =3D g_strdup(pooldef->source.hosts[0].name); if (pooldef->source.hosts[0].port !=3D 0) - def->src->hosts[0].port =3D pooldef->source.hosts[0].port; + src->hosts[0].port =3D pooldef->source.hosts[0].port; else - def->src->hosts[0].port =3D 3260; + src->hosts[0].port =3D 3260; /* iscsi volume has name like "unit:0:0:1" */ - if (!(tokens =3D virStringSplitCount(def->src->srcpool->volume, ":", 0= , &ntokens))) + if (!(tokens =3D virStringSplitCount(src->srcpool->volume, ":", 0, &nt= okens))) return -1; if (ntokens !=3D 4) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected iscsi volume name '%s'"), - def->src->srcpool->volume); + src->srcpool->volume); return -1; } /* iscsi pool has only one source device path */ - def->src->path =3D g_strdup_printf("%s/%s", pooldef->source.devices[0]= .path, - tokens[3]); + src->path =3D g_strdup_printf("%s/%s", pooldef->source.devices[0].path, + tokens[3]); /* Storage pool have not supported these 2 attributes yet, * use the defaults. */ - def->src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; - def->src->hosts[0].socket =3D NULL; + src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + src->hosts[0].socket =3D NULL; - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; + src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; return 0; } @@ -31411,7 +31411,7 @@ virDomainDiskTranslateISCSIDirect(virDomainDiskDefP= tr def, def->src->auth->secrettype =3D g_strdup(secrettype); } - if (virDomainDiskAddISCSIPoolSourceHost(def, pooldef) < 0) + if (virDomainDiskAddISCSIPoolSourceHost(def->src, pooldef) < 0) return -1; if (!def->src->initiator.iqn && pooldef->source.initiator.iqn && --=20 2.24.1 From nobody Thu Apr 25 10:08:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580910126451750.7790693967895; Wed, 5 Feb 2020 05:42:06 -0800 (PST) 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-136-OmwHmRj6MqWrR1WwysgS1A-1; Wed, 05 Feb 2020 08:42:03 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CAE69190D34A; Wed, 5 Feb 2020 13:41:57 +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 A5C0F5DA7B; Wed, 5 Feb 2020 13:41: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 650B518089CF; Wed, 5 Feb 2020 13:41:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015Df9lu008434 for ; Wed, 5 Feb 2020 08:41:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9E7D41001B05; Wed, 5 Feb 2020 13:41:09 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27A0C10018FF for ; Wed, 5 Feb 2020 13:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910125; 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=5GSOmGdJhaRhBEno9llQrMO2m4dgS5mtl6tO52TccNg=; b=CGSWyuiv7hZJgq1D7qbSdwcbEBtXAqSNzNRJEK9LE2qdbMwwL+pfyoKl9NYuaxfx9oWZec pKxd6pXhYoLh8Zi41za4Rt4SLwfW9Jk76/zgp+zKowTP90HbvE7HE9earVcrxdNOinU3fU L/Y3lRBU3bfHgFClens7MByXKjcuh8c= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/9] virDomainDiskTranslateSourcePoolAuth: Take virStorageSourcePtr instead of virDomainDiskDefPtr Date: Wed, 5 Feb 2020 14:40:57 +0100 Message-Id: <802aa834948fb21cf28d3c17675b3e458a59cae5.1580909976.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.79 on 10.5.11.14 X-MC-Unique: OmwHmRj6MqWrR1WwysgS1A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Only 'def->src' was ever used in this function. Use the source directly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bcb17dcc6e..4545c6b314 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31375,18 +31375,18 @@ virDomainDiskAddISCSIPoolSourceHost(virStorageSou= rcePtr src, static int -virDomainDiskTranslateSourcePoolAuth(virDomainDiskDefPtr def, +virDomainDiskTranslateSourcePoolAuth(virStorageSourcePtr src, virStoragePoolSourcePtr source) { /* Only necessary when authentication set */ if (!source->auth) return 0; - def->src->auth =3D virStorageAuthDefCopy(source->auth); - if (!def->src->auth) + src->auth =3D virStorageAuthDefCopy(source->auth); + if (!src->auth) return -1; /* A doesn't use src->auth->authType =3D VIR_STORAGE_AUTH_TYPE_NONE; + src->auth->authType =3D VIR_STORAGE_AUTH_TYPE_NONE; return 0; } @@ -31398,7 +31398,7 @@ virDomainDiskTranslateISCSIDirect(virDomainDiskDefP= tr def, def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_NETWORK; def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; - if (virDomainDiskTranslateSourcePoolAuth(def, + if (virDomainDiskTranslateSourcePoolAuth(def->src, &pooldef->source) < 0) return -1; --=20 2.24.1 From nobody Thu Apr 25 10:08:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580910223160462.78195719617304; Wed, 5 Feb 2020 05:43:43 -0800 (PST) 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-287-otvakOFvN4KuS8f7qQDG2Q-1; Wed, 05 Feb 2020 08:43:39 -0500 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 5BF7C802684; Wed, 5 Feb 2020 13:43:33 +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 328E11001B09; Wed, 5 Feb 2020 13:43:33 +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 D2F7F85CD9; Wed, 5 Feb 2020 13:43:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015DfAC2008444 for ; Wed, 5 Feb 2020 08:41:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6FC0110018FF; Wed, 5 Feb 2020 13:41:10 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED40D1001B05 for ; Wed, 5 Feb 2020 13:41:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910222; 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=zXipiA0iyqnmudoHU1DYjJgk92y2Ot57isv7zMumQw8=; b=TcpoxGscAC588/TXLBmCuhqR9kL/j8LxKUu5TX/qXaBuUXa9j6cE8uwMSbgVxq+P2m95sA Vu38aDSCTqeeTNhAIf6GNi/ZcONikmgPtWQowlsfkjRnwgNEN8NVKNvvDUSq8jtvOc3w+G PIUJ6R6j5JPr9PW7EdcxSvYyjOWeguU= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 7/9] virDomainDiskTranslateISCSIDirect: Take virStorageSourcePtr instead of virDomainDiskDefPtr Date: Wed, 5 Feb 2020 14:40:58 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 X-MC-Unique: otvakOFvN4KuS8f7qQDG2Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Only 'def->src' was ever used in this function. Use the source directly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4545c6b314..531c765032 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31392,30 +31392,30 @@ virDomainDiskTranslateSourcePoolAuth(virStorageSo= urcePtr src, static int -virDomainDiskTranslateISCSIDirect(virDomainDiskDefPtr def, +virDomainDiskTranslateISCSIDirect(virStorageSourcePtr src, virStoragePoolDefPtr pooldef) { - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_NETWORK; - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; + src->srcpool->actualtype =3D VIR_STORAGE_TYPE_NETWORK; + src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; - if (virDomainDiskTranslateSourcePoolAuth(def->src, + if (virDomainDiskTranslateSourcePoolAuth(src, &pooldef->source) < 0) return -1; /* Source pool may not fill in the secrettype field, * so we need to do so here */ - if (def->src->auth && !def->src->auth->secrettype) { + if (src->auth && !src->auth->secrettype) { const char *secrettype =3D virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI); - def->src->auth->secrettype =3D g_strdup(secrettype); + src->auth->secrettype =3D g_strdup(secrettype); } - if (virDomainDiskAddISCSIPoolSourceHost(def->src, pooldef) < 0) + if (virDomainDiskAddISCSIPoolSourceHost(src, pooldef) < 0) return -1; - if (!def->src->initiator.iqn && pooldef->source.initiator.iqn && - virStorageSourceInitiatorCopy(&def->src->initiator, + if (!src->initiator.iqn && pooldef->source.initiator.iqn && + virStorageSourceInitiatorCopy(&src->initiator, &pooldef->source.initiator) < 0) { return -1; } @@ -31540,7 +31540,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPt= r def) return -1; } - if (virDomainDiskTranslateISCSIDirect(def, pooldef) < 0) + if (virDomainDiskTranslateISCSIDirect(def->src, pooldef) < 0) return -1; break; @@ -31565,7 +31565,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPt= r def) break; case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT: - if (virDomainDiskTranslateISCSIDirect(def, pooldef) < 0) + if (virDomainDiskTranslateISCSIDirect(def->src, pooldef) < 0) return -1; break; } --=20 2.24.1 From nobody Thu Apr 25 10:08:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580910189141654.0537016597185; Wed, 5 Feb 2020 05:43:09 -0800 (PST) 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-205-RvARuksCO7mIr36rqOzhJQ-1; Wed, 05 Feb 2020 08:42:11 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2C971005F77; Wed, 5 Feb 2020 13:42:02 +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 A9FF3790C8; Wed, 5 Feb 2020 13:42: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 5039B18089D5; Wed, 5 Feb 2020 13:42:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015DfB9e008457 for ; Wed, 5 Feb 2020 08:41:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 42ACC1001B05; Wed, 5 Feb 2020 13:41:11 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id BECA610018FF for ; Wed, 5 Feb 2020 13:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910187; 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=rve7/HNvpQkx35z7Tuu1C2+hbOUwt+ynqWC/LqX8dFo=; b=YMxnTZli3xc1XX6NxMy9Mdk3raUYAVfsi2np11gPzDTcjZFcNW4gOPwo28cPD+EYyk5RiK +0MMYHupCBPXVtACN8jTcQfogU+MgvtWIiTeWmwhqMlxKPuCXnQQ91e2eUe79k/OtDVaXq dx9rD71H4VsfWJ0ykambKQz78a5W5Fg= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 8/9] virDomainDiskTranslateSourcePool: split code to setup one storage source Date: Wed, 5 Feb 2020 14:40:59 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.79 on 10.5.11.15 X-MC-Unique: RvARuksCO7mIr36rqOzhJQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Extract all the code setting up one storage source from the rest which sets up the whole disk. This will allow us to prepare the whole backing chain. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 112 ++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 57 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 531c765032..7bd86d67e5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31424,37 +31424,28 @@ virDomainDiskTranslateISCSIDirect(virStorageSourc= ePtr src, } -int -virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def) +static int +virDomainStorageSourceTranslateSourcePool(virStorageSourcePtr src, + virConnectPtr conn) { virStorageVolInfo info; g_autoptr(virStoragePoolDef) pooldef =3D NULL; g_autofree char *poolxml =3D NULL; - g_autoptr(virConnect) conn =3D NULL; g_autoptr(virStoragePool) pool =3D NULL; g_autoptr(virStorageVol) vol =3D NULL; - if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME) - return 0; - - if (!def->src->srcpool) - return 0; - - if (!(conn =3D virGetConnectStorage())) - return -1; - - if (!(pool =3D virStoragePoolLookupByName(conn, def->src->srcpool->poo= l))) + if (!(pool =3D virStoragePoolLookupByName(conn, src->srcpool->pool))) return -1; if (virStoragePoolIsActive(pool) !=3D 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("storage pool '%s' containing volume '%s' " "is not active"), - def->src->srcpool->pool, def->src->srcpool->volume); + src->srcpool->pool, src->srcpool->volume); return -1; } - if (!(vol =3D virStorageVolLookupByName(pool, def->src->srcpool->volum= e))) + if (!(vol =3D virStorageVolLookupByName(pool, src->srcpool->volume))) return -1; if (virStorageVolGetInfo(vol, &info) < 0) @@ -31466,22 +31457,22 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef= Ptr def) if (!(pooldef =3D virStoragePoolDefParseString(poolxml))) return -1; - def->src->srcpool->pooltype =3D pooldef->type; - def->src->srcpool->voltype =3D info.type; + src->srcpool->pooltype =3D pooldef->type; + src->srcpool->voltype =3D info.type; - if (def->src->srcpool->mode && pooldef->type !=3D VIR_STORAGE_POOL_ISC= SI) { + if (src->srcpool->mode && pooldef->type !=3D VIR_STORAGE_POOL_ISCSI) { virReportError(VIR_ERR_XML_ERROR, "%s", _("disk source mode is only valid when " "storage pool is of iscsi type")); return -1; } - VIR_FREE(def->src->path); - virStorageNetHostDefFree(def->src->nhosts, def->src->hosts); - def->src->nhosts =3D 0; - def->src->hosts =3D NULL; - virStorageAuthDefFree(def->src->auth); - def->src->auth =3D NULL; + VIR_FREE(src->path); + virStorageNetHostDefFree(src->nhosts, src->hosts); + src->nhosts =3D 0; + src->hosts =3D NULL; + virStorageAuthDefFree(src->auth); + src->auth =3D NULL; switch ((virStoragePoolType) pooldef->type) { case VIR_STORAGE_POOL_DIR: @@ -31492,32 +31483,24 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef= Ptr def) case VIR_STORAGE_POOL_SCSI: case VIR_STORAGE_POOL_ZFS: case VIR_STORAGE_POOL_VSTORAGE: - if (!(def->src->path =3D virStorageVolGetPath(vol))) + if (!(src->path =3D virStorageVolGetPath(vol))) return -1; - if (def->startupPolicy && info.type !=3D VIR_STORAGE_VOL_FILE) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'startupPolicy' is only valid for " - "'file' type volume")); - return -1; - } - - switch (info.type) { case VIR_STORAGE_VOL_FILE: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; + src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; break; case VIR_STORAGE_VOL_DIR: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_DIR; + src->srcpool->actualtype =3D VIR_STORAGE_TYPE_DIR; break; case VIR_STORAGE_VOL_BLOCK: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; + src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; break; case VIR_STORAGE_VOL_PLOOP: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; + src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; break; case VIR_STORAGE_VOL_NETWORK: @@ -31533,39 +31516,25 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef= Ptr def) break; case VIR_STORAGE_POOL_ISCSI_DIRECT: - if (def->startupPolicy) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'startupPolicy' is only valid for " - "'file' type volume")); - return -1; - } - - if (virDomainDiskTranslateISCSIDirect(def->src, pooldef) < 0) + if (virDomainDiskTranslateISCSIDirect(src, pooldef) < 0) return -1; break; case VIR_STORAGE_POOL_ISCSI: - if (def->startupPolicy) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'startupPolicy' is only valid for " - "'file' type volume")); - return -1; - } - - switch (def->src->srcpool->mode) { + switch (src->srcpool->mode) { case VIR_STORAGE_SOURCE_POOL_MODE_DEFAULT: case VIR_STORAGE_SOURCE_POOL_MODE_LAST: - def->src->srcpool->mode =3D VIR_STORAGE_SOURCE_POOL_MODE_HOST; + src->srcpool->mode =3D VIR_STORAGE_SOURCE_POOL_MODE_HOST; G_GNUC_FALLTHROUGH; case VIR_STORAGE_SOURCE_POOL_MODE_HOST: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; - if (!(def->src->path =3D virStorageVolGetPath(vol))) + src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; + if (!(src->path =3D virStorageVolGetPath(vol))) return -1; break; case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT: - if (virDomainDiskTranslateISCSIDirect(def->src, pooldef) < 0) + if (virDomainDiskTranslateISCSIDirect(src, pooldef) < 0) return -1; break; } @@ -31587,6 +31556,35 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefP= tr def) } +int +virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def) +{ + g_autoptr(virConnect) conn =3D NULL; + + if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME) + return 0; + + if (!def->src->srcpool) + return 0; + + if (!(conn =3D virGetConnectStorage())) + return -1; + + if (virDomainStorageSourceTranslateSourcePool(def->src, conn) < 0) + return -1; + + if (def->startupPolicy !=3D 0 && + virStorageSourceGetActualType(def->src) !=3D VIR_STORAGE_VOL_FILE)= { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'startupPolicy' is only valid for " + "'file' type volume")); + return -1; + } + + return 0; +} + + /** * virDomainDiskGetDetectZeroesMode: * @discard: disk/image sector discard setting --=20 2.24.1 From nobody Thu Apr 25 10:08:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580910184250152.01796590350807; Wed, 5 Feb 2020 05:43:04 -0800 (PST) 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-315-ZpgdUctPPauuwhmhGKTs8w-1; Wed, 05 Feb 2020 08:42:06 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29FB68010CB; Wed, 5 Feb 2020 13:42:01 +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 069C05D9E2; Wed, 5 Feb 2020 13:42:01 +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 ADEE18579D; Wed, 5 Feb 2020 13:42:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 015DfCcV008469 for ; Wed, 5 Feb 2020 08:41:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 15E771001B05; Wed, 5 Feb 2020 13:41:12 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9185210018FF for ; Wed, 5 Feb 2020 13:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580910183; 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=fWDW1WjBCqwt855ayGVj0nLY3BjHJ7a44war+rOKF00=; b=HBWurF3ZLHpnbZd4oZ1RLz2Bp6TWWqv3A9ha+RX1Y7LuP+tuiy4QRWE/kLByHhx4T4ZdEi VqDEQrD9Kt0ATHCukHfILPSlwjRb3bpGIEBqqf/vYmz91/BBIYJnUyyz++3qKn8w0gmsDU ZV1gGHWPvVCAEg2+nOdkjD+DrBurCWg= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 9/9] virDomainDiskTranslateSourcePool: Translate 'VOLUME' disks in whole backing chain Date: Wed, 5 Feb 2020 14:41:00 +0100 Message-Id: <6301b5b5867eddf55016ce5c92b5176c59ada868.1580909976.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.79 on 10.5.11.14 X-MC-Unique: ZpgdUctPPauuwhmhGKTs8w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now that we accept full backing chains on input nothing should prevent users from also using disk type 'VOLUME' for specifying the backing images. Do the translation for the whole backing chain. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7bd86d67e5..46062e3969 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31560,18 +31560,20 @@ int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def) { g_autoptr(virConnect) conn =3D NULL; + virStorageSourcePtr n; - if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME) - return 0; - - if (!def->src->srcpool) - return 0; + for (n =3D def->src; virStorageSourceIsBacking(n); n =3D n->backingSto= re) { + if (n->type !=3D VIR_STORAGE_TYPE_VOLUME || !n-> srcpool) + continue; - if (!(conn =3D virGetConnectStorage())) - return -1; + if (!conn) { + if (!(conn =3D virGetConnectStorage())) + return -1; + } - if (virDomainStorageSourceTranslateSourcePool(def->src, conn) < 0) - return -1; + if (virDomainStorageSourceTranslateSourcePool(n, conn) < 0) + return -1; + } if (def->startupPolicy !=3D 0 && virStorageSourceGetActualType(def->src) !=3D VIR_STORAGE_VOL_FILE)= { --=20 2.24.1