#!/bin/bash set -x # Purpose: Attach more than six SCSI disks to a *single* SCSI controller # Create 10 raw disk images function create_disk() { for i in `seq 1 10`; do qemu-img create -f raw $i.raw 1G; done } # This is incrementing the 'unit' (a "2-digit unit number on a bus") # attribute, for the 'address' sub-element, which describes where the # device is placed on the virtual bus presented to the guest. # http://libvirt.org/formatdomain.html#elementsAddress j=1 # Construct a guest XML by attaching 10 disks to a single Virtio SCSI # controller by manually incrementing the 'unit' number function attach_device() { for i in {b..k}; do j=$(expr $j + 1) cat << EOF > disk-$i.xml
EOF # Attach the device; it takes effect on next boot sudo virsh attach-device cvm1 disk-$i.xml --config done } # Invoke the functions create_disk attach_device