8be069e0d5f3bf7ef3cd82e3d5036cb8c0a52251
[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 Build
55 ~~~~~
56
57 Follow the *Getting Started Guide for Linux* on generic info about
58 environment setup and building DPDK from source.
59
60 In this example, you need build DPDK both on the host and inside guest.
61 Also, you need build this example.
62
63 .. code-block:: console
64
65     export RTE_SDK=/path/to/dpdk_source
66     export RTE_TARGET=x86_64-native-linuxapp-gcc
67
68     cd ${RTE_SDK}/examples/vhost_scsi
69     make
70
71
72 Start the vhost_scsi example
73 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74
75 .. code-block:: console
76
77         ./vhost_scsi -m 1024
78
79 .. _vhost_scsi_app_run_vm:
80
81 Start the VM
82 ~~~~~~~~~~~~
83
84 .. code-block:: console
85
86     qemu-system-x86_64 -machine accel=kvm \
87         -m $mem -object memory-backend-file,id=mem,size=$mem,\
88         mem-path=/dev/hugepages,share=on -numa node,memdev=mem \
89         -drive file=os.img,if=none,id=disk \
90         -device ide-hd,drive=disk,bootindex=0 \
91         -chardev socket,id=char0,path=/tmp/vhost.socket \
92         -device vhost-user-scsi-pci,chardev=char0,bootindex=2 \
93         ...
94
95 .. note::
96     You must check whether your Qemu can support "vhost-user-scsi" or not,
97     Qemu v2.10 or newer version is required.
98
99 Vhost_scsi Common Issues
100 ------------------------
101
102 * vhost_scsi can not start with block size 512 Bytes:
103
104   Currently DPDK vhost library was designed for NET device(althrough the APIs
105   are generic now), for 512 Bytes block device, Qemu BIOS(x86 BIOS Enhanced
106   Disk Device) will enumerate all block device and do some IOs to those block
107   devices with 512 Bytes sector size. DPDK vhost library can not process such
108   scenarios(both BIOS and OS will enumerate the block device), so as a
109   workaround, the vhost_scsi example application hardcoded the block size
110   with 4096 Bytes.
111
112 * vhost_scsi can only support the block device as fast data disk(non OS image):
113
114   Make sure ``bootindex=2`` Qemu option is given to vhost-user-scsi-pci device.
115