Skip to content

Commit

Permalink
Tools: hv: kvp: configurable external scripts path
Browse files Browse the repository at this point in the history
error when running hypervkvpd:
$ sudo ./hv_kvp_daemon -n

sh: hv_get_dns_info: command not found
sh: hv_get_dhcp_info: command not found
sh: hv_get_dns_info: command not found
sh: hv_get_dhcp_info: command not found

The external scripts are not installed in system path,
adding a configurable macro.

Signed-off-by: Alex Fluter <afluter@yandex.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Alex Fluter authored and Greg Kroah-Hartman committed Dec 6, 2016
1 parent 95096f2 commit 2eb72d4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tools/hv/hv_kvp_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ static struct utsname uts_buf;

#define KVP_CONFIG_LOC "/var/lib/hyperv"

#ifndef KVP_SCRIPTS_PATH
#define KVP_SCRIPTS_PATH "/usr/libexec/hypervkvpd/"
#endif

#define MAX_FILE_NAME 100
#define ENTRIES_PER_BLOCK 50

Expand Down Expand Up @@ -818,7 +822,7 @@ static void kvp_get_ipconfig_info(char *if_name,
* .
*/

sprintf(cmd, "%s", "hv_get_dns_info");
sprintf(cmd, KVP_SCRIPTS_PATH "%s", "hv_get_dns_info");

/*
* Execute the command to gather DNS info.
Expand All @@ -835,7 +839,7 @@ static void kvp_get_ipconfig_info(char *if_name,
* Enabled: DHCP enabled.
*/

sprintf(cmd, "%s %s", "hv_get_dhcp_info", if_name);
sprintf(cmd, KVP_SCRIPTS_PATH "%s %s", "hv_get_dhcp_info", if_name);

file = popen(cmd, "r");
if (file == NULL)
Expand Down Expand Up @@ -1341,7 +1345,8 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
* invoke the external script to do its magic.
*/

snprintf(cmd, sizeof(cmd), "%s %s", "hv_set_ifconfig", if_file);
snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s",
"hv_set_ifconfig", if_file);
if (system(cmd)) {
syslog(LOG_ERR, "Failed to execute cmd '%s'; error: %d %s",
cmd, errno, strerror(errno));
Expand Down

0 comments on commit 2eb72d4

Please sign in to comment.