Last active
August 29, 2015 14:01
-
-
Save archerslaw/147822965f58a12ff864 to your computer and use it in GitHub Desktop.
Learn_virsh_XML_configure_and_qemu-kvm_cmdline.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.Attach a scsi-block/scsi-hd/scsi-cd/scsi-generic device. | |
1.1.scsi-block device. | |
e.g1:...-drive file=/dev/disk/by-path/ip-10.66.33.253:3260-iscsi-iqn.2014.sluo.com:iscsi.storage.1-lun-1,if=none,id=drive-scsi0-0-0-1,format=raw,cache=none -device scsi-block,bus=scsi0.0,channel=0,scsi-id=0,lun=1,drive=drive-scsi0-0-0-1,id=scsi0-0-0-1 | |
... | |
<disk type='block' device='lun' > | |
<driver name='qemu' type='raw' cache='none'/> | |
<source dev='/dev/disk/by-path/ip-10.66.33.253:3260-iscsi-iqn.2014.sluo.com:iscsi.storage.1-lun-1'/> | |
<target dev='sdb' bus='scsi'/> | |
<alias name='scsi0-0-0-1'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='1'/> | |
</disk> | |
<controller type='scsi' index='0' model='virtio-scsi'> | |
<alias name='scsi0'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> | |
</controller> | |
... | |
1.2.scsi-hd device. | |
e.g2:...-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x7 -drive file=/home/my-data-disk.raw,if=none,id=drive-scsi0-0-0-1,format=raw,cache=none -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=1,drive=drive-scsi0-0-0-1,id=scsi0-0-0-1 | |
... | |
<disk type='file' device='disk' > | |
<driver name='qemu' type='raw' cache='none'/> | |
<source file='/home/my-data-disk.raw'/> | |
<target dev='sdb' bus='scsi'/> | |
<alias name='scsi0-0-0-1'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='1'/> | |
</disk> | |
<controller type='scsi' index='0' model='virtio-scsi'> | |
<alias name='scsi0'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> | |
</controller> | |
... | |
1.3.scsi-cd device. | |
e.g3:...-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x7 -drive file=/home/RHEL-7.0-20131030.1-Server-x86_64-dvd1.iso,if=none,id=drive-scsi0-0-0-1,readonly=on,format=raw,cache=none -device scsi-cd,bus=scsi0.0,channel=0,scsi-id=0,lun=1,drive=drive-scsi0-0-0-1,id=scsi0-0-0-1 | |
... | |
<disk type='file' device='cdrom' > | |
<driver name='qemu' type='raw' cache='none'/> | |
<source file='/home/RHEL-7.0-20131030.1-Server-x86_64-dvd1.iso'/> | |
<target dev='hdb' bus='scsi'/> | |
<alias name='scsi0-0-0-1'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='1'/> | |
</disk> | |
<controller type='scsi' index='0' model='virtio-scsi'> | |
<alias name='scsi0'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> | |
</controller> | |
... | |
1.4.scsi-generic device. | |
# sg_map | grep /dev/sdb | |
/dev/sg3 /dev/sdb | |
# virsh nodedev-list --tree | |
... | |
+- scsi_host6 | |
| | |
+- scsi_target6_0_0 | |
| | |
+- scsi_6_0_0_0 | |
| | | |
| +- scsi_generic_sg2 | |
| | |
+- scsi_6_0_0_1 | |
| | |
+- block_sdb_1IET_00060001 | |
+- scsi_generic_sg3 | |
... | |
e.g4:...-drive file=/dev/sg3,if=none,id=drive-hostdev0,readonly=on -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-hostdev0,id=hostdev0 | |
... | |
</controller> | |
<hostdev mode='subsystem' type='scsi'> | |
<source> | |
<adapter name='scsi_host6'/> | |
<address type='scsi' bus='0' target='0' unit='1'/> | |
</source> | |
<readonly/> | |
<address type='drive' controller='0' bus='0' target='0' unit='0'/> | |
</hostdev> | |
<controller type='scsi' index='0' model='virtio-scsi'> | |
<alias name='scsi0'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> | |
</controller> | |
... | |
2.Attach a virtio-blk device. | |
e.g:...-drive file=/home/my-data-disk.raw,if=none,id=drive-virtio-disk0,format=raw -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0 | |
... | |
<disk type='file' device='disk'> | |
<driver name='qemu' type='raw'/> | |
<source file='/home/my-data-disk.raw'/> | |
<target dev='vda' bus='virtio'/> | |
<alias name='virtio-disk0'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> | |
</disk> | |
... | |
3.Attach a ide-cd/ide-hd device. | |
3.1.ide-hd device. | |
e.g1:...-drive file=/home/my-data-disk.raw,if=none,id=drive-ide0-0-1,format=raw,cache=none -device ide-hd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 | |
... | |
<disk type='file' device='disk'> | |
<driver name='qemu' type='raw' cache='none'/> | |
<source file='/home/my-data-disk.raw'/> | |
<target dev='hdb' bus='ide'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='1'/> | |
</disk> | |
<controller type='ide' index='1'> | |
<alias name='ide1'/> | |
</controller> | |
... | |
3.2.ide-cd device. | |
e.g2:...-drive file=/home/RHEL-7.0-20140507.0-Server-x86_64-dvd1.iso,if=none,id=drive-ide0-0-1,readonly=on,format=raw,cache=none -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 | |
... | |
<disk type='file' device='cdrom'> | |
<driver name='qemu' type='raw' cache='none'/> | |
<source file='/home/RHEL-7.0-20140507.0-Server-x86_64-dvd1.iso'/> | |
<target dev='hdb' bus='ide'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='1'/> | |
</disk> | |
<controller type='ide' index='1'> | |
<alias name='ide1'/> | |
</controller> | |
... | |
4.Attach a ahci-cd/ahci-hd device. | |
4.1.ahci-hd device. | |
e.g1:...-device ahci,id=ahci0,bus=pci.0,addr=0x5 -drive file=/home/my-data-disk.raw,if=none,id=drive-sata0-0-0,format=raw -device ide-hd,bus=ahci0.0,drive=drive-sata0-0-0,id=sata0-0-0 | |
... | |
<disk type='file' device='disk'> | |
<driver name='qemu' type='raw'/> | |
<source file='/home/my-data-disk.raw'/> | |
<target dev='sdb' bus='sata'/> | |
<alias name='ahci-disk0'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='0'/> | |
</disk> | |
<controller type='sata' index='0'> | |
<alias name='sata0'/> | |
</controller> | |
... | |
4.2.ahci-cd device. | |
e.g2:...-device ahci,id=ahci0,bus=pci.0,addr=0x5 -drive file=/home/RHEL-7.0-20140507.0-Server-x86_64-dvd1.iso,if=none,media=cdrom,id=drive-sata0-0-0,readonly=on,format=raw -device ide-cd,bus=ahci0.0,drive=drive-sata0-0-0,id=sata0-0-0 | |
... | |
<disk type='file' device='cdrom'> | |
<driver name='qemu' type='raw'/> | |
<source file='/home/RHEL-7.0-20140507.0-Server-x86_64-dvd1.iso'/> | |
<target dev='sdb' bus='sata'/> | |
<alias name='ahci-disk0'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='0'/> | |
</disk> | |
<controller type='sata' index='0'> | |
<alias name='sata0'/> | |
</controller> | |
... | |
5.Attach/Detach a raw format disk device from XML file to guest. | |
5.1.start a domain. | |
# virsh create scsi-block-testing.xml | |
Domain scsi-block-testing created from scsi-block-testing.xml | |
5.2.create a disk desription file as following XML. | |
# cat disk-scsi-block.xml | |
<disk type='block' device='lun' > | |
<driver name='qemu' type='raw' cache='none'/> | |
<source dev='/dev/disk/by-path/ip-10.66.33.253:3260-iscsi-iqn.2014.sluo.com:iscsi.storage.1-lun-1'/> | |
<target dev='sdb' bus='scsi'/> | |
<alias name='scsi0-0-0-1'/> | |
<address type='drive' controller='0' bus='0' target='0' unit='1'/> | |
</disk> | |
5.3.# virsh attach-device scsi-block-testing disk-scsi-block.xml | |
Device attached successfully | |
5.4.# # virsh detach-disk scsi-block-testing sdb | |
Disk detached successfully | |
6.Attach/Detach a raw format disk device to guest | |
6.1.start a domain. | |
# virsh create scsi-block-testing.xml | |
Domain scsi-block-testing created from scsi-block-testing.xml | |
6.2.# virsh attach-disk scsi-block-testing /dev/disk/by-path/ip-10.66.33.253:3260-iscsi-iqn.2014.sluo.com:iscsi.storage.1-lun-1 sdb --type lun | |
Disk attached successfully | |
6.3.# virsh detach-disk scsi-block-testing sdb | |
Disk detached successfully | |
7.Migration with VM via virsh. | |
# virsh migrate --live $domain_name qemu+ssh://$dst_ip/system | |
migrate-setmaxdowntime set maximum tolerable downtime | |
migrate-compcache get/set compression cache size | |
migrate-setspeed Set the maximum migration bandwidth | |
migrate-getspeed Get the maximum migration bandwidth | |
8.Network device(rtl8139/e1000/virtio-net-pci). | |
e.g1:...-netdev tap,fd=23,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=0a:01:38:b6:40:24,bus=pci.0,addr=0x3 | |
... | |
<interface type='network'> | |
<mac address='0a:01:38:b6:40:24'/> | |
<source network='default'/> | |
<target dev='vnet0'/> | |
<model type='virtio-net-pci'/> | |
<alias name='net0'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> | |
</interface> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment