summaryrefslogtreecommitdiffstats
path: root/test/TEST-64-UDEV-STORAGE/virtio_scsi_identically_named_partitions.configure
blob: e850247c6ab34e1dd0f6b22751e0d0f08e49bbf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python3
# SPDX-License-Identifier: LGPL-2.1-or-later

import json
import os
import subprocess
import sys


config = json.load(sys.stdin)

qemu = f"qemu-system-{os.environ["QEMU_ARCHITECTURE"]}"
result = subprocess.run([qemu, '-device', 'help'], check=True, text=True, stdout=subprocess.PIPE)
if 'name "virtio-scsi-pci"' not in result.stdout:
    print("virtio-scsi-pci device driver is not available, skipping test...", file=sys.stderr)
    exit(77)

num_disk = 16

config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0,num_queues=4"]

for i in range(0, num_disk):
    id = f"drive{i}"
    config["QemuDrives"] += [
        {
            "Id": id,
            "Size": "40M",
            "Options": "cache=unsafe"
        }
    ]
    config["QemuArgs"] += ["-device", f"scsi-hd,drive={id},bus=scsi0.0,channel=0,scsi-id=0,lun={i}"]

json.dump(config, sys.stdout)