sudo virsh net-list
sudo virsh net-dhcp-leases default | grep server_hostname
Tag Archives: libvirt
unsupported driver name ‘file’ for disk ‘hdc’
virsh add iso image like this:
virsh edit some_vm <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/systemrescuecd-6.0.2.iso'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk>
virsh enable autostart
virsh autostart srv_name
Domain srv_name marked as autostarted
debugging libvirt
debuginfo-install libvirt gdb libvirtd Libvirt_pid
lbvirt – change device boot order
<boot dev='network'/>
<boot dev='cdrom'/>
<boot dev='hd'/>
Boot order PXE, CD-ROM, hard disk
kvm change vnc port without guest reboot
qemu-monitor-command centos –hmp change vnc :5
LXC container on Centos
LXC isn’t a real Virtualization technique, but is more like a chroot environment, but on “steroids”. Its similar to OpenVZ virtualization, but can use your native kernel version. In some cases its very important.
mkdir /var/lib/libvirt/lxc/centos-6-x86_64/etc/yum.repos.d/ -p cat /etc/yum.repos.d/CentOS-Base.repo |sed s/'$releasever'/6/g > /var/lib/libvirt/lxc/centos-6-x86_64/etc/yum.repos.d/CentOS-Base.repo yum groupinstall core --installroot=/var/lib/libvirt/lxc/centos-6-x86_64/ --nogpgcheck -y yum install plymouth libselinux-python --installroot=/var/lib/libvirt/lxc/centos-6-x86_64/ --nogpgcheck -y
You should crate selinux rule:
module lxc 1.0;
require {
type hald_t;
type virtd_lxc_t;
class dbus send_msg;
}
#============= hald_t ==============
allow hald_t virtd_lxc_t:dbus send_msg;
You should create manually your selinux rule to allow virtd_lxc_t to use dbus daemon. How crate custom selinux rules, you can check in other my article there.
chroot /var/lib/libvirt/lxc/centos-6-x86_64/ echo your_password_there |passwd root --stdin #Fix root login on console echo "pts/0" >>/etc/securetty sed -i s/"session required pam_selinux.so close"/"#session required pam_selinux.so close"/g /etc/pam.d/login sed -i s/"session required pam_selinux.so open"/"#session required pam_selinux.so open"/g /etc/pam.d/login sed -i s/"session required pam_loginuid.so"/"#session required pam_loginuid.so"/g /etc/pam.d/login #Configuring basic networking cat > /etc/sysconfig/network << EOF NETWORKING=yes HOSTNAME=lxc.linux4you.tk EOF cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes EOF #Enabling sshd chkconfig sshd on # Fixing root login for sshd sed -i s/"session required pam_selinux.so close"/"#session required pam_selinux.so close"/g /etc/pam.d/sshd sed -i s/"session required pam_loginuid.so"/"#session required pam_loginuid.so"/g /etc/pam.d/sshd sed -i s/"session required pam_selinux.so open env_params"/"#session required pam_selinux.so open env_params"/g /etc/pam.d/sshd # Leaving the chroot'ed filesystem exit
virt-install --connect lxc:/// --name test --ram 512 --vcpu 1 --filesystem /var/lib/libvirt/lxc/centos-6-x86_64/,/ --noautoconsole
Creating XML configuration file with VIRSH
If you already have running virtual machine, you should use libvirt tools to manage your virtual instances.
virsh list
Id Name State
—————————————————-
2 Fedora19 running
Ok. Good its running.
virsh dumpxml Fedora19 > ./Fedora19.xml
Done.