int xengnttab_set_max_grants(xengnttab_handle *xgt,
uint32_t nr_grants);
+struct xengnttab_grant_copy_segment {
+ union xengnttab_copy_ptr {
+ void *virt;
+ struct {
+ uint32_t ref;
+ uint16_t offset;
+ uint16_t domid;
+ } foreign;
+ } source, dest;
+ uint16_t len;
+ uint16_t flags;
+ int16_t status;
+};
+
+typedef struct xengnttab_grant_copy_segment xengnttab_grant_copy_segment_t;
+
+/**
+ * Copy memory from or to grant references. The information of each operations
+ * are contained in 'xengnttab_grant_copy_segment_t'. The @flag value indicate
+ * the direction of an operation (GNTCOPY_source_gref\GNTCOPY_dest_gref).
+ *
+ * For each segment, @virt may cross a page boundary but @offset + @len
+ * must not exceed XEN_PAGE_SIZE.
+ */
+int xengnttab_grant_copy(xengnttab_handle *xgt,
+ uint32_t count,
+ xengnttab_grant_copy_segment_t *segs);
+
/*
* Grant Sharing Interface (allocating and granting pages to others)
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
+#include <stddef.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <xen/sys/gntdev.h>
#include <xen/sys/gntalloc.h>
+#include <xen-tools/libs.h>
+
#include "private.h"
#define DEVXEN "/dev/xen/"
return 0;
}
+int osdep_gnttab_grant_copy(xengnttab_handle *xgt,
+ uint32_t count,
+ xengnttab_grant_copy_segment_t *segs)
+{
+ int rc;
+ int fd = xgt->fd;
+ struct ioctl_gntdev_grant_copy copy;
+
+ BUILD_BUG_ON(sizeof(struct ioctl_gntdev_grant_copy_segment) !=
+ sizeof(xengnttab_grant_copy_segment_t));
+
+ BUILD_BUG_ON(__alignof__(struct ioctl_gntdev_grant_copy_segment) !=
+ __alignof__(xengnttab_grant_copy_segment_t));
+
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ source.virt) !=
+ offsetof(xengnttab_grant_copy_segment_t,
+ source.virt));
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ source.foreign) !=
+ offsetof(xengnttab_grant_copy_segment_t,
+ source.foreign));
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ source.foreign.ref) !=
+ offsetof(xengnttab_grant_copy_segment_t,
+ source.foreign));
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ source.foreign.offset) !=
+ offsetof(xengnttab_grant_copy_segment_t,
+ source.foreign.offset));
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ source.foreign.domid) !=
+ offsetof(xengnttab_grant_copy_segment_t,
+ source.foreign.domid));
+
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ dest.virt) !=
+ offsetof(xengnttab_grant_copy_segment_t,
+ dest.virt));
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ dest.foreign) !=
+ offsetof(xengnttab_grant_copy_segment_t,
+ dest.foreign));
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ dest.foreign.ref) !=
+ offsetof(xengnttab_grant_copy_segment_t,
+ dest.foreign));
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ dest.foreign.offset) !=
+ offsetof(xengnttab_grant_copy_segment_t,
+ dest.foreign.offset));
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ dest.foreign.domid) !=
+ offsetof(xengnttab_grant_copy_segment_t,
+ dest.foreign.domid));
+
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ len) !=
+ offsetof(xengnttab_grant_copy_segment_t, len));
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ flags) !=
+ offsetof(xengnttab_grant_copy_segment_t, flags));
+ BUILD_BUG_ON(offsetof(struct ioctl_gntdev_grant_copy_segment,
+ status) !=
+ offsetof(xengnttab_grant_copy_segment_t, status));
+
+ copy.segments = (struct ioctl_gntdev_grant_copy_segment *)segs;
+ copy.count = count;
+
+ rc = ioctl(fd, IOCTL_GNTDEV_GRANT_COPY, ©);
+ if (rc)
+ GTERROR(xgt->logger, "ioctl GRANT COPY failed %d ", errno);
+
+ return rc;
+}
+
int osdep_gntshr_open(xengntshr_handle *xgs)
{
int fd = open(DEVXEN "gntalloc", O_RDWR);