Skip to content

Commit 33b461c

Browse files
committed
Allow to manually set volume target, thereby influence bus
The optional bus attribute specifies the type of disk device to emulate; possible values are driver specific, with typical values being "ide", "scsi", "virtio", "xen", "usb", "sata", or "sd" "sd" since 1.1.2. If omitted, the bus type is inferred from the style of the device name (e.g. a device named 'sda' will typically be exported using a SCSI bus). https://libvirt.org/formatdomain.html#elementsDisks
1 parent 6afb551 commit 33b461c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Role Variables
8686
- `image`: (optional) a URL to an image with which the volume is initalised (full copy).
8787
- `backing_image`: (optional) name of the backing volume which is assumed to already be the same pool (copy-on-write).
8888
- `image` and `backing_image` are mutually exclusive options.
89+
- `target`: (optional) Manually influence type and order of volumes
8990

9091
- `interfaces`: a list of network interfaces to attach to the VM.
9192
Each network interface is defined with the following dict:
@@ -161,6 +162,11 @@ Example Playbook
161162
format: 'qcow2'
162163
capacity: '400GB'
163164
pool: 'my-pool'
165+
- name: 'debian-10.2.0-amd64-netinst.iso'
166+
type: 'file'
167+
device: 'cdrom'
168+
format: 'raw'
169+
target: 'hda' # first device on ide bus
164170
interfaces:
165171
- network: 'br-datacentre'
166172

templates/vm.xml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838
{% else %}
3939
<source pool='{{ volume.pool }}' volume='{{ volume.name }}'/>
4040
{% endif %}
41+
{% if volume.target is undefined %}
4142
<target dev='vd{{ 'abcdefghijklmnopqrstuvwxyz'[loop.index - 1] }}'/>
43+
{% else %}
44+
<target dev={{ volume.target }} />
45+
{% endif %}
4246
</disk>
4347
{% endfor %}
4448
{% for interface in interfaces %}

0 commit comments

Comments
 (0)