Re: [PULL v2 10/20] libvduse: Add VDUSE (vDPA Device in Userspace) library
On Mon, Jun 27, 2022 at 12:45 PM Markus Armbruster wrote: > > Kevin Wolf writes: > > > From: Xie Yongji > > > > VDUSE [1] is a linux framework that makes it possible to implement > > software-emulated vDPA devices in userspace. This adds a library > > as a subproject to help implementing VDUSE backends in QEMU. > > > > [1] https://www.kernel.org/doc/html/latest/userspace-api/vduse.html > > > > Signed-off-by: Xie Yongji > > Message-Id: <20220523084611.91-6-xieyon...@bytedance.com> > > Reviewed-by: Stefan Hajnoczi > > Signed-off-by: Kevin Wolf > > --- > > meson_options.txt |2 + > > subprojects/libvduse/include/atomic.h |1 + > > subprojects/libvduse/include/compiler.h |1 + > > subprojects/libvduse/libvduse.h | 235 > > subprojects/libvduse/libvduse.c | 1150 +++ > > MAINTAINERS |5 + > > meson.build | 15 + > > scripts/meson-buildoptions.sh |3 + > > subprojects/libvduse/linux-headers/linux|1 + > > subprojects/libvduse/meson.build| 10 + > > subprojects/libvduse/standard-headers/linux |1 + > > 11 files changed, 1424 insertions(+) > > create mode 12 subprojects/libvduse/include/atomic.h > > create mode 12 subprojects/libvduse/include/compiler.h > > create mode 100644 subprojects/libvduse/libvduse.h > > create mode 100644 subprojects/libvduse/libvduse.c > > create mode 12 subprojects/libvduse/linux-headers/linux > > create mode 100644 subprojects/libvduse/meson.build > > create mode 12 subprojects/libvduse/standard-headers/linux > > > > diff --git a/meson_options.txt b/meson_options.txt > > index f3e2f22c1e..23a9f440f7 100644 > > --- a/meson_options.txt > > +++ b/meson_options.txt > > @@ -257,6 +257,8 @@ option('virtfs', type: 'feature', value: 'auto', > > description: 'virtio-9p support') > > option('virtiofsd', type: 'feature', value: 'auto', > > description: 'build virtiofs daemon (virtiofsd)') > > +option('libvduse', type: 'feature', value: 'auto', > > + description: 'build VDUSE Library') > > > > option('capstone', type: 'feature', value: 'auto', > > description: 'Whether and how to find the capstone library') > > diff --git a/subprojects/libvduse/include/atomic.h > > b/subprojects/libvduse/include/atomic.h > > new file mode 12 > > index 00..8c2be64f7b > > --- /dev/null > > +++ b/subprojects/libvduse/include/atomic.h > > @@ -0,0 +1 @@ > > +../../../include/qemu/atomic.h > > \ No newline at end of file > > diff --git a/subprojects/libvduse/include/compiler.h > > b/subprojects/libvduse/include/compiler.h > > new file mode 12 > > index 00..de7b70697c > > --- /dev/null > > +++ b/subprojects/libvduse/include/compiler.h > > @@ -0,0 +1 @@ > > +../../../include/qemu/compiler.h > > \ No newline at end of file > > diff --git a/subprojects/libvduse/libvduse.h > > b/subprojects/libvduse/libvduse.h > > new file mode 100644 > > index 00..6c2fe98213 > > --- /dev/null > > +++ b/subprojects/libvduse/libvduse.h > > @@ -0,0 +1,235 @@ > > +/* > > + * VDUSE (vDPA Device in Userspace) library > > + * > > + * Copyright (C) 2022 Bytedance Inc. and/or its affiliates. All rights > > reserved. > > + * > > + * Author: > > + * Xie Yongji > > + * > > + * This work is licensed under the terms of the GNU GPL, version 2 or > > + * later. See the COPYING file in the top-level directory. > > + */ > > + > > +#ifndef LIBVDUSE_H > > +#define LIBVDUSE_H > > + > > +#include > > +#include > > + > > +#define VIRTQUEUE_MAX_SIZE 1024 > > + > > +/* VDUSE device structure */ > > +typedef struct VduseDev VduseDev; > > + > > +/* Virtqueue structure */ > > +typedef struct VduseVirtq VduseVirtq; > > + > > +/* Some operation of VDUSE backend */ > > +typedef struct VduseOps { > > +/* Called when virtqueue can be processed */ > > +void (*enable_queue)(VduseDev *dev, VduseVirtq *vq); > > +/* Called when virtqueue processing should be stopped */ > > +void (*disable_queue)(VduseDev *dev, VduseVirtq *vq); > > +} VduseOps; > > + > > +/* Describing elements of the I/O buffer */ > > +typedef struct VduseVirtqElement { > > +/* Descriptor table index */ > > +unsigned int index; > > +/* Number of physically-contiguous device-readable descriptors */ > > +unsigned int out_num; > > +/* Number of physically-contiguous device-writable descriptors */ > > +unsigned int in_num; > > +/* Array to store physically-contiguous device-writable descriptors */ > > +struct iovec *in_sg; > > +/* Array to store physically-contiguous device-readable descriptors */ > > +struct iovec *out_sg; > > +} VduseVirtqElement; > > + > > + > > +/** > > + * vduse_get_virtio_features: > > + * > > + * Get supported virtio features > > + * > > + * Returns: supported feature bits > > + */ > > +uint64_t vduse_get_virtio_features(void); >
Re: [PULL v2 10/20] libvduse: Add VDUSE (vDPA Device in Userspace) library
Kevin Wolf writes: > From: Xie Yongji > > VDUSE [1] is a linux framework that makes it possible to implement > software-emulated vDPA devices in userspace. This adds a library > as a subproject to help implementing VDUSE backends in QEMU. > > [1] https://www.kernel.org/doc/html/latest/userspace-api/vduse.html > > Signed-off-by: Xie Yongji > Message-Id: <20220523084611.91-6-xieyon...@bytedance.com> > Reviewed-by: Stefan Hajnoczi > Signed-off-by: Kevin Wolf > --- > meson_options.txt |2 + > subprojects/libvduse/include/atomic.h |1 + > subprojects/libvduse/include/compiler.h |1 + > subprojects/libvduse/libvduse.h | 235 > subprojects/libvduse/libvduse.c | 1150 +++ > MAINTAINERS |5 + > meson.build | 15 + > scripts/meson-buildoptions.sh |3 + > subprojects/libvduse/linux-headers/linux|1 + > subprojects/libvduse/meson.build| 10 + > subprojects/libvduse/standard-headers/linux |1 + > 11 files changed, 1424 insertions(+) > create mode 12 subprojects/libvduse/include/atomic.h > create mode 12 subprojects/libvduse/include/compiler.h > create mode 100644 subprojects/libvduse/libvduse.h > create mode 100644 subprojects/libvduse/libvduse.c > create mode 12 subprojects/libvduse/linux-headers/linux > create mode 100644 subprojects/libvduse/meson.build > create mode 12 subprojects/libvduse/standard-headers/linux > > diff --git a/meson_options.txt b/meson_options.txt > index f3e2f22c1e..23a9f440f7 100644 > --- a/meson_options.txt > +++ b/meson_options.txt > @@ -257,6 +257,8 @@ option('virtfs', type: 'feature', value: 'auto', > description: 'virtio-9p support') > option('virtiofsd', type: 'feature', value: 'auto', > description: 'build virtiofs daemon (virtiofsd)') > +option('libvduse', type: 'feature', value: 'auto', > + description: 'build VDUSE Library') > > option('capstone', type: 'feature', value: 'auto', > description: 'Whether and how to find the capstone library') > diff --git a/subprojects/libvduse/include/atomic.h > b/subprojects/libvduse/include/atomic.h > new file mode 12 > index 00..8c2be64f7b > --- /dev/null > +++ b/subprojects/libvduse/include/atomic.h > @@ -0,0 +1 @@ > +../../../include/qemu/atomic.h > \ No newline at end of file > diff --git a/subprojects/libvduse/include/compiler.h > b/subprojects/libvduse/include/compiler.h > new file mode 12 > index 00..de7b70697c > --- /dev/null > +++ b/subprojects/libvduse/include/compiler.h > @@ -0,0 +1 @@ > +../../../include/qemu/compiler.h > \ No newline at end of file > diff --git a/subprojects/libvduse/libvduse.h b/subprojects/libvduse/libvduse.h > new file mode 100644 > index 00..6c2fe98213 > --- /dev/null > +++ b/subprojects/libvduse/libvduse.h > @@ -0,0 +1,235 @@ > +/* > + * VDUSE (vDPA Device in Userspace) library > + * > + * Copyright (C) 2022 Bytedance Inc. and/or its affiliates. All rights > reserved. > + * > + * Author: > + * Xie Yongji > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or > + * later. See the COPYING file in the top-level directory. > + */ > + > +#ifndef LIBVDUSE_H > +#define LIBVDUSE_H > + > +#include > +#include > + > +#define VIRTQUEUE_MAX_SIZE 1024 > + > +/* VDUSE device structure */ > +typedef struct VduseDev VduseDev; > + > +/* Virtqueue structure */ > +typedef struct VduseVirtq VduseVirtq; > + > +/* Some operation of VDUSE backend */ > +typedef struct VduseOps { > +/* Called when virtqueue can be processed */ > +void (*enable_queue)(VduseDev *dev, VduseVirtq *vq); > +/* Called when virtqueue processing should be stopped */ > +void (*disable_queue)(VduseDev *dev, VduseVirtq *vq); > +} VduseOps; > + > +/* Describing elements of the I/O buffer */ > +typedef struct VduseVirtqElement { > +/* Descriptor table index */ > +unsigned int index; > +/* Number of physically-contiguous device-readable descriptors */ > +unsigned int out_num; > +/* Number of physically-contiguous device-writable descriptors */ > +unsigned int in_num; > +/* Array to store physically-contiguous device-writable descriptors */ > +struct iovec *in_sg; > +/* Array to store physically-contiguous device-readable descriptors */ > +struct iovec *out_sg; > +} VduseVirtqElement; > + > + > +/** > + * vduse_get_virtio_features: > + * > + * Get supported virtio features > + * > + * Returns: supported feature bits > + */ > +uint64_t vduse_get_virtio_features(void); > + > +/** > + * vduse_queue_get_dev: > + * @vq: specified virtqueue > + * > + * Get corresponding VDUSE device from the virtqueue. > + * > + * Returns: a pointer to VDUSE device on success, NULL on failure. > + */ > +VduseDev *vduse_queue_get_dev(VduseVirtq *vq); > + > +/** > + * vduse_queue_get_fd: > + * @vq: specified