[hyperv-daemons/f20] Initial SRPM import

Tomas Hozza thozza at fedoraproject.org
Wed Sep 4 14:20:58 UTC 2013


commit 8e8f9a7b031aca6062ef37f733929b89679f8f00
Author: Tomas Hozza <thozza at redhat.com>
Date:   Wed Sep 4 16:12:40 2013 +0200

    Initial SRPM import
    
    Signed-off-by: Tomas Hozza <thozza at redhat.com>

 .gitignore                                         |    6 +
 hyperv-daemons.spec                                |  229 ++++++++++++++++++++
 ...vpd-0-corrected_paths_to_external_scripts.patch |   45 ++++
 hypervkvpd-0-dont_call_deamon.patch                |   12 +
 hypervkvpd-0-include_fix.patch                     |   21 ++
 hypervkvpd-0-long_file_names_from_readdir.patch    |   92 ++++++++
 hypervkvpd.service                                 |   10 +
 hypervvssd-0-dont_call_daemon.patch                |   13 ++
 hypervvssd-0-fix_includes.patch                    |   12 +
 hypervvssd.service                                 |    9 +
 sources                                            |    6 +
 11 files changed, 455 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..864fce1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,6 @@
+/hv_get_dhcp_info.sh
+/hv_get_dns_info.sh
+/hv_kvp_daemon.c
+/hv_set_ifconfig.sh
+/hv_vss_daemon.c
+/COPYING
diff --git a/hyperv-daemons.spec b/hyperv-daemons.spec
new file mode 100644
index 0000000..676b91a
--- /dev/null
+++ b/hyperv-daemons.spec
@@ -0,0 +1,229 @@
+# HyperV KVP daemon binary name
+%global hv_kvp_daemon hypervkvpd
+# HyperV VSS daemon binary name
+%global hv_vss_daemon hypervvssd
+# snapshot version
+%global snapver .20130826git
+# use hardened build
+%global _hardened_build 1
+
+Name:     hyperv-daemons
+Version:  0
+Release:  0.1%{?snapver}%{?dist}
+Summary:  HyperV daemons suite
+
+Group:    System Environment/Daemons
+License:  GPLv2
+URL:      http://www.kernel.org
+
+# Source files obtained from kernel upstream 2013-08-26.
+# git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
+# The daemon and scripts are located in "master branch - /tools/hv"
+# COPYING -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/COPYING?id=refs/tags/next-20130822 
+Source0:  COPYING
+
+# HYPERV KVP DAEMON
+# hv_kvp_daemon.c -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/tools/hv/hv_kvp_daemon.c?id=refs/tags/next-20130822
+Source1:  hv_kvp_daemon.c
+# hv_get_dhcp_info.sh -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/tools/hv/hv_get_dhcp_info.sh?id=refs/tags/next-20130822
+Source2:  hv_get_dhcp_info.sh
+# hv_get_dns_info.sh -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/tools/hv/hv_get_dns_info.sh?id=refs/tags/next-20130822
+Source3:  hv_get_dns_info.sh
+# hv_set_ifconfig.sh -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/tools/hv/hv_set_ifconfig.sh?id=refs/tags/next-20130822
+Source4:  hv_set_ifconfig.sh
+Source5:  hypervkvpd.service
+
+# HYPERV VSS DAEMON
+# hv_vss_daemon.c -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/tools/hv/hv_vss_daemon.c?id=refs/tags/next-20130822
+Source100:  hv_vss_daemon.c
+Source101:  hypervvssd.service
+
+# HYPERV KVP DAEMON
+# Correct paths to external scripts ("/usr/libexec/hypervkvpd").
+Patch0:   hypervkvpd-0-corrected_paths_to_external_scripts.patch
+# use quoted include for linux/hyperv.h because we use gcc option
+# -iquote for include PATH where it is located. This is because
+# some headers in system include PATH are also in kernel-devel
+# package.
+Patch1:   hypervkvpd-0-include_fix.patch
+# rhbz#872566
+Patch2:   hypervkvpd-0-long_file_names_from_readdir.patch
+# Remove daemon() call and let systemd handle it
+Patch3:   hypervkvpd-0-dont_call_deamon.patch
+
+# HYPERV VSS DAEMON
+# use quoted include for linux/hyperv.h because we use gcc option
+# -iquote for include PATH where it is located. This is because
+# some headers in system include PATH are also in kernel-devel
+# package.
+Patch100:   hypervvssd-0-fix_includes.patch
+# Remove daemon() call and let systemd handle it
+Patch101:   hypervvssd-0-dont_call_daemon.patch
+
+BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+# HyperV is available only on x86 architectures
+ExclusiveArch:  i686 x86_64
+Requires:       hypervkvpd = %{version}-%{release}
+Requires:       hypervvssd = %{version}-%{release}
+
+%description
+Suite of daemons that are needed when Linux guest
+is running on Windows Host with HyperV.
+
+
+%package -n hypervkvpd
+Summary: HyperV key value pair (KVP) daemon
+Group:   System Environment/Daemons
+Requires: %{name}-license = %{version}-%{release}
+BuildRequires: systemd, kernel-devel
+Requires(post):   systemd
+Requires(preun):  systemd
+Requires(postun): systemd
+
+%description -n hypervkvpd
+Hypervkvpd is an implementation of HyperV key value pair (KVP) 
+functionality for Linux. The daemon first registers with the
+kernel driver. After this is done it collects information 
+requested by Windows Host about the Linux Guest. It also supports
+IP injection functionality on the Guest.
+
+
+%package -n hypervvssd
+Summary: HyperV VSS daemon
+Group:   System Environment/Daemons
+Requires: %{name}-license = %{version}-%{release}
+BuildRequires: systemd, kernel-devel
+Requires(post):   systemd
+Requires(preun):  systemd
+Requires(postun): systemd
+
+%description -n hypervvssd
+Hypervvssd is an implementation of HyperV VSS functionality
+for Linux. The daemon is used for host initiated guest snapshot
+on HyperV hypervisor. The daemon first registers with the
+kernel driver. After this is done it waits for instructions 
+from Windows Host if to "freeze" or "thaw" the filesystem
+on the Linux Guest.
+
+
+%package license
+Summary:    License of the HyperV daemons suite
+Group:      Applications/System
+BuildArch:  noarch
+
+%description license
+Contains license of the HyperV daemons suite.
+
+
+%prep
+%setup -Tc
+cp -pvL %{SOURCE0} COPYING
+
+cp -pvL %{SOURCE1} hv_kvp_daemon.c
+cp -pvL %{SOURCE2} hv_get_dhcp_info.sh
+cp -pvL %{SOURCE3} hv_get_dns_info.sh
+cp -pvL %{SOURCE4} hv_set_ifconfig.sh
+cp -pvL %{SOURCE5} hypervkvpd.service
+
+cp -pvL %{SOURCE100} hv_vss_daemon.c
+cp -pvL %{SOURCE101} hypervvssd.service
+
+%patch0 -p1 -b .external_scripts
+%patch1 -p1 -b .include
+%patch2 -p1 -b .long_names
+%patch3 -p1 -b .daemon
+
+%patch100 -p1 -b .include
+%patch101 -p1 -b .daemon
+
+
+%build
+# kernel-devel version
+%{!?kversion: %global kversion `ls %{_usrsrc}/kernels | sort -dr | head -n 1`}
+
+# HYPERV KVP DAEMON
+gcc \
+    $RPM_OPT_FLAGS \
+    -iquote %{_usrsrc}/kernels/%{kversion}/include \
+    -c hv_kvp_daemon.c
+    
+gcc \
+    $RPM_LD_FLAGS \
+    hv_kvp_daemon.o \
+    -o %{hv_kvp_daemon}
+
+# HYPERV VSS DAEMON
+gcc \
+    $RPM_OPT_FLAGS \
+    -iquote %{_usrsrc}/kernels/%{kversion}/include \
+    -c hv_vss_daemon.c
+    
+gcc \
+    $RPM_LD_FLAGS \
+    hv_vss_daemon.o \
+    -o %{hv_vss_daemon}
+
+
+%install
+rm -rf %{buildroot}
+
+mkdir -p %{buildroot}%{_sbindir}
+install -p -m 0755 %{hv_kvp_daemon} %{buildroot}%{_sbindir}
+install -p -m 0755 %{hv_vss_daemon} %{buildroot}%{_sbindir}
+mkdir -p %{buildroot}%{_unitdir}
+# Systemd unit file
+install -p -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}
+install -p -m 0644 %{SOURCE101} %{buildroot}%{_unitdir}
+# Shell scripts for the daemon
+mkdir -p %{buildroot}%{_libexecdir}/%{name}
+install -p -m 0755 hv_get_dhcp_info.sh %{buildroot}%{_libexecdir}/%{name}/hv_get_dhcp_info
+install -p -m 0755 hv_get_dns_info.sh %{buildroot}%{_libexecdir}/%{name}/hv_get_dns_info
+install -p -m 0755 hv_set_ifconfig.sh %{buildroot}%{_libexecdir}/%{name}/hv_set_ifconfig
+# Directory for pool files
+mkdir -p %{buildroot}%{_sharedstatedir}/hyperv
+
+
+%post -n hypervkvpd
+%systemd_post hypervkvpd.service
+
+%preun -n hypervkvpd
+%systemd_preun hypervkvpd.service
+
+%postun -n hypervkvpd
+# hypervkvpd daemon does NOT support restarting (driver, neither)
+%systemd_postun hypervkvpd.service
+# If removing the package, delete %%{_sharedstatedir}/hyperv directory
+if [ "$1" -eq "0" ] ; then
+    rm -rf %{_sharedstatedir}/hyperv || :
+fi
+
+
+%post -n hypervvssd
+%systemd_post hypervvssd.service
+
+%postun -n hypervvssd
+%systemd_postun hypervvssd.service
+
+%preun -n hypervvssd
+%systemd_preun hypervvssd.service
+
+
+%files -n hypervkvpd
+%{_sbindir}/%{hv_kvp_daemon}
+%{_unitdir}/hypervkvpd.service
+%dir %{_libexecdir}/%{name}
+%{_libexecdir}/%{name}/hv_get_dhcp_info
+%{_libexecdir}/%{name}/hv_get_dns_info
+%{_libexecdir}/%{name}/hv_set_ifconfig
+%dir %{_sharedstatedir}/hyperv
+
+%files -n hypervvssd
+%{_sbindir}/%{hv_vss_daemon}
+%{_unitdir}/hypervvssd.service
+
+%files license
+%doc COPYING
+
+%changelog
+* Mon Aug 26 2013 Tomas Hozza <thozza at redhat.com> - 0-0.1.20130826git
+- Initial package
diff --git a/hypervkvpd-0-corrected_paths_to_external_scripts.patch b/hypervkvpd-0-corrected_paths_to_external_scripts.patch
new file mode 100644
index 0000000..64463e9
--- /dev/null
+++ b/hypervkvpd-0-corrected_paths_to_external_scripts.patch
@@ -0,0 +1,45 @@
+From c8cec9f3f9c34aa824e652a01ae08e7e7a621daa Mon Sep 17 00:00:00 2001
+From: Tomas Hozza <thozza at redhat.com>
+Date: Wed, 26 Sep 2012 10:26:55 +0200
+Subject: [PATCH] Corrected paths to hypervkvpd external scripts.
+
+Corrected paths to hypervkvpd external scripts, because
+they will be located in "/usr/libexec/hypervkvpd".
+---
+ hv_kvp_daemon.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/hv_kvp_daemon.c b/hv_kvp_daemon.c
+index 5959aff..3ea3af2 100644
+--- a/hv_kvp_daemon.c
++++ b/hv_kvp_daemon.c
+@@ -812,7 +812,7 @@ static void kvp_get_ipconfig_info(char *if_name,
+ 	 * .
+ 	 */
+ 
+-	sprintf(cmd, "%s",  "hv_get_dns_info");
++	sprintf(cmd, "%s",  "/usr/libexec/hypervkvpd/hv_get_dns_info");
+ 
+ 	/*
+ 	 * Execute the command to gather DNS info.
+@@ -829,7 +829,7 @@ static void kvp_get_ipconfig_info(char *if_name,
+ 	 * Enabled: DHCP enabled.
+ 	 */
+ 
+-	sprintf(cmd, "%s %s", "hv_get_dhcp_info", if_name);
++	sprintf(cmd, "%s %s", "/usr/libexec/hypervkvpd/hv_get_dhcp_info", if_name);
+ 
+ 	file = popen(cmd, "r");
+ 	if (file == NULL)
+@@ -1331,7 +1331,7 @@ setval_done:
+ 	 * invoke the external script to do its magic.
+ 	 */
+ 
+-	snprintf(cmd, sizeof(cmd), "%s %s", "hv_set_ifconfig", if_file);
++	snprintf(cmd, sizeof(cmd), "%s %s", "/usr/libexec/hypervkvpd/hv_set_ifconfig", if_file);
+ 	if (system(cmd)) {
+ 		syslog(LOG_ERR, "Failed to execute cmd '%s'; error: %d %s",
+ 				cmd, errno, strerror(errno));
+-- 
+1.7.11.4
+
diff --git a/hypervkvpd-0-dont_call_deamon.patch b/hypervkvpd-0-dont_call_deamon.patch
new file mode 100644
index 0000000..02822ba
--- /dev/null
+++ b/hypervkvpd-0-dont_call_deamon.patch
@@ -0,0 +1,12 @@
+diff -up hypervkvpd-0/hv_kvp_daemon.c.daemon hypervkvpd-0/hv_kvp_daemon.c
+--- hypervkvpd-0/hv_kvp_daemon.c.daemon	2013-08-09 10:51:41.020041192 +0200
++++ hypervkvpd-0/hv_kvp_daemon.c	2013-08-09 10:53:23.217056215 +0200
+@@ -1434,8 +1434,6 @@ int main(void)
+ 	char *kvp_recv_buffer;
+ 	size_t kvp_recv_buffer_len;
+ 
+-	if (daemon(1, 0))
+-		return 1;
+ 	openlog("KVP", 0, LOG_USER);
+ 	syslog(LOG_INFO, "KVP starting; pid is:%d", getpid());
+ 
diff --git a/hypervkvpd-0-include_fix.patch b/hypervkvpd-0-include_fix.patch
new file mode 100644
index 0000000..736396c
--- /dev/null
+++ b/hypervkvpd-0-include_fix.patch
@@ -0,0 +1,21 @@
+diff -up hypervkvpd-0/hv_kvp_daemon.c.include hypervkvpd-0/hv_kvp_daemon.c
+--- hypervkvpd-0/hv_kvp_daemon.c.include	2013-03-20 14:47:30.812899613 +0100
++++ hypervkvpd-0/hv_kvp_daemon.c	2013-03-20 14:47:42.337896971 +0100
+@@ -26,7 +26,7 @@
+ #include <sys/socket.h>
+ #include <sys/poll.h>
+ #include <sys/utsname.h>
+-#include <linux/types.h>
++/* #include <linux/types.h> */
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+@@ -35,7 +35,7 @@
+ #include <errno.h>
+ #include <arpa/inet.h>
+ #include <linux/connector.h>
+-#include <linux/hyperv.h>
++#include "linux/hyperv.h"
+ #include <linux/netlink.h>
+ #include <ifaddrs.h>
+ #include <netdb.h>
diff --git a/hypervkvpd-0-long_file_names_from_readdir.patch b/hypervkvpd-0-long_file_names_from_readdir.patch
new file mode 100644
index 0000000..ee14a34
--- /dev/null
+++ b/hypervkvpd-0-long_file_names_from_readdir.patch
@@ -0,0 +1,92 @@
+From 396ee697e4d5c7d10bacf6d4670fb4ddab357330 Mon Sep 17 00:00:00 2001
+From: Tomas Hozza <thozza at redhat.com>
+Date: Mon, 5 Nov 2012 13:56:02 +0100
+Subject: [PATCH] Tools: hv: Fix for long file names from readdir
+
+kvp_get_if_name and kvp_mac_to_if_name copy strings into statically
+sized buffers which could be too small to store really long names.
+
+Buffer sizes have been increased and length checks added via snprintf.
+---
+ hv_kvp_daemon.c | 26 +++++++++-----------------
+ 1 file changed, 9 insertions(+), 17 deletions(-)
+
+diff --git a/hv_kvp_daemon.c b/hv_kvp_daemon.c
+index 3ea3af2..4c2ab6a 100755
+--- a/hv_kvp_daemon.c
++++ b/hv_kvp_daemon.c
+@@ -44,6 +44,7 @@
+ #include <fcntl.h>
+ #include <dirent.h>
+ #include <net/if.h>
++#include <limits.h>
+ 
+ /*
+  * KVP protocol: The user mode component first registers with the
+@@ -588,26 +589,22 @@ static char *kvp_get_if_name(char *guid)
+ 	DIR *dir;
+ 	struct dirent *entry;
+ 	FILE    *file;
+-	char    *p, *q, *x;
++	char    *p, *x;
+ 	char    *if_name = NULL;
+ 	char    buf[256];
+ 	char *kvp_net_dir = "/sys/class/net/";
+-	char dev_id[256];
++	char dev_id[PATH_MAX];
+ 
+ 	dir = opendir(kvp_net_dir);
+ 	if (dir == NULL)
+ 		return NULL;
+ 
+-	snprintf(dev_id, sizeof(dev_id), "%s", kvp_net_dir);
+-	q = dev_id + strlen(kvp_net_dir);
+-
+ 	while ((entry = readdir(dir)) != NULL) {
+ 		/*
+ 		 * Set the state for the next pass.
+ 		 */
+-		*q = '\0';
+-		strcat(dev_id, entry->d_name);
+-		strcat(dev_id, "/device/device_id");
++		snprintf(dev_id, sizeof(dev_id), "%s%s/device/device_id", kvp_net_dir,
++				entry->d_name);
+ 
+ 		file = fopen(dev_id, "r");
+ 		if (file == NULL)
+@@ -680,28 +677,23 @@ static char *kvp_mac_to_if_name(char *mac)
+ 	DIR *dir;
+ 	struct dirent *entry;
+ 	FILE    *file;
+-	char    *p, *q, *x;
++	char    *p, *x;
+ 	char    *if_name = NULL;
+ 	char    buf[256];
+ 	char *kvp_net_dir = "/sys/class/net/";
+-	char dev_id[256];
++	char dev_id[PATH_MAX];
+ 	int i;
+ 
+ 	dir = opendir(kvp_net_dir);
+ 	if (dir == NULL)
+ 		return NULL;
+ 
+-	snprintf(dev_id, sizeof(dev_id), kvp_net_dir);
+-	q = dev_id + strlen(kvp_net_dir);
+-
+ 	while ((entry = readdir(dir)) != NULL) {
+ 		/*
+ 		 * Set the state for the next pass.
+ 		 */
+-		*q = '\0';
+-
+-		strcat(dev_id, entry->d_name);
+-		strcat(dev_id, "/address");
++		snprintf(dev_id, sizeof(dev_id), "%s%s/address", kvp_net_dir,
++                entry->d_name);
+ 
+ 		file = fopen(dev_id, "r");
+ 		if (file == NULL)
+-- 
+1.7.11.7
+
diff --git a/hypervkvpd.service b/hypervkvpd.service
new file mode 100644
index 0000000..f87925f
--- /dev/null
+++ b/hypervkvpd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Hyper-V KVP daemon
+ConditionVirtualization=microsoft
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/hypervkvpd
+
+[Install]
+WantedBy=basic.target
diff --git a/hypervvssd-0-dont_call_daemon.patch b/hypervvssd-0-dont_call_daemon.patch
new file mode 100644
index 0000000..e8f7c69
--- /dev/null
+++ b/hypervvssd-0-dont_call_daemon.patch
@@ -0,0 +1,13 @@
+diff -up ./hv_vss_daemon.c.daemon ./hv_vss_daemon.c
+--- ./hv_vss_daemon.c.daemon	2013-06-26 10:26:42.272419971 +0200
++++ ./hv_vss_daemon.c	2013-06-26 10:27:12.894443174 +0200
+@@ -148,9 +148,6 @@ int main(void)
+ 	char *vss_recv_buffer;
+ 	size_t vss_recv_buffer_len;
+ 
+-	if (daemon(1, 0))
+-		return 1;
+-
+ 	openlog("Hyper-V VSS", 0, LOG_USER);
+ 	syslog(LOG_INFO, "VSS starting; pid is:%d", getpid());
+ 
diff --git a/hypervvssd-0-fix_includes.patch b/hypervvssd-0-fix_includes.patch
new file mode 100644
index 0000000..c65dcaf
--- /dev/null
+++ b/hypervvssd-0-fix_includes.patch
@@ -0,0 +1,12 @@
+diff -up ./hv_vss_daemon.c.include ./hv_vss_daemon.c
+--- ./hv_vss_daemon.c.include	2013-06-26 10:36:36.444910963 +0200
++++ ./hv_vss_daemon.c	2013-06-26 10:37:22.115951240 +0200
+@@ -34,7 +34,7 @@
+ #include <arpa/inet.h>
+ #include <linux/fs.h>
+ #include <linux/connector.h>
+-#include <linux/hyperv.h>
++#include "linux/hyperv.h"
+ #include <linux/netlink.h>
+ #include <syslog.h>
+ 
diff --git a/hypervvssd.service b/hypervvssd.service
new file mode 100644
index 0000000..889e0ac
--- /dev/null
+++ b/hypervvssd.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Hyper-V VSS daemon
+ConditionVirtualization=microsoft
+
+[Service]
+ExecStart=/usr/sbin/hypervvssd
+
+[Install]
+WantedBy=basic.target
diff --git a/sources b/sources
index e69de29..550f731 100644
--- a/sources
+++ b/sources
@@ -0,0 +1,6 @@
+5a1b4a81be9d5bbbf8869976408354e8  hv_get_dhcp_info.sh
+dbb5cc7ec83ccc7b1c39458a7521c9b4  hv_get_dns_info.sh
+38064680ecf579444d853803ab265528  hv_kvp_daemon.c
+da7f77aa7507e950851cbb53673ce5d4  hv_set_ifconfig.sh
+8ae1875cc2bbf54e4a0b39f9f75a457d  hv_vss_daemon.c
+d7810fab7487fb0aad327b76f1be7cd7  COPYING


More information about the scm-commits mailing list