[dpdk-dev] [PATCH] vhost: fix mem share between VM and host
Yuanhan Liu
yuanhan.liu at linux.intel.com
Mon Apr 11 18:41:20 CEST 2016
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
More information about the dev
mailing list