vhost-blk: enable vhost block with new added get/set config messages
New vhost user messages GET_CONFIG/SET_CONFIG can be used for vhost-blk for the purpose to get configuration parameter such as: Capacity and block size. This commit enable this feature, users don't need to append capacity any more when started QEMU. Also event notifier is added for the purpose to change capacity of block device while QEMU is running. Also re-enable the vhost-blk tests. Change-Id: I06ef697984eeea3abbbd655bdcaccaa3b7aa72d7 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/386546 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
1ca22afa2e
commit
1c164f117d
12
autotest.sh
12
autotest.sh
@ -137,9 +137,9 @@ if [ $SPDK_TEST_VHOST -eq 1 ]; then
|
||||
timing_exit negative
|
||||
|
||||
if [ $RUN_NIGHTLY -eq 1 ]; then
|
||||
# timing_enter integrity_blk
|
||||
# run_test ./test/vhost/spdk_vhost.sh --integrity-blk
|
||||
# timing_exit integrity_blk
|
||||
timing_enter integrity_blk
|
||||
run_test ./test/vhost/spdk_vhost.sh --integrity-blk
|
||||
timing_exit integrity_blk
|
||||
|
||||
timing_enter integrity
|
||||
run_test ./test/vhost/spdk_vhost.sh --integrity
|
||||
@ -170,9 +170,9 @@ if [ $SPDK_TEST_VHOST -eq 1 ]; then
|
||||
run_test ./test/vhost/spdk_vhost.sh --integrity-lvol-scsi
|
||||
timing_exit integrity_lvol_scsi
|
||||
|
||||
# timing_enter integrity_lvol_blk
|
||||
# run_test ./test/vhost/spdk_vhost.sh --integrity-lvol-blk
|
||||
# timing_exit integrity_lvol_blk
|
||||
timing_enter integrity_lvol_blk
|
||||
run_test ./test/vhost/spdk_vhost.sh --integrity-lvol-blk
|
||||
timing_exit integrity_lvol_blk
|
||||
|
||||
timing_exit vhost
|
||||
fi
|
||||
|
23
doc/vhost.md
23
doc/vhost.md
@ -72,19 +72,8 @@ the following command to confirm your QEMU supports userspace vhost-scsi.
|
||||
qemu-system-x86_64 -device vhost-user-scsi-pci,help
|
||||
~~~
|
||||
|
||||
Userspace vhost-blk target support is not yet upstream in QEMU, but patches
|
||||
are available in SPDK's QEMU repository:
|
||||
|
||||
~~~{.sh}
|
||||
git clone -b spdk https://github.com/spdk/qemu
|
||||
cd qemu
|
||||
mkdir build
|
||||
cd build
|
||||
../configure
|
||||
make
|
||||
~~~
|
||||
|
||||
Run the following command to confirm your QEMU supports userspace vhost-blk.
|
||||
Userspace vhost-blk target support was added to upstream QEMU in v2.12.0. Run
|
||||
the following command to confirm your QEMU supports userspace vhost-blk.
|
||||
|
||||
~~~{.sh}
|
||||
qemu-system-x86_64 -device vhost-user-blk-pci,help
|
||||
@ -221,7 +210,7 @@ Finally, specify the SPDK vhost devices:
|
||||
|
||||
~~~{.sh}
|
||||
-chardev socket,id=char1,path=/var/tmp/vhost.1
|
||||
-device vhost-user-blk-pci,id=blk0,chardev=char1,logical_block_size=512,size=64M
|
||||
-device vhost-user-blk-pci,id=blk0,chardev=char1
|
||||
~~~
|
||||
|
||||
## Example output {#vhost_example}
|
||||
@ -297,7 +286,7 @@ host:~# taskset -c 2,3 qemu-system-x86_64 \
|
||||
-chardev socket,id=spdk_vhost_scsi0,path=/var/tmp/vhost.0 \
|
||||
-device vhost-user-scsi-pci,id=scsi0,chardev=spdk_vhost_scsi0,num_queues=4 \
|
||||
-chardev socket,id=spdk_vhost_blk0,path=/var/tmp/vhost.1 \
|
||||
-device vhost-user-blk-pci,logical_block_size=512,size=64M,chardev=spdk_vhost_blk0,num_queues=4
|
||||
-device vhost-user-blk-pci,chardev=spdk_vhost_blk0,num-queues=4
|
||||
~~~
|
||||
|
||||
Please note the following two commands are run on the guest VM.
|
||||
@ -392,3 +381,7 @@ The Windows `viostor` driver before version 0.1.130-1 is buggy and does not
|
||||
correctly support vhost-blk devices with non-512-byte block size.
|
||||
See the [bug report](https://bugzilla.redhat.com/show_bug.cgi?id=1411092) for
|
||||
more information.
|
||||
|
||||
## QEMU vhost-user-blk
|
||||
QEMU [vhost-user-blk](https://git.qemu.org/?p=qemu.git;a=commit;h=00343e4b54ba) is
|
||||
supported from version 2.12.
|
||||
|
@ -615,6 +615,45 @@ spdk_vhost_blk_dump_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_wr
|
||||
|
||||
static int spdk_vhost_blk_destroy(struct spdk_vhost_dev *dev);
|
||||
|
||||
static int
|
||||
spdk_vhost_blk_get_config(struct spdk_vhost_dev *vdev, uint8_t *config,
|
||||
uint32_t len)
|
||||
{
|
||||
struct virtio_blk_config *blkcfg = (struct virtio_blk_config *)config;
|
||||
struct spdk_vhost_blk_dev *bvdev;
|
||||
struct spdk_bdev *bdev;
|
||||
uint32_t blk_size;
|
||||
uint64_t blkcnt;
|
||||
|
||||
bvdev = to_blk_dev(vdev);
|
||||
if (bvdev == NULL) {
|
||||
SPDK_ERRLOG("Trying to get virito_blk configuration failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (len < sizeof(*blkcfg)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bdev = bvdev->bdev;
|
||||
blk_size = spdk_bdev_get_block_size(bdev);
|
||||
blkcnt = spdk_bdev_get_num_blocks(bdev);
|
||||
|
||||
memset(blkcfg, 0, sizeof(*blkcfg));
|
||||
blkcfg->blk_size = blk_size;
|
||||
/* minimum I/O size in blocks */
|
||||
blkcfg->min_io_size = 1;
|
||||
/* expressed in 512 Bytes sectors */
|
||||
blkcfg->capacity = (blkcnt * blk_size) / 512;
|
||||
blkcfg->size_max = 131072;
|
||||
/* -2 for REQ and RESP and -1 for region boundary splitting */
|
||||
blkcfg->seg_max = SPDK_VHOST_IOVS_MAX - 2 - 1;
|
||||
/* QEMU can overwrite this value when started */
|
||||
blkcfg->num_queues = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spdk_vhost_dev_backend vhost_blk_device_backend = {
|
||||
.virtio_features = SPDK_VHOST_FEATURES |
|
||||
(1ULL << VIRTIO_BLK_F_SIZE_MAX) | (1ULL << VIRTIO_BLK_F_SEG_MAX) |
|
||||
@ -628,6 +667,7 @@ static const struct spdk_vhost_dev_backend vhost_blk_device_backend = {
|
||||
(1ULL << VIRTIO_BLK_F_BARRIER) | (1ULL << VIRTIO_BLK_F_SCSI),
|
||||
.start_device = spdk_vhost_blk_start,
|
||||
.stop_device = spdk_vhost_blk_stop,
|
||||
.vhost_get_config = spdk_vhost_blk_get_config,
|
||||
.dump_config_json = spdk_vhost_blk_dump_config_json,
|
||||
.remove_device = spdk_vhost_blk_destroy,
|
||||
};
|
||||
|
@ -61,6 +61,24 @@ DEFINE_STUB_V(spdk_bdev_close, (struct spdk_bdev_desc *desc));
|
||||
DEFINE_STUB(rte_vhost_driver_enable_features, int, (const char *path, uint64_t features), 0);
|
||||
DEFINE_STUB_P(spdk_bdev_get_io_channel, struct spdk_io_channel, (struct spdk_bdev_desc *desc), {0});
|
||||
|
||||
uint32_t
|
||||
spdk_bdev_get_block_size(const struct spdk_bdev *bdev)
|
||||
{
|
||||
return 512;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
spdk_bdev_get_num_blocks(const struct spdk_bdev *bdev)
|
||||
{
|
||||
return 0x1;
|
||||
}
|
||||
|
||||
bool
|
||||
spdk_bdev_has_write_cache(const struct spdk_bdev *bdev)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
vhost_blk_controller_construct_test(void)
|
||||
{
|
||||
|
@ -629,8 +629,7 @@ function vm_setup()
|
||||
disk=${disk%%_*}
|
||||
notice "using socket $SPDK_VHOST_SCSI_TEST_DIR/naa.$disk.$vm_num"
|
||||
cmd+="-chardev socket,id=char_$disk,path=$SPDK_VHOST_SCSI_TEST_DIR/naa.$disk.$vm_num ${eol}"
|
||||
cmd+="-device vhost-user-blk-pci,num_queues=$queue_number,chardev=char_$disk,"
|
||||
cmd+="logical_block_size=4096,size=$size ${eol}"
|
||||
cmd+="-device vhost-user-blk-pci,num-queues=$queue_number,chardev=char_$disk ${eol}"
|
||||
;;
|
||||
kernel_vhost)
|
||||
if [[ -z $disk ]]; then
|
||||
|
@ -39,8 +39,6 @@ function usage()
|
||||
echo " NUM - VM number (mandatory)"
|
||||
echo " OS - VM os disk path (optional)"
|
||||
echo " DISKS - VM os test disks/devices path (virtio - optional, kernel_vhost - mandatory)"
|
||||
echo " If test-type=spdk_vhost_blk then each disk can have additional size parameter, e.g."
|
||||
echo " --vm=X,os.qcow,DISK_size_35G; unit can be M or G; default - 20G"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,6 @@ function usage() {
|
||||
echo " NUM - VM number (mandatory)"
|
||||
echo " OS - VM os disk path (optional)"
|
||||
echo " DISKS - VM os test disks/devices path (virtio - optional, kernel_vhost - mandatory)"
|
||||
echo " If test-type=spdk_vhost_blk then each disk can have additional size parameter, e.g."
|
||||
echo " --vm=X,os.qcow,DISK_size_35G; unit can be M or G; default - 20G"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ sed -i "s@<name></name>@<name>$VM_NET_NAME</name>@g" $basedir/vnet_conf.xml
|
||||
if [[ "$VHOST_MODE" == "scsi" ]]; then
|
||||
sed -i "s@vhost_dev_args@vhost-user-scsi-pci,id=scsi0@g" $basedir/vm_conf.xml
|
||||
else
|
||||
sed -i "s@vhost_dev_args@vhost-user-blk-pci,size=30G,logical_block_size=4096@g" $basedir/vm_conf.xml
|
||||
sed -i "s@vhost_dev_args@vhost-user-blk-pci@g" $basedir/vm_conf.xml
|
||||
fi
|
||||
|
||||
trap "cleanup_virsh; killprocess $pid; exit 1" SIGINT SIGTERM EXIT
|
||||
|
Loading…
Reference in New Issue
Block a user