From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwXAN-0004X0-Fu for qemu-devel@nongnu.org; Wed, 11 Nov 2015 10:19:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwX9M-00027j-DX for qemu-devel@nongnu.org; Wed, 11 Nov 2015 10:18:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwX9M-00027U-17 for qemu-devel@nongnu.org; Wed, 11 Nov 2015 10:17:28 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id F3E3FC0BA170 for ; Wed, 11 Nov 2015 15:17:26 +0000 (UTC) Date: Wed, 11 Nov 2015 17:17:23 +0200 From: "Michael S. Tsirkin" Message-ID: <20151111171615-mutt-send-email-mst@redhat.com> References: <1447251876-4811-1-git-send-email-victork@redhat.com> <1366243584.6979611.1447252337630.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1366243584.6979611.1447252337630.JavaMail.zimbra@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] vhost-user: modify SET_LOG_BASE to pass mmap size and offset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Marc-Andr=E9?= Lureau Cc: Victor Kaplansky , qemu-devel@nongnu.org On Wed, Nov 11, 2015 at 09:32:17AM -0500, Marc-Andr=E9 Lureau wrote: > Hi >=20 > ----- Original Message ----- > > Unlike the kernel, vhost-user application accesses log table by > > mmaping it to its user space. This change adds two new fields to > > VhostUserMsg payload: mmap_size, and mmap_offset and make QEMU to > > pass the to vhost-user application in VHOST_USER_SET_LOG_BASE > > request. > >=20 > > Signed-off-by: Victor Kaplansky >=20 > What's the motivation for doing this? The offset is always 0, and the s= ize must at least match the size of VM memory. Remote doesn't know the size though, and offset is only there in the current implementation. > >=20 > > --- > > hw/virtio/vhost-user.c | 11 +++++++++-- > > tests/vhost-user-test.c | 8 ++++++++ > > docs/specs/vhost-user.txt | 8 +++++++- > > 3 files changed, 24 insertions(+), 3 deletions(-) > >=20 > > diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c > > index 83c84f1..46c63bc 100644 > > --- a/hw/virtio/vhost-user.c > > +++ b/hw/virtio/vhost-user.c > > @@ -75,6 +75,11 @@ typedef struct VhostUserMemory { > > VhostUserMemoryRegion regions[VHOST_MEMORY_MAX_NREGIONS]; > > } VhostUserMemory; > > =20 > > +typedef struct VhostUserLog { > > + uint64_t mmap_size; > > + uint64_t mmap_offset; > > +} VhostUserLog; > > + > > typedef struct VhostUserMsg { > > VhostUserRequest request; > > =20 > > @@ -89,6 +94,7 @@ typedef struct VhostUserMsg { > > struct vhost_vring_state state; > > struct vhost_vring_addr addr; > > VhostUserMemory memory; > > + VhostUserLog log; > > } payload; > > } QEMU_PACKED VhostUserMsg; > > =20 > > @@ -200,8 +206,9 @@ static int vhost_user_set_log_base(struct vhost_d= ev *dev, > > uint64_t base, > > VhostUserMsg msg =3D { > > .request =3D VHOST_USER_SET_LOG_BASE, > > .flags =3D VHOST_USER_VERSION, > > - .payload.u64 =3D base, > > - .size =3D sizeof(msg.payload.u64), > > + .payload.log.mmap_size =3D log->size, > > + .payload.log.mmap_offset =3D 0, > > + .size =3D sizeof(msg.payload.log), > > }; > > =20 > > if (shmfd && log->fd !=3D -1) { > > diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c > > index b6dde75..f005ecf 100644 > > --- a/tests/vhost-user-test.c > > +++ b/tests/vhost-user-test.c > > @@ -86,6 +86,11 @@ typedef struct VhostUserMemory { > > VhostUserMemoryRegion regions[VHOST_MEMORY_MAX_NREGIONS]; > > } VhostUserMemory; > > =20 > > +typedef struct VhostUserLog { > > + uint64_t mmap_size; > > + uint64_t mmap_offset; > > +} VhostUserLog; > > + > > typedef struct VhostUserMsg { > > VhostUserRequest request; > > =20 > > @@ -94,10 +99,13 @@ typedef struct VhostUserMsg { > > uint32_t flags; > > uint32_t size; /* the following payload size */ > > union { > > +#define VHOST_USER_VRING_IDX_MASK (0xff) > > +#define VHOST_USER_VRING_NOFD_MASK (0x1<<8) > > uint64_t u64; > > struct vhost_vring_state state; > > struct vhost_vring_addr addr; > > VhostUserMemory memory; > > + VhostUserLog log; > > } payload; > > } QEMU_PACKED VhostUserMsg; > > =20 > > diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt > > index e0d71e2..eb8f2b2 100644 > > --- a/docs/specs/vhost-user.txt > > +++ b/docs/specs/vhost-user.txt > > @@ -98,6 +98,7 @@ typedef struct VhostUserMsg { > > struct vhost_vring_state state; > > struct vhost_vring_addr addr; > > VhostUserMemory memory; > > + VhostUserLog log; > > }; > > } QEMU_PACKED VhostUserMsg; > > =20 > > @@ -282,7 +283,12 @@ Message types > > Master payload: u64 > > Slave payload: N/A > > =20 > > - Sets the logging base address. > > + Sets logging shared memory space. > > + When slave has VHOST_USER_PROTOCOL_F_LOG_SHMFD protocol > > + feature, the log memory fd is provided in the ancillary data o= f > > + VHOST_USER_SET_LOG_BASE message, the size and offset of shared > > + memory area provided in the message. > > + > > =20 > > * VHOST_USER_SET_LOG_FD > > =20 > > -- > > --Victor > >=20