Skip to contentSkip to conversation

tools/hv: async name resolution in kvp_daemon

PATCH In review Olaf Hering 1 participant 3 messages Nov 13, 2019 – Jan 3, 2020

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

PATCH v2 1/1 tools/hv: async name resolution in kvp_daemon

The hostname is resolved just once since commit 58125210ab3b ("Tools:
hv: cache FQDN in kvp_daemon to avoid timeouts") to make sure the VM responds within the timeout limits to requests from the host.

If for some reason getaddrinfo fails, the string returned by the "FullyQualifiedDomainName" request contains some error string, which is then used by tools on the host side.

Adjust the code to resolve the current hostname in a separate thread. This thread loops until getaddrinfo returns success. During this time all "FullyQualifiedDomainName" requests will be answered with an empty string.

---

v2:
- link with -pthread instead of -lpthread
- consider some errors from getaddrinfo fatal, log them via syslog
- update also hostname in the loop

 tools/hv/Makefile        |  2 ++
 tools/hv/hv_kvp_daemon.c | 83 ++++++++++++++++++++++++++++++++++--------------
 2 files changed, 62 insertions(+), 23 deletions(-)
tools/hv/Makefile +2 -0
index b57143d9459c..9bbab96ac06d 100644
@@ -22,6 +22,8 @@ ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
 
 ALL_SCRIPTS := hv_get_dhcp_info.sh hv_get_dns_info.sh hv_set_ifconfig.sh
 
+$(OUTPUT)hv_kvp_daemon: LDFLAGS += -pthread
+
 all: $(ALL_PROGRAMS)
 
 export srctree OUTPUT CC LD CFLAGS
tools/hv/hv_kvp_daemon.c +60 -23

118 lines not on this page · raw message

#1 lore raw

Am Wed, 13 Nov 2019 16:54:00 +0100
schrieb Olaf Hering <[email protected]>:

tools/hv/hv_kvp_daemon.c int main(int argc, char *argv[]) · line 1612

Quoted 5 lines

During this time all "FullyQualifiedDomainName" requests will be answered with an empty string.

tools/hv/hv_kvp_daemon.c +1 -0
+			strcpy(key_value, full_domain_name ? : "");
 			strcpy(key_name, "FullyQualifiedDomainName");

KY, Haiyang, Stephen,

please check if the host side can actually handle such temporary, empty string. If the tools cache the first result, the implemented approach can not work. If that is indeed the case, is there some sort of -ERETRY in the protocol?

Olaf

#2 lore raw
In reply to Olaf Hering

Am Wed, 13 Nov 2019 16:54:00 +0100
schrieb Olaf Hering <[email protected]>:

Quoted 1 line

Adjust the code to resolve the current hostname in a separate thread.

Are you now finally able to compile the patch?
Did you find some documentation about the host-side API of the "FullyQualifiedDomainName" request? Any further comments about the "aim for success" approach?

Thanks,
Olaf