diff options
Diffstat (limited to 'tools')
24 files changed, 826 insertions, 298 deletions
diff --git a/tools/Makefile b/tools/Makefile index feec3ad5fd09..bcae806b0c39 100644 --- a/tools/Makefile +++ b/tools/Makefile | |||
| @@ -7,6 +7,7 @@ help: | |||
| 7 | @echo ' cgroup - cgroup tools' | 7 | @echo ' cgroup - cgroup tools' |
| 8 | @echo ' cpupower - a tool for all things x86 CPU power' | 8 | @echo ' cpupower - a tool for all things x86 CPU power' |
| 9 | @echo ' firewire - the userspace part of nosy, an IEEE-1394 traffic sniffer' | 9 | @echo ' firewire - the userspace part of nosy, an IEEE-1394 traffic sniffer' |
| 10 | @echo ' hv - tools used when in Hyper-V clients' | ||
| 10 | @echo ' lguest - a minimal 32-bit x86 hypervisor' | 11 | @echo ' lguest - a minimal 32-bit x86 hypervisor' |
| 11 | @echo ' perf - Linux performance measurement and analysis tool' | 12 | @echo ' perf - Linux performance measurement and analysis tool' |
| 12 | @echo ' selftests - various kernel selftests' | 13 | @echo ' selftests - various kernel selftests' |
| @@ -40,7 +41,7 @@ acpi: FORCE | |||
| 40 | cpupower: FORCE | 41 | cpupower: FORCE |
| 41 | $(call descend,power/$@) | 42 | $(call descend,power/$@) |
| 42 | 43 | ||
| 43 | cgroup firewire guest usb virtio vm net: FORCE | 44 | cgroup firewire hv guest usb virtio vm net: FORCE |
| 44 | $(call descend,$@) | 45 | $(call descend,$@) |
| 45 | 46 | ||
| 46 | libapikfs: FORCE | 47 | libapikfs: FORCE |
| @@ -64,7 +65,7 @@ acpi_install: | |||
| 64 | cpupower_install: | 65 | cpupower_install: |
| 65 | $(call descend,power/$(@:_install=),install) | 66 | $(call descend,power/$(@:_install=),install) |
| 66 | 67 | ||
| 67 | cgroup_install firewire_install lguest_install perf_install usb_install virtio_install vm_install net_install: | 68 | cgroup_install firewire_install hv_install lguest_install perf_install usb_install virtio_install vm_install net_install: |
| 68 | $(call descend,$(@:_install=),install) | 69 | $(call descend,$(@:_install=),install) |
| 69 | 70 | ||
| 70 | selftests_install: | 71 | selftests_install: |
| @@ -76,7 +77,7 @@ turbostat_install x86_energy_perf_policy_install: | |||
| 76 | tmon_install: | 77 | tmon_install: |
| 77 | $(call descend,thermal/$(@:_install=),install) | 78 | $(call descend,thermal/$(@:_install=),install) |
| 78 | 79 | ||
| 79 | install: acpi_install cgroup_install cpupower_install firewire_install lguest_install \ | 80 | install: acpi_install cgroup_install cpupower_install hv_install firewire_install lguest_install \ |
| 80 | perf_install selftests_install turbostat_install usb_install \ | 81 | perf_install selftests_install turbostat_install usb_install \ |
| 81 | virtio_install vm_install net_install x86_energy_perf_policy_install \ | 82 | virtio_install vm_install net_install x86_energy_perf_policy_install \ |
| 82 | tmon | 83 | tmon |
| @@ -87,7 +88,7 @@ acpi_clean: | |||
| 87 | cpupower_clean: | 88 | cpupower_clean: |
| 88 | $(call descend,power/cpupower,clean) | 89 | $(call descend,power/cpupower,clean) |
| 89 | 90 | ||
| 90 | cgroup_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean: | 91 | cgroup_clean hv_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean: |
| 91 | $(call descend,$(@:_clean=),clean) | 92 | $(call descend,$(@:_clean=),clean) |
| 92 | 93 | ||
| 93 | libapikfs_clean: | 94 | libapikfs_clean: |
| @@ -105,7 +106,7 @@ turbostat_clean x86_energy_perf_policy_clean: | |||
| 105 | tmon_clean: | 106 | tmon_clean: |
| 106 | $(call descend,thermal/tmon,clean) | 107 | $(call descend,thermal/tmon,clean) |
| 107 | 108 | ||
| 108 | clean: acpi_clean cgroup_clean cpupower_clean firewire_clean lguest_clean \ | 109 | clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean lguest_clean \ |
| 109 | perf_clean selftests_clean turbostat_clean usb_clean virtio_clean \ | 110 | perf_clean selftests_clean turbostat_clean usb_clean virtio_clean \ |
| 110 | vm_clean net_clean x86_energy_perf_policy_clean tmon_clean | 111 | vm_clean net_clean x86_energy_perf_policy_clean tmon_clean |
| 111 | 112 | ||
diff --git a/tools/hv/Makefile b/tools/hv/Makefile new file mode 100644 index 000000000000..bd22f786a60c --- /dev/null +++ b/tools/hv/Makefile | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | # Makefile for Hyper-V tools | ||
| 2 | |||
| 3 | CC = $(CROSS_COMPILE)gcc | ||
| 4 | PTHREAD_LIBS = -lpthread | ||
| 5 | WARNINGS = -Wall -Wextra | ||
| 6 | CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) | ||
| 7 | |||
| 8 | all: hv_kvp_daemon hv_vss_daemon | ||
| 9 | %: %.c | ||
| 10 | $(CC) $(CFLAGS) -o $@ $^ | ||
| 11 | |||
| 12 | clean: | ||
| 13 | $(RM) hv_kvp_daemon hv_vss_daemon | ||
diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c new file mode 100644 index 000000000000..4ecc4fd0bc1b --- /dev/null +++ b/tools/hv/hv_fcopy_daemon.c | |||
| @@ -0,0 +1,195 @@ | |||
| 1 | /* | ||
| 2 | * An implementation of host to guest copy functionality for Linux. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2014, Microsoft, Inc. | ||
| 5 | * | ||
| 6 | * Author : K. Y. Srinivasan <kys@microsoft.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify it | ||
| 9 | * under the terms of the GNU General Public License version 2 as published | ||
| 10 | * by the Free Software Foundation. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but | ||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
| 15 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
| 16 | * details. | ||
| 17 | */ | ||
| 18 | |||
| 19 | |||
| 20 | #include <sys/types.h> | ||
| 21 | #include <sys/socket.h> | ||
| 22 | #include <sys/poll.h> | ||
| 23 | #include <linux/types.h> | ||
| 24 | #include <linux/kdev_t.h> | ||
| 25 | #include <stdio.h> | ||
| 26 | #include <stdlib.h> | ||
| 27 | #include <unistd.h> | ||
| 28 | #include <string.h> | ||
| 29 | #include <ctype.h> | ||
| 30 | #include <errno.h> | ||
| 31 | #include <linux/hyperv.h> | ||
| 32 | #include <syslog.h> | ||
| 33 | #include <sys/stat.h> | ||
| 34 | #include <fcntl.h> | ||
| 35 | #include <dirent.h> | ||
| 36 | |||
| 37 | static int target_fd; | ||
| 38 | static char target_fname[W_MAX_PATH]; | ||
| 39 | |||
| 40 | static int hv_start_fcopy(struct hv_start_fcopy *smsg) | ||
| 41 | { | ||
| 42 | int error = HV_E_FAIL; | ||
| 43 | char *q, *p; | ||
| 44 | |||
| 45 | /* | ||
| 46 | * If possile append a path seperator to the path. | ||
| 47 | */ | ||
| 48 | if (strlen((char *)smsg->path_name) < (W_MAX_PATH - 2)) | ||
| 49 | strcat((char *)smsg->path_name, "/"); | ||
| 50 | |||
| 51 | p = (char *)smsg->path_name; | ||
| 52 | snprintf(target_fname, sizeof(target_fname), "%s/%s", | ||
| 53 | (char *)smsg->path_name, smsg->file_name); | ||
| 54 | |||
| 55 | syslog(LOG_INFO, "Target file name: %s", target_fname); | ||
| 56 | /* | ||
| 57 | * Check to see if the path is already in place; if not, | ||
| 58 | * create if required. | ||
| 59 | */ | ||
| 60 | while ((q = strchr(p, '/')) != NULL) { | ||
| 61 | if (q == p) { | ||
| 62 | p++; | ||
| 63 | continue; | ||
| 64 | } | ||
| 65 | *q = '\0'; | ||
| 66 | if (access((char *)smsg->path_name, F_OK)) { | ||
| 67 | if (smsg->copy_flags & CREATE_PATH) { | ||
| 68 | if (mkdir((char *)smsg->path_name, 0755)) { | ||
| 69 | syslog(LOG_ERR, "Failed to create %s", | ||
| 70 | (char *)smsg->path_name); | ||
| 71 | goto done; | ||
| 72 | } | ||
| 73 | } else { | ||
| 74 | syslog(LOG_ERR, "Invalid path: %s", | ||
| 75 | (char *)smsg->path_name); | ||
| 76 | goto done; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | p = q + 1; | ||
| 80 | *q = '/'; | ||
| 81 | } | ||
| 82 | |||
