Skip to content

Commit 175c71c

Browse files
olafheringliuw
authored andcommitted
tools/hv: reduce resource usage in hv_kvp_daemon
hv_kvp_daemon uses popen(3) and system(3) as convinience helper to launch external helpers. These helpers are invoked via a temporary shell process. There is no need to keep this temporary process around while the helper runs. Replace this temporary shell with the actual helper process via 'exec'. Signed-off-by: Olaf Hering <[email protected]> Link: https://lore.kernel.org/linux-hyperv/[email protected]/ Signed-off-by: Wei Liu <[email protected]>
1 parent becc7fe commit 175c71c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tools/hv/hv_kvp_daemon.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ static void kvp_get_ipconfig_info(char *if_name,
725725
* .
726726
*/
727727

728-
sprintf(cmd, KVP_SCRIPTS_PATH "%s %s", "hv_get_dns_info", if_name);
728+
sprintf(cmd, "exec %s %s", KVP_SCRIPTS_PATH "hv_get_dns_info", if_name);
729729

730730
/*
731731
* Execute the command to gather DNS info.
@@ -742,7 +742,7 @@ static void kvp_get_ipconfig_info(char *if_name,
742742
* Enabled: DHCP enabled.
743743
*/
744744

745-
sprintf(cmd, KVP_SCRIPTS_PATH "%s %s", "hv_get_dhcp_info", if_name);
745+
sprintf(cmd, "exec %s %s", KVP_SCRIPTS_PATH "hv_get_dhcp_info", if_name);
746746

747747
file = popen(cmd, "r");
748748
if (file == NULL)
@@ -1606,8 +1606,9 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
16061606
* invoke the external script to do its magic.
16071607
*/
16081608

1609-
str_len = snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s %s",
1610-
"hv_set_ifconfig", if_filename, nm_filename);
1609+
str_len = snprintf(cmd, sizeof(cmd), "exec %s %s %s",
1610+
KVP_SCRIPTS_PATH "hv_set_ifconfig",
1611+
if_filename, nm_filename);
16111612
/*
16121613
* This is a little overcautious, but it's necessary to suppress some
16131614
* false warnings from gcc 8.0.1.

0 commit comments

Comments
 (0)