diff --git a/.gitignore b/.gitignore index ed1acdb..4b455ba 100644 --- a/.gitignore +++ b/.gitignore @@ -128,3 +128,5 @@ dmypy.json # Pyre type checker .pyre/ src/molecule_plugins/_version.py + +.vscode/ diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index d98a589..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "files.exclude": { - "**/.git": true, - "**/.venv": true, - "**/__pycache__": true, - "**/*.egg-info": true, - "**/build": true - } -} diff --git a/README.md b/README.md index caea8a2..5d1847e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,17 @@ Supported network modes: - `user` - QEMU's user networking mode - `vmnet-shared` - QEMU's `vmnet-shared` networking mode (MacOS only) + +Supported disk types: + +- `virtio` - QEMU's virtio disk type +- `virtio-scsi` - QEMU's virtio-scsi disk type + +Supported BIOS types: + +- `uefi` - QEMU's uefi used for image with uefi configured +- `bios` - QEMU's bios used for image with bios configured + ## Quick start Install `molecule-qemu` python package: @@ -78,6 +89,10 @@ platforms: vm_memory: 512 # optional, default is 512 vm_disk: 8G # optional, default is 8G vm_extra_args: "" # optional, additional arguments to be passed to QEMU, default is empty + + disk_type: virtio-scsi # optional, default is virtio + + bios_type: bios # optional, default is uefi ``` ### Dependencies diff --git a/molecule_qemu/driver.json b/molecule_qemu/driver.json index 508040f..a4a3be9 100644 --- a/molecule_qemu/driver.json +++ b/molecule_qemu/driver.json @@ -78,6 +78,22 @@ "name": { "title": "Name", "type": "string" + }, + "disk_type": { + "title": "Disk Type", + "type": "string", + "enum": [ + "virtio", + "virtio-scsi" + ] + }, + "bios_type": { + "title": "Bios Type", + "type": "string", + "enum": [ + "uefi", + "bios" + ] } }, "required": [ diff --git a/molecule_qemu/playbooks/create.yml b/molecule_qemu/playbooks/create.yml index 63be9dd..a13d140 100644 --- a/molecule_qemu/playbooks/create.yml +++ b/molecule_qemu/playbooks/create.yml @@ -19,6 +19,8 @@ qemu_vm_disk: "8G" qemu_network_extra_args: "" qemu_network_mode: "user" + qemu_bios_type: "uefi" + qemu_disk_type: "virtio" qemu_timeout_arp: 120 qemu_timeout_ssh: 600 @@ -60,6 +62,10 @@ "vm_cpus": "{{ item.vm_cpus | default(qemu_vm_cpus) }}", "vm_memory": "{{ item.vm_memory | default(qemu_vm_memory) }}", "vm_disk": "{{ item.vm_disk | default(qemu_vm_disk) }}", + + "disk_type": "{{ item.disk_type | default(qemu_disk_type) }}", + + "bios_type": "{{ item.bios_type | default(qemu_bios_type) }}", "path_disk": "{{ molecule_ephemeral_directory }}/run/{{ item.name }}.qcow2", "path_pid": "{{ molecule_ephemeral_directory }}/run/{{ item.name }}.pid", @@ -89,6 +95,8 @@ that: - item.image_arch in ['x86_64', 'aarch64'] - item.network_mode in ['user', 'vmnet-shared'] + - item.disk_type in ['virtio', 'virtio-scsi'] + - item.bios_type in ['uefi', 'bios'] fail_msg: "Molecule instance {{ item.name }} configuration is not supported" success_msg: "Molecule instance {{ item.name }} configuration is supported" loop: "{{ molecule_instances }}" @@ -293,7 +301,13 @@ -boot d -cdrom {{ molecule_ephemeral_directory }}/run/cloud-init/{{ item.name }}.iso - -drive if=virtio,file={{ item.path_disk }} + {% if item.disk_type == 'virtio' %} + -drive if=virtio,file={{ item.path_disk }} + {% elif item.disk_type == 'virtio-scsi' %} + -drive if=none,id=hd,file={{ item.path_disk }} + -device virtio-scsi-pci,id=scsi + -device scsi-hd,drive=hd + {% endif %} {% if item.network_mode == 'vmnet-shared' %} -nic vmnet-shared,model=virtio-net-pci,mac={{ item.network_mac }} @@ -307,7 +321,9 @@ {% endif %} {% endif %} - -bios {{ molecule_driver_directory }}/edk2-{{ item.image_arch }}.fd + {% if item.bios_type == 'uefi' %} + -bios {{ molecule_driver_directory }}/edk2-{{ item.image_arch }}.fd + {% endif %} {% if item.image_arch == 'aarch64' %} -machine virt