From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH] vhost: fix mem share between VM and host Date: Tue, 12 Apr 2016 00:41:20 +0800 Message-ID: <20160411164120.GH3080@yliu-dev.sh.intel.com> References: <1460309332-21981-1-git-send-email-zhe.tao@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "Tao, Zhe" , "dev@dpdk.org" To: "Xie, Huawei" Return-path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id E0BF8CE7 for ; Mon, 11 Apr 2016 18:38:53 +0200 (CEST) Content-Disposition: inline In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Mon, Apr 11, 2016 at 06:22:12AM +0000, Xie, Huawei wrote: > On 4/11/2016 1:29 AM, Zhe Tao wrote: > > > > +/* Check the share memory in case the QEMU doesn't set the share option > > + * as on for the memory-backend-file object in the QEMU command line. > > + */ > > + > > +int > > +vhost_check_mem_shared(struct vhost_device_ctx ctx) > > +{ > > + struct virtio_net *dev; > > + struct vhost_virtqueue *vq; > > + int ret = 0; > > + > > + dev = get_device(ctx); > > + if ((dev == NULL) || (dev->mem == NULL)) > > + return -1; > > + > > + /* check first virtqueue 0 rxq. */ > > + vq = dev->virtqueue[VIRTIO_RXQ]; > > + ret = vq->desc[0].next == 0 ? -1 : 0; > > + > > + if (ret) > > + RTE_LOG(ERR, VHOST_CONFIG, > > + "The mem is not shared between VM and host\n"); > > + > > + return ret; > > +} > > + > > Zhe: This is known to vhost-user users that share=on is a must-to-have > option. I think this isn't an issue. Agreed. > It is OK if we could do some early check in vhost, however we couldn't I think if there is really a need to do the check, it might should be done in QEMU: the option is from QEMU after all. > assume the value of vq->desc[0].next. > Check if there is other simple and reliable way. I will not say no to an elegant check though. --yliu