From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ew51f-00034Q-WC for qemu-devel@nongnu.org; Wed, 14 Mar 2018 07:57:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ew51f-0004fn-3a for qemu-devel@nongnu.org; Wed, 14 Mar 2018 07:57:00 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40894 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ew51e-0004fW-Vq for qemu-devel@nongnu.org; Wed, 14 Mar 2018 07:56:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 825858182D16 for ; Wed, 14 Mar 2018 11:56:58 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" Date: Wed, 14 Mar 2018 11:55:59 +0000 Message-Id: <20180314115618.28831-11-dgilbert@redhat.com> In-Reply-To: <20180314115618.28831-1-dgilbert@redhat.com> References: <20180314115618.28831-1-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v6 10/29] vhost+postcopy: Register shared ufd with postcopy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, mst@redhat.com, maxime.coquelin@redhat.com, marcandre.lureau@redhat.com, peterx@redhat.com, quintela@redhat.com Cc: aarcange@redhat.com From: "Dr. David Alan Gilbert" Register the UFD that comes in as the response to the 'advise' method with the postcopy code. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/virtio/vhost-user.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 5bcf4c3b91..ae7754f596 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -173,6 +173,7 @@ struct vhost_user { CharBackend *chr; int slave_fd; NotifierWithReturn postcopy_notifier; + struct PostCopyFD postcopy_fd; }; =20 static bool ioeventfd_enabled(void) @@ -812,6 +813,17 @@ out: return ret; } =20 +/* + * Called back from the postcopy fault thread when a fault is received o= n our + * ufd. + * TODO: This is Linux specific + */ +static int vhost_user_postcopy_fault_handler(struct PostCopyFD *pcfd, + void *ufd) +{ + return 0; +} + /* * Called at the start of an inbound postcopy on reception of the * 'advise' command. @@ -851,8 +863,14 @@ static int vhost_user_postcopy_advise(struct vhost_d= ev *dev, Error **errp) error_setg(errp, "%s: Failed to get ufd", __func__); return -1; } + fcntl(ufd, F_SETFL, O_NONBLOCK); =20 - /* TODO: register ufd with userfault thread */ + /* register ufd with userfault thread */ + u->postcopy_fd.fd =3D ufd; + u->postcopy_fd.data =3D dev; + u->postcopy_fd.handler =3D vhost_user_postcopy_fault_handler; + u->postcopy_fd.idstr =3D "vhost-user"; /* Need to find unique name *= / + postcopy_register_shared_ufd(&u->postcopy_fd); return 0; } =20 --=20 2.14.3