summaryrefslogtreecommitdiff
path: root/tools/hv/hv_kvp_daemon.c
diff options
context:
space:
mode:
authorTomas Hozza <thozza@redhat.com>2013-06-17 12:39:44 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-18 02:54:59 +0400
commit12e50c30545b74ca8b6ef7f442b826fed155193f (patch)
treea250f87fa7fe6c10ca9e1726fc065f12da0fdd2f /tools/hv/hv_kvp_daemon.c
parent0e496b8e84410c96d1ffc86f0b37b0328a4234da (diff)
downloadlinux-12e50c30545b74ca8b6ef7f442b826fed155193f.tar.xz
tools: hv: Improve error logging in KVP daemon.
Use errno and strerror() when logging errors to provide more information. Signed-off-by: Tomas Hozza <thozza@redhat.com> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/hv/hv_kvp_daemon.c')
-rw-r--r--tools/hv/hv_kvp_daemon.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index d55ce4040b74..ca9fa4d32e07 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -127,7 +127,8 @@ static void kvp_acquire_lock(int pool)
fl.l_pid = getpid();
if (fcntl(kvp_file_info[pool].fd, F_SETLKW, &fl) == -1) {
- syslog(LOG_ERR, "Failed to acquire the lock pool: %d", pool);
+ syslog(LOG_ERR, "Failed to acquire the lock pool: %d; error: %d %s", pool,
+ errno, strerror(errno));
exit(EXIT_FAILURE);
}
}
@@ -138,8 +139,8 @@ static void kvp_release_lock(int pool)
fl.l_pid = getpid();
if (fcntl(kvp_file_info[pool].fd, F_SETLK, &fl) == -1) {
- perror("fcntl");
- syslog(LOG_ERR, "Failed to release the lock pool: %d", pool);
+ syslog(LOG_ERR, "Failed to release the lock pool: %d; error: %d %s", pool,
+ errno, strerror(errno));
exit(EXIT_FAILURE);
}
}
@@ -157,8 +158,9 @@ static void kvp_update_file(int pool)
filep = fopen(kvp_file_info[pool].fname, "we");
if (!filep) {
+ syslog(LOG_ERR, "Failed to open file, pool: %d; error: %d %s", pool,
+ errno, strerror(errno));
kvp_release_lock(pool);
- syslog(LOG_ERR, "Failed to open file, pool: %d", pool);
exit(EXIT_FAILURE);
}
@@ -188,8 +190,9 @@ static void kvp_update_mem_state(int pool)
filep = fopen(kvp_file_info[pool].fname, "re");
if (!filep) {
+ syslog(LOG_ERR, "Failed to open file, pool: %d; error: %d %s", pool,
+ errno, strerror(errno));
kvp_release_lock(pool);
- syslog(LOG_ERR, "Failed to open file, pool: %d", pool);
exit(EXIT_FAILURE);
}
for (;;) {
@@ -240,7 +243,8 @@ static int kvp_file_init(void)
if (access(KVP_CONFIG_LOC, F_OK)) {
if (mkdir(KVP_CONFIG_LOC, 0755 /* rwxr-xr-x */)) {
- syslog(LOG_ERR, " Failed to create %s", KVP_CONFIG_LOC);
+ syslog(LOG_ERR, "Failed to create '%s'; error: %d %s", KVP_CONFIG_LOC,
+ errno, strerror(errno));
exit(EXIT_FAILURE);
}
}
@@ -1280,7 +1284,8 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
file = fopen(if_file, "w");
if (file == NULL) {
- syslog(LOG_ERR, "Failed to open config file");
+ syslog(LOG_ERR, "Failed to open config file; error: %d %s",
+ errno, strerror(errno));
return HV_E_FAIL;
}
@@ -1447,7 +1452,8 @@ int main(void)
fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
if (fd < 0) {
- syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd);
+ syslog(LOG_ERR, "netlink socket creation failed; error: %d %s", errno,
+ strerror(errno));
exit(EXIT_FAILURE);
}
addr.nl_family = AF_NETLINK;
@@ -1458,7 +1464,7 @@ int main(void)
error = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
if (error < 0) {
- syslog(LOG_ERR, "bind failed; error:%d", error);
+ syslog(LOG_ERR, "bind failed; error: %d %s", errno, strerror(errno));
close(fd);
exit(EXIT_FAILURE);
}
@@ -1484,7 +1490,7 @@ int main(void)
len = netlink_send(fd, message);
if (len < 0) {
- syslog(LOG_ERR, "netlink_send failed; error:%d", len);
+ syslog(LOG_ERR, "netlink_send failed; error: %d %s", errno, strerror(errno));
close(fd);
exit(EXIT_FAILURE);
}
@@ -1716,7 +1722,8 @@ kvp_done:
len = netlink_send(fd, incoming_cn_msg);
if (len < 0) {
- syslog(LOG_ERR, "net_link send failed; error:%d", len);
+ syslog(LOG_ERR, "net_link send failed; error: %d %s", errno,
+ strerror(errno));
exit(EXIT_FAILURE);
}
}