Skip to content

Commit

Permalink
virt: disk target device depends on the bus
Browse files Browse the repository at this point in the history
Not all disk target devices should start with 'vd' for non-vmware
hypervisors. Map the bus type to the right device name prefix. While at
it, also make sure the disks are created right for xen.
  • Loading branch information
cbosdo committed Sep 5, 2018
1 parent 2463ebe commit 2c456f5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions salt/modules/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,16 +615,17 @@ def _gen_xml(name,
context['console'] = True

context['disks'] = {}
disk_bus_map = {'virtio': 'vd', 'xen': 'xvd', 'fdc': 'fd', 'ide': 'hd'}
for i, disk in enumerate(diskp):
context['disks'][disk['name']] = {}
context['disks'][disk['name']]['file_name'] = disk['filename']
context['disks'][disk['name']]['source_file'] = disk['source_file']
if hypervisor in ['qemu', 'kvm', 'bhyve']:
context['disks'][disk['name']]['target_dev'] = 'vd{0}'.format(string.ascii_lowercase[i])
prefix = disk_bus_map.get(disk['model'], 'sd')
context['disks'][disk['name']]['target_dev'] = '{0}{1}'.format(prefix, string.ascii_lowercase[i])
if hypervisor in ['qemu', 'kvm', 'bhyve', 'xen']:
context['disks'][disk['name']]['address'] = False
context['disks'][disk['name']]['driver'] = True
elif hypervisor in ['esxi', 'vmware']:
context['disks'][disk['name']]['target_dev'] = 'sd{0}'.format(string.ascii_lowercase[i])
context['disks'][disk['name']]['address'] = True
context['disks'][disk['name']]['driver'] = False
context['disks'][disk['name']]['disk_bus'] = disk['model']
Expand Down

0 comments on commit 2c456f5

Please sign in to comment.