From Fedora Project Wiki
Description
Setup
- make sure install qemu-img:
#yum install qemu-img
- if the guest is rhel5, execute the following command in guest before attach-disk:
# modprobe acpiphp
How to test
# virsh start demo
# qemu-img create foo.img 10M
- Create a disk desription file as following XML:
# cat disk.xml
- <disk type='file' device='disk'>
- <driver name='qemu' type='raw'/>
- <source file=''/var/lib/libvirt/images/foo.img''/>
- <target dev='sda' bus='scsi'/>
- </disk>
# virsh attach-device demo disk.xml
- Run command
fdisk -l
in guest - Restart demo and check:
- # virsh shutdown demo
- # virsh start demo
- log in guest:
- # fdisk -l
# virsh detach-disk demo sda
- Run command
fdisk -l
in guest
Expected Results
- step 4: Device attached successfully
- step 5: check the disk device is existing.
- step 6: boot successfully and check the disk device is existing.
- step 7: Disk detached successfully
- step 8: check the disk device is not existing.