Commit Graph

86 Commits

Author SHA1 Message Date
Vitaly Kuznetsov c1136da621 Tools: hv: do not add redundant '/' in hv_start_fcopy()
We don't need to add additional '/' to smsg->path_name as snprintf("%s/%s")
does the right thing. Without the patch we get doubled '//' in the log message.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-01-25 09:17:57 -08:00
Vitaly Kuznetsov aba474b818 Tools: hv: address compiler warnings for hv_fcopy_daemon.c
This patch addresses two types of compiler warnings:
... warning: unused variable .fd. [-Wunused-variable]
and
... warning: format .%s. expects argument of type .char *., but argument 5 has type .__u16 *. [-Wformat=]

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-01-25 09:17:57 -08:00
Vitaly Kuznetsov 69258c058d Tools: hv: address compiler warnings for hv_kvp_daemon.c
This patch addresses two types of compiler warnings:
... warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
and
... warning: pointer targets in passing argument N of .kvp_.... differ in signedness [-Wpointer-sign]

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-01-25 09:17:57 -08:00
Vitaly Kuznetsov 77ce247a8d Tools: hv: remove unused bytes_written from kvp_update_file()
fwrite() does not actually return the number of bytes written and
this value is being ignored anyway and ferror() is being called to
check for an error. As we assign to this variable and never use it
we get the following compile-time warning:
hv_kvp_daemon.c:149:9: warning: variable .bytes_written. set but not used [-Wunused-but-set-variable]
Remove bytes_written completely.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-01-25 09:17:57 -08:00
Dexuan Cui 787d618225 tools: hv: kvp_daemon: make IPv6-only-injection work
In the case the host only injects an IPv6 address, the dhcp_enabled flag is
true (it's only for IPv4 according to Hyper-V host team), but we still need to
proceed to parse the IPv6 information.

Cc: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Reviewed-By: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-01-12 05:04:10 -08:00
Matej Muzila ca04455fba tools: hv: Makefile: Add hv_fcopy_daemon to Makefile
hv_fcopy_daemon is not mentioned in Makefile so it must be built
manually. Add hv_fcopy_daemon to Makefile.

Signed-off-by: Matej Muzila <mmuzila@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-01-12 04:51:02 -08:00
Dexuan Cui 4300f26492 tools: hv: ignore ENOBUFS and ENOMEM in the KVP daemon
Under high memory pressure and very high KVP R/W test pressure, the netlink
recvfrom() may transiently return ENOBUFS to the daemon -- we found this
during a 2-week stress test.

We'd better not terminate the daemon on the failure, because a typical KVP
user will re-try the R/W and hopefully it will succeed next time.

We can also ignore the errors on sending.

Cc: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 19:01:12 -08:00
Vitaly Kuznetsov 9e5db05aae Tools: hv: vssdaemon: skip all filesystems mounted readonly
Instead of making a list of exceptions for readonly filesystems
in addition to iso9660 we already have it is better to skip freeze
operation for all readonly-mounted filesystems.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Acked-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 19:01:11 -08:00
Vitaly Kuznetsov 7a401744d5 Tools: hv: vssdaemon: report freeze errors
When ioctl(fd, FIFREEZE, 0) results in an error we cannot report it
to syslog instantly since that can cause write to a frozen disk.
However, the name of the filesystem which caused the error and errno
are valuable and we would like to get a nice human-readable message
in the log. Save errno before calling vss_operate(VSS_OP_THAW) and
report the error right after.

Unfortunately, FITHAW errors cannot be reported the same way as we
need to finish thawing all filesystems before calling syslog().

We should also avoid calling endmntent() for the second time in
case we encountered an error during freezing of '/' as it usually
results in SEGSEGV.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Acked-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 19:01:11 -08:00
Vitaly Kuznetsov 170f4bea20 tools: hv: introduce -n/--no-daemon option
All tools/hv daemons do mandatory daemon() on startup. However, no pidfile
is created, this make it difficult for an init system to track such daemons.
Modern linux distros use systemd as their init system. It can handle the
daemonizing by itself, however, it requires a daemon to stay in foreground
for that. Some distros already carry distro-specific patch for hv tools
which switches off daemon().

Introduce -n/--no-daemon option for all 3 daemons in hv/tools. Parse options
with getopt() to make this part easily expandable.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 10:21:44 -08:00
Dexuan Cui 4f689190bb Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition
If a partition appears mounted more than once in /proc/mounts, vss_do_freeze()
succeeds only for the first time and gets EBUSY (on freeze) or EINVAL (on
thaw) for the second time. The patch ignores these to make the backup feature
work.

Also improved the error handling in case a freeze operation fails.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 10:13:29 -08:00
Yue Zhang e013ac312c Tools: hv: fix file overwriting of hv_fcopy_daemon
hv_fcopy_daemon fails to overwrite a file if the target file already
exits.

Add O_TRUNC flag on opening.

Signed-off-by: Yue Zhang <yuezha@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-09 14:21:26 -07:00
K. Y. Srinivasan 314672a2c2 Tools: hv: Handle the case when the target file exists correctly
Return the appropriate error code and handle the case when the target
file exists correctly. This fixes a bug.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org> [3.14]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-04-16 14:10:36 -07:00
K. Y. Srinivasan 01325476d6 Drivers: hv: Implement the file copy service
Implement the file copy service for Linux guests on Hyper-V. This permits the
host to copy a file (over VMBUS) into the guest. This facility is part of
"guest integration services" supported on the Windows platform.
Here is a link that provides additional details on this functionality:

http://technet.microsoft.com/en-us/library/dn464282.aspx

In V1 version of the patch I have addressed comments from
Olaf Hering <olaf@aepfle.de> and Dan Carpenter <dan.carpenter@oracle.com>

In V2 version of this patch I did some minor cleanup (making some globals
static). In V4 version of the patch I have addressed all of Olaf's
most recent set of comments/concerns.

In V5 version of the patch I had addressed Greg's most recent comments.
I would like to thank Greg for suggesting that I use misc device; it has
significantly simplified the code.

In V6 version of the patch I have cleaned up error message based on Olaf's
comments. I have also rebased the patch based on the current tip.

In this version of the patch, I have addressed the latest comments from Greg.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-18 10:53:48 -08:00
K. Y. Srinivasan f33b215549 Tools: hv: vssdaemon: Ignore VFAT mounts during the Freeze operation
If the guest has a FAT file system mounted, skip it during the FREEZE
operation. With this change we can support host initiated backup of
the guest even when the guest may have FAT file systems mounted.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-15 11:53:39 -08:00
Bjarke Istrup Pedersen 3eb2094c59 Adding makefile for tools/hv
Currently, there is no makefile for the Hyper-V tools.
This patch adds the missing makefile, and adds it to the main tools makefile.

Signed-off-by: Bjarke Istrup Pedersen <gurligebis@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-15 11:52:35 -08:00
Olaf Hering 51b68128ef Tools: hv: remove inclusion of linux/types.h
With very old libc headers the inclusion of sys/types.h causes conflicts
with linux/types.h. Since the latter is not required anyway, remove it
from the source files. If any of the headers really needs linux/types.h
it has to include it itself.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-08 22:47:12 -08:00
Olaf Hering 269ce62bbc Tools: hv: use single send+recv buffer
send_buffer is used only once during registration. To reduce runtime
memory usage reuse the recv_buffer for registration. Also use
NLMSG_LENGTH instead of NLMSG_HDRLEN to take alignment into account.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-26 12:03:31 -07:00
Olaf Hering 58125210ab Tools: hv: cache FQDN in kvp_daemon to avoid timeouts
kvp_daemon does some operations which take an unpredicable amount of
time. In addition the kernel driver gives the kvp_daemon a 5 second
timeout to respond to message from the host. If an operation such as
getaddrinfo takes a long time and the timeout triggers then netlink
errors occour. As a result of such errors the daemon just terminates and
the service becomes unavailable.

Idendifying and fixing these shortcomings in the kernel-userland
communication protocol will be done in separate patches. This change
fixes just one obvious timeout bug.

Update kvp_get_domain_name to not return a value, better diagnostic for
the consumer of the hostname string, remove trailing newline in error
case, use snprintf to not overrun output buffer, get hostname only once
and return the cached result.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-26 12:03:31 -07:00
Olaf Hering b4fb0ca260 Tools: hv: use full nlmsghdr in netlink_send
There is no need to have a nlmsghdr pointer to another temporary buffer.
Instead use a full struct nlmsghdr.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-12 15:44:57 -07:00
Olaf Hering 2bc41ea3b3 Tools: hv: correct payload size in netlink_send
netlink_send is supposed to send just the cn_msg+hv_kvp_msg via netlink.
Currently it sets an incorrect iovec size, as reported by valgrind.

In the case of registering with the kernel the allocated buffer is large
enough to hold nlmsghdr+cn_msg+hv_kvp_msg, no overrun happens. In the
case of responding to the kernel the cn_msg is located in the middle of
recv_buffer, after the nlmsghdr. Currently the code in netlink_send adds
also the size of nlmsghdr to the payload. But nlmsghdr is a separate
iovec. This leads to an (harmless) out-of-bounds access when the kernel
processes the iovec. Correct the iovec size of the cn_msg to be just
cn_msg + its payload.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-12 15:44:57 -07:00
Olaf Hering d3b688c662 Tools: hv: check return value of system in hv_kvp_daemon
hv_kvp_daemon.c: In function 'main':
hv_kvp_daemon.c:1441:8: warning: ignoring return value of 'daemon', declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-05 14:36:31 +08:00
Olaf Hering 57969af029 Tools: hv: in kvp_set_ip_info free mac_addr right after usage
... to simplify error path in upcoming changes.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-05 14:36:31 +08:00
Olaf Hering 00663d73e3 Tools: hv: check return value of daemon to fix compiler warning.
hv_kvp_daemon.c: In function 'main':
hv_kvp_daemon.c:1441:8: warning: ignoring return value of 'daemon', declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-02 11:44:52 +08:00
Olaf Hering b4919a5f95 Tools: hv: fix send/recv buffer allocation
hv_kvp_daemon fails to start in current openSuSE 13.1 snapshots because
the kvp_send_buffer is too small to hold cn_msg+hv_kvp_msg, the very
first sendmsg returns with EFAULT. In addition it fixes the Network info
tab in Windows Server 2012R2 in SLES11.

Adjust the code in kvp and vss daemon to allocate the needed buffers at
runtime. To keep the code simple, the buffer_len includes also the
nlmsghdr, although only the recv_buffer needs this extra space.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-02 11:44:18 +08:00
Greg Kroah-Hartman 9c5891bd43 Merge 3.11-rc3 into char-misc-next.
This resolves a merge issue with:
	drivers/misc/mei/init.c

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-07-29 11:50:17 -07:00
Tomas Hozza d12e146924 tools: hv: Check return value of setsockopt call
Check return value of setsockopt call and if it fails print error to the
system log and exit with non-zero value.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-07-26 16:40:41 -07:00
Tomas Hozza 9561d47931 tools: hv: Check return value of poll call
Check return value of poll call and if it fails print error to the
system log. If errno is EINVAL then exit with non-zero value otherwise
continue the while loop and call poll again.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-07-26 16:40:41 -07:00
Tomas Hozza 5c28926981 tools: hv: Improve error logging in VSS daemon.
Use errno and strerror() when logging errors to provide more
information.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-07-26 16:40:41 -07:00
K. Y. Srinivasan ed4bb9744b Tools: hv: KVP: Fix a bug in IPV6 subnet enumeration
Each subnet string needs to be separated with a semicolon. Fix this bug.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: Stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-07-16 23:19:19 -07:00
Tomas Hozza 12e50c3054 tools: hv: Improve error logging in KVP daemon.
Use errno and strerror() when logging errors to provide
more information.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-17 15:54:59 -07:00
Tomas Hozza fca597558e tools: hv: Fix file descriptor leaks
Close "fd" file descriptor when is goes out of scope so it does
not leak.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by:  K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-03 14:13:09 -07:00
Tomas Hozza f14e600a3b tools: hv: Check retrun value of strchr call
Check return value of strchr call and dereference it only if it is
not NULL.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by:  K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-03 14:13:09 -07:00
Tomas Hozza 4d81e30744 tools: hv: Check return value of poll call
Check return value of poll call and if it fails print error
to the system log. If errno is EINVAL then exit with non-zero
value otherwise continue the while loop and call poll again.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by:  K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-03 14:13:09 -07:00
Tomas Hozza 3590160322 tools: hv: Check return value of setsockopt call
Check return value of setsockopt call and if it fails print error
to the system log and exit with non-zero value.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by:  K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-03 14:13:09 -07:00
K. Y. Srinivasan 0e27263926 Tools: hv: Fix a checkpatch warning
Fix a checkpatch warning.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-24 09:02:36 -07:00
Olaf Hering 10b637b4c8 tools: hv: skip iso9660 mounts in hv_vss_daemon
fsreeze does not work for iso9660 filesystems. A ENOSUPP may be caught
in the freeze case, but the subsequent thaw call would fail and leads to
a false error.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-24 09:02:35 -07:00
Olaf Hering 7b413b6553 tools: hv: use FIFREEZE/FITHAW in hv_vss_daemon
As suggested by Paolo Bonzini, use ioctl instead of calling fsfreeze.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-24 09:02:35 -07:00
Olaf Hering d3d1ee3ab2 tools: hv: use getmntent in hv_vss_daemon
As suggested by Paolo Bonzini, use getmntent instead of parsing output
of mount(1).

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-24 09:02:35 -07:00
K. Y. Srinivasan 038336a5b4 Tools: hv: Fix a checkpatch warning
Fix a checkpatch warning.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-24 09:02:35 -07:00
Olaf Hering 5edf5ee42a tools: hv: fix checks for origin of netlink message in hv_vss_daemon
Similar to what commit 95a69adab9 ("tools:
hv: Netlink source address validation allows DoS") does in
hv_kvp_daemon, improve checks for origin of netlink connector message.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-24 09:02:35 -07:00
Olaf Hering eb8905b8ff Tools: hv: fix warnings in hv_vss_daemon
This change fixes a few compile errors:

hv_vss_daemon.c:64:15: warning: unknown escape sequence '\/'
hv_vss_daemon.c:64:15: warning: unknown escape sequence '\/'
hv_vss_daemon.c: In function 'vss_operate':
hv_vss_daemon.c:66: warning: 'return' with no value, in function returning non-void
hv_vss_daemon.c: In function 'main':
hv_vss_daemon.c:130: warning: ignoring return value of 'daemon', declared with attribute warn_unused_result
hv_vss_daemon.c: In function 'vss_operate':
hv_vss_daemon.c:47: warning: 'fs_op' may be used uninitialized in this function

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-24 09:02:35 -07:00
K. Y. Srinivasan 96dd86fa58 Drivers: hv: Add a new driver to support host initiated backup
This driver supports host initiated backup of the guest. On Windows guests,
the host can generate application consistent backups using the Windows VSS
framework. On Linux, we ensure that the backup will be file system consistent.
This driver allows the host to initiate a  "Freeze" operation on all the mounted
file systems in the guest. Once the mounted file systems in the guest are frozen,
the host snapshots the guest's file systems. Once this is done, the guest's file
systems are "thawed".

This driver has a user-level component (daemon) that invokes the appropriate
operation on all the mounted file systems in response to the requests from
the host. The duration for which the guest is frozen is very short - a few seconds.
During this interval, the diff disk is comitted.

In this version of the patch I have addressed the feedback from Olaf Herring.
Also, some of the connector related issues have been fixed.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-15 12:12:36 -07:00
Tomas Hozza 75db601496 tools: hv: daemon should check type of received Netlink msg
HyperV KVP daemon should check nlmsg_type in received netlink message
header. If message type is NLMSG_DONE daemon can proceed with processing
otherwise it should wait for next message.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-15 11:23:16 -07:00
Tomas Hozza f4685fa6d0 tools: hv: daemon setsockopt should use options macros
HyperV daemon should use macros for option values when calling setsockopt.
Using specific numeric values instead of macros is confusing.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-15 11:23:16 -07:00
Tomas Hozza 77d6a52893 tools: hv: daemon should subscribe only to CN_KVP_IDX group
Previously HyperV daemon set sockaddr_nl.nl_groups to CN_KVP_IDX.
Netlink documentation says: "nl_groups is a bit mask with every bit
representing a netlink group number". Since CN_KVP_IDX value is "9"
HyperV daemon was receiving Netlink messages also from group number
"1" which is used by CGroup Rules Engine Daemon. This caused the
daemon to segfault (at least on 2.6.32 kernel).

HyperV daemon should set nl_groups to zero and specify multicast
group CN_KVP_IDX only by using socket options.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-15 11:23:15 -07:00
Tomas Hozza 8467fdbb09 tools: hv: Use CLOEXEC when opening kvp_pool files
Use CLOEXEC flag when opening kvp_pool_x files to prevent file
descriptor leakage. Not using it was causing a problem when
SELinux was enabled.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-18 16:03:34 -08:00
Tomas Hozza 0783d72fa4 tools: hv: Fix how ifcfg-* file is created
Fix for the daemon code and for hv_set_ifconfig.sh script, so
that the created ifcfg-* file is consistent with initscripts
documentation.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17 11:47:21 -08:00
Jason Wang 00246d08be tools: hv: fix a typo in hv_set_ifconfig.sh
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17 11:47:02 -08:00
Ben Hutchings 0bffd25ce9 tools/hv: Fix permissions of created directory and files
It's silly to create directories without execute permission, or to
give permissions to 'other' but not the group-owner.

Write the permissions in octal and 'ls -l' format since these are much
easier to read than the named macros.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17 10:41:46 -08:00