libs/types: use contains to make code more readable

use contains to when validate hypervisor block_device_driver

Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
This commit is contained in:
Zhongtao Hu 2022-01-31 11:25:13 +08:00 committed by Fupan Li
parent 45e5780e7c
commit 6ae87d9d66

View File

@ -165,12 +165,14 @@ impl BlockDeviceInfo {
if self.disable_block_device_use {
return Ok(());
}
if self.block_device_driver != VIRTIO_BLK
&& self.block_device_driver != VIRTIO_BLK_CCW
&& self.block_device_driver != VIRTIO_BLK_MMIO
&& self.block_device_driver != VIRTIO_SCSI
&& self.block_device_driver != VIRTIO_PMEM
{
let l = [
VIRTIO_BLK,
VIRTIO_BLK_CCW,
VIRTIO_BLK_MMIO,
VIRTIO_SCSI,
VIRTIO_PMEM,
];
if !l.contains(&self.block_device_driver.as_str()) {
return Err(eother!(
"{} is unsupported block device type.",
self.block_device_driver