From nobody Sun Apr 28 20:06:45 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15447125483613.8199347812426367; Thu, 13 Dec 2018 06:49:08 -0800 (PST) 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 712D7307CDC9; Thu, 13 Dec 2018 14:49:06 +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 1E0826012E; Thu, 13 Dec 2018 14:49:06 +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 6590F3F604; Thu, 13 Dec 2018 14:49:05 +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 wBDEn3WO011767 for ; Thu, 13 Dec 2018 09:49:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 61D6D1019630; Thu, 13 Dec 2018 14:49:03 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDA91105706B for ; Thu, 13 Dec 2018 14:49:02 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 13 Dec 2018 15:48:48 +0100 Message-Id: <60ef39190eebecdc03106815cc2c58277a6de2d1.1544712448.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 Subject: [libvirt] [PATCH v2 1/9] include: error: Add enum sentinel for virErrorNumber enum 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: , 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.49]); Thu, 13 Dec 2018 14:49:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We do have one for the error domain but not for the error number itself. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- include/libvirt/virterror.h | 5 +++++ src/util/virerror.c | 1 + 2 files changed, 6 insertions(+) diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 57aadb8d16..9867c05450 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -323,6 +323,11 @@ typedef enum { VIR_ERR_DEVICE_MISSING =3D 99, /* fail to find the desired devi= ce */ VIR_ERR_INVALID_NWFILTER_BINDING =3D 100, /* invalid nwfilter binding= */ VIR_ERR_NO_NWFILTER_BINDING =3D 101, /* no nwfilter binding */ + +# ifdef VIR_ENUM_SENTINELS + VIR_ERR_NUMBER_LAST +# endif + } virErrorNumber; /** diff --git a/src/util/virerror.c b/src/util/virerror.c index 683e51aa19..eca6ddf7d1 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -916,6 +916,7 @@ virErrorMsg(virErrorNumber error, const char *info) const char *errmsg =3D NULL; switch (error) { + case VIR_ERR_NUMBER_LAST: case VIR_ERR_OK: return NULL; case VIR_ERR_INTERNAL_ERROR: --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:06:45 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1544712549968508.38731523833087; Thu, 13 Dec 2018 06:49:09 -0800 (PST) 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 A6F3CC04BD35; Thu, 13 Dec 2018 14:49:07 +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 5972D648B6; Thu, 13 Dec 2018 14:49: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 09AA93F606; Thu, 13 Dec 2018 14:49:07 +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 wBDEn4Sh011777 for ; Thu, 13 Dec 2018 09:49:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 357E6101963C; Thu, 13 Dec 2018 14:49:04 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id B10C71019630 for ; Thu, 13 Dec 2018 14:49:03 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 13 Dec 2018 15:48:49 +0100 Message-Id: <8dbebfa06b9bf91e8c3364a40bee476c3dcd957a.1544712448.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 Subject: [libvirt] [PATCH v2 2/9] util: error: Fix error message strings to play well with additional info 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: , 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.31]); Thu, 13 Dec 2018 14:49:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Additional information for an error message is either in form of a string or empty. Fix two offenders. One used %d as the format modifier and the second one always expected a string. Thankfully, neither of the offenders are currently in effect. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/util/virerror.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util/virerror.c b/src/util/virerror.c index eca6ddf7d1..5d515bde57 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -977,7 +977,10 @@ virErrorMsg(virErrorNumber error, const char *info) errmsg =3D _("POST operation failed"); break; case VIR_ERR_HTTP_ERROR: - errmsg =3D _("got unknown HTTP error code %d"); + if (info !=3D NULL) + errmsg =3D _("got unknown HTTP error code %s"); + else + errmsg =3D _("got unknown HTTP error code"); break; case VIR_ERR_UNKNOWN_HOST: if (info !=3D NULL) @@ -1004,7 +1007,10 @@ virErrorMsg(virErrorNumber error, const char *info) errmsg =3D _("could not connect to Xen Store %s"); break; case VIR_ERR_XEN_CALL: - errmsg =3D _("failed Xen syscall %s"); + if (info =3D=3D NULL) + errmsg =3D _("failed Xen syscall"); + else + errmsg =3D _("failed Xen syscall %s"); break; case VIR_ERR_OS_TYPE: if (info =3D=3D NULL) --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:06:45 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15447125559521001.5361200460712; Thu, 13 Dec 2018 06:49:15 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id B2FE930023A2; Thu, 13 Dec 2018 14:49:14 +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 80DFA607C4; Thu, 13 Dec 2018 14:49:14 +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 34853181B9E7; Thu, 13 Dec 2018 14:49:14 +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 wBDEn5YL011785 for ; Thu, 13 Dec 2018 09:49:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 083221019630; Thu, 13 Dec 2018 14:49:05 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83DCA101963C for ; Thu, 13 Dec 2018 14:49:04 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 13 Dec 2018 15:48:50 +0100 Message-Id: <3812d74ddb63c08c0c819c3455b6952e0a15419f.1544712448.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 Subject: [libvirt] [PATCH v2 3/9] util: error: Add error message versions with info for some error codes 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: , 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 13 Dec 2018 14:49:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Few error codes were missing the version of the message with additional info. In case of the modified messages it's not very likely they'll ever report any additional data, but for the sake of consistency we should provide them. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/util/virerror.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/util/virerror.c b/src/util/virerror.c index 5d515bde57..64be00dc75 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -926,7 +926,10 @@ virErrorMsg(virErrorNumber error, const char *info) errmsg =3D _("internal error"); break; case VIR_ERR_NO_MEMORY: - errmsg =3D _("out of memory"); + if (info =3D=3D NULL) + errmsg =3D _("out of memory"); + else + errmsg =3D _("out of memory: %s"); break; case VIR_ERR_NO_SUPPORT: if (info =3D=3D NULL) @@ -1019,7 +1022,10 @@ virErrorMsg(virErrorNumber error, const char *info) errmsg =3D _("unknown OS type %s"); break; case VIR_ERR_NO_KERNEL: - errmsg =3D _("missing kernel information"); + if (info =3D=3D NULL) + errmsg =3D _("missing kernel information"); + else + errmsg =3D _("missing kernel information: %s"); break; case VIR_ERR_NO_ROOT: if (info =3D=3D NULL) @@ -1472,7 +1478,10 @@ virErrorMsg(virErrorNumber error, const char *info) errmsg =3D _("XML document failed to validate against sche= ma: %s"); break; case VIR_ERR_MIGRATE_FINISH_OK: - errmsg =3D _("migration successfully aborted"); + if (info =3D=3D NULL) + errmsg =3D _("migration successfully aborted"); + else + errmsg =3D _("migration successfully aborted: %s"); break; case VIR_ERR_NO_SERVER: if (info =3D=3D NULL) --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:06:45 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 154471255648750.262335161225224; Thu, 13 Dec 2018 06:49:16 -0800 (PST) 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 BDC6C3002F95; Thu, 13 Dec 2018 14:49:14 +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 7EB0F61791; Thu, 13 Dec 2018 14:49:14 +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 350023F60B; Thu, 13 Dec 2018 14:49:14 +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 wBDEn94K011803 for ; Thu, 13 Dec 2018 09:49:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id A09681057070; Thu, 13 Dec 2018 14:49:09 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2718D1057074 for ; Thu, 13 Dec 2018 14:49:05 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 13 Dec 2018 15:48:51 +0100 Message-Id: <3a96d7603ebea6a9ea4e73ad7ef2d3c02c7485fb.1544712448.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 Subject: [libvirt] [PATCH v2 4/9] util: error: Reword some unused error messages 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: , 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.47]); Thu, 13 Dec 2018 14:49:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Simplify wording of the error string for VIR_ERR_OPEN_FAILED and VIR_ERR_CALL_FAILED. The error codes itself are currently unused so it will not impact any client. This will simplify upcomming patch which refactors how we convert these. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/util/virerror.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/virerror.c b/src/util/virerror.c index 64be00dc75..eed65e8f6a 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -1071,9 +1071,9 @@ virErrorMsg(virErrorNumber error, const char *info) break; case VIR_ERR_CALL_FAILED: /* DEPRECATED, use VIR_ERR_NO_SUPPORT */ if (info =3D=3D NULL) - errmsg =3D _("library call failed, possibly not supported"= ); + errmsg =3D _("library call failed"); else - errmsg =3D _("library call %s failed, possibly not support= ed"); + errmsg =3D _("library call failed: %s"); break; case VIR_ERR_XML_ERROR: if (info =3D=3D NULL) @@ -1095,9 +1095,9 @@ virErrorMsg(virErrorNumber error, const char *info) break; case VIR_ERR_OPEN_FAILED: if (info =3D=3D NULL) - errmsg =3D _("failed to open configuration file for readin= g"); + errmsg =3D _("failed to open configuration file"); else - errmsg =3D _("failed to open %s for reading"); + errmsg =3D _("failed to open configuration file %s"); break; case VIR_ERR_READ_FAILED: if (info =3D=3D NULL) --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:06:45 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1544712563223865.1501642870088; Thu, 13 Dec 2018 06:49:23 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 95EC17F6C7; Thu, 13 Dec 2018 14:49:20 +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 548C41019630; Thu, 13 Dec 2018 14:49:20 +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 F384B3F60A; Thu, 13 Dec 2018 14:49:19 +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 wBDEnALV011808 for ; Thu, 13 Dec 2018 09:49:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 768651057072; Thu, 13 Dec 2018 14:49:10 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF4041057070 for ; Thu, 13 Dec 2018 14:49:09 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 13 Dec 2018 15:48:52 +0100 Message-Id: <0d8d6b22968a0c075354f6032ac0ae81207835a7.1544712448.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 Subject: [libvirt] [PATCH v2 5/9] util: error: Export virErrorMsg for use in testsuite 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 13 Dec 2018 14:49:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/libvirt_private.syms | 1 + src/util/Makefile.inc.am | 1 + src/util/virerror.c | 6 +++++- src/util/virerrorpriv.h | 28 ++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/util/virerrorpriv.h diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fd63c9ca61..6184030d59 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1752,6 +1752,7 @@ ebtablesRemoveForwardAllowIn; virDispatchError; virErrorCopyNew; virErrorInitialize; +virErrorMsg; virErrorPreserveLast; virErrorRestore; virErrorSetErrnoFromLastError; diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index cffbb357bc..4295babac3 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -50,6 +50,7 @@ UTIL_SOURCES =3D \ util/virendian.h \ util/virerror.c \ util/virerror.h \ + util/virerrorpriv.h \ util/virevent.c \ util/virevent.h \ util/vireventpoll.c \ diff --git a/src/util/virerror.c b/src/util/virerror.c index eed65e8f6a..1e7c8bdb90 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -31,6 +31,10 @@ #include "virutil.h" #include "virstring.h" +#define __VIR_ERROR_ALLOW_INCLUDE_PRIV_H__ +#include "virerrorpriv.h" +#undef __VIR_ERROR_ALLOW_INCLUDE_PRIV_H__ + VIR_LOG_INIT("util.error"); virThreadLocal virLastErr; @@ -910,7 +914,7 @@ void virRaiseErrorObject(const char *filename, * * Returns the constant string associated to @error */ -static const char * +const char * virErrorMsg(virErrorNumber error, const char *info) { const char *errmsg =3D NULL; diff --git a/src/util/virerrorpriv.h b/src/util/virerrorpriv.h new file mode 100644 index 0000000000..bc214393e6 --- /dev/null +++ b/src/util/virerrorpriv.h @@ -0,0 +1,28 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#ifndef __VIR_ERROR_ALLOW_INCLUDE_PRIV_H__ +# error "virerrorpriv.h may only be included by virerror.c or its test sui= te" +#endif + +#ifndef __VIR_ERROR_PRIV_H__ +# define __VIR_ERROR_PRIV_H__ + +const char * +virErrorMsg(virErrorNumber error, + const char *info); + +#endif /* __VIR_ERROR_PRIV_H__ */ --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:06:45 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1544712556283730.2595021745874; Thu, 13 Dec 2018 06:49:16 -0800 (PST) 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 C8D743082132; Thu, 13 Dec 2018 14:49:14 +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 894E8648B6; Thu, 13 Dec 2018 14:49:14 +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 3A1C2181B9E9; Thu, 13 Dec 2018 14:49:14 +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 wBDEnBhO011815 for ; Thu, 13 Dec 2018 09:49:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4987F1019630; Thu, 13 Dec 2018 14:49:11 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C46F31057070 for ; Thu, 13 Dec 2018 14:49:10 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 13 Dec 2018 15:48:53 +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 Subject: [libvirt] [PATCH v2 6/9] tests: Add test for virErrorMsg message constraints 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: , 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.42]); Thu, 13 Dec 2018 14:49:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Make sure that we don't add any broken error message strings any more. This ensures that both the version with and without additional info is populated, the version without info does not have any formatting modifiers and the version with info has exactly one. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- tests/Makefile.am | 6 +++ tests/virerrortest.c | 101 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 tests/virerrortest.c diff --git a/tests/Makefile.am b/tests/Makefile.am index d7ec7e3a6f..f2eef2293f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -207,6 +207,7 @@ test_programs =3D virshtest sockettest \ virnetdevtest \ virtypedparamtest \ vshtabletest \ + virerrortest \ $(NULL) test_libraries =3D libshunload.la \ @@ -940,6 +941,11 @@ metadatatest_SOURCES =3D \ testutils.c testutils.h metadatatest_LDADD =3D $(LDADDS) $(LIBXML_LIBS) +virerrortest_SOURCES =3D \ + virerrortest.c \ + testutils.c testutils.h +virerrortest_LDADD =3D $(LDADDS) + vshtabletest_SOURCES =3D \ vshtabletest.c \ testutils.c testutils.h diff --git a/tests/virerrortest.c b/tests/virerrortest.c new file mode 100644 index 0000000000..0d0377bfa8 --- /dev/null +++ b/tests/virerrortest.c @@ -0,0 +1,101 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see + * . + */ + +#include + +#include "testutils.h" + +#define __VIR_ERROR_ALLOW_INCLUDE_PRIV_H__ +#include "virerrorpriv.h" + +static int +virErrorTestMsgFormatInfoOne(const char *msg) +{ + bool found =3D false; + char *next; + int ret =3D 0; + + for (next =3D (char *)msg; (next =3D strchr(next, '%')); next++) { + if (next[1] !=3D 's') { + VIR_TEST_VERBOSE("\nerror message '%s' contains disallowed pri= ntf modifiers\n", msg); + ret =3D -1; + } else { + if (found) { + VIR_TEST_VERBOSE("\nerror message '%s' contains multiple %= %s modifiers\n", msg); + ret =3D -1; + } else { + found =3D true; + } + } + } + + if (!found) { + VIR_TEST_VERBOSE("\nerror message '%s' does not contain any %%s mo= difiers\n", msg); + ret =3D -1; + } + + return ret; +} + + +static int +virErrorTestMsgs(const void *opaque ATTRIBUTE_UNUSED) +{ + const char *err_noinfo; + const char *err_info; + size_t i; + int ret =3D 0; + + for (i =3D 1; i < VIR_ERR_NUMBER_LAST; i++) { + err_noinfo =3D virErrorMsg(i, NULL); + err_info =3D virErrorMsg(i, ""); + + if (!err_noinfo) { + VIR_TEST_VERBOSE("\nmissing string without info for error id %= zu\n", i); + ret =3D -1; + } + + if (!err_info) { + VIR_TEST_VERBOSE("\nmissing string with info for error id %zu\= n", i); + ret =3D -1; + } + + if (strchr(err_noinfo, '%')) { + VIR_TEST_VERBOSE("\nerror message id %zu contains formatting c= haracters: '%s'\n", + i, err_noinfo); + ret =3D -1; + } + + if (virErrorTestMsgFormatInfoOne(err_info) < 0) + ret =3D -1; + } + + return ret; +} + + +static int +mymain(void) +{ + int ret =3D 0; + + if (virTestRun("error message strings ", virErrorTestMsgs, NULL) < 0) + ret =3D -1; + + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; +} + +VIR_TEST_MAIN(mymain) --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:06:45 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1544712560691535.9599317356304; Thu, 13 Dec 2018 06:49:20 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id DC413307EA8A; Thu, 13 Dec 2018 14:49:18 +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 AE756607D8; Thu, 13 Dec 2018 14:49:18 +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 6739E181B9F6; Thu, 13 Dec 2018 14:49:18 +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 wBDEnE4V011837 for ; Thu, 13 Dec 2018 09:49:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6E5BC1057074; Thu, 13 Dec 2018 14:49:14 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA3811057070 for ; Thu, 13 Dec 2018 14:49:11 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 13 Dec 2018 15:48:54 +0100 Message-Id: <90c54e69c16247ad95fb78fdd484323bcff451d5.1544712448.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 Subject: [libvirt] [PATCH v2 7/9] util: error: Improve docs for virErrorMsg 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: , 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 13 Dec 2018 14:49:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Clarify how @info is used and what the returned values look like. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/util/virerror.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/virerror.c b/src/util/virerror.c index 1e7c8bdb90..03166d85d2 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -907,12 +907,14 @@ void virRaiseErrorObject(const char *filename, /** * virErrorMsg: * @error: the virErrorNumber - * @info: usually the first parameter string + * @info: additional info string * - * Internal routine to get the message associated to an error raised - * from the library + * Internal routine to get the message associated to @error raised + * from the library. * - * Returns the constant string associated to @error + * Returns a *printf format string which describes @error. The returned st= ring + * contains exactly one '%s' modifier if @info is non-NULL, or no modifier= s at + * all if @info is NULL. If @error is invalid NULL is returned. */ const char * virErrorMsg(virErrorNumber error, const char *info) --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:06:45 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1544712592415857.1538845670917; Thu, 13 Dec 2018 06:49:52 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 54A8B7F40E; Thu, 13 Dec 2018 14:49: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 E5FCB10595BA; Thu, 13 Dec 2018 14:49:48 +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 8582E181BA17; Thu, 13 Dec 2018 14:49:48 +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 wBDEnl0Z011916 for ; Thu, 13 Dec 2018 09:49:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 445A41057072; Thu, 13 Dec 2018 14:49:47 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id B752E105958F for ; Thu, 13 Dec 2018 14:49:14 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 13 Dec 2018 15:48: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 Subject: [libvirt] [PATCH v2 8/9] DO NOT PUSH: Make sure that error messages are not moved around 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 13 Dec 2018 14:49:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add a virerrortest case that makes sure that all error messages stay the same while refactoring. This patch will not be pushed upstream to avoid polluting the git history. --- tests/virerrormessages.txt | 101 +++++++++++++++++++++++++++++++++++++ tests/virerrortest.c | 25 +++++++++ 2 files changed, 126 insertions(+) create mode 100644 tests/virerrormessages.txt diff --git a/tests/virerrormessages.txt b/tests/virerrormessages.txt new file mode 100644 index 0000000000..8da486638e --- /dev/null +++ b/tests/virerrormessages.txt @@ -0,0 +1,101 @@ +1-internal error-internal error: %s +2-out of memory-out of memory: %s +3-this function is not supported by the connection driver-this function is= not supported by the connection driver: %s +4-unknown host-unknown host %s +5-no connection driver available-no connection driver available for %s +6-invalid connection pointer in-invalid connection pointer in %s +7-invalid domain pointer in-invalid domain pointer in %s +8-invalid argument-invalid argument: %s +9-operation failed-operation failed: %s +10-GET operation failed-GET operation failed: %s +11-POST operation failed-POST operation failed: %s +12-got unknown HTTP error code-got unknown HTTP error code %s +13-failed to serialize S-Expr-failed to serialize S-Expr: %s +14-could not use Xen hypervisor entry-could not use Xen hypervisor entry %s +15-failed Xen syscall-failed Xen syscall %s +16-unknown OS type-unknown OS type %s +17-missing kernel information-missing kernel information: %s +18-missing root device information-missing root device information in %s +19-missing source information for device-missing source information for de= vice %s +20-missing target information for device-missing target information for de= vice %s +21-missing name information-missing name information in %s +22-missing operating system information-missing operating system informati= on for %s +23-missing devices information-missing devices information for %s +24-could not connect to Xen Store-could not connect to Xen Store %s +25-too many drivers registered-too many drivers registered in %s +26-library call failed-library call failed: %s +27-XML description is invalid or not well formed-XML error: %s +28-this domain exists already-domain %s exists already +29-operation forbidden for read only access-operation forbidden: %s +30-failed to open configuration file-failed to open configuration file %s +31-failed to read configuration file-failed to read configuration file %s +32-failed to parse configuration file-failed to parse configuration file %s +33-configuration file syntax error-configuration file syntax error: %s +34-failed to write configuration file-failed to write configuration file: = %s +35-parser error-%s +36-invalid network pointer in-invalid network pointer in %s +37-this network exists already-network %s exists already +38-system call error-%s +39-RPC error-%s +40-GNUTLS call error-%s +41-Failed to find the network-Failed to find the network: %s +42-Domain not found-Domain not found: %s +43-Network not found-Network not found: %s +44-invalid MAC address-invalid MAC address: %s +45-authentication failed-authentication failed: %s +46-invalid storage pool pointer in-invalid storage pool pointer in %s +47-invalid storage volume pointer in-invalid storage volume pointer in %s +48-Failed to find a storage driver-Failed to find a storage driver: %s +49-Storage pool not found-Storage pool not found: %s +50-Storage volume not found-Storage volume not found: %s +51-Failed to find a node driver-Failed to find a node driver: %s +52-invalid node device pointer-invalid node device pointer in %s +53-Node device not found-Node device not found: %s +54-Security model not found-Security model not found: %s +55-Requested operation is not valid-Requested operation is not valid: %s +56-Failed to find the interface-Failed to find the interface: %s +57-Interface not found-Interface not found: %s +58-invalid interface pointer in-invalid interface pointer in %s +59-multiple matching interfaces found-multiple matching interfaces found: = %s +60-Failed to start the nwfilter driver-Failed to start the nwfilter driver= : %s +61-Invalid network filter-Invalid network filter: %s +62-Network filter not found-Network filter not found: %s +63-Error while building firewall-Error while building firewall: %s +64-Failed to find a secret storage driver-Failed to find a secret storage = driver: %s +65-Invalid secret-Invalid secret: %s +66-Secret not found-Secret not found: %s +67-unsupported configuration-unsupported configuration: %s +68-Timed out during operation-Timed out during operation: %s +69-Failed to make domain persistent after migration-Failed to make domain = persistent after migration: %s +70-Hook script execution failed-Hook script execution failed: %s +71-Invalid snapshot-Invalid snapshot: %s +72-Domain snapshot not found-Domain snapshot not found: %s +73-invalid stream pointer-invalid stream pointer in %s +74-argument unsupported-argument unsupported: %s +75-Storage pool probe failed-Storage pool probe failed: %s +76-Storage pool already built-Storage pool already built: %s +77-revert requires force-revert requires force: %s +78-operation aborted-operation aborted: %s +79-authentication cancelled-authentication cancelled: %s +80-metadata not found-metadata not found: %s +81-Unsafe migration-Unsafe migration: %s +82-numerical overflow-numerical overflow: %s +83-block copy still active-block copy still active: %s +84-Operation not supported-Operation not supported: %s +85-SSH transport error-SSH transport error: %s +86-Guest agent is not responding-Guest agent is not responding: %s +87-resource busy-resource busy: %s +88-access denied-access denied: %s +89-error from service-error from service: %s +90-this storage volume exists already-storage volume %s exists already +91-the CPU is incompatible with host CPU-the CPU is incompatible with host= CPU: %s +92-XML document failed to validate against schema-XML document failed to v= alidate against schema: %s +93-migration successfully aborted-migration successfully aborted: %s +94-authentication unavailable-authentication unavailable: %s +95-Server not found-Server not found: %s +96-Client not found-Client not found: %s +97-guest agent replied with wrong id to guest-sync command-guest agent rep= lied with wrong id to guest-sync command: %s +98-libssh transport error-libssh transport error: %s +99-device not found-device not found: %s +100-Invalid network filter binding-Invalid network filter binding: %s +101-Network filter binding not found-Network filter binding not found: %s diff --git a/tests/virerrortest.c b/tests/virerrortest.c index 0d0377bfa8..e985ca743b 100644 --- a/tests/virerrortest.c +++ b/tests/virerrortest.c @@ -87,6 +87,29 @@ virErrorTestMsgs(const void *opaque ATTRIBUTE_UNUSED) } +static int +virErrorTestMsgsStable(const void *opaque ATTRIBUTE_UNUSED) +{ + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + char *actual =3D NULL; + size_t i; + int ret =3D 0; + + for (i =3D 1; i < VIR_ERR_NUMBER_LAST; i++) { + virBufferAsprintf(&buf, "%zu-", i); + virBufferStrcat(&buf, virErrorMsg(i, NULL), "-", virErrorMsg(i, ""= ), "\n", NULL); + } + + actual =3D virBufferContentAndReset(&buf); + + if (virTestCompareToFile(actual, abs_srcdir "/virerrormessages.txt") <= 0) + ret =3D -1; + + VIR_FREE(actual); + return ret; +} + + static int mymain(void) { @@ -94,6 +117,8 @@ mymain(void) if (virTestRun("error message strings ", virErrorTestMsgs, NULL) < 0) ret =3D -1; + if (virTestRun("error message strings stability ", virErrorTestMsgsSta= ble, NULL) < 0) + ret =3D -1; return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:06:45 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1544712597865239.15512928272983; Thu, 13 Dec 2018 06:49:57 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 04B473082A34; Thu, 13 Dec 2018 14:49:55 +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 BCB8F1057072; Thu, 13 Dec 2018 14:49: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 6D2EE3F610; Thu, 13 Dec 2018 14:49:54 +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 wBDEnqLq011950 for ; Thu, 13 Dec 2018 09:49:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id D135F105B1E8; Thu, 13 Dec 2018 14:49:51 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF1B6105958C for ; Thu, 13 Dec 2018 14:49:47 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 13 Dec 2018 15:48:56 +0100 Message-Id: <5ee52febf45205adc0bc11f6a8336441a43dc730.1544712448.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 Subject: [libvirt] [PATCH v2 9/9] util: error: Put error code messages into an array 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 13 Dec 2018 14:49:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Simplify adding of new errors by just adding them to the array of messages rather than having to add conversion code. Additionally most of the messages add the format string part as a suffix so we can avoid some of the duplication by using a macro which adds the suffix to the original string. This way most messages fit into the 80 column limit and only 3 exceed 100 colums. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- Notes: v2: - use positional initializers - add macros for shortening the messages - make it gettext-friendly, since the last version was not src/libvirt_private.syms | 1 + src/util/virerror.c | 738 +++++++-------------------------------- 2 files changed, 126 insertions(+), 613 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6184030d59..775b33e151 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1753,6 +1753,7 @@ virDispatchError; virErrorCopyNew; virErrorInitialize; virErrorMsg; +virErrorMsgStrings; virErrorPreserveLast; virErrorRestore; virErrorSetErrnoFromLastError; diff --git a/src/util/virerror.c b/src/util/virerror.c index 03166d85d2..d3f1d7d0e1 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -904,6 +904,124 @@ void virRaiseErrorObject(const char *filename, } +typedef struct { + const char *msg; + const char *msginfo; +} virErrorMsgTuple; + +#define MSG(msg, sfx) \ + { N_(msg), N_(msg sfx) } +#define MSG_EXISTS(object) \ + { N_("this " object " exists already"), N_(object " %s exists already")= } + +const virErrorMsgTuple virErrorMsgStrings[VIR_ERR_NUMBER_LAST] =3D { + [VIR_ERR_OK] =3D { NULL, NULL }, + [VIR_ERR_INTERNAL_ERROR] =3D MSG("internal error", ": %s"), + [VIR_ERR_NO_MEMORY] =3D MSG("out of memory", ": %s"), + [VIR_ERR_NO_SUPPORT] =3D MSG("this function is not supported by the co= nnection driver", ": %s"), + [VIR_ERR_UNKNOWN_HOST] =3D MSG("unknown host", " %s"), + [VIR_ERR_NO_CONNECT] =3D MSG("no connection driver available", " for %= s"), + [VIR_ERR_INVALID_CONN] =3D MSG("invalid connection pointer in", " %s"), + [VIR_ERR_INVALID_DOMAIN] =3D MSG("invalid domain pointer in", " %s"), + [VIR_ERR_INVALID_ARG] =3D MSG("invalid argument", ": %s"), + [VIR_ERR_OPERATION_FAILED] =3D MSG("operation failed", ": %s"), + [VIR_ERR_GET_FAILED] =3D MSG("GET operation failed", ": %s"), + [VIR_ERR_POST_FAILED] =3D MSG("POST operation failed", ": %s"), + [VIR_ERR_HTTP_ERROR] =3D MSG("got unknown HTTP error code", " %s"), + [VIR_ERR_SEXPR_SERIAL] =3D MSG("failed to serialize S-Expr", ": %s"), + [VIR_ERR_NO_XEN] =3D MSG("could not use Xen hypervisor entry", " %s"), + [VIR_ERR_XEN_CALL] =3D MSG("failed Xen syscall", " %s"), + [VIR_ERR_OS_TYPE] =3D MSG("unknown OS type", " %s"), + [VIR_ERR_NO_KERNEL] =3D MSG("missing kernel information", ": %s"), + [VIR_ERR_NO_ROOT] =3D MSG("missing root device information", " in %s"), + [VIR_ERR_NO_SOURCE] =3D MSG("missing source information for device", "= %s"), + [VIR_ERR_NO_TARGET] =3D MSG("missing target information for device", "= %s"), + [VIR_ERR_NO_NAME] =3D MSG("missing name information", " in %s"), + [VIR_ERR_NO_OS] =3D MSG("missing operating system information", " for = %s"), + [VIR_ERR_NO_DEVICE] =3D MSG("missing devices information", " for %s"), + [VIR_ERR_NO_XENSTORE] =3D MSG("could not connect to Xen Store", " %s"), + [VIR_ERR_DRIVER_FULL] =3D MSG("too many drivers registered", " in %s"), + [VIR_ERR_CALL_FAILED] =3D MSG("library call failed", ": %s"), + [VIR_ERR_XML_ERROR] =3D { "XML description is invalid or not well form= ed", "XML error: %s" }, + [VIR_ERR_DOM_EXIST] =3D MSG_EXISTS("domain"), + [VIR_ERR_OPERATION_DENIED] =3D { "operation forbidden for read only ac= cess", "operation forbidden: %s" }, + [VIR_ERR_OPEN_FAILED] =3D MSG("failed to open configuration file", " %= s"), + [VIR_ERR_READ_FAILED] =3D MSG("failed to read configuration file", " %= s"), + [VIR_ERR_PARSE_FAILED] =3D MSG("failed to parse configuration file", "= %s"), + [VIR_ERR_CONF_SYNTAX] =3D MSG("configuration file syntax error", ": %s= "), + [VIR_ERR_WRITE_FAILED] =3D MSG("failed to write configuration file", "= : %s"), + [VIR_ERR_XML_DETAIL] =3D { "parser error", "%s" }, + [VIR_ERR_INVALID_NETWORK] =3D MSG("invalid network pointer in", " %s"), + [VIR_ERR_NETWORK_EXIST] =3D MSG_EXISTS("network"), + [VIR_ERR_SYSTEM_ERROR] =3D { "system call error", "%s" }, + [VIR_ERR_RPC] =3D { "RPC error", "%s" }, + [VIR_ERR_GNUTLS_ERROR] =3D { "GNUTLS call error", "%s" }, + [VIR_WAR_NO_NETWORK] =3D MSG("Failed to find the network", ": %s"), + [VIR_ERR_NO_DOMAIN] =3D MSG("Domain not found", ": %s"), + [VIR_ERR_NO_NETWORK] =3D MSG("Network not found", ": %s"), + [VIR_ERR_INVALID_MAC] =3D MSG("invalid MAC address", ": %s"), + [VIR_ERR_AUTH_FAILED] =3D MSG("authentication failed", ": %s"), + [VIR_ERR_INVALID_STORAGE_POOL] =3D MSG("invalid storage pool pointer i= n", " %s"), + [VIR_ERR_INVALID_STORAGE_VOL] =3D MSG("invalid storage volume pointer = in", " %s"), + [VIR_WAR_NO_STORAGE] =3D MSG("Failed to find a storage driver", ": %s"= ), + [VIR_ERR_NO_STORAGE_POOL] =3D MSG("Storage pool not found", ": %s"), + [VIR_ERR_NO_STORAGE_VOL] =3D MSG("Storage volume not found", ": %s"), + [VIR_WAR_NO_NODE] =3D MSG("Failed to find a node driver", ": %s"), + [VIR_ERR_INVALID_NODE_DEVICE] =3D MSG("invalid node device pointer", "= in %s"), + [VIR_ERR_NO_NODE_DEVICE] =3D MSG("Node device not found", ": %s"), + [VIR_ERR_NO_SECURITY_MODEL] =3D MSG("Security model not found", ": %s"= ), + [VIR_ERR_OPERATION_INVALID] =3D MSG("Requested operation is not valid"= , ": %s"), + [VIR_WAR_NO_INTERFACE] =3D MSG("Failed to find the interface", ": %s"), + [VIR_ERR_NO_INTERFACE] =3D MSG("Interface not found", ": %s"), + [VIR_ERR_INVALID_INTERFACE] =3D MSG("invalid interface pointer in", " = %s"), + [VIR_ERR_MULTIPLE_INTERFACES] =3D MSG("multiple matching interfaces fo= und", ": %s"), + [VIR_WAR_NO_NWFILTER] =3D MSG("Failed to start the nwfilter driver", "= : %s"), + [VIR_ERR_INVALID_NWFILTER] =3D MSG("Invalid network filter", ": %s"), + [VIR_ERR_NO_NWFILTER] =3D MSG("Network filter not found", ": %s"), + [VIR_ERR_BUILD_FIREWALL] =3D MSG("Error while building firewall", ": %= s"), + [VIR_WAR_NO_SECRET] =3D MSG("Failed to find a secret storage driver", = ": %s"), + [VIR_ERR_INVALID_SECRET] =3D MSG("Invalid secret", ": %s"), + [VIR_ERR_NO_SECRET] =3D MSG("Secret not found", ": %s"), + [VIR_ERR_CONFIG_UNSUPPORTED] =3D MSG("unsupported configuration", ": %= s"), + [VIR_ERR_OPERATION_TIMEOUT] =3D MSG("Timed out during operation", ": %= s"), + [VIR_ERR_MIGRATE_PERSIST_FAILED] =3D MSG("Failed to make domain persis= tent after migration", ": %s"), + [VIR_ERR_HOOK_SCRIPT_FAILED] =3D MSG("Hook script execution failed", "= : %s"), + [VIR_ERR_INVALID_DOMAIN_SNAPSHOT] =3D MSG("Invalid snapshot", ": %s"), + [VIR_ERR_NO_DOMAIN_SNAPSHOT] =3D MSG("Domain snapshot not found", ": %= s"), + [VIR_ERR_INVALID_STREAM] =3D MSG("invalid stream pointer", " in %s"), + [VIR_ERR_ARGUMENT_UNSUPPORTED] =3D MSG("argument unsupported", ": %s"), + [VIR_ERR_STORAGE_PROBE_FAILED] =3D MSG("Storage pool probe failed", ":= %s"), + [VIR_ERR_STORAGE_POOL_BUILT] =3D MSG("Storage pool already built", ": = %s"), + [VIR_ERR_SNAPSHOT_REVERT_RISKY] =3D MSG("revert requires force", ": %s= "), + [VIR_ERR_OPERATION_ABORTED] =3D MSG("operation aborted", ": %s"), + [VIR_ERR_AUTH_CANCELLED] =3D MSG("authentication cancelled", ": %s"), + [VIR_ERR_NO_DOMAIN_METADATA] =3D MSG("metadata not found", ": %s"), + [VIR_ERR_MIGRATE_UNSAFE] =3D MSG("Unsafe migration", ": %s"), + [VIR_ERR_OVERFLOW] =3D MSG("numerical overflow", ": %s"), + [VIR_ERR_BLOCK_COPY_ACTIVE] =3D MSG("block copy still active", ": %s"), + [VIR_ERR_OPERATION_UNSUPPORTED] =3D MSG("Operation not supported", ": = %s"), + [VIR_ERR_SSH] =3D MSG("SSH transport error", ": %s"), + [VIR_ERR_AGENT_UNRESPONSIVE] =3D MSG("Guest agent is not responding", = ": %s"), + [VIR_ERR_RESOURCE_BUSY] =3D MSG("resource busy", ": %s"), + [VIR_ERR_ACCESS_DENIED] =3D MSG("access denied", ": %s"), + [VIR_ERR_DBUS_SERVICE] =3D MSG("error from service", ": %s"), + [VIR_ERR_STORAGE_VOL_EXIST] =3D MSG_EXISTS("storage volume"), + [VIR_ERR_CPU_INCOMPATIBLE] =3D MSG("the CPU is incompatible with host = CPU", ": %s"), + [VIR_ERR_XML_INVALID_SCHEMA] =3D MSG("XML document failed to validate = against schema", ": %s"), + [VIR_ERR_MIGRATE_FINISH_OK] =3D MSG("migration successfully aborted", = ": %s"), + [VIR_ERR_AUTH_UNAVAILABLE] =3D MSG("authentication unavailable", ": %s= "), + [VIR_ERR_NO_SERVER] =3D MSG("Server not found", ": %s"), + [VIR_ERR_NO_CLIENT] =3D MSG("Client not found", ": %s"), + [VIR_ERR_AGENT_UNSYNCED] =3D MSG("guest agent replied with wrong id to= guest-sync command", ": %s"), + [VIR_ERR_LIBSSH] =3D MSG("libssh transport error", ": %s"), + [VIR_ERR_DEVICE_MISSING] =3D MSG("device not found", ": %s"), + [VIR_ERR_INVALID_NWFILTER_BINDING] =3D MSG("Invalid network filter bin= ding", ": %s"), + [VIR_ERR_NO_NWFILTER_BINDING] =3D MSG("Network filter binding not foun= d", ": %s"), +}; + +#undef MSG +#undef MSG_EXISTS + /** * virErrorMsg: * @error: the virErrorNumber @@ -919,622 +1037,16 @@ void virRaiseErrorObject(const char *filename, const char * virErrorMsg(virErrorNumber error, const char *info) { - const char *errmsg =3D NULL; + if (error >=3D VIR_ERR_NUMBER_LAST) + return NULL; - switch (error) { - case VIR_ERR_NUMBER_LAST: - case VIR_ERR_OK: - return NULL; - case VIR_ERR_INTERNAL_ERROR: - if (info !=3D NULL) - errmsg =3D _("internal error: %s"); - else - errmsg =3D _("internal error"); - break; - case VIR_ERR_NO_MEMORY: - if (info =3D=3D NULL) - errmsg =3D _("out of memory"); - else - errmsg =3D _("out of memory: %s"); - break; - case VIR_ERR_NO_SUPPORT: - if (info =3D=3D NULL) - errmsg =3D _("this function is not supported by the connec= tion driver"); - else - errmsg =3D _("this function is not supported by the connec= tion driver: %s"); - break; - case VIR_ERR_NO_CONNECT: - if (info =3D=3D NULL) - errmsg =3D _("no connection driver available"); - else - errmsg =3D _("no connection driver available for %s"); - break; - case VIR_ERR_INVALID_CONN: - if (info =3D=3D NULL) - errmsg =3D _("invalid connection pointer in"); - else - errmsg =3D _("invalid connection pointer in %s"); - break; - case VIR_ERR_INVALID_DOMAIN: - if (info =3D=3D NULL) - errmsg =3D _("invalid domain pointer in"); - else - errmsg =3D _("invalid domain pointer in %s"); - break; - case VIR_ERR_INVALID_ARG: - if (info =3D=3D NULL) - errmsg =3D _("invalid argument"); - else - errmsg =3D _("invalid argument: %s"); - break; - case VIR_ERR_OPERATION_FAILED: - if (info !=3D NULL) - errmsg =3D _("operation failed: %s"); - else - errmsg =3D _("operation failed"); - break; - case VIR_ERR_GET_FAILED: - if (info !=3D NULL) - errmsg =3D _("GET operation failed: %s"); - else - errmsg =3D _("GET operation failed"); - break; - case VIR_ERR_POST_FAILED: - if (info !=3D NULL) - errmsg =3D _("POST operation failed: %s"); - else - errmsg =3D _("POST operation failed"); - break; - case VIR_ERR_HTTP_ERROR: - if (info !=3D NULL) - errmsg =3D _("got unknown HTTP error code %s"); - else - errmsg =3D _("got unknown HTTP error code"); - break; - case VIR_ERR_UNKNOWN_HOST: - if (info !=3D NULL) - errmsg =3D _("unknown host %s"); - else - errmsg =3D _("unknown host"); - break; - case VIR_ERR_SEXPR_SERIAL: - if (info !=3D NULL) - errmsg =3D _("failed to serialize S-Expr: %s"); - else - errmsg =3D _("failed to serialize S-Expr"); - break; - case VIR_ERR_NO_XEN: - if (info =3D=3D NULL) - errmsg =3D _("could not use Xen hypervisor entry"); - else - errmsg =3D _("could not use Xen hypervisor entry %s"); - break; - case VIR_ERR_NO_XENSTORE: - if (info =3D=3D NULL) - errmsg =3D _("could not connect to Xen Store"); - else - errmsg =3D _("could not connect to Xen Store %s"); - break; - case VIR_ERR_XEN_CALL: - if (info =3D=3D NULL) - errmsg =3D _("failed Xen syscall"); - else - errmsg =3D _("failed Xen syscall %s"); - break; - case VIR_ERR_OS_TYPE: - if (info =3D=3D NULL) - errmsg =3D _("unknown OS type"); - else - errmsg =3D _("unknown OS type %s"); - break; - case VIR_ERR_NO_KERNEL: - if (info =3D=3D NULL) - errmsg =3D _("missing kernel information"); - else - errmsg =3D _("missing kernel information: %s"); - break; - case VIR_ERR_NO_ROOT: - if (info =3D=3D NULL) - errmsg =3D _("missing root device information"); - else - errmsg =3D _("missing root device information in %s"); - break; - case VIR_ERR_NO_SOURCE: - if (info =3D=3D NULL) - errmsg =3D _("missing source information for device"); - else - errmsg =3D _("missing source information for device %s"); - break; - case VIR_ERR_NO_TARGET: - if (info =3D=3D NULL) - errmsg =3D _("missing target information for device"); - else - errmsg =3D _("missing target information for device %s"); - break; - case VIR_ERR_NO_NAME: - if (info =3D=3D NULL) - errmsg =3D _("missing name information"); - else - errmsg =3D _("missing name information in %s"); - break; - case VIR_ERR_NO_OS: - if (info =3D=3D NULL) - errmsg =3D _("missing operating system information"); - else - errmsg =3D _("missing operating system information for %s"= ); - break; - case VIR_ERR_NO_DEVICE: - if (info =3D=3D NULL) - errmsg =3D _("missing devices information"); - else - errmsg =3D _("missing devices information for %s"); - break; - case VIR_ERR_DRIVER_FULL: - if (info =3D=3D NULL) - errmsg =3D _("too many drivers registered"); - else - errmsg =3D _("too many drivers registered in %s"); - break; - case VIR_ERR_CALL_FAILED: /* DEPRECATED, use VIR_ERR_NO_SUPPORT */ - if (info =3D=3D NULL) - errmsg =3D _("library call failed"); - else - errmsg =3D _("library call failed: %s"); - break; - case VIR_ERR_XML_ERROR: - if (info =3D=3D NULL) - errmsg =3D _("XML description is invalid or not well forme= d"); - else - errmsg =3D _("XML error: %s"); - break; - case VIR_ERR_DOM_EXIST: - if (info =3D=3D NULL) - errmsg =3D _("this domain exists already"); - else - errmsg =3D _("domain %s exists already"); - break; - case VIR_ERR_OPERATION_DENIED: - if (info =3D=3D NULL) - errmsg =3D _("operation forbidden for read only access"); - else - errmsg =3D _("operation forbidden: %s"); - break; - case VIR_ERR_OPEN_FAILED: - if (info =3D=3D NULL) - errmsg =3D _("failed to open configuration file"); - else - errmsg =3D _("failed to open configuration file %s"); - break; - case VIR_ERR_READ_FAILED: - if (info =3D=3D NULL) - errmsg =3D _("failed to read configuration file"); - else - errmsg =3D _("failed to read configuration file %s"); - break; - case VIR_ERR_PARSE_FAILED: - if (info =3D=3D NULL) - errmsg =3D _("failed to parse configuration file"); - else - errmsg =3D _("failed to parse configuration file %s"); - break; - case VIR_ERR_CONF_SYNTAX: - if (info =3D=3D NULL) - errmsg =3D _("configuration file syntax error"); - else - errmsg =3D _("configuration file syntax error: %s"); - break; - case VIR_ERR_WRITE_FAILED: - if (info =3D=3D NULL) - errmsg =3D _("failed to write configuration file"); - else - errmsg =3D _("failed to write configuration file: %s"); - break; - case VIR_ERR_XML_DETAIL: - if (info =3D=3D NULL) - errmsg =3D _("parser error"); - else - errmsg =3D "%s"; - break; - case VIR_ERR_INVALID_NETWORK: - if (info =3D=3D NULL) - errmsg =3D _("invalid network pointer in"); - else - errmsg =3D _("invalid network pointer in %s"); - break; - case VIR_ERR_NETWORK_EXIST: - if (info =3D=3D NULL) - errmsg =3D _("this network exists already"); - else - errmsg =3D _("network %s exists already"); - break; - case VIR_ERR_SYSTEM_ERROR: - if (info =3D=3D NULL) - errmsg =3D _("system call error"); - else - errmsg =3D "%s"; - break; - case VIR_ERR_RPC: - if (info =3D=3D NULL) - errmsg =3D _("RPC error"); - else - errmsg =3D "%s"; - break; - case VIR_ERR_GNUTLS_ERROR: - if (info =3D=3D NULL) - errmsg =3D _("GNUTLS call error"); - else - errmsg =3D "%s"; - break; - case VIR_WAR_NO_NETWORK: - if (info =3D=3D NULL) - errmsg =3D _("Failed to find the network"); - else - errmsg =3D _("Failed to find the network: %s"); - break; - case VIR_ERR_NO_DOMAIN: - if (info =3D=3D NULL) - errmsg =3D _("Domain not found"); - else - errmsg =3D _("Domain not found: %s"); - break; - case VIR_ERR_NO_NETWORK: - if (info =3D=3D NULL) - errmsg =3D _("Network not found"); - else - errmsg =3D _("Network not found: %s"); - break; - case VIR_ERR_INVALID_MAC: - if (info =3D=3D NULL) - errmsg =3D _("invalid MAC address"); - else - errmsg =3D _("invalid MAC address: %s"); - break; - case VIR_ERR_AUTH_FAILED: - if (info =3D=3D NULL) - errmsg =3D _("authentication failed"); - else - errmsg =3D _("authentication failed: %s"); - break; - case VIR_ERR_AUTH_CANCELLED: - if (info =3D=3D NULL) - errmsg =3D _("authentication cancelled"); - else - errmsg =3D _("authentication cancelled: %s"); - break; - case VIR_ERR_AUTH_UNAVAILABLE: - if (info =3D=3D NULL) - errmsg =3D _("authentication unavailable"); - else - errmsg =3D _("authentication unavailable: %s"); - break; - case VIR_ERR_NO_STORAGE_POOL: - if (info =3D=3D NULL) - errmsg =3D _("Storage pool not found"); - else - errmsg =3D _("Storage pool not found: %s"); - break; - case VIR_ERR_NO_STORAGE_VOL: - if (info =3D=3D NULL) - errmsg =3D _("Storage volume not found"); - else - errmsg =3D _("Storage volume not found: %s"); - break; - case VIR_ERR_STORAGE_VOL_EXIST: - if (info =3D=3D NULL) - errmsg =3D _("this storage volume exists already"); - else - errmsg =3D _("storage volume %s exists already"); - break; - case VIR_ERR_STORAGE_PROBE_FAILED: - if (info =3D=3D NULL) - errmsg =3D _("Storage pool probe failed"); - else - errmsg =3D _("Storage pool probe failed: %s"); - break; - case VIR_ERR_STORAGE_POOL_BUILT: - if (info =3D=3D NULL) - errmsg =3D _("Storage pool already built"); - else - errmsg =3D _("Storage pool already built: %s"); - break; - case VIR_ERR_INVALID_STORAGE_POOL: - if (info =3D=3D NULL) - errmsg =3D _("invalid storage pool pointer in"); - else - errmsg =3D _("invalid storage pool pointer in %s"); - break; - case VIR_ERR_INVALID_STORAGE_VOL: - if (info =3D=3D NULL) - errmsg =3D _("invalid storage volume pointer in"); - else - errmsg =3D _("invalid storage volume pointer in %s"); - break; - case VIR_WAR_NO_STORAGE: - if (info =3D=3D NULL) - errmsg =3D _("Failed to find a storage driver"); - else - errmsg =3D _("Failed to find a storage driver: %s"); - break; - case VIR_WAR_NO_NODE: - if (info =3D=3D NULL) - errmsg =3D _("Failed to find a node driver"); - else - errmsg =3D _("Failed to find a node driver: %s"); - break; - case VIR_ERR_INVALID_NODE_DEVICE: - if (info =3D=3D NULL) - errmsg =3D _("invalid node device pointer"); - else - errmsg =3D _("invalid node device pointer in %s"); - break; - case VIR_ERR_NO_NODE_DEVICE: - if (info =3D=3D NULL) - errmsg =3D _("Node device not found"); - else - errmsg =3D _("Node device not found: %s"); - break; - case VIR_ERR_NO_SECURITY_MODEL: - if (info =3D=3D NULL) - errmsg =3D _("Security model not found"); - else - errmsg =3D _("Security model not found: %s"); - break; - case VIR_ERR_OPERATION_INVALID: - if (info =3D=3D NULL) - errmsg =3D _("Requested operation is not valid"); - else - errmsg =3D _("Requested operation is not valid: %s"); - break; - case VIR_WAR_NO_INTERFACE: - if (info =3D=3D NULL) - errmsg =3D _("Failed to find the interface"); - else - errmsg =3D _("Failed to find the interface: %s"); - break; - case VIR_ERR_NO_INTERFACE: - if (info =3D=3D NULL) - errmsg =3D _("Interface not found"); - else - errmsg =3D _("Interface not found: %s"); - break; - case VIR_ERR_INVALID_INTERFACE: - if (info =3D=3D NULL) - errmsg =3D _("invalid interface pointer in"); - else - errmsg =3D _("invalid interface pointer in %s"); - break; - case VIR_ERR_MULTIPLE_INTERFACES: - if (info =3D=3D NULL) - errmsg =3D _("multiple matching interfaces found"); - else - errmsg =3D _("multiple matching interfaces found: %s"); - break; - case VIR_WAR_NO_SECRET: - if (info =3D=3D NULL) - errmsg =3D _("Failed to find a secret storage driver"); - else - errmsg =3D _("Failed to find a secret storage driver: %s"); - break; - case VIR_ERR_INVALID_SECRET: - if (info =3D=3D NULL) - errmsg =3D _("Invalid secret"); - else - errmsg =3D _("Invalid secret: %s"); - break; - case VIR_ERR_NO_SECRET: - if (info =3D=3D NULL) - errmsg =3D _("Secret not found"); - else - errmsg =3D _("Secret not found: %s"); - break; - case VIR_WAR_NO_NWFILTER: - if (info =3D=3D NULL) - errmsg =3D _("Failed to start the nwfilter driver"); - else - errmsg =3D _("Failed to start the nwfilter driver: %s"); - break; - case VIR_ERR_INVALID_NWFILTER: - if (info =3D=3D NULL) - errmsg =3D _("Invalid network filter"); - else - errmsg =3D _("Invalid network filter: %s"); - break; - case VIR_ERR_NO_NWFILTER: - if (info =3D=3D NULL) - errmsg =3D _("Network filter not found"); - else - errmsg =3D _("Network filter not found: %s"); - break; - case VIR_ERR_BUILD_FIREWALL: - if (info =3D=3D NULL) - errmsg =3D _("Error while building firewall"); - else - errmsg =3D _("Error while building firewall: %s"); - break; - case VIR_ERR_CONFIG_UNSUPPORTED: - if (info =3D=3D NULL) - errmsg =3D _("unsupported configuration"); - else - errmsg =3D _("unsupported configuration: %s"); - break; - case VIR_ERR_OPERATION_TIMEOUT: - if (info =3D=3D NULL) - errmsg =3D _("Timed out during operation"); - else - errmsg =3D _("Timed out during operation: %s"); - break; - case VIR_ERR_MIGRATE_PERSIST_FAILED: - if (info =3D=3D NULL) - errmsg =3D _("Failed to make domain persistent after migra= tion"); - else - errmsg =3D _("Failed to make domain persistent after migra= tion: %s"); - break; - case VIR_ERR_HOOK_SCRIPT_FAILED: - if (info =3D=3D NULL) - errmsg =3D _("Hook script execution failed"); - else - errmsg =3D _("Hook script execution failed: %s"); - break; - case VIR_ERR_INVALID_DOMAIN_SNAPSHOT: - if (info =3D=3D NULL) - errmsg =3D _("Invalid snapshot"); - else - errmsg =3D _("Invalid snapshot: %s"); - break; - case VIR_ERR_NO_DOMAIN_SNAPSHOT: - if (info =3D=3D NULL) - errmsg =3D _("Domain snapshot not found"); - else - errmsg =3D _("Domain snapshot not found: %s"); - break; - case VIR_ERR_INVALID_STREAM: - if (info =3D=3D NULL) - errmsg =3D _("invalid stream pointer"); - else - errmsg =3D _("invalid stream pointer in %s"); - break; - case VIR_ERR_ARGUMENT_UNSUPPORTED: - if (info =3D=3D NULL) - errmsg =3D _("argument unsupported"); - else - errmsg =3D _("argument unsupported: %s"); - break; - case VIR_ERR_SNAPSHOT_REVERT_RISKY: - if (info =3D=3D NULL) - errmsg =3D _("revert requires force"); - else - errmsg =3D _("revert requires force: %s"); - break; - case VIR_ERR_OPERATION_ABORTED: - if (info =3D=3D NULL) - errmsg =3D _("operation aborted"); - else - errmsg =3D _("operation aborted: %s"); - break; - case VIR_ERR_NO_DOMAIN_METADATA: - if (info =3D=3D NULL) - errmsg =3D _("metadata not found"); - else - errmsg =3D _("metadata not found: %s"); - break; - case VIR_ERR_MIGRATE_UNSAFE: - if (!info) - errmsg =3D _("Unsafe migration"); - else - errmsg =3D _("Unsafe migration: %s"); - break; - case VIR_ERR_OVERFLOW: - if (!info) - errmsg =3D _("numerical overflow"); - else - errmsg =3D _("numerical overflow: %s"); - break; - case VIR_ERR_BLOCK_COPY_ACTIVE: - if (!info) - errmsg =3D _("block copy still active"); - else - errmsg =3D _("block copy still active: %s"); - break; - case VIR_ERR_OPERATION_UNSUPPORTED: - if (!info) - errmsg =3D _("Operation not supported"); - else - errmsg =3D _("Operation not supported: %s"); - break; - case VIR_ERR_SSH: - if (info =3D=3D NULL) - errmsg =3D _("SSH transport error"); - else - errmsg =3D _("SSH transport error: %s"); - break; - case VIR_ERR_AGENT_UNRESPONSIVE: - if (info =3D=3D NULL) - errmsg =3D _("Guest agent is not responding"); - else - errmsg =3D _("Guest agent is not responding: %s"); - break; - case VIR_ERR_RESOURCE_BUSY: - if (info =3D=3D NULL) - errmsg =3D _("resource busy"); - else - errmsg =3D _("resource busy: %s"); - break; - case VIR_ERR_ACCESS_DENIED: - if (info =3D=3D NULL) - errmsg =3D _("access denied"); - else - errmsg =3D _("access denied: %s"); - break; - case VIR_ERR_DBUS_SERVICE: - if (info =3D=3D NULL) - errmsg =3D _("error from service"); - else - errmsg =3D _("error from service: %s"); - break; - case VIR_ERR_CPU_INCOMPATIBLE: - if (info =3D=3D NULL) - errmsg =3D _("the CPU is incompatible with host CPU"); - else - errmsg =3D _("the CPU is incompatible with host CPU: %s"); - break; - case VIR_ERR_XML_INVALID_SCHEMA: - if (info =3D=3D NULL) - errmsg =3D _("XML document failed to validate against sche= ma"); - else - errmsg =3D _("XML document failed to validate against sche= ma: %s"); - break; - case VIR_ERR_MIGRATE_FINISH_OK: - if (info =3D=3D NULL) - errmsg =3D _("migration successfully aborted"); - else - errmsg =3D _("migration successfully aborted: %s"); - break; - case VIR_ERR_NO_SERVER: - if (info =3D=3D NULL) - errmsg =3D _("Server not found"); - else - errmsg =3D _("Server not found: %s"); - break; - case VIR_ERR_NO_CLIENT: - if (info =3D=3D NULL) - errmsg =3D _("Client not found"); - else - errmsg =3D _("Client not found: %s"); - break; - case VIR_ERR_AGENT_UNSYNCED: /* DEPRECATED */ - if (info =3D=3D NULL) - errmsg =3D _("guest agent replied with wrong id to guest-s= ync command"); - else - errmsg =3D _("guest agent replied with wrong id to guest-s= ync command: %s"); - break; - case VIR_ERR_LIBSSH: - if (info =3D=3D NULL) - errmsg =3D _("libssh transport error"); - else - errmsg =3D _("libssh transport error: %s"); - break; - case VIR_ERR_DEVICE_MISSING: - if (info =3D=3D NULL) - errmsg =3D _("device not found"); - else - errmsg =3D _("device not found: %s"); - break; - case VIR_ERR_INVALID_NWFILTER_BINDING: - if (info =3D=3D NULL) - errmsg =3D _("Invalid network filter binding"); - else - errmsg =3D _("Invalid network filter binding: %s"); - break; - case VIR_ERR_NO_NWFILTER_BINDING: - if (info =3D=3D NULL) - errmsg =3D _("Network filter binding not found"); - else - errmsg =3D _("Network filter binding not found: %s"); - break; - } - return errmsg; + if (info) + return _(virErrorMsgStrings[error].msginfo); + else + return _(virErrorMsgStrings[error].msg); } + /** * virReportErrorHelper: * --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list