| |
@@ -99,17 +99,33 @@
|
| |
"""
|
| |
result = []
|
| |
drives = fmf_get(['qemu', 'drive'], list())
|
| |
+ dev_id = 0
|
| |
+ scsi_device_exists = False
|
| |
for drive in drives:
|
| |
# create temporary sparse file
|
| |
size = int(drive.get('size', 2 * 1024 ** 3)) # default size: 2G
|
| |
path = drive.get('path', None)
|
| |
path = str(path) if path is not None else None
|
| |
+ interface = drive.get('interface', None)
|
| |
drive_file = tempfile.NamedTemporaryFile(dir=path, delete=False)
|
| |
drive_file.truncate(size)
|
| |
cls._tempfiles.append(drive_file)
|
| |
logger.info("Created temporary sparse file '%s'.", drive_file.name)
|
| |
# translate data into qemu command options
|
| |
- result += ["-drive", "file=%s,media=disk,if=virtio" % drive_file.name]
|
| |
+
|
| |
+ if interface is None or interface.lower() == 'virtio':
|
| |
+ result += ["-drive", "file=%s,media=disk,if=virtio" % drive_file.name]
|
| |
+ elif interface.lower() == 'nvme':
|
| |
+ result += ["-device", "nvme,drive=nvme%s,serial=def%s" % (dev_id, dev_id)]
|
| |
+ result += ["-drive", "file=%s,media=disk,if=none,id=nvme%s" % (drive_file.name, dev_id)]
|
| |
+ dev_id += 1
|
| |
+ elif interface.lower() == 'scsi':
|
| |
+ if not scsi_device_exists:
|
| |
+ result += ["-device", "virtio-scsi-pci,id=scsi0"]
|
| |
+ scsi_device_exists = True
|
| |
+ result += ["-device", "scsi-hd,drive=drive%s,bus=scsi0.0" % dev_id]
|
| |
+ result += ["-drive", "if=none,file=%s,id=drive%s" % (drive_file.name, dev_id)]
|
| |
+ dev_id += 1
|
| |
|
| |
usb_drives = fmf_get(['qemu', 'usb_drive'], list())
|
| |
if usb_drives:
|
| |
@@ -398,9 +414,9 @@
|
| |
"-smp", get_qemu_smp_arg(),
|
| |
# Set startup RAM size
|
| |
"-m", param_m,
|
| |
- # Add image with RHEL as drive (if=virtio is important for newer
|
| |
- # RHEL 8 images)
|
| |
- "-drive", "file={0},if=virtio".format(image),
|
| |
+ # Add image with RHEL as drive
|
| |
+ "-drive", "if=none,file=%s,id=virtio-disk0" % image,
|
| |
+ "-device", "virtio-blk-pci,drive=virtio-disk0,bootindex=1",
|
| |
# Write to temporary files instead of disk image files
|
| |
"-snapshot",
|
| |
# Use `cloudinit` as CD-ROM image
|
| |