1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

lvmpolld-client.c: explain known return codes

lvmpolld returns few well known return codes. Explain
these to users and suggest reading lvmpolld log files
for more details
This commit is contained in:
Ondrej Kozina 2015-05-14 16:44:31 +02:00
parent 333fdfd4b6
commit 6cdd153b89

View File

@ -20,6 +20,7 @@
#include "metadata-exported.h" #include "metadata-exported.h"
#include "polldaemon.h" #include "polldaemon.h"
#include "toolcontext.h" #include "toolcontext.h"
#include "lvm2cmd.h"
struct progress_info { struct progress_info {
unsigned error:1; unsigned error:1;
@ -88,6 +89,33 @@ void lvmpolld_disconnect(void)
} }
} }
static void _explain_error_codes(int retcode)
{
switch (retcode) {
/* LVM2 return codes */
case LVM2_NO_SUCH_COMMAND:
log_error("LVM command run by lvmpolld responded with: 'No such command.'");
break;
case LVM2_INVALID_PARAMETERS:
log_error("LVM command run by lvmpolld failed due to invalid parameters.");
break;
case LVM2_PROCESSING_FAILED:
log_error("LVM command executed by lvmpolld failed.");
break;
/* lvmpolld specific return codes */
case LVMPD_RET_DUP_FAILED:
log_error("lvmpolld failed to duplicate file descriptors.");
case LVMPD_RET_EXC_FAILED:
log_error("lvmpolld failed to exec() lvm binary.");
break;
default:
log_error("lvmpolld responded with unexpected return code.");
}
log_print_unless_silent("For more information see lvmpolld messages in syslog or lvmpolld log file.");
}
static void _process_error_response(daemon_reply rep) static void _process_error_response(daemon_reply rep)
{ {
if (!strcmp(daemon_reply_str(rep, "response", ""), LVMPD_RESP_FAILED)) if (!strcmp(daemon_reply_str(rep, "response", ""), LVMPD_RESP_FAILED))
@ -102,7 +130,7 @@ static void _process_error_response(daemon_reply rep)
daemon_reply_str(rep, "response", "<empty>"), daemon_reply_str(rep, "response", "<empty>"),
daemon_reply_str(rep, "reason", "<empty>")); daemon_reply_str(rep, "reason", "<empty>"));
log_print_unless_silent("For more detailed information see lvmpolld log file."); log_print_unless_silent("For more information see lvmpolld messages in syslog or lvmpolld log file.");
} }
static struct progress_info _request_progress_info(const char *uuid, unsigned abort_polling) static struct progress_info _request_progress_info(const char *uuid, unsigned abort_polling)
@ -310,11 +338,10 @@ int lvmpolld_request_info(const struct poll_operation_id *id, const struct daemo
if (info.finished) { if (info.finished) {
if (info.cmd_signal) if (info.cmd_signal)
log_error("Polling command got terminated by signal (%d).", log_error("Command executed by lvmpolld got terminated by signal (%d).",
info.cmd_signal); info.cmd_signal);
else if (info.cmd_retcode) else if (info.cmd_retcode)
log_error("Polling command exited with return code: %d.", _explain_error_codes(info.cmd_retcode);
info.cmd_retcode);
else { else {
log_verbose("Polling finished successfully."); log_verbose("Polling finished successfully.");
ret = 1; ret = 1;