Skip to contentSkip to conversation

Drivers: hv: Implement the file copy service

PATCH New K. Y. Srinivasan 1 participant 1 message Feb 16, 2014 Hyper-V/Azure core and drivers

lore
Share & tools
lore
#0 lore raw

PATCH v7 1/1 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 <[email protected]> and Dan Carpenter <[email protected]>

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.

---
 drivers/hv/Makefile         |    2 +-
 drivers/hv/hv_fcopy.c       |  414 +++++++++++++++++++++++++++++++++++++++++++
 drivers/hv/hv_util.c        |   11 ++
 drivers/hv/hyperv_vmbus.h   |    4 +
 include/linux/hyperv.h      |   12 ++-
 include/uapi/linux/hyperv.h |   46 +++++
 tools/hv/hv_fcopy_daemon.c  |  195 ++++++++++++++++++++
 7 files changed, 682 insertions(+), 2 deletions(-)
 create mode 100644 drivers/hv/hv_fcopy.c
 create mode 100644 tools/hv/hv_fcopy_daemon.c
drivers/hv/Makefile +1 -1
index 0a74b56..5e4dfa4 100644
@@ -5,4 +5,4 @@ obj-$(CONFIG_HYPERV_BALLOON)	+= hv_balloon.o
 hv_vmbus-y := vmbus_drv.o \
 		 hv.o connection.o channel.o \
 		 channel_mgmt.o ring_buffer.o
-hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o
+hv_utils-y := hv_util.o hv_kvp.o hv_snapshot.o hv_fcopy.o
drivers/hv/hv_fcopy.c new file +414 -0

414 lines not on this page · raw message

drivers/hv/hv_util.c +11 -0
index 62dfd246..dd76180 100644
@@ -28,6 +28,7 @@
 #include <linux/reboot.h>
 #include <linux/hyperv.h>
 
+#include "hyperv_vmbus.h"
 
 #define SD_MAJOR	3
 #define SD_MINOR	0
@@ -82,6 +83,12 @@ static struct hv_util_service util_vss = {
 	.util_deinit = hv_vss_deinit,
 };
 
+static struct hv_util_service util_fcopy = {
+	.util_cb = hv_fcopy_onchannelcallback,
+	.util_init = hv_fcopy_init,
+	.util_deinit = hv_fcopy_deinit,
+};
+
 static void perform_shutdown(struct work_struct *dummy)
 {
 	orderly_poweroff(true);
@@ -401,6 +408,10 @@ static const struct hv_vmbus_device_id id_table[] = {
 	{ HV_VSS_GUID,
 	  .driver_data = (unsigned long)&util_vss
 	},
+	/* File copy GUID */
+	{ HV_FCOPY_GUID,
+	  .driver_data = (unsigned long)&util_fcopy
+	},
 	{ },
 };
 
drivers/hv/hyperv_vmbus.h +4 -0
index 1544609..860134d 100644
@@ -669,5 +669,9 @@ int vmbus_set_event(struct vmbus_channel *channel);
 
 void vmbus_on_event(unsigned long data);
 
+int hv_fcopy_init(struct hv_util_service *);
+void hv_fcopy_deinit(void);
+void hv_fcopy_onchannelcallback(void *);
+
 
 #endif /* _HYPERV_VMBUS_H */
include/linux/hyperv.h +11 -1
index fb66fba..62ea1a0 100644
@@ -30,7 +30,6 @@
 #include <linux/types.h>
 #include <linux/scatterlist.h>
 #include <linux/list.h>
-#include <linux/uuid.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
 #include <linux/completion.h>
@@ -1050,6 +1049,17 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver);
 		}
 
 /*
+ * Guest File Copy Service
+ * {34D14BE3-DEE4-41c8-9AE7-6B174977C192}
+ */
+
+#define HV_FCOPY_GUID \
+	.guid = { \
+			0xE3, 0x4B, 0xD1, 0x34, 0xE4, 0xDE, 0xC8, 0x41, \
+			0x9A, 0xE7, 0x6B, 0x17, 0x49, 0x77, 0xC1, 0x92 \
+		}
+
+/*
  * Common header for Hyper-V ICs
  */
 
include/uapi/linux/hyperv.h +46 -0

58 lines not on this page · raw message

tools/hv/hv_fcopy_daemon.c new file +195 -0

195 lines not on this page · raw message

Signature · 1 line
1.7.4.1