New upstream version 17.11-rc3
[deb_dpdk.git] / doc / guides / sample_app_ug / vhost_scsi.rst
1
2 ..  BSD LICENSE
3     Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
4     All rights reserved.
5
6     Redistribution and use in source and binary forms, with or without
7     modification, are permitted provided that the following conditions
8     are met:
9
10     * Redistributions of source code must retain the above copyright
11     notice, this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright
13     notice, this list of conditions and the following disclaimer in
14     the documentation and/or other materials provided with the
15     distribution.
16     * Neither the name of Intel Corporation nor the names of its
17     contributors may be used to endorse or promote products derived
18     from this software without specific prior written permission.
19
20     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32
33 Vhost_scsi Sample Application
34 =============================
35
36 The vhost_scsi sample application implemented a simple SCSI block device,
37 which used as the  backend of Qemu vhost-user-scsi device. Users can extend
38 the exist example to use other type of block device(e.g. AIO) besides
39 memory based block device. Similar with vhost-user-net device, the sample
40 application used domain socket to communicate with Qemu, and the virtio
41 ring was processed by vhost_scsi sample application.
42
43 The sample application reuse lots codes from SPDK(Storage Performance
44 Development Kit, https://github.com/spdk/spdk) vhost-user-scsi target,
45 for DPDK vhost library used in storage area, user can take SPDK as
46 reference as well.
47
48 Testing steps
49 -------------
50
51 This section shows the steps how to start a VM with the block device as
52 fast data path for critical application.
53
54 Compiling the Application
55 -------------------------
56
57 To compile the sample application see :doc:`compiling`.
58
59 The application is located in the ``examples`` sub-directory.
60
61 You will also need to build DPDK both on the host and inside the guest
62
63 Start the vhost_scsi example
64 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65
66 .. code-block:: console
67
68         ./vhost_scsi -m 1024
69
70 .. _vhost_scsi_app_run_vm:
71
72 Start the VM
73 ~~~~~~~~~~~~
74
75 .. code-block:: console
76
77     qemu-system-x86_64 -machine accel=kvm \
78         -m $mem -object memory-backend-file,id=mem,size=$mem,\
79         mem-path=/dev/hugepages,share=on -numa node,memdev=mem \
80         -drive file=os.img,if=none,id=disk \
81         -device ide-hd,drive=disk,bootindex=0 \
82         -chardev socket,id=char0,path=/tmp/vhost.socket \
83         -device vhost-user-scsi-pci,chardev=char0,bootindex=2 \
84         ...
85
86 .. note::
87     You must check whether your Qemu can support "vhost-user-scsi" or not,
88     Qemu v2.10 or newer version is required.
89
90 Vhost_scsi Common Issues
91 ------------------------
92
93 * vhost_scsi can not start with block size 512 Bytes:
94
95   Currently DPDK vhost library was designed for NET device(althrough the APIs
96   are generic now), for 512 Bytes block device, Qemu BIOS(x86 BIOS Enhanced
97   Disk Device) will enumerate all block device and do some IOs to those block
98   devices with 512 Bytes sector size. DPDK vhost library can not process such
99   scenarios(both BIOS and OS will enumerate the block device), so as a
100   workaround, the vhost_scsi example application hardcoded the block size
101   with 4096 Bytes.
102
103 * vhost_scsi can only support the block device as fast data disk(non OS image):
104
105   Make sure ``bootindex=2`` Qemu option is given to vhost-user-scsi-pci device.
106