mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +00:00
alpine: Add Hyper-V daemons to the build
The daemons allow proper shutdown of a VM, heartbeats, inquiring and setting the network configuratio etc etc. They are only started with running in a Hyper-V VM Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
b8b9126323
commit
bdd1efe043
@ -41,6 +41,13 @@ COPY packages/database/etc /etc/
|
||||
COPY packages/hupper/hupper /bin/
|
||||
COPY packages/hupper/etc /etc/
|
||||
COPY packages/hostlog/etc /etc/
|
||||
COPY packages/hvtools/hv_fcopy_daemon /sbin/
|
||||
COPY packages/hvtools/hv_kvp_daemon /sbin/
|
||||
COPY packages/hvtools/hv_vss_daemon /sbin/
|
||||
COPY packages/hvtools/etc /etc/
|
||||
COPY packages/hvtools/hv_get_dhcp_info /sbin/
|
||||
COPY packages/hvtools/hv_get_dns_info /sbin/
|
||||
COPY packages/hvtools/hv_set_ifconfig /sbin/
|
||||
|
||||
RUN \
|
||||
rc-update add swap boot && \
|
||||
@ -77,6 +84,9 @@ RUN \
|
||||
rc-update add database boot && \
|
||||
rc-update add hupper default && \
|
||||
rc-update add hostlog default && \
|
||||
rc-update add hv_fcopy_daemon default && \
|
||||
rc-update add hv_kvp_daemon default && \
|
||||
rc-update add hv_vss_daemon default && \
|
||||
ln -s /bin/busybox /init
|
||||
|
||||
CMD ["/bin/sh"]
|
||||
|
@ -4,6 +4,7 @@ all:
|
||||
$(MAKE) -C mdnstool
|
||||
$(MAKE) -C docker
|
||||
$(MAKE) -C hupper
|
||||
$(MAKE) -C hvtools
|
||||
|
||||
arm:
|
||||
$(MAKE) -C 9pudc ARCH=arm
|
||||
@ -18,3 +19,4 @@ clean:
|
||||
$(MAKE) -C mdnstool clean
|
||||
$(MAKE) -C docker clean
|
||||
$(MAKE) -C hupper clean
|
||||
$(MAKE) -C hvtools clean
|
||||
|
10
alpine/packages/hvtools/Dockerfile
Normal file
10
alpine/packages/hvtools/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM alpine:3.3
|
||||
|
||||
RUN apk update && apk upgrade && apk add alpine-sdk linux-headers
|
||||
|
||||
RUN mkdir -p /hvtools
|
||||
WORKDIR /hvtools
|
||||
|
||||
COPY src /hvtools/
|
||||
|
||||
RUN make
|
12
alpine/packages/hvtools/Makefile
Normal file
12
alpine/packages/hvtools/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
all: hvtools
|
||||
|
||||
hvtools: Dockerfile src/*
|
||||
docker build -t hvtools:build .
|
||||
docker run hvtools:build cat /hvtools/hv_fcopy_daemon > hv_fcopy_daemon
|
||||
docker run hvtools:build cat /hvtools/hv_kvp_daemon > hv_kvp_daemon
|
||||
docker run hvtools:build cat /hvtools/hv_vss_daemon > hv_vss_daemon
|
||||
chmod 755 hv_fcopy_daemon hv_kvp_daemon hv_vss_daemon
|
||||
|
||||
clean:
|
||||
rm -f hv_fcopy_daemon hv_kvp_daemon hv_vss_daemon
|
||||
docker images -q hvtools:build | xargs docker rmi -f
|
3
alpine/packages/hvtools/README.md
Normal file
3
alpine/packages/hvtools/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Hyper-V guest tools and daemons
|
||||
|
||||
This package contains a copy of the ./tools/hv directory of the matching Linux kernel source in ./src. At the top level directory are customised versions of the various scripts used by the daemons.
|
32
alpine/packages/hvtools/etc/init.d/hv_fcopy_daemon
Executable file
32
alpine/packages/hvtools/etc/init.d/hv_fcopy_daemon
Executable file
@ -0,0 +1,32 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
HV_DAEMON=hv_fcopy_daemon
|
||||
|
||||
start()
|
||||
{
|
||||
[ ! -d /sys/bus/vmbus ] && exit 0
|
||||
|
||||
ebegin "Starting Hyper-V Daemon: ${HV_DAEMON}"
|
||||
|
||||
[ -n "${PIDFILE}" ] || PIDFILE=/var/run/${HV_DAEMON}.pid
|
||||
|
||||
start-stop-daemon --start --quiet \
|
||||
--background \
|
||||
--exec /sbin/${HV_DAEMON} \
|
||||
--make-pidfile --pidfile ${PIDFILE} \
|
||||
--
|
||||
eend 0
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
[ ! -d /sys/bus/vmbus ] && exit 0
|
||||
|
||||
ebegin "Stopping Hyper-V Daemon: ${HV_DAEMON}"
|
||||
|
||||
[ -n "${PIDFILE}" ] || PIDFILE=/var/run/${HV_DAEMON}.pid
|
||||
|
||||
start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
|
||||
|
||||
eend $? "Failed to stop ${HV_DAEMON}"
|
||||
}
|
32
alpine/packages/hvtools/etc/init.d/hv_kvp_daemon
Executable file
32
alpine/packages/hvtools/etc/init.d/hv_kvp_daemon
Executable file
@ -0,0 +1,32 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
HV_DAEMON=hv_kvp_daemon
|
||||
|
||||
start()
|
||||
{
|
||||
[ ! -d /sys/bus/vmbus ] && exit 0
|
||||
|
||||
ebegin "Starting Hyper-V Daemon: ${HV_DAEMON}"
|
||||
|
||||
[ -n "${PIDFILE}" ] || PIDFILE=/var/run/${HV_DAEMON}.pid
|
||||
|
||||
start-stop-daemon --start --quiet \
|
||||
--background \
|
||||
--exec /sbin/${HV_DAEMON} \
|
||||
--make-pidfile --pidfile ${PIDFILE} \
|
||||
--
|
||||
eend 0
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
[ ! -d /sys/bus/vmbus ] && exit 0
|
||||
|
||||
ebegin "Stopping Hyper-V Daemon: ${HV_DAEMON}"
|
||||
|
||||
[ -n "${PIDFILE}" ] || PIDFILE=/var/run/${HV_DAEMON}.pid
|
||||
|
||||
start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
|
||||
|
||||
eend $? "Failed to stop ${HV_DAEMON}"
|
||||
}
|
32
alpine/packages/hvtools/etc/init.d/hv_vss_daemon
Executable file
32
alpine/packages/hvtools/etc/init.d/hv_vss_daemon
Executable file
@ -0,0 +1,32 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
HV_DAEMON=hv_vss_daemon
|
||||
|
||||
start()
|
||||
{
|
||||
[ ! -d /sys/bus/vmbus ] && exit 0
|
||||
|
||||
ebegin "Starting Hyper-V Daemon: ${HV_DAEMON}"
|
||||
|
||||
[ -n "${PIDFILE}" ] || PIDFILE=/var/run/${HV_DAEMON}.pid
|
||||
|
||||
start-stop-daemon --start --quiet \
|
||||
--background \
|
||||
--exec /sbin/${HV_DAEMON} \
|
||||
--make-pidfile --pidfile ${PIDFILE} \
|
||||
--
|
||||
eend 0
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
[ ! -d /sys/bus/vmbus ] && exit 0
|
||||
|
||||
ebegin "Stopping Hyper-V Daemon: ${HV_DAEMON}"
|
||||
|
||||
[ -n "${PIDFILE}" ] || PIDFILE=/var/run/${HV_DAEMON}.pid
|
||||
|
||||
start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
|
||||
|
||||
eend $? "Failed to stop ${HV_DAEMON}"
|
||||
}
|
30
alpine/packages/hvtools/hv_get_dhcp_info
Executable file
30
alpine/packages/hvtools/hv_get_dhcp_info
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Adjusted for Alpine
|
||||
|
||||
# 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/network/interfaces"
|
||||
|
||||
dhcp=$(grep "$1.*dhcp" $if_file 2>/dev/null)
|
||||
|
||||
if [ "$dhcp" != "" ];
|
||||
then
|
||||
echo "Enabled"
|
||||
else
|
||||
echo "Disabled"
|
||||
fi
|
13
alpine/packages/hvtools/hv_get_dns_info
Executable file
13
alpine/packages/hvtools/hv_get_dns_info
Executable 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 }'
|
90
alpine/packages/hvtools/hv_set_ifconfig
Executable file
90
alpine/packages/hvtools/hv_set_ifconfig
Executable file
@ -0,0 +1,90 @@
|
||||
#!/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
|
||||
# DEVICE=interface name
|
||||
# BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured
|
||||
# or "none" if no boot-time protocol should be used)
|
||||
#
|
||||
# IPADDR0=ipaddr1
|
||||
# IPADDR1=ipaddr2
|
||||
# IPADDRx=ipaddry (where y = x + 1)
|
||||
#
|
||||
# NETMASK0=netmask1
|
||||
# NETMASKx=netmasky (where y = x + 1)
|
||||
#
|
||||
# GATEWAY=ipaddr1
|
||||
# GATEWAYx=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.
|
||||
#
|
||||
|
||||
|
||||
##
|
||||
## XXX This is really hacky. We just whack the existing
|
||||
## /etc/network/interfaces and also only configure IPv4. This will
|
||||
## break with multiple network interfaces etc.
|
||||
##
|
||||
|
||||
|
||||
# Stash away a copy of the config we got
|
||||
cp $1 /etc/network/hv_config
|
||||
|
||||
# This is where we write the configuration
|
||||
outf=/etc/network/interfaces
|
||||
|
||||
# Source it
|
||||
. $1
|
||||
|
||||
# Down the interface
|
||||
ifdown $DEVICE
|
||||
|
||||
# create a new interfaces file
|
||||
echo "auto lo" > $outf
|
||||
echo "iface lo inet loopback" >> $outf
|
||||
echo "" >> outf
|
||||
echo "auto $DEVICE" >> $outf
|
||||
|
||||
if [ "$BOOTPROTO" = "dhcp" ]; then
|
||||
echo "iface $DEVICE inet dhcp" >> $outf
|
||||
else
|
||||
echo "iface $DEVICE inet static" >> $outf
|
||||
echo " address $IPADDR0" >> outf
|
||||
echo " netmask $NETMASK0" >> outf
|
||||
echo " gateway $GATEWAY" >> outf
|
||||
fi
|
||||
|
||||
echo " nameserver $DNS0" >> outf
|
||||
|
||||
echo " hwaddress ether $HWADDR" >> outf
|
||||
|
||||
# Up the interface
|
||||
ifup $DEVICE
|
13
alpine/packages/hvtools/src/Makefile
Normal file
13
alpine/packages/hvtools/src/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
# Makefile for Hyper-V tools
|
||||
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
PTHREAD_LIBS = -lpthread
|
||||
WARNINGS = -Wall -Wextra
|
||||
CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) $(shell getconf LFS_CFLAGS)
|
||||
|
||||
all: hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
|
||||
%: %.c
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
clean:
|
||||
$(RM) hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
|
221
alpine/packages/hvtools/src/hv_fcopy_daemon.c
Normal file
221
alpine/packages/hvtools/src/hv_fcopy_daemon.c
Normal file
@ -0,0 +1,221 @@
|
||||
/*
|
||||
* An implementation of host to guest copy functionality for Linux.
|
||||
*
|
||||
* Copyright (C) 2014, Microsoft, Inc.
|
||||
*
|
||||
* Author : K. Y. Srinivasan <kys@microsoft.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published
|
||||
* by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
|
||||
* NON INFRINGEMENT. See the GNU General Public License for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/poll.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/kdev_t.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <linux/hyperv.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <getopt.h>
|
||||
|
||||
static int target_fd;
|
||||
static char target_fname[W_MAX_PATH];
|
||||
|
||||
static int hv_start_fcopy(struct hv_start_fcopy *smsg)
|
||||
{
|
||||
int error = HV_E_FAIL;
|
||||
char *q, *p;
|
||||
|
||||
p = (char *)smsg->path_name;
|
||||
snprintf(target_fname, sizeof(target_fname), "%s/%s",
|
||||
(char *)smsg->path_name, (char *)smsg->file_name);
|
||||
|
||||
syslog(LOG_INFO, "Target file name: %s", target_fname);
|
||||
/*
|
||||
* Check to see if the path is already in place; if not,
|
||||
* create if required.
|
||||
*/
|
||||
while ((q = strchr(p, '/')) != NULL) {
|
||||
if (q == p) {
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
*q = '\0';
|
||||
if (access((char *)smsg->path_name, F_OK)) {
|
||||
if (smsg->copy_flags & CREATE_PATH) {
|
||||
if (mkdir((char *)smsg->path_name, 0755)) {
|
||||
syslog(LOG_ERR, "Failed to create %s",
|
||||
(char *)smsg->path_name);
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
syslog(LOG_ERR, "Invalid path: %s",
|
||||
(char *)smsg->path_name);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
p = q + 1;
|
||||
*q = '/';
|
||||
}
|
||||
|
||||
if (!access(target_fname, F_OK)) {
|
||||
syslog(LOG_INFO, "File: %s exists", target_fname);
|
||||
if (!(smsg->copy_flags & OVER_WRITE)) {
|
||||
error = HV_ERROR_ALREADY_EXISTS;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
target_fd = open(target_fname,
|
||||
O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744);
|
||||
if (target_fd == -1) {
|
||||
syslog(LOG_INFO, "Open Failed: %s", strerror(errno));
|
||||
goto done;
|
||||
}
|
||||
|
||||
error = 0;
|
||||
done:
|
||||
return error;
|
||||
}
|
||||
|
||||
static int hv_copy_data(struct hv_do_fcopy *cpmsg)
|
||||
{
|
||||
ssize_t bytes_written;
|
||||
|
||||
bytes_written = pwrite(target_fd, cpmsg->data, cpmsg->size,
|
||||
cpmsg->offset);
|
||||
|
||||
if (bytes_written != cpmsg->size)
|
||||
return HV_E_FAIL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hv_copy_finished(void)
|
||||
{
|
||||
close(target_fd);
|
||||
return 0;
|
||||
}
|
||||
static int hv_copy_cancel(void)
|
||||
{
|
||||
close(target_fd);
|
||||
unlink(target_fname);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void print_usage(char *argv[])
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [options]\n"
|
||||
"Options are:\n"
|
||||
" -n, --no-daemon stay in foreground, don't daemonize\n"
|
||||
" -h, --help print this help\n", argv[0]);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fcopy_fd, len;
|
||||
int error;
|
||||
int daemonize = 1, long_index = 0, opt;
|
||||
int version = FCOPY_CURRENT_VERSION;
|
||||
char *buffer[4096 * 2];
|
||||
struct hv_fcopy_hdr *in_msg;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"help", no_argument, 0, 'h' },
|
||||
{"no-daemon", no_argument, 0, 'n' },
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "hn", long_options,
|
||||
&long_index)) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
daemonize = 0;
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
print_usage(argv);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (daemonize && daemon(1, 0)) {
|
||||
syslog(LOG_ERR, "daemon() failed; error: %s", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
openlog("HV_FCOPY", 0, LOG_USER);
|
||||
syslog(LOG_INFO, "HV_FCOPY starting; pid is:%d", getpid());
|
||||
|
||||
fcopy_fd = open("/dev/vmbus/hv_fcopy", O_RDWR);
|
||||
|
||||
if (fcopy_fd < 0) {
|
||||
syslog(LOG_ERR, "open /dev/vmbus/hv_fcopy failed; error: %d %s",
|
||||
errno, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register with the kernel.
|
||||
*/
|
||||
if ((write(fcopy_fd, &version, sizeof(int))) != sizeof(int)) {
|
||||
syslog(LOG_ERR, "Registration failed: %s", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
/*
|
||||
* In this loop we process fcopy messages after the
|
||||
* handshake is complete.
|
||||
*/
|
||||
len = pread(fcopy_fd, buffer, (4096 * 2), 0);
|
||||
if (len < 0) {
|
||||
syslog(LOG_ERR, "pread failed: %s", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
in_msg = (struct hv_fcopy_hdr *)buffer;
|
||||
|
||||
switch (in_msg->operation) {
|
||||
case START_FILE_COPY:
|
||||
error = hv_start_fcopy((struct hv_start_fcopy *)in_msg);
|
||||
break;
|
||||
case WRITE_TO_FILE:
|
||||
error = hv_copy_data((struct hv_do_fcopy *)in_msg);
|
||||
break;
|
||||
case COMPLETE_FCOPY:
|
||||
error = hv_copy_finished();
|
||||
break;
|
||||
case CANCEL_FCOPY:
|
||||
error = hv_copy_cancel();
|
||||
break;
|
||||
|
||||
default:
|
||||
syslog(LOG_ERR, "Unknown operation: %d",
|
||||
in_msg->operation);
|
||||
|
||||
}
|
||||
|
||||
if (pwrite(fcopy_fd, &error, sizeof(int), 0) != sizeof(int)) {
|
||||
syslog(LOG_ERR, "pwrite failed: %s", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
28
alpine/packages/hvtools/src/hv_get_dhcp_info.sh
Executable file
28
alpine/packages/hvtools/src/hv_get_dhcp_info.sh
Executable 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
alpine/packages/hvtools/src/hv_get_dns_info.sh
Executable file
13
alpine/packages/hvtools/src/hv_get_dns_info.sh
Executable 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 }'
|
1783
alpine/packages/hvtools/src/hv_kvp_daemon.c
Normal file
1783
alpine/packages/hvtools/src/hv_kvp_daemon.c
Normal file
File diff suppressed because it is too large
Load Diff
64
alpine/packages/hvtools/src/hv_set_ifconfig.sh
Executable file
64
alpine/packages/hvtools/src/hv_set_ifconfig.sh
Executable file
@ -0,0 +1,64 @@
|
||||
#!/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
|
||||
# DEVICE=interface name
|
||||
# BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured
|
||||
# or "none" if no boot-time protocol should be used)
|
||||
#
|
||||
# IPADDR0=ipaddr1
|
||||
# IPADDR1=ipaddr2
|
||||
# IPADDRx=ipaddry (where y = x + 1)
|
||||
#
|
||||
# NETMASK0=netmask1
|
||||
# NETMASKx=netmasky (where y = x + 1)
|
||||
#
|
||||
# GATEWAY=ipaddr1
|
||||
# GATEWAYx=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
|
||||
|
||||
|
||||
cp $1 /etc/sysconfig/network-scripts/
|
||||
|
||||
|
||||
interface=$(echo $1 | awk -F - '{ print $2 }')
|
||||
|
||||
/sbin/ifdown $interface 2>/dev/null
|
||||
/sbin/ifup $interface 2>/dev/null
|
342
alpine/packages/hvtools/src/hv_vss_daemon.c
Normal file
342
alpine/packages/hvtools/src/hv_vss_daemon.c
Normal file
@ -0,0 +1,342 @@
|
||||
/*
|
||||
* An implementation of the host initiated guest snapshot for Hyper-V.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2013, Microsoft, Inc.
|
||||
* Author : K. Y. Srinivasan <kys@microsoft.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published
|
||||
* by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
|
||||
* NON INFRINGEMENT. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <mntent.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/connector.h>
|
||||
#include <linux/hyperv.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <syslog.h>
|
||||
#include <getopt.h>
|
||||
|
||||
static struct sockaddr_nl addr;
|
||||
|
||||
#ifndef SOL_NETLINK
|
||||
#define SOL_NETLINK 270
|
||||
#endif
|
||||
|
||||
|
||||
/* Don't use syslog() in the function since that can cause write to disk */
|
||||
static int vss_do_freeze(char *dir, unsigned int cmd)
|
||||
{
|
||||
int ret, fd = open(dir, O_RDONLY);
|
||||
|
||||
if (fd < 0)
|
||||
return 1;
|
||||
|
||||
ret = ioctl(fd, cmd, 0);
|
||||
|
||||
/*
|
||||
* If a partition is mounted more than once, only the first
|
||||
* FREEZE/THAW can succeed and the later ones will get
|
||||
* EBUSY/EINVAL respectively: there could be 2 cases:
|
||||
* 1) a user may mount the same partition to differnt directories
|
||||
* by mistake or on purpose;
|
||||
* 2) The subvolume of btrfs appears to have the same partition
|
||||
* mounted more than once.
|
||||
*/
|
||||
if (ret) {
|
||||
if ((cmd == FIFREEZE && errno == EBUSY) ||
|
||||
(cmd == FITHAW && errno == EINVAL)) {
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return !!ret;
|
||||
}
|
||||
|
||||
static int vss_operate(int operation)
|
||||
{
|
||||
char match[] = "/dev/";
|
||||
FILE *mounts;
|
||||
struct mntent *ent;
|
||||
char errdir[1024] = {0};
|
||||
unsigned int cmd;
|
||||
int error = 0, root_seen = 0, save_errno = 0;
|
||||
|
||||
switch (operation) {
|
||||
case VSS_OP_FREEZE:
|
||||
cmd = FIFREEZE;
|
||||
break;
|
||||
case VSS_OP_THAW:
|
||||
cmd = FITHAW;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
mounts = setmntent("/proc/mounts", "r");
|
||||
if (mounts == NULL)
|
||||
return -1;
|
||||
|
||||
while ((ent = getmntent(mounts))) {
|
||||
if (strncmp(ent->mnt_fsname, match, strlen(match)))
|
||||
continue;
|
||||
if (hasmntopt(ent, MNTOPT_RO) != NULL)
|
||||
continue;
|
||||
if (strcmp(ent->mnt_type, "vfat") == 0)
|
||||
continue;
|
||||
if (strcmp(ent->mnt_dir, "/") == 0) {
|
||||
root_seen = 1;
|
||||
continue;
|
||||
}
|
||||
error |= vss_do_freeze(ent->mnt_dir, cmd);
|
||||
if (error && operation == VSS_OP_FREEZE)
|
||||
goto err;
|
||||
}
|
||||
|
||||
endmntent(mounts);
|
||||
|
||||
if (root_seen) {
|
||||
error |= vss_do_freeze("/", cmd);
|
||||
if (error && operation == VSS_OP_FREEZE)
|
||||
goto err;
|
||||
}
|
||||
|
||||
goto out;
|
||||
err:
|
||||
save_errno = errno;
|
||||
if (ent) {
|
||||
strncpy(errdir, ent->mnt_dir, sizeof(errdir)-1);
|
||||
endmntent(mounts);
|
||||
}
|
||||
vss_operate(VSS_OP_THAW);
|
||||
/* Call syslog after we thaw all filesystems */
|
||||
if (ent)
|
||||
syslog(LOG_ERR, "FREEZE of %s failed; error:%d %s",
|
||||
errdir, save_errno, strerror(save_errno));
|
||||
else
|
||||
syslog(LOG_ERR, "FREEZE of / failed; error:%d %s", save_errno,
|
||||
strerror(save_errno));
|
||||
out:
|
||||
return error;
|
||||
}
|
||||
|
||||
static int netlink_send(int fd, struct cn_msg *msg)
|
||||
{
|
||||
struct nlmsghdr nlh = { .nlmsg_type = NLMSG_DONE };
|
||||
unsigned int size;
|
||||
struct msghdr message;
|
||||
struct iovec iov[2];
|
||||
|
||||
size = sizeof(struct cn_msg) + msg->len;
|
||||
|
||||
nlh.nlmsg_pid = getpid();
|
||||
nlh.nlmsg_len = NLMSG_LENGTH(size);
|
||||
|
||||
iov[0].iov_base = &nlh;
|
||||
iov[0].iov_len = sizeof(nlh);
|
||||
|
||||
iov[1].iov_base = msg;
|
||||
iov[1].iov_len = size;
|
||||
|
||||
memset(&message, 0, sizeof(message));
|
||||
message.msg_name = &addr;
|
||||
message.msg_namelen = sizeof(addr);
|
||||
message.msg_iov = iov;
|
||||
message.msg_iovlen = 2;
|
||||
|
||||
return sendmsg(fd, &message, 0);
|
||||
}
|
||||
|
||||
void print_usage(char *argv[])
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [options]\n"
|
||||
"Options are:\n"
|
||||
" -n, --no-daemon stay in foreground, don't daemonize\n"
|
||||
" -h, --help print this help\n", argv[0]);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd, len, nl_group;
|
||||
int error;
|
||||
struct cn_msg *message;
|
||||
struct pollfd pfd;
|
||||
struct nlmsghdr *incoming_msg;
|
||||
struct cn_msg *incoming_cn_msg;
|
||||
int op;
|
||||
struct hv_vss_msg *vss_msg;
|
||||
char *vss_recv_buffer;
|
||||
size_t vss_recv_buffer_len;
|
||||
int daemonize = 1, long_index = 0, opt;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"help", no_argument, 0, 'h' },
|
||||
{"no-daemon", no_argument, 0, 'n' },
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "hn", long_options,
|
||||
&long_index)) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
daemonize = 0;
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
print_usage(argv);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (daemonize && daemon(1, 0))
|
||||
return 1;
|
||||
|
||||
openlog("Hyper-V VSS", 0, LOG_USER);
|
||||
syslog(LOG_INFO, "VSS starting; pid is:%d", getpid());
|
||||
|
||||
vss_recv_buffer_len = NLMSG_LENGTH(0) + sizeof(struct cn_msg) + sizeof(struct hv_vss_msg);
|
||||
vss_recv_buffer = calloc(1, vss_recv_buffer_len);
|
||||
if (!vss_recv_buffer) {
|
||||
syslog(LOG_ERR, "Failed to allocate netlink buffers");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
|
||||
if (fd < 0) {
|
||||
syslog(LOG_ERR, "netlink socket creation failed; error:%d %s",
|
||||
errno, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
addr.nl_family = AF_NETLINK;
|
||||
addr.nl_pad = 0;
|
||||
addr.nl_pid = 0;
|
||||
addr.nl_groups = 0;
|
||||
|
||||
|
||||
error = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
|
||||
if (error < 0) {
|
||||
syslog(LOG_ERR, "bind failed; error:%d %s", errno, strerror(errno));
|
||||
close(fd);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
nl_group = CN_VSS_IDX;
|
||||
if (setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, sizeof(nl_group)) < 0) {
|
||||
syslog(LOG_ERR, "setsockopt failed; error:%d %s", errno, strerror(errno));
|
||||
close(fd);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/*
|
||||
* Register ourselves with the kernel.
|
||||
*/
|
||||
message = (struct cn_msg *)vss_recv_buffer;
|
||||
message->id.idx = CN_VSS_IDX;
|
||||
message->id.val = CN_VSS_VAL;
|
||||
message->ack = 0;
|
||||
vss_msg = (struct hv_vss_msg *)message->data;
|
||||
vss_msg->vss_hdr.operation = VSS_OP_REGISTER;
|
||||
|
||||
message->len = sizeof(struct hv_vss_msg);
|
||||
|
||||
len = netlink_send(fd, message);
|
||||
if (len < 0) {
|
||||
syslog(LOG_ERR, "netlink_send failed; error:%d %s", errno, strerror(errno));
|
||||
close(fd);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
pfd.fd = fd;
|
||||
|
||||
while (1) {
|
||||
struct sockaddr *addr_p = (struct sockaddr *) &addr;
|
||||
socklen_t addr_l = sizeof(addr);
|
||||
pfd.events = POLLIN;
|
||||
pfd.revents = 0;
|
||||
|
||||
if (poll(&pfd, 1, -1) < 0) {
|
||||
syslog(LOG_ERR, "poll failed; error:%d %s", errno, strerror(errno));
|
||||
if (errno == EINVAL) {
|
||||
close(fd);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
len = recvfrom(fd, vss_recv_buffer, vss_recv_buffer_len, 0,
|
||||
addr_p, &addr_l);
|
||||
|
||||
if (len < 0) {
|
||||
syslog(LOG_ERR, "recvfrom failed; pid:%u error:%d %s",
|
||||
addr.nl_pid, errno, strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (addr.nl_pid) {
|
||||
syslog(LOG_WARNING,
|
||||
"Received packet from untrusted pid:%u",
|
||||
addr.nl_pid);
|
||||
continue;
|
||||
}
|
||||
|
||||
incoming_msg = (struct nlmsghdr *)vss_recv_buffer;
|
||||
|
||||
if (incoming_msg->nlmsg_type != NLMSG_DONE)
|
||||
continue;
|
||||
|
||||
incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg);
|
||||
vss_msg = (struct hv_vss_msg *)incoming_cn_msg->data;
|
||||
op = vss_msg->vss_hdr.operation;
|
||||
error = HV_S_OK;
|
||||
|
||||
switch (op) {
|
||||
case VSS_OP_FREEZE:
|
||||
case VSS_OP_THAW:
|
||||
error = vss_operate(op);
|
||||
syslog(LOG_INFO, "VSS: op=%s: %s\n",
|
||||
op == VSS_OP_FREEZE ? "FREEZE" : "THAW",
|
||||
error ? "failed" : "succeeded");
|
||||
|
||||
if (error) {
|
||||
error = HV_E_FAIL;
|
||||
syslog(LOG_ERR, "op=%d failed!", op);
|
||||
syslog(LOG_ERR, "report it with these files:");
|
||||
syslog(LOG_ERR, "/etc/fstab and /proc/mounts");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
syslog(LOG_ERR, "Illegal op:%d\n", op);
|
||||
}
|
||||
vss_msg->error = error;
|
||||
len = netlink_send(fd, incoming_cn_msg);
|
||||
if (len < 0) {
|
||||
syslog(LOG_ERR, "net_link send failed; error:%d %s",
|
||||
errno, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
101
alpine/packages/hvtools/src/lsvmbus
Executable file
101
alpine/packages/hvtools/src/lsvmbus
Executable file
@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
from optparse import OptionParser
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-v", "--verbose", dest="verbose",
|
||||
help="print verbose messages. Try -vv, -vvv for \
|
||||
more verbose messages", action="count")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
verbose = 0
|
||||
if options.verbose is not None:
|
||||
verbose = options.verbose
|
||||
|
||||
vmbus_sys_path = '/sys/bus/vmbus/devices'
|
||||
if not os.path.isdir(vmbus_sys_path):
|
||||
print "%s doesn't exist: exiting..." % vmbus_sys_path
|
||||
exit(-1)
|
||||
|
||||
vmbus_dev_dict = {
|
||||
'{0e0b6031-5213-4934-818b-38d90ced39db}' : '[Operating system shutdown]',
|
||||
'{9527e630-d0ae-497b-adce-e80ab0175caf}' : '[Time Synchronization]',
|
||||
'{57164f39-9115-4e78-ab55-382f3bd5422d}' : '[Heartbeat]',
|
||||
'{a9a0f4e7-5a45-4d96-b827-8a841e8c03e6}' : '[Data Exchange]',
|
||||
'{35fa2e29-ea23-4236-96ae-3a6ebacba440}' : '[Backup (volume checkpoint)]',
|
||||
'{34d14be3-dee4-41c8-9ae7-6b174977c192}' : '[Guest services]',
|
||||
'{525074dc-8985-46e2-8057-a307dc18a502}' : '[Dynamic Memory]',
|
||||
'{cfa8b69e-5b4a-4cc0-b98b-8ba1a1f3f95a}' : 'Synthetic mouse',
|
||||
'{f912ad6d-2b17-48ea-bd65-f927a61c7684}' : 'Synthetic keyboard',
|
||||
'{da0a7802-e377-4aac-8e77-0558eb1073f8}' : 'Synthetic framebuffer adapter',
|
||||
'{f8615163-df3e-46c5-913f-f2d2f965ed0e}' : 'Synthetic network adapter',
|
||||
'{32412632-86cb-44a2-9b5c-50d1417354f5}' : 'Synthetic IDE Controller',
|
||||
'{ba6163d9-04a1-4d29-b605-72e2ffb1dc7f}' : 'Synthetic SCSI Controller',
|
||||
'{2f9bcc4a-0069-4af3-b76b-6fd0be528cda}' : 'Synthetic fiber channel adapter',
|
||||
'{8c2eaf3d-32a7-4b09-ab99-bd1f1c86b501}' : 'Synthetic RDMA adapter',
|
||||
'{276aacf4-ac15-426c-98dd-7521ad3f01fe}' : '[Reserved system device]',
|
||||
'{f8e65716-3cb3-4a06-9a60-1889c5cccab5}' : '[Reserved system device]',
|
||||
'{3375baf4-9e15-4b30-b765-67acb10d607b}' : '[Reserved system device]',
|
||||
}
|
||||
|
||||
def get_vmbus_dev_attr(dev_name, attr):
|
||||
try:
|
||||
f = open('%s/%s/%s' % (vmbus_sys_path, dev_name, attr), 'r')
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
except IOError:
|
||||
lines = []
|
||||
|
||||
return lines
|
||||
|
||||
class VMBus_Dev:
|
||||
pass
|
||||
|
||||
|
||||
vmbus_dev_list = []
|
||||
|
||||
for f in os.listdir(vmbus_sys_path):
|
||||
vmbus_id = get_vmbus_dev_attr(f, 'id')[0].strip()
|
||||
class_id = get_vmbus_dev_attr(f, 'class_id')[0].strip()
|
||||
device_id = get_vmbus_dev_attr(f, 'device_id')[0].strip()
|
||||
dev_desc = vmbus_dev_dict.get(class_id, 'Unknown')
|
||||
|
||||
chn_vp_mapping = get_vmbus_dev_attr(f, 'channel_vp_mapping')
|
||||
chn_vp_mapping = [c.strip() for c in chn_vp_mapping]
|
||||
chn_vp_mapping = sorted(chn_vp_mapping,
|
||||
key = lambda c : int(c.split(':')[0]))
|
||||
|
||||
chn_vp_mapping = ['\tRel_ID=%s, target_cpu=%s' %
|
||||
(c.split(':')[0], c.split(':')[1])
|
||||
for c in chn_vp_mapping]
|
||||
d = VMBus_Dev()
|
||||
d.sysfs_path = '%s/%s' % (vmbus_sys_path, f)
|
||||
d.vmbus_id = vmbus_id
|
||||
d.class_id = class_id
|
||||
d.device_id = device_id
|
||||
d.dev_desc = dev_desc
|
||||
d.chn_vp_mapping = '\n'.join(chn_vp_mapping)
|
||||
if d.chn_vp_mapping:
|
||||
d.chn_vp_mapping += '\n'
|
||||
|
||||
vmbus_dev_list.append(d)
|
||||
|
||||
|
||||
vmbus_dev_list = sorted(vmbus_dev_list, key = lambda d : int(d.vmbus_id))
|
||||
|
||||
format0 = '%2s: %s'
|
||||
format1 = '%2s: Class_ID = %s - %s\n%s'
|
||||
format2 = '%2s: Class_ID = %s - %s\n\tDevice_ID = %s\n\tSysfs path: %s\n%s'
|
||||
|
||||
for d in vmbus_dev_list:
|
||||
if verbose == 0:
|
||||
print ('VMBUS ID ' + format0) % (d.vmbus_id, d.dev_desc)
|
||||
elif verbose == 1:
|
||||
print ('VMBUS ID ' + format1) % \
|
||||
(d.vmbus_id, d.class_id, d.dev_desc, d.chn_vp_mapping)
|
||||
else:
|
||||
print ('VMBUS ID ' + format2) % \
|
||||
(d.vmbus_id, d.class_id, d.dev_desc, \
|
||||
d.device_id, d.sysfs_path, d.chn_vp_mapping)
|
Loading…
Reference in New Issue
Block a user