Accepting request 777742 from Virtualization
- Revert previous non-upstream change for async name resolution Just use gethostname via hyper-v.kvp.gethostname.patch (bsc#1100758) OBS-URL: https://build.opensuse.org/request/show/777742 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/hyper-v?expand=0&rev=41
This commit is contained in:
commit
4e410e2b00
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Feb 20 16:16:16 UTC 2020 - ohering@suse.de
|
||||||
|
|
||||||
|
- Revert previous non-upstream change for async name resolution
|
||||||
|
Just use gethostname via hyper-v.kvp.gethostname.patch (bsc#1100758)
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Nov 29 16:41:25 UTC 2019 - ohering@suse.de
|
Fri Nov 29 16:41:25 UTC 2019 - ohering@suse.de
|
||||||
|
|
||||||
|
23
hyper-v.kvp.gethostname.patch
Normal file
23
hyper-v.kvp.gethostname.patch
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
--- 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;
|
@ -61,7 +61,7 @@ Source20: hyper-v.tools.hv.hv_get_dhcp_info.sh
|
|||||||
Source21: hyper-v.tools.hv.hv_get_dns_info.sh
|
Source21: hyper-v.tools.hv.hv_get_dns_info.sh
|
||||||
Source22: hyper-v.tools.hv.hv_set_ifconfig.sh
|
Source22: hyper-v.tools.hv.hv_set_ifconfig.sh
|
||||||
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
Patch0: hyper-v.kvp.gethostname.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
This package contains the Microsoft Hyper-V tools.
|
This package contains the Microsoft Hyper-V tools.
|
||||||
@ -70,9 +70,11 @@ This package contains the Microsoft Hyper-V tools.
|
|||||||
%setup -Tc
|
%setup -Tc
|
||||||
cp -avL %{S:5} kvptest.ps1.txt
|
cp -avL %{S:5} kvptest.ps1.txt
|
||||||
cp -vL %{S:9} %{hv_kvp_daemon}.h
|
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:12} %{hv_vss_daemon}.c
|
||||||
cp -vL %{S:14} %{hv_fcopy_daemon}.c
|
cp -vL %{S:14} %{hv_fcopy_daemon}.c
|
||||||
|
%patch0 -p1
|
||||||
|
mv `basename %{S:10}` %{hv_kvp_daemon}.c
|
||||||
|
|
||||||
%build
|
%build
|
||||||
sed -i~ '/#include <linux.hyperv.h>/d' %{hv_kvp_daemon}.c
|
sed -i~ '/#include <linux.hyperv.h>/d' %{hv_kvp_daemon}.c
|
||||||
@ -237,7 +239,6 @@ ln -sfvbn ../../etc/init.d/%{hv_fcopy_daemon} $RPM_BUILD_ROOT${bindir}/rc%{hv_fc
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr (-,root,root)
|
|
||||||
%doc kvptest.ps1.txt
|
%doc kvptest.ps1.txt
|
||||||
%if %{use_systemd}
|
%if %{use_systemd}
|
||||||
%{_unitdir}
|
%{_unitdir}
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* KVP protocol: The user mode component first registers with the
|
* KVP protocol: The user mode component first registers with the
|
||||||
@ -86,7 +85,7 @@ static char *processor_arch;
|
|||||||
static char *os_build;
|
static char *os_build;
|
||||||
static char *os_version;
|
static char *os_version;
|
||||||
static char *lic_version = "Unknown 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;
|
static struct utsname uts_buf;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1329,76 +1328,27 @@ setval_error:
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Async retrival of Fully Qualified Domain Name because getaddrinfo takes an
|
static void
|
||||||
* unpredictable amount of time to finish.
|
kvp_get_domain_name(char *buffer, int length)
|
||||||
*/
|
|
||||||
static void *kvp_getaddrinfo(void *p)
|
|
||||||
{
|
{
|
||||||
char *tmp, **str_ptr = (char **)p;
|
struct addrinfo hints, *info ;
|
||||||
char hostname[HOST_NAME_MAX + 1];
|
int error = 0;
|
||||||
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 {
|
gethostname(buffer, length);
|
||||||
if (gethostname(hostname, sizeof(hostname) - 1) < 0)
|
memset(&hints, 0, sizeof(hints));
|
||||||
goto out;
|
hints.ai_family = AF_INET; /*Get only ipv4 addrinfo. */
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_flags = AI_CANONNAME;
|
||||||
|
|
||||||
ret = getaddrinfo(hostname, NULL, &hints, &info);
|
error = getaddrinfo(buffer, NULL, &hints, &info);
|
||||||
switch (ret) {
|
if (error != 0) {
|
||||||
case 0:
|
snprintf(buffer, length, "getaddrinfo failed: 0x%x %s",
|
||||||
break;
|
error, gai_strerror(error));
|
||||||
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)
|
|
||||||
{
|
|
||||||
pthread_t t;
|
|
||||||
|
|
||||||
if (pthread_create(&t, NULL, kvp_getaddrinfo, str_ptr)) {
|
|
||||||
syslog(LOG_ERR, "pthread_create failed; error: %d %s",
|
|
||||||
errno, strerror(errno));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pthread_detach(t);
|
snprintf(buffer, length, "%s", info->ai_canonname);
|
||||||
|
freeaddrinfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_usage(char *argv[])
|
void print_usage(char *argv[])
|
||||||
@ -1463,7 +1413,11 @@ int main(int argc, char *argv[])
|
|||||||
* Retrieve OS release information.
|
* Retrieve OS release information.
|
||||||
*/
|
*/
|
||||||
kvp_get_os_info();
|
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()) {
|
if (kvp_file_init()) {
|
||||||
syslog(LOG_ERR, "Failed to initialize the pools");
|
syslog(LOG_ERR, "Failed to initialize the pools");
|
||||||
@ -1618,7 +1572,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
switch (hv_msg->body.kvp_enum_data.index) {
|
switch (hv_msg->body.kvp_enum_data.index) {
|
||||||
case FullyQualifiedDomainName:
|
case FullyQualifiedDomainName:
|
||||||
strcpy(key_value, full_domain_name ? : "");
|
strcpy(key_value, full_domain_name);
|
||||||
strcpy(key_name, "FullyQualifiedDomainName");
|
strcpy(key_name, "FullyQualifiedDomainName");
|
||||||
break;
|
break;
|
||||||
case IntegrationServicesVersion:
|
case IntegrationServicesVersion:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user