From nobody Sun Feb 8 16:50:12 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1576854017; cv=none; d=zohomail.com; s=zohoarc; b=n01BYtrMDDwDZrb68nyykhtYyqXqyTorhZHf9lmFNJQw+ZA3aobCEs8CA5HBwe1BBXsa1vqGiCfK1Nxu9d7IdphdQatpmfenes94HxO0X96AqlZowBkkGPWeB89EVz5vDhek9mSn7OCnt4Ox7238oX3yPCV39ea8X4N1JBg/kA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576854017; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z+3Hw65iFUDYC/5ivIco5nrtu6lnajNd0PV6sbNh+Eg=; b=KffkfMNNrEgyWj3qPpFbtU4HBkkECB0wpk+HidvyXUKb2TF/8n6uwBe4vLa4jZWt0DwAw2TAKKOK/5F0QI/Q43fQQMKYlFdYlM4RfAK4DkcpkJtzN4JDuXkQLt66m42nDnHGXUpWc/rb3+G1m1HqVmjsnxbvGi4cgsKzXVbO/us= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= 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 1576854017465414.1758509504126; Fri, 20 Dec 2019 07:00:17 -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-319-Vq5WFnqzOQSWK5QYuTC6Pg-1; Fri, 20 Dec 2019 09:59:02 -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 435FB107ACE6; Fri, 20 Dec 2019 14:58:54 +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 1B4D15D72A; Fri, 20 Dec 2019 14:58:54 +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 C8253252F8; Fri, 20 Dec 2019 14:58:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBKEwPKR032530 for ; Fri, 20 Dec 2019 09:58:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id ABA506FDCE; Fri, 20 Dec 2019 14:58:25 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E20A6E41E for ; Fri, 20 Dec 2019 14:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576854014; 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=Z+3Hw65iFUDYC/5ivIco5nrtu6lnajNd0PV6sbNh+Eg=; b=H6I0D/fFWrITxoD2xBE4xHKhs2ZKYYGzYBoRMLavxTGLLQ9thTTdIMqJvH3TAzIhAeHeyu 1/8hR3YMXTIxBoOlRPhrWR1vBzMAwwxQmjk/3BSAmJNAPTJkAWnUIHuRkhE1QRy3Xezijn 0w6K/BRac4omevC5DhW+AvTeVBhru1A= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:08 +0100 Message-Id: <20191220145813.756206-7-ptoscano@redhat.com> In-Reply-To: <20191220145813.756206-1-ptoscano@redhat.com> References: <20191220145813.756206-1-ptoscano@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 06/11] esx: improve some of the virErrorNumber used 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: Vq5WFnqzOQSWK5QYuTC6Pg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" A lot of virReportError() calls use VIR_ERR_INTERNAL_ERROR to represent the number of the error, even in cases where there is one fitting more. Hence, replace some of them with better virErrorNumber values. Signed-off-by: Pino Toscano --- src/esx/esx_network_driver.c | 4 ++-- src/esx/esx_storage_backend_iscsi.c | 4 ++-- src/esx/esx_storage_backend_vmfs.c | 12 +++++----- src/esx/esx_util.c | 4 ++-- src/esx/esx_vi.c | 36 ++++++++++++++--------------- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index f14d309293..2a76831606 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -355,7 +355,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) for (hostPortGroup =3D hostPortGroupList; hostPortGroup; hostPortGroup =3D hostPortGroup->_next) { if (STREQ(def->portGroups[i].name, hostPortGroup->spec->na= me)) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NETWORK_EXIST, _("HostPortGroup with name '%s' exists = already"), def->portGroups[i].name); goto cleanup; @@ -388,7 +388,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) =20 if (def->forward.ifs[i].type !=3D VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_SUPPORT, _("unsupported device type in network %s " "interface pool"), def->name); diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index cd83a0fbfd..1e54cef948 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -321,7 +321,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsign= ed int flags) =20 if (!target) { /* pool not found */ - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_STORAGE_POOL, _("Could not find storage pool with name '%s'"), pool->name); goto cleanup; @@ -701,7 +701,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, } =20 if (!scsiLun) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_STORAGE_VOL, _("Could find volume with name: %s"), volume->name); goto cleanup; } diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 70005717cb..d4b23c6d51 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -906,7 +906,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, goto cleanup; =20 if (def->type !=3D VIR_STORAGE_VOL_FILE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_NO_SUPPORT, "%s", _("Creating non-file volumes is not supported")); goto cleanup; } @@ -922,7 +922,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, } =20 if (!virStringHasCaseSuffix(def->name, ".vmdk")) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_SUPPORT, _("Volume name '%s' has unsupported suffix, " "expecting '.vmdk'"), def->name); goto cleanup; @@ -1041,7 +1041,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, key =3D g_strdup(datastorePath); } } else { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_SUPPORT, _("Creation of %s volumes is not supported"), virStorageFileFormatTypeToString(def->target.format= )); goto cleanup; @@ -1120,7 +1120,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, goto cleanup; =20 if (def->type !=3D VIR_STORAGE_VOL_FILE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_NO_SUPPORT, "%s", _("Creating non-file volumes is not supported")); goto cleanup; } @@ -1136,7 +1136,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, } =20 if (!virStringHasCaseSuffix(def->name, ".vmdk")) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_SUPPORT, _("Volume name '%s' has unsupported suffix, " "expecting '.vmdk'"), def->name); goto cleanup; @@ -1221,7 +1221,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, key =3D g_strdup(datastorePath); } } else { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_SUPPORT, _("Creation of %s volumes is not supported"), virStorageFileFormatTypeToString(def->target.format= )); goto cleanup; diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index c265528056..dc0983a47d 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -218,7 +218,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, c= har **datastoreName, if ((datastoreName && *datastoreName) || (directoryName && *directoryName) || (directoryAndFileName && *directoryAndFileName)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 @@ -227,7 +227,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, c= har **datastoreName, /* Expected format: '[] ' where is optional */ if (!(tmp =3D STRSKIP(copyOfDatastorePath, "[")) || *tmp =3D=3D ']' || !(preliminaryDatastoreName =3D strtok_r(tmp, "]", &saveptr))) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_INVALID_ARG, _("Datastore path '%s' doesn't have expected format= " "'[] '"), datastorePath); goto cleanup; diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 4e67d76bfe..3c5a994848 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -435,7 +435,7 @@ esxVI_CURL_Upload(esxVI_CURL *curl, const char *url, co= nst char *content) int responseCode =3D 0; =20 if (!content) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 @@ -552,13 +552,13 @@ esxVI_SharedCURL_Add(esxVI_SharedCURL *shared, esxVI_= CURL *curl) size_t i; =20 if (!curl->handle) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot share uninitialized CURL handle")); return -1; } =20 if (curl->shared) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot share CURL handle that is already shared"= )); return -1; } @@ -607,19 +607,19 @@ int esxVI_SharedCURL_Remove(esxVI_SharedCURL *shared, esxVI_CURL *curl) { if (!curl->handle) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot unshare uninitialized CURL handle")); return -1; } =20 if (!curl->shared) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot unshare CURL handle that is not shared")); return -1; } =20 if (curl->shared !=3D shared) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("CURL (share) misma= tch")); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("CURL (share) mismatch= ")); return -1; } =20 @@ -727,13 +727,13 @@ int esxVI_MultiCURL_Add(esxVI_MultiCURL *multi, esxVI_CURL *curl) { if (!curl->handle) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot add uninitialized CURL handle to a multi = handle")); return -1; } =20 if (curl->multi) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot add CURL handle to a multi handle twice")= ); return -1; } @@ -773,21 +773,21 @@ int esxVI_MultiCURL_Remove(esxVI_MultiCURL *multi, esxVI_CURL *curl) { if (!curl->handle) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot remove uninitialized CURL handle from a " "multi handle")); return -1; } =20 if (!curl->multi) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot remove CURL handle from a multi handle wh= en it " "wasn't added before")); return -1; } =20 if (curl->multi !=3D multi) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("CURL (multi) misma= tch")); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("CURL (multi) mismatch= ")); return -1; } =20 @@ -994,7 +994,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, =20 if (!ctx || !url || !ipAddress || !username || !password || ctx->url || ctx->service || ctx->curl) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 @@ -1405,7 +1405,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char = *methodName, xmlNodePtr responseNode =3D NULL; =20 if (!request || !response || *response) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 @@ -1548,7 +1548,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char = *methodName, } } } else { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_HTTP_ERROR, _("HTTP response code %d for call to '%s'"), (*response)->responseCode, methodName); goto cleanup; @@ -1599,14 +1599,14 @@ esxVI_Enumeration_CastFromAnyType(const esxVI_Enume= ration *enumeration, size_t i; =20 if (!anyType || !value) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 *value =3D 0; /* undefined */ =20 if (anyType->type !=3D enumeration->type) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_INVALID_ARG, _("Expecting type '%s' but found '%s'"), esxVI_Type_ToString(enumeration->type), esxVI_AnyType_TypeToString(anyType)); @@ -1635,7 +1635,7 @@ esxVI_Enumeration_Serialize(const esxVI_Enumeration *= enumeration, const char *name =3D NULL; =20 if (!element || !output) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 @@ -1674,7 +1674,7 @@ esxVI_Enumeration_Deserialize(const esxVI_Enumeration= *enumeration, char *name =3D NULL; =20 if (!value) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list