It is much easier to use than the xen native tools for VM creation, network management and storage management
Pros:
- Standard, easy and neat commands to manage VM creation, network management and storage management.
- Support all well known hypervisors (Linux KVM, Xen, VMware ESX, OpenVZ..), so the knowledge is transferable.
- Remote management with TLS encryption and Kerberos authentication.
- API bindings for multiple languages: Python,Perl,Ruby, Java, OCaml , C#, and PHP
- Operation isolation: Stopping libvirt (version> 0.6.0) daemon won't affect VM
Cons:
- Libvirt couldn’t keep up with the development of the underlying hypervisor, so it might not be able understand new features in hypervisor.
- An additional layer of management introduces availability and security concerns. Although stopping libvirt daemon won’t affect VM, but if libvrit daemon fails upon hypervisor reboot. The network bridge managed by libvirt won’t be created. But it can be quickly remedied by simple command:
$brctl addbr br-name; ifconfig br-name IP upWhere does libvirt save the VM configuration file?
It depends on the hypervisor. For Xen, libvirt use Xen API to save it to xenstore(/var/lib/xenstored). Because xenstore is Xen component, that is why VM native tools can start VM without libvirt daemon.
The following stript can be used to examine the VM configuration.
#!/bin/sh
Install libvirt on Debianfunction dumpkey() {local param=${1}local keylocal resultresult=$(xenstore-list ${param})if [ "${result}" != "" ] ; thenfor key in ${result} ; do dumpkey ${param}/${key} ; doneelseecho -n ${param}'='xenstore-read ${param}fi}for key in /vm /local/domain /tool ; do dumpkey ${key} ; done
$apt-get install libvirt-bin virtinst
Enable xend-unix-server in xend to talk to libvirt
$ grep xend-unix-server /etc/xen/xend-config.sxp
(xend-unix-server yes) $/etc/init.d/xend restartDefine new network bridge
root@xen4:/etc/xen# cat /tmp/net.xml
Type “virsh” to enter an virsh interactive prompt<network><name>private</name><bridge name="virbr2" /><ip address="192.168.152.1" netmask="255.255.255.0"></ip></network>
virsh # net-define /tmp/net.xml
Install Centos para-virtualization guest.Network private defined from /tmp/net.xmlvirsh # net-autostart private
Network private marked as autostartedvirsh # net-start private
Network private startedvirsh # net-list
Name State Autostart-----------------------------------------private active yesroot@xen4:/# ifconfig virbr2
virbr2 Link encap:Ethernet HWaddr de:49:4e:43:c5:5dinet addr:192.168.152.1 Bcast:192.168.152.255 Mask:255.255.255.0UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
#Prepare sparse disk file with qemu-img tool
$qemu-img create -f raw /data/pv2.raw 2G
Para virtualization guest can’t use cdrom as install source, In this example, I mount the ISO file to a web server directory.
$virt-install \
After the VM has been created, you can use xen native tool /usr/sbin/xm or libvirt virsh command to start/stop VM. But any configuration change require the virsh edit commands (edit, net-edit, pool-edit vol-edit, iface-edit)--paravirt \--name pv2 \--ram 256 \--disk path=/data/pv2.raw,size=2,format=raw \
--os-type=linux --os-variant=rhel5.4 \--nographics \--network network=private \--location http://192.168.152.1/pkgs/
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.