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>
This commit is contained in:
K. Y. Srinivasan 2014-02-16 11:34:30 -08:00 committed by Greg Kroah-Hartman
parent e0270addae
commit 01325476d6
7 changed files with 682 additions and 2 deletions

View file

@ -25,6 +25,8 @@
#ifndef _UAPI_HYPERV_H
#define _UAPI_HYPERV_H
#include <linux/uuid.h>
/*
* Framework version for util services.
*/
@ -93,6 +95,50 @@ struct hv_vss_msg {
};
} __attribute__((packed));
/*
* Implementation of a host to guest copy facility.
*/
#define FCOPY_VERSION_0 0
#define FCOPY_CURRENT_VERSION FCOPY_VERSION_0
#define W_MAX_PATH 260
enum hv_fcopy_op {
START_FILE_COPY = 0,
WRITE_TO_FILE,
COMPLETE_FCOPY,
CANCEL_FCOPY,
};
struct hv_fcopy_hdr {
__u32 operation;
uuid_le service_id0; /* currently unused */
uuid_le service_id1; /* currently unused */
} __attribute__((packed));
#define OVER_WRITE 0x1
#define CREATE_PATH 0x2
struct hv_start_fcopy {
struct hv_fcopy_hdr hdr;
__u16 file_name[W_MAX_PATH];
__u16 path_name[W_MAX_PATH];
__u32 copy_flags;
__u64 file_size;
} __attribute__((packed));
/*
* The file is chunked into fragments.
*/
#define DATA_FRAGMENT (6 * 1024)
struct hv_do_fcopy {
struct hv_fcopy_hdr hdr;
__u64 offset;
__u32 size;
__u8 data[DATA_FRAGMENT];
};
/*
* An implementation of HyperV key value pair (KVP) functionality for Linux.
*