If you defined no CDROM when you created your virtual machine, you can attach the device even to a running domain (virtual machine) by running the following command:
virsh attach-disk testbed /dev/sr0 hdc --type cdrom
If you already defined a CDROM, but it pointed to an ISO image, in my experience, you can still run the same command. The hdc
part needs to match the block device you have in the testbed
virtual machine.
When you want to point to an ISO image again, you replace /dev/sr0
to the filename on the host, something like
virsh attach-disk testbed ~/virtio-win-0.1-22.iso hdc --type cdrom
The documentation suggests using virsh update-device
, but it is more labour to create an XML definition something like:
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<source dev='/dev/sr0'/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
If you are into this way, save something like that into a file (say ~/cdrom-real.xml
) and then fire:
virsh update-device testbed ~/cdrom-real.xml