summaryrefslogtreecommitdiffstats
path: root/contrib/vhost-user-scsi
Commit message (Collapse)AuthorAgeFilesLines
* vhost-user-scsi: avoid unlink(NULL) with fd passingStefan Hajnoczi2022-05-161-1/+4
| | | | | | | | | | | | | | | | | | | | | Commit 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend Program conventions for vhost-user-scsi") introduced fd-passing support as part of implementing the vhost-user backend program conventions. When fd passing is used the UNIX domain socket path is NULL and we must not call unlink(2). The unlink(2) call is necessary when the listen socket, lsock, was created successfully since that means the UNIX domain socket is visible in the file system. Fixes: Coverity CID 1488353 Fixes: 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend Program conventions for vhost-user-scsi") Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20220516155701.1789638-1-stefanha@redhat.com> Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* Implements Backend Program conventions for vhost-user-scsiSakshi Kaushik2022-04-211-26/+53
| | | | | | | | | | | | Signed-off-by: Sakshi Kaushik <sakshikaushik717@gmail.com> Message-id: 20220406162410.8536-1-sakshikaushik717@gmail.com [Name the iSCSI URL long option --iscsi-uri instead of --iscsi_uri for consistency, fix --fd which was rejected due to an outdated --socket-path check, and add missing entries[] terminator. --Stefan] Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* libiscsi: convert to mesonPaolo Bonzini2021-01-021-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* libvhost-user: make it a meson subprojectMarc-André Lureau2020-12-082-3/+2Star
| | | | | | | | | | | | | By making libvhost-user a subproject, check it builds standalone (without the global QEMU cflags etc). Note that the library still relies on QEMU include/qemu/atomic.h and linux_headers/. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20201125100640.366523-6-marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost-user-scsi: Fix memleaks in vus_proc_req()Alex Chen2020-12-081-1/+2
| | | | | | | | | | | | | | The 'elem' is allocated memory in vu_queue_pop(), and its memory should be freed in all error branches after vu_queue_pop(). In addition, in order to free the 'elem' memory outside of while(1) loop, move the definition of 'elem' to the beginning of vus_proc_req(). Reported-by: Euler Robot <euler.robot@huawei.com> Signed-off-by: Alex Chen <alex.chen@huawei.com> Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com> Message-Id: <20201125013055.34147-1-alex.chen@huawei.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost-user-blk/scsi: Fix broken error handling for socket callAlexChen2020-11-171-1/+1
| | | | | | | | | | | When socket() fails, it returns -1, 0 is the normal return value and should not return error. Reported-by: Euler Robot <euler.robot@huawei.com> Signed-off-by: AlexChen <alex.chen@huawei.com> Message-Id: <5F9A5B48.9030509@huawei.com> Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* contrib/vhost-user-scsi: convert to MesonPaolo Bonzini2020-08-212-1/+7
| | | | | | | The libiscsi pkg-config information is extracted from config-host.mak and used to link vhost-user-blk. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* vhost-user-scsi: add compatibility for libiscsi 1.9.0Paolo Bonzini2020-08-211-0/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* vhost-user-scsi: fix printf format warningMarc-André Lureau2019-12-171-1/+1
| | | | | | | | | | Fixes: ../contrib/vhost-user-scsi/vhost-user-scsi.c:118:57: error: format specifies type 'unsigned char' but the argument has type 'int' [-Werror,-Wformat] g_warning("Unable to determine cdb len (0x%02hhX)", cdb[0] >> 5); Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* libvhost-user: support many virtqueuesStefan Hajnoczi2019-07-041-12/+9Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently libvhost-user is hardcoded to at most 8 virtqueues. The device backend should decide the number of virtqueues, not libvhost-user. This is important for multiqueue device backends where the guest driver needs an accurate number of virtqueues. This change breaks libvhost-user and libvhost-user-glib API stability. There is no stability guarantee yet, so make this change now and update all in-tree library users. This patch touches up vhost-user-blk, vhost-user-gpu, vhost-user-input, vhost-user-scsi, and vhost-user-bridge. If the device has a fixed number of queues that exact number is used. Otherwise the previous default of 8 virtqueues is used. vu_init() and vug_init() can now fail if malloc() returns NULL. I considered aborting with an error in libvhost-user but it should be safe to instantiate new vhost-user instances at runtime without risk of terminating the process. Therefore callers need to handle the vu_init() failure now. vhost-user-blk and vhost-user-scsi duplicate virtqueue index checks that are already performed by libvhost-user. This code would need to be modified to use max_queues but remove it completely instead since it's redundant. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190626074815.19994-3-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* Clean up includesMarkus Armbruster2018-12-201-1/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes, with the changes to the following files manually reverted: contrib/libvhost-user/libvhost-user-glib.h contrib/libvhost-user/libvhost-user.c contrib/libvhost-user/libvhost-user.h linux-user/mips64/cpu_loop.c linux-user/mips64/signal.c linux-user/sparc64/cpu_loop.c linux-user/sparc64/signal.c linux-user/x86_64/cpu_loop.c linux-user/x86_64/signal.c target/s390x/gen-features.c tests/migration/s390x/a-b-bios.c tests/test-rcu-simpleq.c tests/test-rcu-tailq.c Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20181204172535.2799-1-armbru@redhat.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Acked-by: Halil Pasic <pasic@linux.ibm.com> Acked-by: Yuval Shaia <yuval.shaia@oracle.com> Acked-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
* Use #include "..." for our own headers, <...> for othersMarkus Armbruster2018-02-091-2/+2
| | | | | | | | | | | | | | | | | | | | System headers should be included with <...>, our own headers with "...". Offenders tracked down with an ugly, brittle and probably buggy Perl script. Previous iteration was commit a9c94277f0. Delete inclusions of "string.h" and "strings.h" instead of fixing them to <string.h> and <strings.h>, because we always include these via osdep.h. Put the cleaned up system header includes first. While there, separate #include from file comment with exactly one blank line. Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20180201111846.21846-2-armbru@redhat.com>
* vhost-user-scsi: remove server_sock from VusDevMarc-André Lureau2017-10-101-53/+24Star
| | | | | | | | It is unneeded in the VusDev device structure, and also simplify a bit the code. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: use libvhost-user glib helperMarc-André Lureau2017-10-101-146/+16Star
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* vhost-user-scsi: use glib loggingMarc-André Lureau2017-10-101-56/+21Star
| | | | | | | | | | | - PLOG is unused - code is compiled out unless debug is enabled - logging is too verbose - you can pipe to ts to have timestamp if needed, or use structured logging with more recent glib Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: simplify source handlingMarc-André Lureau2017-10-101-33/+12Star
| | | | | | | Using a hashtable. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* vhost-user-scsi: drop extra callback pointerMarc-André Lureau2017-10-101-9/+3Star
| | | | | | | Use the one from the source with casting, like any other glib source. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: don't copy iscsi/scsi-lowlevel.hMarc-André Lureau2017-10-101-87/+9Star
| | | | | | | | There is no need to include hw/virtio/virtio-scsi.h, then the conflict with SCSI_XFER enum goes away. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: avoid use of iscsi_ namespaceMarc-André Lureau2017-10-101-2/+2
| | | | | | | It is confusing and could easily conflict with future versions. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: rename VUS typesMarc-André Lureau2017-10-101-23/+23
| | | | | | | | | - use Vus prefix consistently - use CamelCase, since that's glib & libvhost-user style - avoid _t postfix, usually for system headers Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: remove unimplemented functionsMarc-André Lureau2017-10-101-18/+3Star
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* vhost-user-scsi: remove VUS_MAX_LUNSMarc-André Lureau2017-10-101-5/+3Star
| | | | | | | There is no code to support more than 1 yet, no need for that today. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: remove vdev_scsi_add_iscsi_lun()Marc-André Lureau2017-10-101-15/+1Star
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: assert() in iscsi_add_lun()Marc-André Lureau2017-10-101-5/+1Star
| | | | | | | | Instead of a preliminary check, add an assert to the function that has the pre-condition. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: use NULL pointerMarc-André Lureau2017-10-101-1/+1
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: simplify unix path cleanupMarc-André Lureau2017-10-101-17/+5Star
| | | | | | | | | Always remove the unix path when leaving the program (instead of when freeing scsi_dev). Note that unix_sock_new() also unlink() exisiting path before creating the socket. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* vhost-user-scsi: remove vdev_scsi_find_by_vu()Marc-André Lureau2017-10-101-43/+4Star
| | | | | | | The *dev pointer belongs to the vhost_scsi_dev_t parent. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* vhost-user-scsi: also free the gtreeMarc-André Lureau2017-10-101-0/+1
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: glib calls that allocate don't return NULLMarc-André Lureau2017-10-101-45/+7Star
| | | | | | | They abort instead, so get rid of failure conditions. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* vhost-user-scsi: use glib allocationMarc-André Lureau2017-10-101-26/+9Star
| | | | | | | | Use g_new/g_free instead of plain malloc. This simplify a bit memory handling since glib will abort if it cannot allocate. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: code style fixesMarc-André Lureau2017-10-101-8/+12
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: connect unix socket before allocatingMarc-André Lureau2017-10-101-10/+8Star
| | | | | | | This simplify a little bit memory management in the following patches. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: use g_strdup()Marc-André Lureau2017-10-101-8/+4Star
| | | | | | | Since vhost-user-scsi uses glib. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* glib-compat: move G_SOURCE_CONTINUE/REMOVE thereMarc-André Lureau2017-10-101-8/+0Star
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* vhost-user-scsi: Introduce a vhost-user-scsi sample applicationFelipe Franciosi2017-06-152-0/+887
This commit introduces a vhost-user-scsi backend sample application. It must be linked with libiscsi and libvhost-user. To use it, compile with: $ make vhost-user-scsi And run as follows: $ ./vhost-user-scsi -u vus.sock -i iscsi://uri_to_target/ $ qemu-system-x86_64 --enable-kvm -m 512 \ -object memory-backend-file,id=mem,size=512m,share=on,mem-path=guestmem \ -numa node,memdev=mem \ -chardev socket,id=vhost-user-scsi,path=vus.sock \ -device vhost-user-scsi-pci,chardev=vhost-user-scsi \ The application is currently limited at one LUN only and it processes requests synchronously (therefore only achieving QD1). The purpose of the code is to show how a backend can be implemented and to test the vhost-user-scsi Qemu implementation. If a different instance of this vhost-user-scsi application is executed at a remote host, a VM can be live migrated to such a host. Signed-off-by: Felipe Franciosi <felipe@nutanix.com> Message-Id: <1488479153-21203-5-git-send-email-felipe@nutanix.com>