Skip to contentSkip to conversation

tools/hv: reduce resouce usage in hv_kvp_daemon

PATCH In review Olaf Hering 2 participants 4 messages Dec 2, 2024 – Dec 9, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/hv: reduce resouce 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'.

---
 tools/hv/hv_kvp_daemon.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/hv/hv_kvp_daemon.c +3 -3
index ae57bf69ad4a..91b50cadfc52 100644
@@ -725,7 +725,7 @@ static void kvp_get_ipconfig_info(char *if_name,
 	 * .
 	 */
 
-	sprintf(cmd, KVP_SCRIPTS_PATH "%s",  "hv_get_dns_info");
+	sprintf(cmd, "exec %s", KVP_SCRIPTS_PATH "hv_get_dns_info");
 
 	/*
 	 * Execute the command to gather DNS info.
@@ -742,7 +742,7 @@ static void kvp_get_ipconfig_info(char *if_name,
 	 * Enabled: DHCP enabled.
 	 */
 
-	sprintf(cmd, KVP_SCRIPTS_PATH "%s %s", "hv_get_dhcp_info", if_name);
+	sprintf(cmd, "exec %s %s", KVP_SCRIPTS_PATH "hv_get_dhcp_info", if_name);
 
 	file = popen(cmd, "r");
 	if (file == NULL)
@@ -1606,7 +1606,7 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
 	 * invoke the external script to do its magic.
 	 */
 
-	str_len = snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s %s",
+	str_len = snprintf(cmd, sizeof(cmd), "exec %s %s %s", KVP_SCRIPTS_PATH
 			   "hv_set_ifconfig", if_filename, nm_filename);
 	/*
 	 * This is a little overcautious, but it's necessary to suppress some
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Olaf Hering

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'.

maintainer
#2 lore raw
Quoted 10 lines · Wei Liu
Quoted 7 lines · Olaf Hering

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'.

There's one conflict caused by an earlier patch by Vitaly. I've resolved the conflict and applied the patch to hyperv-fixes. Please check the final result.

Thanks,
Wei.

#3 lore raw

Sun, 8 Dec 2024 23:52:54 +0000 Wei Liu <[email protected]>:

Quoted 3 lines

There's one conflict caused by an earlier patch by Vitaly. I've resolved the conflict and applied the patch to hyperv-fixes. Please check the final result.

Commit b8ea8cd0fbd358feee3e9172c5ef8afd671e0d11 looks good, thanks.

Olaf