From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 0076E2BE6 for ; Mon, 11 Apr 2016 08:23:01 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 10 Apr 2016 23:23:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,462,1455004800"; d="scan'208";a="929708839" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga001.jf.intel.com with ESMTP; 10 Apr 2016 23:22:58 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 10 Apr 2016 23:22:47 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 10 Apr 2016 23:22:47 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.136]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.10]) with mapi id 14.03.0248.002; Mon, 11 Apr 2016 14:22:13 +0800 From: "Xie, Huawei" To: "Tao, Zhe" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] vhost: fix mem share between VM and host Thread-Index: AdGTunrJxVkJxEYUQsKLdkzY8lzPwQ== Date: Mon, 11 Apr 2016 06:22:12 +0000 Message-ID: References: <1460309332-21981-1-git-send-email-zhe.tao@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] vhost: fix mem share between VM and host X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2016 06:23:04 -0000 On 4/11/2016 1:29 AM, Zhe Tao wrote:=0A= > =0A= > +/* Check the share memory in case the QEMU doesn't set the share option= =0A= > + * as on for the memory-backend-file object in the QEMU command line.=0A= > + */=0A= > +=0A= > +int=0A= > +vhost_check_mem_shared(struct vhost_device_ctx ctx)=0A= > +{=0A= > + struct virtio_net *dev;=0A= > + struct vhost_virtqueue *vq;=0A= > + int ret =3D 0;=0A= > +=0A= > + dev =3D get_device(ctx);=0A= > + if ((dev =3D=3D NULL) || (dev->mem =3D=3D NULL))=0A= > + return -1;=0A= > +=0A= > + /* check first virtqueue 0 rxq. */=0A= > + vq =3D dev->virtqueue[VIRTIO_RXQ];=0A= > + ret =3D vq->desc[0].next =3D=3D 0 ? -1 : 0;=0A= > +=0A= > + if (ret)=0A= > + RTE_LOG(ERR, VHOST_CONFIG,=0A= > + "The mem is not shared between VM and host\n");=0A= > +=0A= > + return ret;=0A= > +}=0A= > +=0A= =0A= Zhe: This is known to vhost-user users that share=3Don is a must-to-have=0A= option. I think this isn't an issue.=0A= It is OK if we could do some early check in vhost, however we couldn't=0A= assume the value of vq->desc[0].next.=0A= Check if there is other simple and reliable way.=0A= =0A=