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.
It is OK if we could do some early check in vhost, however we couldn't
assume the value of vq->desc[0].next.
Check if there is other simple and reliable way.

Reply via email to