Hello community,

here is the log from the commit of package hyper-v for openSUSE:Factory checked 
in at 2020-02-25 16:01:50
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/hyper-v (Old)
 and      /work/SRC/openSUSE:Factory/.hyper-v.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "hyper-v"

Tue Feb 25 16:01:50 2020 rev:41 rq:777742 version:7

Changes:
--------
--- /work/SRC/openSUSE:Factory/hyper-v/hyper-v.changes  2019-12-02 
11:38:07.370457923 +0100
+++ /work/SRC/openSUSE:Factory/.hyper-v.new.26092/hyper-v.changes       
2020-02-25 16:02:25.048107599 +0100
@@ -1,0 +2,6 @@
+Thu Feb 20 16:16:16 UTC 2020 - oher...@suse.de
+
+- Revert previous non-upstream change for async name resolution
+  Just use gethostname via hyper-v.kvp.gethostname.patch (bsc#1100758)
+
+-------------------------------------------------------------------

New:
----
  hyper-v.kvp.gethostname.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ hyper-v.spec ++++++
--- /var/tmp/diff_new_pack.SC5hrn/_old  2020-02-25 16:02:27.504113521 +0100
+++ /var/tmp/diff_new_pack.SC5hrn/_new  2020-02-25 16:02:27.508113531 +0100
@@ -61,7 +61,7 @@
 Source21:       hyper-v.tools.hv.hv_get_dns_info.sh
 Source22:       hyper-v.tools.hv.hv_set_ifconfig.sh
 
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+Patch0:         hyper-v.kvp.gethostname.patch
 
 %description
 This package contains the Microsoft Hyper-V tools.
@@ -70,9 +70,11 @@
 %setup -Tc
 cp -avL %{S:5} kvptest.ps1.txt
 cp -vL %{S:9} %{hv_kvp_daemon}.h
-cp -vL %{S:10} %{hv_kvp_daemon}.c
+cp -vL %{S:10} .
 cp -vL %{S:12} %{hv_vss_daemon}.c
 cp -vL %{S:14} %{hv_fcopy_daemon}.c
+%patch0 -p1
+mv `basename %{S:10}` %{hv_kvp_daemon}.c
 
 %build
 sed -i~ '/#include <linux.hyperv.h>/d' %{hv_kvp_daemon}.c
@@ -237,7 +239,6 @@
 %endif
 
 %files
-%defattr (-,root,root)
 %doc kvptest.ps1.txt
 %if %{use_systemd}
 %{_unitdir}

++++++ hyper-v.kvp.gethostname.patch ++++++
--- a/hyper-v.tools.hv.hv_kvp_daemon.c
+++ b/hyper-v.tools.hv.hv_kvp_daemon.c
@@ -1335,6 +1335,7 @@ kvp_get_domain_name(char *buffer, int le
        struct addrinfo hints, *info ;
        int error = 0;
 
+       return;
        gethostname(buffer, length);
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = AF_INET; /*Get only ipv4 addrinfo. */
@@ -1572,6 +1573,12 @@ int main(int argc, char *argv[])
 
                switch (hv_msg->body.kvp_enum_data.index) {
                case FullyQualifiedDomainName:
+                       /*
+                        * The API is undocumented.
+                        * The Host can not possibly care about DNS within the 
guest network
+                        * The time it takes to get the hostname is much 
shorter than a DNS lookup.
+                        */
+                       gethostname(full_domain_name, sizeof(full_domain_name));
                        strcpy(key_value, full_domain_name);
                        strcpy(key_name, "FullyQualifiedDomainName");
                        break;
++++++ hyper-v.tools.hv.hv_kvp_daemon.c ++++++
--- /var/tmp/diff_new_pack.SC5hrn/_old  2020-02-25 16:02:27.608113771 +0100
+++ /var/tmp/diff_new_pack.SC5hrn/_new  2020-02-25 16:02:27.608113771 +0100
@@ -41,7 +41,6 @@
 #include <net/if.h>
 #include <limits.h>
 #include <getopt.h>
-#include <pthread.h>
 
 /*
  * KVP protocol: The user mode component first registers with the
@@ -86,7 +85,7 @@
 static char *os_build;
 static char *os_version;
 static char *lic_version = "Unknown version";
-static char *full_domain_name;
+static char full_domain_name[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
 static struct utsname uts_buf;
 
 /*
@@ -1329,76 +1328,27 @@
        return error;
 }
 
-/*
- * Async retrival of Fully Qualified Domain Name because getaddrinfo takes an
- * unpredictable amount of time to finish.
- */
-static void *kvp_getaddrinfo(void *p)
-{
-       char *tmp, **str_ptr = (char **)p;
-       char hostname[HOST_NAME_MAX + 1];
-       struct addrinfo *info, hints = {
-               .ai_family = AF_INET, /* Get only ipv4 addrinfo. */
-               .ai_socktype = SOCK_STREAM,
-               .ai_flags = AI_CANONNAME,
-       };
-       int ret;
-       int prev_ret = 0, cnt = 5;
-
-       do {
-               if (gethostname(hostname, sizeof(hostname) - 1) < 0)
-                       goto out;
-
-               ret = getaddrinfo(hostname, NULL, &hints, &info);
-               switch (ret) {
-               case 0:
-                       break;
-               case EAI_BADFLAGS:
-               case EAI_MEMORY:
-               case EAI_OVERFLOW:
-               case EAI_SOCKTYPE:
-               case EAI_SYSTEM:
-                       /* Permanent failure */
-                       syslog(LOG_ERR, "getaddrinfo failed: %d %s",
-                               ret, gai_strerror(ret));
-                       goto out;
-               default:
-                       /* runtime debug */
-                       if (cnt) {
-                               if (prev_ret != ret) {
-                                       prev_ret = ret;
-                                       syslog(LOG_ERR, "getaddrinfo warning: 
%d %s", ret, gai_strerror(ret));
-                                       cnt--;
-                               }
-                       }
-                       /* Temporary failure, aim for success. */
-                       sleep(5);
-               }
-       } while (ret);
 
-       ret = asprintf(&tmp, "%s", info->ai_canonname);
-       freeaddrinfo(info);
-       if (ret <= 0)
-               goto out;
-
-       if (ret > HV_KVP_EXCHANGE_MAX_VALUE_SIZE)
-               tmp[HV_KVP_EXCHANGE_MAX_VALUE_SIZE - 1] = '\0';
-       *str_ptr = tmp;
-
-out:
-       pthread_exit(NULL);
-}
-
-static void kvp_obtain_domain_name(char **str_ptr)
+static void
+kvp_get_domain_name(char *buffer, int length)
 {
-       pthread_t t;
+       struct addrinfo hints, *info ;
+       int error = 0;
 
-       if (pthread_create(&t, NULL, kvp_getaddrinfo, str_ptr)) {
-               syslog(LOG_ERR, "pthread_create failed; error: %d %s",
-                       errno, strerror(errno));
+       gethostname(buffer, length);
+       memset(&hints, 0, sizeof(hints));
+       hints.ai_family = AF_INET; /*Get only ipv4 addrinfo. */
+       hints.ai_socktype = SOCK_STREAM;
+       hints.ai_flags = AI_CANONNAME;
+
+       error = getaddrinfo(buffer, NULL, &hints, &info);
+       if (error != 0) {
+               snprintf(buffer, length, "getaddrinfo failed: 0x%x %s",
+                       error, gai_strerror(error));
                return;
        }
-       pthread_detach(t);
+       snprintf(buffer, length, "%s", info->ai_canonname);
+       freeaddrinfo(info);
 }
 
 void print_usage(char *argv[])
@@ -1463,7 +1413,11 @@
         * Retrieve OS release information.
         */
        kvp_get_os_info();
-       kvp_obtain_domain_name(&full_domain_name);
+       /*
+        * Cache Fully Qualified Domain Name because getaddrinfo takes an
+        * unpredictable amount of time to finish.
+        */
+       kvp_get_domain_name(full_domain_name, sizeof(full_domain_name));
 
        if (kvp_file_init()) {
                syslog(LOG_ERR, "Failed to initialize the pools");
@@ -1618,7 +1572,7 @@
 
                switch (hv_msg->body.kvp_enum_data.index) {
                case FullyQualifiedDomainName:
-                       strcpy(key_value, full_domain_name ? : "");
+                       strcpy(key_value, full_domain_name);
                        strcpy(key_name, "FullyQualifiedDomainName");
                        break;
                case IntegrationServicesVersion:


Reply via email to