From: "Jan Beulich" Subject: [PATCH] libxc: implement gnttab.set_max_grants for Linux Date: Fri, 11 May 2012 08:23:20 +0100 Message-ID: <4FACDA880200007800082F18@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part4D63A378.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part4D63A378.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Legacy (non-pvops) gntdev drivers may require this operation to be performed when the number of grants intended to be used simultaneously exceeds a certain driver specific default limit, and qemu's qdisk driver is an example of needing to do so. Signed-off-by: Jan Beulich --- a/tools/libxc/xc_linux_osdep.c +++ b/tools/libxc/xc_linux_osdep.c @@ -541,6 +541,27 @@ static int linux_gnttab_close(xc_gnttab=20 return close(fd); } =20 +static int linux_gnttab_set_max_grants(xc_gnttab *xch, xc_osdep_handle h, + uint32_t count) +{ + int fd =3D (int)h, rc; + struct ioctl_gntdev_set_max_grants max_grants =3D { .count =3D count = }; + + rc =3D ioctl(fd, IOCTL_GNTDEV_SET_MAX_GRANTS, &max_grants); + if (rc) { + /* + * Newer (e.g. pv-ops) kernels don't implement this IOCTL, + * so ignore the resulting specific failure. + */ + if (errno =3D=3D ENOTTY) + rc =3D 0; + else + PERROR("linux_gnttab_set_max_grants: ioctl SET_MAX_GRANTS = failed"); + } + + return rc; +} + static void *linux_gnttab_grant_map(xc_gnttab *xch, xc_osdep_handle h, uint32_t count, int flags, int prot, uint32_t *domids, uint32_t *refs, @@ -680,6 +701,7 @@ static struct xc_osdep_ops linux_gnttab_ .close =3D &linux_gnttab_close, =20 .u.gnttab =3D { + .set_max_grants =3D linux_gnttab_set_max_grants, .grant_map =3D &linux_gnttab_grant_map, .munmap =3D &linux_gnttab_munmap, }, --=__Part4D63A378.0__= Content-Type: text/plain; name="libxc-linux-set-max-grants.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="libxc-linux-set-max-grants.patch" libxc: implement gnttab.set_max_grants for Linux=0A=0ALegacy (non-pvops) = gntdev drivers may require this operation to be=0Aperformed when the = number of grants intended to be used simultaneously=0Aexceeds a certain = driver specific default limit, and qemu's qdisk=0Adriver is an example of = needing to do so.=0A=0ASigned-off-by: Jan Beulich =0A=0A= --- a/tools/libxc/xc_linux_osdep.c=0A+++ b/tools/libxc/xc_linux_osdep.c=0A@= @ -541,6 +541,27 @@ static int linux_gnttab_close(xc_gnttab =0A return = close(fd);=0A }=0A =0A+static int linux_gnttab_set_max_grants(xc_gnttab = *xch, xc_osdep_handle h,=0A+ = uint32_t count)=0A+{=0A+ int fd =3D (int)h, rc;=0A+ struct ioctl_gntd= ev_set_max_grants max_grants =3D { .count =3D count };=0A+=0A+ rc =3D = ioctl(fd, IOCTL_GNTDEV_SET_MAX_GRANTS, &max_grants);=0A+ if (rc) {=0A+ = /*=0A+ * Newer (e.g. pv-ops) kernels don't implement this = IOCTL,=0A+ * so ignore the resulting specific failure.=0A+ = */=0A+ if (errno =3D=3D ENOTTY)=0A+ rc =3D 0;=0A+ = else=0A+ PERROR("linux_gnttab_set_max_grants: ioctl SET_MAX_GRAN= TS failed");=0A+ }=0A+=0A+ return rc;=0A+}=0A+=0A static void = *linux_gnttab_grant_map(xc_gnttab *xch, xc_osdep_handle h,=0A = uint32_t count, int flags, int prot,=0A = uint32_t *domids, uint32_t *refs,=0A@@ -680,6 = +701,7 @@ static struct xc_osdep_ops linux_gnttab_=0A .close =3D = &linux_gnttab_close,=0A =0A .u.gnttab =3D {=0A+ .set_max_grants = =3D linux_gnttab_set_max_grants,=0A .grant_map =3D &linux_gnttab_gr= ant_map,=0A .munmap =3D &linux_gnttab_munmap,=0A },=0A --=__Part4D63A378.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part4D63A378.0__=--