Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for disk type virtio-scsi and bios type #32

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ dmypy.json
# Pyre type checker
.pyre/
src/molecule_plugins/_version.py

.vscode/
9 changes: 0 additions & 9 deletions .vscode/settings.json

This file was deleted.

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions molecule_qemu/driver.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
20 changes: 18 additions & 2 deletions molecule_qemu/playbooks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand Down