Skip to content

Commit 96e7249

Browse files
committed
libvirt: add scsi extra storage option
1 parent 9c98133 commit 96e7249

7 files changed

Lines changed: 73 additions & 21 deletions

File tree

defconfigs/blktests_scsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CONFIG_GUESTFS_BRINGUP_DEBUG_1=y
99
CONFIG_BOOTLINUX=y
1010
CONFIG_BOOTLINUX_9P=y
1111

12-
CONFIG_LIBVIRT_EXTRA_STORAGE_DRIVE_NVME=y
12+
CONFIG_LIBVIRT_EXTRA_STORAGE_DRIVE_SCSI=y
1313

1414
CONFIG_WORKFLOWS_TESTS=y
1515
CONFIG_WORKFLOWS_LINUX_TESTS=y

kconfigs/Kconfig.libvirt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ config LIBVIRT_MACHINE_TYPE_DEFAULT
487487
is the old i440x, so you will not get PCIe support.
488488

489489
We only want to support PCI-E capable guests with libguest so the
490-
deafult is not allowed on libguest.
490+
default is not allowed on libguest.
491491

492492
config LIBVIRT_MACHINE_TYPE_Q35
493493
bool "q35"
@@ -548,11 +548,18 @@ config LIBVIRT_EXTRA_STORAGE_DRIVE_VIRTIO
548548
you won't be able to test ZNS.
549549

550550
config LIBVIRT_EXTRA_STORAGE_DRIVE_IDE
551-
bool "ide"
552-
output yaml
553-
help
554-
Use the QEMU ide driver for extra storage drives. This is useful for
555-
really old Linux distributions that lack the virtio backend driver.
551+
bool "ide"
552+
output yaml
553+
help
554+
Use the QEMU ide driver for extra storage drives. This is useful for
555+
really old Linux distributions that lack the virtio backend driver.
556+
557+
config LIBVIRT_EXTRA_STORAGE_DRIVE_SCSI
558+
bool "scsi"
559+
output yaml
560+
help
561+
Use the QEMU SCSI driver for extra storage drives. This relies on a
562+
virtio-scsi controller with scsi-hd devices attached.
556563

557564
endchoice
558565

@@ -817,7 +824,7 @@ config LIBVIRT_AIO_MODE_NATIVE
817824
help
818825
Use the aio=native mode. For some older kernels it is known that
819826
native will cause corruption if used on ext4 or xfs filesystem if
820-
you also use cace=none. This corruption is documented for RHEL:
827+
you also use cache=none. This corruption is documented for RHEL:
821828

822829
https://access.redhat.com/articles/41313
823830
https://bugzilla.redhat.com/show_bug.cgi?id=615309
@@ -1104,7 +1111,7 @@ config LIBVIRT_ENABLE_GDB
11041111
output yaml
11051112
help
11061113
Select this option if you want to enable debugging support for GDB.
1107-
By default , it is assumed that gdb is disabled since we dont want
1114+
By default , it is assumed that gdb is disabled since we don't want
11081115
to complicate this for the CI runs. If enabled then libvirt guest
11091116
xml for each guest will be configured to use gdb on a specific
11101117
tcp port.
@@ -1116,7 +1123,7 @@ config LIBVIRT_GDB_BASEPORT
11161123
depends on LIBVIRT_ENABLE_GDB
11171124
help
11181125
This option defines the base port to be used for the GDB.
1119-
Esentially we need to make QEMU listen for an incoming connection from
1126+
Essentially we need to make QEMU listen for an incoming connection from
11201127
gdb on a TCP port. The default port is chosen to be 1234. However we
11211128
introduce variability for assigning the port to each guest by defining
11221129
a base port and adding an index to it based on the number of libvrt guest

playbooks/roles/gen_nodes/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ libvirt_extra_drive_id_prefix: 'drv'
7070
libvirt_extra_storage_drive_nvme: False
7171
libvirt_extra_storage_drive_virtio: False
7272
libvirt_extra_storage_drive_ide: False
73+
libvirt_extra_storage_drive_scsi: False
7374
libvirt_extra_storage_aio_mode: "native"
7475
libvirt_extra_storage_aio_cache_mode: "none"
7576
# Note that NVMe on qemu does not allow the physical block size

playbooks/roles/gen_nodes/templates/Vagrantfile.j2

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,15 @@ Vagrant.configure("2") do |config|
244244
#
245245
# Just create a PCI or PCI-E root bus dedicated for extra drives. We
246246
# use 0x08 to place this PCI / PCI-E root bus as we know this is
247-
# avilable on modern x86-64 systems. Eventually we may need to bump
247+
# available on modern x86-64 systems. Eventually we may need to bump
248248
# this to 0x9, but it would be better instead to have vagant-libvirt
249249
# speak "add a new PCI or PCI-E root bus" and "add extra drives" whether
250250
# that is nvme or virtio.
251251
#
252252
{% if not libvirt_override_machine_type %}
253253
# For i440x on x86_64 (default on libvirt as of today) we use PCI, not
254254
# PCI-E. Below assumes i440x. i440x cannot support CXL as it does not
255-
# suport PCI-E.
255+
# support PCI-E.
256256
libvirt.qemuargs :value => "-device"
257257
libvirt.qemuargs :value => "pci-bridge,id=custom-pci-for-{{ extra_disk_driver }},chassis_nr=1,bus=pci.0,addr=0x8"
258258
{% else %}
@@ -417,6 +417,13 @@ Vagrant.configure("2") do |config|
417417
libvirt.qemuargs :value => "file=#{extra_disk},format={{ libvirt_extra_drive_format }},if=none,aio={{ libvirt_extra_storage_aio_mode }},cache={{ libvirt_extra_storage_aio_cache_mode }},id=#{disk_id}"
418418
libvirt.qemuargs :value => "-device"
419419
libvirt.qemuargs :value => "virtio-blk-pci,drive=#{disk_id},id=virtio-#{disk_id},serial=#{serial_id},bus=#{bus_for_extra_drives},addr=#{pci_function},iothread=kdevops-virtio-iothread-#{port}#{extra_drive_largio_args},logical_block_size=#{virtio_lbs},physical_block_size=#{virtio_pbs}"
420+
{% elif libvirt_extra_storage_drive_scsi %}
421+
libvirt.qemuargs :value => "-device"
422+
libvirt.qemuargs :value => "virtio-scsi-pci,id=scsi#{port},bus=#{bus_for_extra_drives},addr=#{pci_function}"
423+
libvirt.qemuargs :value => "-drive"
424+
libvirt.qemuargs :value => "file=#{extra_disk},format={{ libvirt_extra_drive_format }},if=none,aio={{ libvirt_extra_storage_aio_mode }},cache={{ libvirt_extra_storage_aio_cache_mode }},id=#{disk_id}"
425+
libvirt.qemuargs :value => "-device"
426+
libvirt.qemuargs :value => "scsi-hd,drive=#{disk_id},bus=scsi#{port}.0"
420427
{% elif libvirt_extra_storage_drive_nvme %}
421428
if ! largio
422429
nvme_lbs = "{{ libvirt_extra_storage_nvme_logical_block_size }}"

playbooks/roles/gen_nodes/templates/drives.j2

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ the drives can vary by type, so we have one macro by type of drive.
4040
{% endfor %}
4141
<!-- End of virtio drives-->
4242
{%- endmacro -%}
43+
{%- macro gen_drive_scsi(num_drives,
44+
kdevops_storage_pool_path,
45+
hostname,
46+
libvirt_extra_drive_format,
47+
libvirt_extra_storage_aio_mode,
48+
libvirt_extra_storage_aio_cache_mode) -%}
49+
<!-- We generated {{ num_drives }} scsi dives -->
50+
{% for n in range(0,num_drives) %}
51+
<!-- This is scsi drive # {{ n + 1 }} -->
52+
<qemu:arg value='-device'/>
53+
<qemu:arg value='pcie-root-port,id=pcie-port-for-scsi-{{ n }},multifunction=on,bus=pcie.1,addr=0x{{ "%0x" | format( n | int) }},chassis=5{{ n }}'/>
54+
<qemu:arg value='-device'/>
55+
<qemu:arg value='virtio-scsi-pci,id=scsi{{ n }},bus=pcie-port-for-scsi-{{ n }},addr=0x0'/>
56+
<qemu:arg value='-drive'/>
57+
<qemu:arg value='file={{ kdevops_storage_pool_path }}/guestfs/{{ hostname }}/extra{{ n }}.{{ libvirt_extra_drive_format }},format={{ libvirt_extra_drive_format }},if=none,aio={{ libvirt_extra_storage_aio_mode }},cache={{ libvirt_extra_storage_aio_cache_mode }},id=drv{{ n }}'/>
58+
<qemu:arg value='-device'/>
59+
<qemu:arg value='scsi-hd,drive=drv{{ n }},bus=scsi{{ n }}.0'/>
60+
{% endfor %}
61+
<!-- End of scsi drives-->
62+
{%- endmacro -%}
4363
{%- macro gen_drive_large_io_virtio(libvirt_largeio_logical_compat,
4464
libvirt_largeio_logical_compat_size,
4565
libvirt_largeio_pow_limit,
@@ -49,7 +69,7 @@ the drives can vary by type, so we have one macro by type of drive.
4969
libvirt_extra_storage_aio_mode,
5070
libvirt_extra_storage_aio_cache_mode,
5171
kdevops_storage_pool_path) -%}
52-
<!-- These are virtio drives used for large IO experimentaiton, with LBS support -->
72+
<!-- These are virtio drives used for large IO experimentation, with LBS support -->
5373
{% set ns = namespace(lbs_idx=0) %}
5474
{% set max_pbs = libvirt_largeio_logical_compat_size * (2 ** libvirt_largeio_pow_limit) %}
5575
{% for n in range(0,libvirt_largeio_pow_limit+1) %}
@@ -106,7 +126,7 @@ the drives can vary by type, so we have one macro by type of drive.
106126
libvirt_extra_storage_aio_mode,
107127
libvirt_extra_storage_aio_cache_mode,
108128
kdevops_storage_pool_path) -%}
109-
<!-- These are NVMe drives used for large IO experimentaiton, with LBS support -->
129+
<!-- These are NVMe drives used for large IO experimentation, with LBS support -->
110130
{% set ns = namespace(lbs_idx=0) %}
111131
{% set max_pbs = libvirt_largeio_logical_compat_size * (2 ** libvirt_largeio_pow_limit) %}
112132
{% for n in range(0,libvirt_largeio_pow_limit+1) %}

playbooks/roles/gen_nodes/templates/gen_drives.j2

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@
1919
kdevops_storage_pool_path) }}
2020
{% else %}
2121
{{ drives.gen_drive_virtio(4,
22-
kdevops_storage_pool_path,
23-
hostname,
24-
libvirt_extra_drive_format,
25-
libvirt_extra_storage_aio_mode,
26-
libvirt_extra_storage_aio_cache_mode,
27-
libvirt_extra_storage_virtio_logical_block_size,
28-
libvirt_extra_storage_virtio_physical_block_size) }}
22+
kdevops_storage_pool_path,
23+
hostname,
24+
libvirt_extra_drive_format,
25+
libvirt_extra_storage_aio_mode,
26+
libvirt_extra_storage_aio_cache_mode,
27+
libvirt_extra_storage_virtio_logical_block_size,
28+
libvirt_extra_storage_virtio_physical_block_size) }}
2929
{% endif %}
30+
{% elif libvirt_extra_storage_drive_scsi %}
31+
{{ drives.gen_drive_scsi(4,
32+
kdevops_storage_pool_path,
33+
hostname,
34+
libvirt_extra_drive_format,
35+
libvirt_extra_storage_aio_mode,
36+
libvirt_extra_storage_aio_cache_mode) }}
3037
{% elif libvirt_extra_storage_drive_nvme %}
3138
{% if libvirt_largeio_enable %}
3239
{{ drives.gen_drive_large_io_nvme(libvirt_largeio_logical_compat,

playbooks/roles/gen_nodes/templates/kdevops_nodes_split_start.j2.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ vagrant_global:
7676
physical_block_size: {{ libvirt_extra_storage_virtio_physical_block_size }}
7777
logical_block_size: {{ libvirt_extra_storage_virtio_logical_block_size }}
7878
{% endif %}
79+
{% elif libvirt_extra_storage_drive_scsi %}
80+
extra_disks:
81+
data:
82+
size: 102400
83+
scratch:
84+
size: 102400
85+
extra1:
86+
size: 102400
87+
extra2:
88+
size: 102400
7989
{% elif libvirt_extra_storage_drive_nvme %}
8090
extra_disks:
8191
data:

0 commit comments

Comments
 (0)