From ac114d5cd593b428074b5978e9a80efd812210e5 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 13 Nov 2020 09:26:17 +0100 Subject: qerror: Drop unused QERR_ macros QERR_INVALID_BLOCK_FORMAT is dead since commit e6641719fe "block: Always pass NULL as drv for bdrv_open()", 2015-09-14. QERR_INVALID_PASSWORD is dead since commit c01c214b69 "block: remove all encryption handling APIs", 2017-07-11. Bury them. Signed-off-by: Markus Armbruster Message-Id: <20201113082626.2725812-2-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé --- include/qapi/qmp/qerror.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include/qapi/qmp/qerror.h') diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index 7c76e24aa7..3eabd451d8 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -43,9 +43,6 @@ #define QERR_FEATURE_DISABLED \ "The feature '%s' is not enabled" -#define QERR_INVALID_BLOCK_FORMAT \ - "Invalid block format '%s'" - #define QERR_INVALID_PARAMETER \ "Invalid parameter '%s'" @@ -55,9 +52,6 @@ #define QERR_INVALID_PARAMETER_VALUE \ "Parameter '%s' expects %s" -#define QERR_INVALID_PASSWORD \ - "Password incorrect" - #define QERR_IO_ERROR \ "An IO error has occurred" -- cgit v1.2.3-55-g7522 From f820af87433af84c13cd260807b59bbce47e2f0a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 13 Nov 2020 09:26:18 +0100 Subject: qerror: Eliminate QERR_ macros used in just one place Signed-off-by: Markus Armbruster Message-Id: <20201113082626.2725812-3-armbru@redhat.com> --- include/qapi/qmp/qerror.h | 9 --------- monitor/misc.c | 8 ++++---- net/net.c | 2 +- 3 files changed, 5 insertions(+), 14 deletions(-) (limited to 'include/qapi/qmp/qerror.h') diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index 3eabd451d8..c272e3fc29 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -25,21 +25,12 @@ #define QERR_DEVICE_HAS_NO_MEDIUM \ "Device '%s' has no medium" -#define QERR_DEVICE_INIT_FAILED \ - "Device '%s' could not be initialized" - #define QERR_DEVICE_IN_USE \ "Device '%s' is in use" #define QERR_DEVICE_NO_HOTPLUG \ "Device '%s' does not support hotplugging" -#define QERR_FD_NOT_FOUND \ - "File descriptor named '%s' not found" - -#define QERR_FD_NOT_SUPPLIED \ - "No file descriptor supplied via SCM_RIGHTS" - #define QERR_FEATURE_DISABLED \ "The feature '%s' is not enabled" diff --git a/monitor/misc.c b/monitor/misc.c index 398211a034..c563e901c0 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1232,7 +1232,7 @@ void qmp_getfd(const char *fdname, Error **errp) fd = qemu_chr_fe_get_msgfd(&cur_mon->chr); if (fd == -1) { - error_setg(errp, QERR_FD_NOT_SUPPLIED); + error_setg(errp, "No file descriptor supplied via SCM_RIGHTS"); return; } @@ -1286,7 +1286,7 @@ void qmp_closefd(const char *fdname, Error **errp) } qemu_mutex_unlock(&cur_mon->mon_lock); - error_setg(errp, QERR_FD_NOT_FOUND, fdname); + error_setg(errp, "File descriptor named '%s' not found", fdname); } int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp) @@ -1357,7 +1357,7 @@ AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque, fd = qemu_chr_fe_get_msgfd(&mon->chr); if (fd == -1) { - error_setg(errp, QERR_FD_NOT_SUPPLIED); + error_setg(errp, "No file descriptor supplied via SCM_RIGHTS"); goto error; } @@ -1410,7 +1410,7 @@ error: } else { snprintf(fd_str, sizeof(fd_str), "fdset-id:%" PRId64, fdset_id); } - error_setg(errp, QERR_FD_NOT_FOUND, fd_str); + error_setg(errp, "File descriptor named '%s' not found", fd_str); } FdsetInfoList *qmp_query_fdsets(Error **errp) diff --git a/net/net.c b/net/net.c index 6a2c3d9567..e1035f21d1 100644 --- a/net/net.c +++ b/net/net.c @@ -1013,7 +1013,7 @@ static int net_client_init1(const Netdev *netdev, bool is_netdev, Error **errp) if (net_client_init_fun[netdev->type](netdev, netdev->id, peer, errp) < 0) { /* FIXME drop when all init functions store an Error */ if (errp && !*errp) { - error_setg(errp, QERR_DEVICE_INIT_FAILED, + error_setg(errp, "Device '%s' could not be initialized", NetClientDriver_str(netdev->type)); } return -1; -- cgit v1.2.3-55-g7522 From b0d7be2a62eecade217fa45521be18149346eaa1 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 13 Nov 2020 09:26:19 +0100 Subject: block: Improve some block-commit, block-stream error messages block-commit defaults @base-node to the deepest backing image. When there is none, it fails with "Base 'NULL' not found". Improve to "There is no backing image". block-commit and block-stream reject a @base argument that doesn't resolve with "Base 'BASE' not found". Commit 6b33f3ae8b "qemu-img: Improve commit invalid base message" improved this message in qemu-img. Improve it here, too: "Can't find '%s' in the backing chain". QERR_BASE_NOT_FOUND is now unused. Drop. Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster Message-Id: <20201113082626.2725812-4-armbru@redhat.com> Reviewed-by: Max Reitz --- blockdev.c | 15 +++++++++------ include/qapi/qmp/qerror.h | 2 -- tests/qemu-iotests/040 | 12 ++++++------ 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'include/qapi/qmp/qerror.h') diff --git a/blockdev.c b/blockdev.c index fe6fb5dc1d..d05a8740f4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2531,7 +2531,7 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device, if (has_base) { base_bs = bdrv_find_backing_image(bs, base); if (base_bs == NULL) { - error_setg(errp, QERR_BASE_NOT_FOUND, base); + error_setg(errp, "Can't find '%s' in the backing chain", base); goto out; } assert(bdrv_get_aio_context(base_bs) == aio_context); @@ -2703,13 +2703,16 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device, } } else if (has_base && base) { base_bs = bdrv_find_backing_image(top_bs, base); + if (base_bs == NULL) { + error_setg(errp, "Can't find '%s' in the backing chain", base); + goto out; + } } else { base_bs = bdrv_find_base(top_bs); - } - - if (base_bs == NULL) { - error_setg(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL"); - goto out; + if (base_bs == NULL) { + error_setg(errp, "There is no backimg image"); + goto out; + } } assert(bdrv_get_aio_context(base_bs) == aio_context); diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index c272e3fc29..5d7e69cc1f 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -16,8 +16,6 @@ * These macros will go away, please don't use in new code, and do not * add new ones! */ -#define QERR_BASE_NOT_FOUND \ - "Base '%s' not found" #define QERR_BUS_NO_HOTPLUG \ "Bus '%s' does not support hotplugging" diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index caf286571a..dc6069edc0 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -156,7 +156,7 @@ class TestSingleDrive(ImageCommitTestCase): self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % backing_img, base='%s' % backing_img) self.assert_qmp(result, 'error/class', 'GenericError') - self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % backing_img) + self.assert_qmp(result, 'error/desc', "Can't find '%s' in the backing chain" % backing_img) def test_top_invalid(self): self.assert_no_active_block_jobs() @@ -168,7 +168,7 @@ class TestSingleDrive(ImageCommitTestCase): self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % mid_img, base='badfile') self.assert_qmp(result, 'error/class', 'GenericError') - self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found') + self.assert_qmp(result, 'error/desc', "Can't find 'badfile' in the backing chain") def test_top_node_invalid(self): self.assert_no_active_block_jobs() @@ -208,7 +208,7 @@ class TestSingleDrive(ImageCommitTestCase): self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % backing_img, base='%s' % mid_img) self.assert_qmp(result, 'error/class', 'GenericError') - self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % mid_img) + self.assert_qmp(result, 'error/desc', "Can't find '%s' in the backing chain" % mid_img) def test_top_and_base_node_reversed(self): self.assert_no_active_block_jobs() @@ -349,7 +349,7 @@ class TestRelativePaths(ImageCommitTestCase): self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.mid_img, base='%s' % self.mid_img) self.assert_qmp(result, 'error/class', 'GenericError') - self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % self.mid_img) + self.assert_qmp(result, 'error/desc', "Can't find '%s' in the backing chain" % self.mid_img) def test_top_invalid(self): self.assert_no_active_block_jobs() @@ -361,7 +361,7 @@ class TestRelativePaths(ImageCommitTestCase): self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.mid_img, base='badfile') self.assert_qmp(result, 'error/class', 'GenericError') - self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found') + self.assert_qmp(result, 'error/desc', "Can't find 'badfile' in the backing chain") def test_top_is_active(self): self.run_commit_test(self.test_img, self.backing_img) @@ -372,7 +372,7 @@ class TestRelativePaths(ImageCommitTestCase): self.assert_no_active_block_jobs() result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.backing_img, base='%s' % self.mid_img) self.assert_qmp(result, 'error/class', 'GenericError') - self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % self.mid_img) + self.assert_qmp(result, 'error/desc', "Can't find '%s' in the backing chain" % self.mid_img) class TestSetSpeed(ImageCommitTestCase): -- cgit v1.2.3-55-g7522 From 9272186d3dbfc770993195f480422fdf058896c5 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 13 Nov 2020 09:26:20 +0100 Subject: ui: Improve some set_passwd, expire_password error messages set_passwd and expire_password reject invalid "protocol" with "Invalid parameter 'protocol'". Misleading; the parameter is valid, its value isn't. Improve to "Parameter 'protocol' expects 'vnc' or 'spice'". expire_password fails with "Could not set password". Misleading; improve to "Could not set password expire time". QERR_SET_PASSWD_FAILED is now unused. Drop. Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Message-Id: <20201113082626.2725812-5-armbru@redhat.com> --- include/qapi/qmp/qerror.h | 3 --- monitor/qmp-cmds.c | 38 +++++++++++++++----------------------- 2 files changed, 15 insertions(+), 26 deletions(-) (limited to 'include/qapi/qmp/qerror.h') diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index 5d7e69cc1f..d8267129bc 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -65,9 +65,6 @@ #define QERR_REPLAY_NOT_SUPPORTED \ "Record/replay feature is not supported for '%s'" -#define QERR_SET_PASSWD_FAILED \ - "Could not set password" - #define QERR_UNDEFINED_ERROR \ "An undefined error has occurred" diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index a08143b323..ffbf948d55 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -199,13 +199,7 @@ void qmp_set_password(const char *protocol, const char *password, } rc = qemu_spice.set_passwd(password, fail_if_connected, disconnect_if_connected); - if (rc != 0) { - error_setg(errp, QERR_SET_PASSWD_FAILED); - } - return; - } - - if (strcmp(protocol, "vnc") == 0) { + } else if (strcmp(protocol, "vnc") == 0) { if (fail_if_connected || disconnect_if_connected) { /* vnc supports "connected=keep" only */ error_setg(errp, QERR_INVALID_PARAMETER, "connected"); @@ -214,13 +208,15 @@ void qmp_set_password(const char *protocol, const char *password, /* Note that setting an empty password will not disable login through * this interface. */ rc = vnc_display_password(NULL, password); - if (rc < 0) { - error_setg(errp, QERR_SET_PASSWD_FAILED); - } + } else { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", + "'vnc' or 'spice'"); return; } - error_setg(errp, QERR_INVALID_PARAMETER, "protocol"); + if (rc != 0) { + error_setg(errp, "Could not set password"); + } } void qmp_expire_password(const char *protocol, const char *whenstr, @@ -244,28 +240,24 @@ void qmp_expire_password(const char *protocol, const char *whenstr, return; } rc = qemu_spice.set_pw_expire(when); - if (rc != 0) { - error_setg(errp, QERR_SET_PASSWD_FAILED); - } - return; - } - - if (strcmp(protocol, "vnc") == 0) { + } else if (strcmp(protocol, "vnc") == 0) { rc = vnc_display_pw_expire(NULL, when); - if (rc != 0) { - error_setg(errp, QERR_SET_PASSWD_FAILED); - } + } else { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", + "'vnc' or 'spice'"); return; } - error_setg(errp, QERR_INVALID_PARAMETER, "protocol"); + if (rc != 0) { + error_setg(errp, "Could not set password expire time"); + } } #ifdef CONFIG_VNC void qmp_change_vnc_password(const char *password, Error **errp) { if (vnc_display_password(NULL, password) < 0) { - error_setg(errp, QERR_SET_PASSWD_FAILED); + error_setg(errp, "Could not set password"); } } -- cgit v1.2.3-55-g7522 From 9e1b9c6c2d909d399ced0379e7095716c611b0f9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 13 Nov 2020 09:26:21 +0100 Subject: ui: Improve a client_migrate_info error message client_migrate_info reports spice_server_migrate_connect() failure as "An undefined error has occurred". Improve to "Could not set up display for migration". QERR_UNDEFINED_ERROR is now unused. Drop. Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Message-Id: <20201113082626.2725812-6-armbru@redhat.com> --- include/qapi/qmp/qerror.h | 3 --- monitor/misc.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'include/qapi/qmp/qerror.h') diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index d8267129bc..596fce0c54 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -65,9 +65,6 @@ #define QERR_REPLAY_NOT_SUPPORTED \ "Record/replay feature is not supported for '%s'" -#define QERR_UNDEFINED_ERROR \ - "An undefined error has occurred" - #define QERR_UNSUPPORTED \ "this feature or command is not currently supported" diff --git a/monitor/misc.c b/monitor/misc.c index c563e901c0..bb102df823 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -441,7 +441,7 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname, has_port ? port : -1, has_tls_port ? tls_port : -1, cert_subject)) { - error_setg(errp, QERR_UNDEFINED_ERROR); + error_setg(errp, "Could not set up display for migration"); return; } return; -- cgit v1.2.3-55-g7522