linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] tools/hv: reduce resouce usage in hv_kvp_daemon
@ 2024-12-02 12:35 Olaf Hering
  2024-12-07  7:18 ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Olaf Hering @ 2024-12-02 12:35 UTC (permalink / raw)
  To: linux-hyperv, linux-kernel
  Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui

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 <olaf@aepfle.de>
---
 tools/hv/hv_kvp_daemon.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index ae57bf69ad4a..91b50cadfc52 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] tools/hv: reduce resouce usage in hv_kvp_daemon
  2024-12-02 12:35 [PATCH v1] tools/hv: reduce resouce usage in hv_kvp_daemon Olaf Hering
@ 2024-12-07  7:18 ` Wei Liu
  2024-12-08 23:52   ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2024-12-07  7:18 UTC (permalink / raw)
  To: Olaf Hering
  Cc: linux-hyperv, linux-kernel, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui

On Mon, Dec 02, 2024 at 01:35:16PM +0100, Olaf Hering wrote:
> 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 <olaf@aepfle.de>

Acked-by: Wei Liu <wei.liu@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] tools/hv: reduce resouce usage in hv_kvp_daemon
  2024-12-07  7:18 ` Wei Liu
@ 2024-12-08 23:52   ` Wei Liu
  2024-12-09  7:51     ` Olaf Hering
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2024-12-08 23:52 UTC (permalink / raw)
  To: Olaf Hering
  Cc: linux-hyperv, linux-kernel, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui

On Sat, Dec 07, 2024 at 07:18:17AM +0000, Wei Liu wrote:
> On Mon, Dec 02, 2024 at 01:35:16PM +0100, Olaf Hering wrote:
> > 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 <olaf@aepfle.de>
> 
> Acked-by: Wei Liu <wei.liu@kernel.org>

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] tools/hv: reduce resouce usage in hv_kvp_daemon
  2024-12-08 23:52   ` Wei Liu
@ 2024-12-09  7:51     ` Olaf Hering
  0 siblings, 0 replies; 4+ messages in thread
From: Olaf Hering @ 2024-12-09  7:51 UTC (permalink / raw)
  To: Wei Liu
  Cc: linux-hyperv, linux-kernel, K. Y. Srinivasan, Haiyang Zhang,
	Dexuan Cui

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

Sun, 8 Dec 2024 23:52:54 +0000 Wei Liu <wei.liu@kernel.org>:

> 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

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-09  7:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-02 12:35 [PATCH v1] tools/hv: reduce resouce usage in hv_kvp_daemon Olaf Hering
2024-12-07  7:18 ` Wei Liu
2024-12-08 23:52   ` Wei Liu
2024-12-09  7:51     ` Olaf Hering

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).