From 23a42178210135d9524e7b86be269821a75bb784 Mon Sep 17 00:00:00 2001 From: Jan Pokorny Date: Dec 07 2020 14:29:43 +0000 Subject: new scsi, nvme support for VM - added support for SCSI and NVME into VM creation script - storage role enhancement - provision file now supports new 'drive' suboption 'interface' - accepted values: 'virtio' (default), 'scsi', 'nvme' --- diff --git a/inventory/standard-inventory-qcow2 b/inventory/standard-inventory-qcow2 index 522555d..f401539 100755 --- a/inventory/standard-inventory-qcow2 +++ b/inventory/standard-inventory-qcow2 @@ -99,17 +99,33 @@ class AdditionalDrives(object): """ 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 @@ def start_qemu(image, cloudinit, portrange=(2222, 5555)): "-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