- bump to version 4
- update kv_kvp_daemon to 3.7-rc1 state [fate#31441] support KVP IP Injection, helper scripts go to /usr/lib/hyper-v/bin: hv_get_dhcp_info, hv_get_dns_info, hv_set_ifconfig - remove usage of absolute paths in runlevel script OBS-URL: https://build.opensuse.org/package/show/Virtualization/hyper-v?expand=0&rev=31
This commit is contained in:
parent
68b36b1c2a
commit
8709575eff
@ -1,3 +1,12 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Oct 4 15:14:05 CEST 2012 - ohering@suse.de
|
||||
|
||||
- bump to version 4
|
||||
- update kv_kvp_daemon to 3.7-rc1 state [fate#31441]
|
||||
support KVP IP Injection, helper scripts go to /usr/lib/hyper-v/bin:
|
||||
hv_get_dhcp_info, hv_get_dns_info, hv_set_ifconfig
|
||||
- remove usage of absolute paths in runlevel script
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Sep 4 14:55:38 CEST 2012 - ohering@suse.de
|
||||
|
||||
|
@ -122,12 +122,53 @@
|
||||
#define REG_U32 4
|
||||
#define REG_U64 8
|
||||
|
||||
/*
|
||||
* As we look at expanding the KVP functionality to include
|
||||
* IP injection functionality, we need to maintain binary
|
||||
* compatibility with older daemons.
|
||||
*
|
||||
* The KVP opcodes are defined by the host and it was unfortunate
|
||||
* that I chose to treat the registration operation as part of the
|
||||
* KVP operations defined by the host.
|
||||
* Here is the level of compatibility
|
||||
* (between the user level daemon and the kernel KVP driver) that we
|
||||
* will implement:
|
||||
*
|
||||
* An older daemon will always be supported on a newer driver.
|
||||
* A given user level daemon will require a minimal version of the
|
||||
* kernel driver.
|
||||
* If we cannot handle the version differences, we will fail gracefully
|
||||
* (this can happen when we have a user level daemon that is more
|
||||
* advanced than the KVP driver.
|
||||
*
|
||||
* We will use values used in this handshake for determining if we have
|
||||
* workable user level daemon and the kernel driver. We begin by taking the
|
||||
* registration opcode out of the KVP opcode namespace. We will however,
|
||||
* maintain compatibility with the existing user-level daemon code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Daemon code not supporting IP injection (legacy daemon).
|
||||
*/
|
||||
|
||||
#define KVP_OP_REGISTER 4
|
||||
|
||||
/*
|
||||
* Daemon code supporting IP injection.
|
||||
* The KVP opcode field is used to communicate the
|
||||
* registration information; so define a namespace that
|
||||
* will be distinct from the host defined KVP opcode.
|
||||
*/
|
||||
|
||||
#define KVP_OP_REGISTER1 100
|
||||
|
||||
enum hv_kvp_exchg_op {
|
||||
KVP_OP_GET = 0,
|
||||
KVP_OP_SET,
|
||||
KVP_OP_DELETE,
|
||||
KVP_OP_ENUMERATE,
|
||||
KVP_OP_REGISTER,
|
||||
KVP_OP_GET_IP_INFO,
|
||||
KVP_OP_SET_IP_INFO,
|
||||
KVP_OP_COUNT /* Number of operations, must be last. */
|
||||
};
|
||||
|
||||
@ -140,6 +181,39 @@ enum hv_kvp_exchg_pool {
|
||||
KVP_POOL_COUNT /* Number of pools, must be last. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Some Hyper-V status codes.
|
||||
*/
|
||||
|
||||
#define HV_S_OK 0x00000000
|
||||
#define HV_E_FAIL 0x80004005
|
||||
#define HV_S_CONT 0x80070103
|
||||
#define HV_ERROR_NOT_SUPPORTED 0x80070032
|
||||
#define HV_ERROR_MACHINE_LOCKED 0x800704F7
|
||||
#define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F
|
||||
#define HV_INVALIDARG 0x80070057
|
||||
#define HV_GUID_NOTFOUND 0x80041002
|
||||
|
||||
#define ADDR_FAMILY_NONE 0x00
|
||||
#define ADDR_FAMILY_IPV4 0x01
|
||||
#define ADDR_FAMILY_IPV6 0x02
|
||||
|
||||
#define MAX_ADAPTER_ID_SIZE 128
|
||||
#define MAX_IP_ADDR_SIZE 1024
|
||||
#define MAX_GATEWAY_SIZE 512
|
||||
|
||||
|
||||
struct hv_kvp_ipaddr_value {
|
||||
__u16 adapter_id[MAX_ADAPTER_ID_SIZE];
|
||||
__u8 addr_family;
|
||||
__u8 dhcp_enabled;
|
||||
__u16 ip_addr[MAX_IP_ADDR_SIZE];
|
||||
__u16 sub_net[MAX_IP_ADDR_SIZE];
|
||||
__u16 gate_way[MAX_GATEWAY_SIZE];
|
||||
__u16 dns_addr[MAX_IP_ADDR_SIZE];
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
struct hv_kvp_hdr {
|
||||
__u8 operation;
|
||||
__u8 pool;
|
||||
@ -181,16 +255,26 @@ struct hv_kvp_register {
|
||||
};
|
||||
|
||||
struct hv_kvp_msg {
|
||||
struct hv_kvp_hdr kvp_hdr;
|
||||
union {
|
||||
struct hv_kvp_hdr kvp_hdr;
|
||||
int error;
|
||||
};
|
||||
union {
|
||||
struct hv_kvp_msg_get kvp_get;
|
||||
struct hv_kvp_msg_set kvp_set;
|
||||
struct hv_kvp_msg_delete kvp_delete;
|
||||
struct hv_kvp_msg_enumerate kvp_enum_data;
|
||||
struct hv_kvp_ipaddr_value kvp_ip_val;
|
||||
struct hv_kvp_register kvp_register;
|
||||
} body;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct hv_kvp_ip_msg {
|
||||
__u8 operation;
|
||||
__u8 pool;
|
||||
struct hv_kvp_ipaddr_value kvp_ip_val;
|
||||
} __attribute__((packed));
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/scatterlist.h>
|
||||
#include <linux/list.h>
|
||||
@ -274,6 +358,33 @@ struct hv_ring_buffer_debug_info {
|
||||
u32 bytes_avail_towrite;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* hv_get_ringbuffer_availbytes()
|
||||
*
|
||||
* Get number of bytes available to read and to write to
|
||||
* for the specified ring buffer
|
||||
*/
|
||||
static inline void
|
||||
hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
|
||||
u32 *read, u32 *write)
|
||||
{
|
||||
u32 read_loc, write_loc, dsize;
|
||||
|
||||
smp_read_barrier_depends();
|
||||
|
||||
/* Capture the read/write indices before they changed */
|
||||
read_loc = rbi->ring_buffer->read_index;
|
||||
write_loc = rbi->ring_buffer->write_index;
|
||||
dsize = rbi->ring_datasize;
|
||||
|
||||
*write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
|
||||
read_loc - write_loc;
|
||||
*read = dsize - *write;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* We use the same version numbering for all Hyper-V modules.
|
||||
*
|
||||
@ -378,7 +489,7 @@ struct vmtransfer_page_range {
|
||||
struct vmtransfer_page_packet_header {
|
||||
struct vmpacket_descriptor d;
|
||||
u16 xfer_pageset_id;
|
||||
bool sender_owns_set;
|
||||
u8 sender_owns_set;
|
||||
u8 reserved;
|
||||
u32 range_cnt;
|
||||
struct vmtransfer_page_range ranges[1];
|
||||
@ -532,7 +643,7 @@ struct vmbus_channel_query_vmbus_version {
|
||||
/* VMBus Version Supported parameters */
|
||||
struct vmbus_channel_version_supported {
|
||||
struct vmbus_channel_message_header header;
|
||||
bool version_supported;
|
||||
u8 version_supported;
|
||||
} __packed;
|
||||
|
||||
/* Offer Channel parameters */
|
||||
@ -541,7 +652,7 @@ struct vmbus_channel_offer_channel {
|
||||
struct vmbus_channel_offer offer;
|
||||
u32 child_relid;
|
||||
u8 monitorid;
|
||||
bool monitor_allocated;
|
||||
u8 monitor_allocated;
|
||||
} __packed;
|
||||
|
||||
/* Rescind Offer parameters */
|
||||
@ -677,7 +788,7 @@ struct vmbus_channel_initiate_contact {
|
||||
|
||||
struct vmbus_channel_version_response {
|
||||
struct vmbus_channel_message_header header;
|
||||
bool version_supported;
|
||||
u8 version_supported;
|
||||
} __packed;
|
||||
|
||||
enum vmbus_channel_state {
|
||||
@ -950,11 +1061,6 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver);
|
||||
#define ICMSGHDRFLAG_REQUEST 2
|
||||
#define ICMSGHDRFLAG_RESPONSE 4
|
||||
|
||||
#define HV_S_OK 0x00000000
|
||||
#define HV_E_FAIL 0x80004005
|
||||
#define HV_S_CONT 0x80070103
|
||||
#define HV_ERROR_NOT_SUPPORTED 0x80070032
|
||||
#define HV_ERROR_MACHINE_LOCKED 0x800704F7
|
||||
|
||||
/*
|
||||
* While we want to handle util services as regular devices,
|
||||
@ -1035,8 +1141,10 @@ struct hyperv_service_callback {
|
||||
void (*callback) (void *context);
|
||||
};
|
||||
|
||||
#define MAX_SRV_VER 0x7ffffff
|
||||
extern void vmbus_prep_negotiate_resp(struct icmsg_hdr *,
|
||||
struct icmsg_negotiate *, u8 *);
|
||||
struct icmsg_negotiate *, u8 *, int,
|
||||
int);
|
||||
|
||||
int hv_kvp_init(struct hv_util_service *);
|
||||
void hv_kvp_deinit(void);
|
||||
|
@ -29,12 +29,13 @@ rc_reset
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting Hyper-V KVP daemon "
|
||||
/sbin/startproc $HV_KVP_BIN
|
||||
env PATH=/usr/lib/hyper-v/bin:$PATH \
|
||||
startproc $HV_KVP_BIN
|
||||
rc_status -v
|
||||
;;
|
||||
stop)
|
||||
echo -n "Shutting down Hyper-V KVP daemon "
|
||||
/sbin/killproc -TERM $HV_KVP_BIN
|
||||
killproc -TERM $HV_KVP_BIN
|
||||
rc_status -v
|
||||
;;
|
||||
try-restart|condrestart)
|
||||
@ -70,7 +71,7 @@ case "$1" in
|
||||
;;
|
||||
status)
|
||||
echo -n "Checking for service Hyper-V KVP daemon "
|
||||
/sbin/checkproc $HV_KVP_BIN
|
||||
checkproc $HV_KVP_BIN
|
||||
rc_status -v
|
||||
;;
|
||||
*)
|
||||
|
14
hyper-v.spec
14
hyper-v.spec
@ -39,7 +39,7 @@ Group: System/Kernel
|
||||
Supplements: modalias(dmi*:svn*MicrosoftCorporation*:pn*VirtualMachine*:rn*VirtualMachine*)
|
||||
Supplements: modalias(pci:v00001414d00005353sv*sd*bc*sc*i*)
|
||||
Url: http://www.kernel.org
|
||||
Version: 3
|
||||
Version: 4
|
||||
Release: 0
|
||||
Source: Module.supported
|
||||
Source1: hyperv_pvdrivers.conf
|
||||
@ -50,7 +50,10 @@ Source5: hyper-v.kvptest.ps1.txt
|
||||
Source9: hyper-v.include.linux.hyperv.h
|
||||
Source10: hyper-v.tools.hv.hv_kvp_daemon.c
|
||||
Source11: hyper-v.init.sh
|
||||
Patch761200: hyper-v.tools.hv.hv_kvp_daemon.c.patch
|
||||
Source20: hyper-v.tools.hv.hv_get_dhcp_info.sh
|
||||
Source21: hyper-v.tools.hv.hv_get_dns_info.sh
|
||||
Source22: hyper-v.tools.hv.hv_set_ifconfig.sh
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
%if %{with_kmp}
|
||||
%if %{with_drivers_in_kmp}
|
||||
@ -84,7 +87,6 @@ This package contains the Microsoft Hyper-V drivers.
|
||||
cp -avL %{S:5} kvptest.ps1.txt
|
||||
cp -vL %{S:9} %{hv_kvp_daemon}.h
|
||||
cp -vL %{S:10} %{hv_kvp_daemon}.c
|
||||
%patch761200 -p0
|
||||
|
||||
%build
|
||||
sed -i~ '/#include <linux.hyperv.h>/d' %{hv_kvp_daemon}.c
|
||||
@ -125,6 +127,11 @@ done
|
||||
%endif
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/sbin
|
||||
install -m755 %{hv_kvp_daemon} $RPM_BUILD_ROOT/usr/sbin
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib/%{name}/bin
|
||||
cp -avL %{S:20} $RPM_BUILD_ROOT/usr/lib/%{name}/bin/hv_get_dhcp_info
|
||||
cp -avL %{S:21} $RPM_BUILD_ROOT/usr/lib/%{name}/bin/hv_get_dns_info
|
||||
cp -avL %{S:22} $RPM_BUILD_ROOT/usr/lib/%{name}/bin/hv_set_ifconfig
|
||||
chmod 755 $RPM_BUILD_ROOT/usr/lib/%{name}/bin/*
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/init.d
|
||||
install -m755 %{S:11} $RPM_BUILD_ROOT/etc/init.d/%{hv_kvp_daemon}
|
||||
ln -sfvbn ../../etc/init.d/%{hv_kvp_daemon} $RPM_BUILD_ROOT/usr/sbin/rc%{hv_kvp_daemon}
|
||||
@ -145,6 +152,7 @@ install -m644 %SOURCE1 $RPM_BUILD_ROOT/etc/modprobe.d/hyperv_pvdrivers.conf
|
||||
/etc/init.d/%{hv_kvp_daemon}
|
||||
/usr/sbin/rc%{hv_kvp_daemon}
|
||||
/usr/sbin/%{hv_kvp_daemon}
|
||||
/usr/lib/%{name}
|
||||
|
||||
%post
|
||||
board_vendor=
|
||||
|
28
hyper-v.tools.hv.hv_get_dhcp_info.sh
Normal file
28
hyper-v.tools.hv.hv_get_dhcp_info.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This example script retrieves the DHCP state of a given interface.
|
||||
# In the interest of keeping the KVP daemon code free of distro specific
|
||||
# information; the kvp daemon code invokes this external script to gather
|
||||
# DHCP setting for the specific interface.
|
||||
#
|
||||
# Input: Name of the interface
|
||||
#
|
||||
# Output: The script prints the string "Enabled" to stdout to indicate
|
||||
# that DHCP is enabled on the interface. If DHCP is not enabled,
|
||||
# the script prints the string "Disabled" to stdout.
|
||||
#
|
||||
# Each Distro is expected to implement this script in a distro specific
|
||||
# fashion. For instance on Distros that ship with Network Manager enabled,
|
||||
# this script can be based on the Network Manager APIs for retrieving DHCP
|
||||
# information.
|
||||
|
||||
if_file="/etc/sysconfig/network-scripts/ifcfg-"$1
|
||||
|
||||
dhcp=$(grep "dhcp" $if_file 2>/dev/null)
|
||||
|
||||
if [ "$dhcp" != "" ];
|
||||
then
|
||||
echo "Enabled"
|
||||
else
|
||||
echo "Disabled"
|
||||
fi
|
13
hyper-v.tools.hv.hv_get_dns_info.sh
Normal file
13
hyper-v.tools.hv.hv_get_dns_info.sh
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This example script parses /etc/resolv.conf to retrive DNS information.
|
||||
# In the interest of keeping the KVP daemon code free of distro specific
|
||||
# information; the kvp daemon code invokes this external script to gather
|
||||
# DNS information.
|
||||
# This script is expected to print the nameserver values to stdout.
|
||||
# Each Distro is expected to implement this script in a distro specific
|
||||
# fashion. For instance on Distros that ship with Network Manager enabled,
|
||||
# this script can be based on the Network Manager APIs for retrieving DNS
|
||||
# entries.
|
||||
|
||||
cat /etc/resolv.conf 2>/dev/null | awk '/^nameserver/ { print $2 }'
|
File diff suppressed because it is too large
Load Diff
@ -1,22 +0,0 @@
|
||||
--- hv_kvp_daemon.c.orig 2012-05-16 20:11:10.000000000 +0200
|
||||
+++ hv_kvp_daemon.c 2012-05-16 20:40:08.000000000 +0200
|
||||
@@ -701,14 +701,16 @@ int main(void)
|
||||
pfd.fd = fd;
|
||||
|
||||
while (1) {
|
||||
+ struct sockaddr *addr_p = (struct sockaddr *) &addr;
|
||||
+ socklen_t addr_l = sizeof(addr);
|
||||
pfd.events = POLLIN;
|
||||
pfd.revents = 0;
|
||||
poll(&pfd, 1, -1);
|
||||
|
||||
- len = recv(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0);
|
||||
+ len = recvfrom(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0, addr_p, &addr_l);
|
||||
|
||||
- if (len < 0) {
|
||||
- syslog(LOG_ERR, "recv failed; error:%d", len);
|
||||
+ if (len < 0 || addr.nl_pid) {
|
||||
+ syslog(LOG_ERR, "recvfrom failed; pid:%u error:%d %s", addr.nl_pid, errno, strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
68
hyper-v.tools.hv.hv_set_ifconfig.sh
Normal file
68
hyper-v.tools.hv.hv_set_ifconfig.sh
Normal file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This example script activates an interface based on the specified
|
||||
# configuration.
|
||||
#
|
||||
# In the interest of keeping the KVP daemon code free of distro specific
|
||||
# information; the kvp daemon code invokes this external script to configure
|
||||
# the interface.
|
||||
#
|
||||
# The only argument to this script is the configuration file that is to
|
||||
# be used to configure the interface.
|
||||
#
|
||||
# Each Distro is expected to implement this script in a distro specific
|
||||
# fashion. For instance on Distros that ship with Network Manager enabled,
|
||||
# this script can be based on the Network Manager APIs for configuring the
|
||||
# interface.
|
||||
#
|
||||
# This example script is based on a RHEL environment.
|
||||
#
|
||||
# Here is the format of the ip configuration file:
|
||||
#
|
||||
# HWADDR=macaddr
|
||||
# IF_NAME=interface name
|
||||
# DHCP=yes (This is optional; if yes, DHCP is configured)
|
||||
#
|
||||
# IPADDR=ipaddr1
|
||||
# IPADDR_1=ipaddr2
|
||||
# IPADDR_x=ipaddry (where y = x + 1)
|
||||
#
|
||||
# NETMASK=netmask1
|
||||
# NETMASK_x=netmasky (where y = x + 1)
|
||||
#
|
||||
# GATEWAY=ipaddr1
|
||||
# GATEWAY_x=ipaddry (where y = x + 1)
|
||||
#
|
||||
# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc)
|
||||
#
|
||||
# IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be
|
||||
# tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as
|
||||
# IPV6NETMASK.
|
||||
#
|
||||
# The host can specify multiple ipv4 and ipv6 addresses to be
|
||||
# configured for the interface. Furthermore, the configuration
|
||||
# needs to be persistent. A subsequent GET call on the interface
|
||||
# is expected to return the configuration that is set via the SET
|
||||
# call.
|
||||
#
|
||||
|
||||
|
||||
|
||||
echo "IPV6INIT=yes" >> $1
|
||||
echo "NM_CONTROLLED=no" >> $1
|
||||
echo "PEERDNS=yes" >> $1
|
||||
echo "ONBOOT=yes" >> $1
|
||||
|
||||
dhcp=$(grep "DHCP" $1 2>/dev/null)
|
||||
if [ "$dhcp" != "" ];
|
||||
then
|
||||
echo "BOOTPROTO=dhcp" >> $1;
|
||||
fi
|
||||
|
||||
cp $1 /etc/sysconfig/network-scripts/
|
||||
|
||||
|
||||
interface=$(echo $1 | awk -F - '{ print $2 }')
|
||||
|
||||
/sbin/ifdown $interface 2>/dev/null
|
||||
/sbin/ifup $interfac 2>/dev/null
|
Loading…
Reference in New Issue
Block a user