aboutsummaryrefslogtreecommitdiff
path: root/subprojects/libvduse
AgeCommit message (Collapse)AuthorFilesLines
2022-11-12libvduse: Avoid warning about dangerous use of strncpy()Philippe Mathieu-Daudé1-2/+2
GCC 8 added a -Wstringop-truncation warning: The -Wstringop-truncation warning added in GCC 8.0 via r254630 for bug 81117 is specifically intended to highlight likely unintended uses of the strncpy function that truncate the terminating NUL character from the source string. Here the next line indeed unconditionally zeroes the last byte, but 1/ the buffer has been calloc'd, so we don't need to add an extra byte, and 2/ we called vduse_name_is_invalid() which checked the string length, so we can simply call strcpy(). This fixes when using gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0: [42/666] Compiling C object subprojects/libvduse/libvduse.a.p/libvduse.c.o FAILED: subprojects/libvduse/libvduse.a.p/libvduse.c.o cc -m64 -mcx16 -Isubprojects/libvduse/libvduse.a.p -Isubprojects/libvduse -I../../subprojects/libvduse [...] -o subprojects/libvduse/libvduse.a.p/libvduse.c.o -c ../../subprojects/libvduse/libvduse.c In file included from /usr/include/string.h:495, from ../../subprojects/libvduse/libvduse.c:24: In function ‘strncpy’, inlined from ‘vduse_dev_create’ at ../../subprojects/libvduse/libvduse.c:1312:5: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 256 equals destination size [-Werror=stringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ninja: build stopped: cannot make progress due to previous errors. Fixes: d9cf16c0be ("libvduse: Replace strcpy() with strncpy()") Suggested-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Xie Yongji <xieyongji@bytedance.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Tested-by: Bin Meng <bmeng@tinylab.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221111124550.35753-1-philmd@linaro.org>
2022-08-02libvduse: Pass positive value to strerror()Xie Yongji1-2/+2
The value passed to strerror() should be positive. So let's fix it. Fixes: Coverity CID 1490226, 1490223 Signed-off-by: Xie Yongji <xieyongji@bytedance.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20220706095624.328-4-xieyongji@bytedance.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2022-08-02libvduse: Replace strcpy() with strncpy()Xie Yongji1-1/+2
Coverity reported a string overflow issue since we copied "name" to "dev_config->name" without checking the length. This should be a false positive since we already checked the length of "name" in vduse_name_is_invalid(). But anyway, let's replace strcpy() with strncpy() (as a general library, we'd like to minimize dependencies on other libraries, so we didn't use g_strlcpy() here) to fix the coverity complaint. Fixes: Coverity CID 1490224 Signed-off-by: Xie Yongji <xieyongji@bytedance.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20220706095624.328-3-xieyongji@bytedance.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2022-08-02libvduse: Fix the incorrect function nameXie Yongji1-3/+3
In vduse_name_is_valid(), we actually check whether the name is invalid or not. So let's change the function name to vduse_name_is_invalid() to match the behavior. Signed-off-by: Xie Yongji <xieyongji@bytedance.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20220706095624.328-2-xieyongji@bytedance.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2022-06-24libvduse: Add support for reconnectingXie Yongji2-5/+242
To support reconnecting after restart or crash, VDUSE backend might need to resubmit inflight I/Os. This stores the metadata such as the index of inflight I/O's descriptors to a shm file so that VDUSE backend can restore them during reconnecting. Signed-off-by: Xie Yongji <xieyongji@bytedance.com> Message-Id: <20220523084611.91-9-xieyongji@bytedance.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2022-06-24libvduse: Add VDUSE (vDPA Device in Userspace) libraryXie Yongji7-0/+1399
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 <xieyongji@bytedance.com> Message-Id: <20220523084611.91-6-xieyongji@bytedance.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>