virt-install –cpuset=auto

INFORMATIONAL NOTE: The option “virt-install –cpuset=auto ( with other switches)” can be used to pin physical cpus for the guest cpus. This option is really useful when “numa” capable host system is in use. So that you dont need to select host cpus to pin for guest cpus. The utility “virt-install” will form the optimal …

Read more

Share host filsystem to guest using virtfs 9p filesystem passthrough

Virtfs is a virtualization aware filesystem passthrough..Sharing host files on the guest through generic network file systems like NFS and CIFS suffer from major performance and feature deficiencies as these protocols are not designed or optimized for virtualization. To address the needs of
the virtualization paradigm, a new paravirtualized file system called VirtFS has been intorduced. Virtfs takes features of 9p2000.L protocol.

Using virtfs, you can share filesystem of host to the guest system. It works via para virtual transport mechanism called ‘virtio’. Virtfs has been implemented with ‘zero copy’ mechanism. This is a key advantage of VirtFS compared to using a network file system which would always require at least one (but usually more) data copies.

There are mainly 2 components in this implementation.

1)  virtio-9p-pci device ::

This will be used to transport protocol messages and data between the host
and the guest.

2) ‘fsdev’ device :

This is used to define the export file system characteristics like file
system type, security model .

For more about the implementation details,please  look at reference section..

Below is demo of this feature in “qemu” , “kvm”, “libvirt” environment.

Host system details : Fedora 15 :

[root@humbles-lap Desktop]$ cat /etc/redhat-release
Fedora release 15 (Lovelock)
[root@humbles-lap Desktop]$ uname -r
2.6.43.5-2.fc15.x86_64

Guest System details:  Fedora 16:

[root@localhost mnt]# cat /etc/redhat-release
Fedora release 16 (Verne)
[root@localhost mnt]# uname -r
3.1.0-7.fc16.x86_64
[root@localhost mnt]#

First of all, check support for above mentioned components ( virtio-9p-pci & fsdev) in host system qemu-kvm binary..

Host:

[root@humbles-lap Desktop]$ qemu-kvm –help|grep virtfs
-virtfs local,path=path,mount_tag=tag,security_model=[mapped|passthrough|none]

[root@humbles-lap Desktop]$ qemu-kvm device ?

name “virtio-9p-pci”, bus PCI

[root@humbles-lap Desktop]# lsmod |grep virt
9pnet_virtio           13416  0
9pnet                  73543  1 9pnet_virtio
virtio_net             23133  0
[root@humbles-lap Desktop]#

Guest Kernel has to support 9p:

[root@humbles-lap bin]#  grep 9P /boot/config-$(uname -r)
CONFIG_NET_9P=m
CONFIG_NET_9P_VIRTIO=m
CONFIG_NET_9P_RDMA=m
# CONFIG_NET_9P_DEBUG is not set
CONFIG_9P_FS=m
CONFIG_9P_FSCACHE=y
CONFIG_9P_FS_POSIX_ACL=y

IN HOST SYSTEM:
—————————————————-

The below string has to be specified with ‘qemu-kvm’ process to export a ‘virtfs’ filesystem for guest.

-virtfs local,path=[path to share],security_model=[mapped|passthrough|
none],mount_tag=[mount tag]

Where : Path = Sharing filesystem path
security_model: This can be either “mapped” or “passthrough”..
mount_tag: This is the idenitifier which can be used in guest when moutning.

The easiest way for defining this is, placing it in the guest configuration file..


< source dir='/misc/shared'/>

< address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>

After placing this in “guest configuration” file:

Start the guest :

ex: virsh create Fedora-16.xml

Check for “qemu-kvm” process to know whether “virtfs” options has been picked properly..

[root@humbles-lap Desktop]# ps aux |grep qemu-kvm
qemu      7473  0.8  8.0 1356940 314552 ?      Sl   17:00   0:27 /usr/bin/qemu-kvm -S -M pc-0.14 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name Fedora-16 -uuid 75d12600-d3c5-9bb1-7d0a-5ed0e550f5ee -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/Fedora-16.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -boot c -drive file=/var/lib/libvirt/images/Fedora-16.img,if=none,id=drive-virtio-disk0,boot=on,format=raw -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/misc/shared -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=test_mount,bus=pci.0,addr=0x6 -netdev tap,fd=24,id=hostnet0,vhost=on,vhostfd=25 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:80:db:8d,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -usb -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

IN GUEST SYSTEM:

You have to mount the shared filesystem using “9p” . Use below command for the same:

#mount -t 9p -o trans=virtio test_mount /mnt

Where,

Filesyste type: 9p
Transport mechanism: virtio
Mount tag: This is the tag ‘test_mount’ which used when sharing from host system.
Mount Point: /mnt

Check for filesystem :

HOST

[root@humbles-lap shared]# pwd
/misc/shared
[root@humbles-lap shared]# echo “Hi Guest” –> virtfs_file
[root@humbles-lap shared]#

GUEST:

[root@localhost mnt]# mount |grep test_mount
test_mount on /mnt type 9p (rw,relatime,sync,dirsync,trans=virtio)
[root@localhost mnt]# pwd
/mnt
[root@localhost mnt]# cat virtfs_file
Hi Guest

Reference: www.kernel.org/doc/ols/2010/ols2010-pages-109-120.pdf

error: Requested operation is not valid: Disk .. does not support snapshotting

When I first tried virsh snapshot, I too got the same error. But it was easy to understand why I got that. It is nothing but the image format was “raw’. The snapshot feature depends on qemu to perform its operation.. For the qemu to work , the image format should be “qcow2“.. Now, a …

Read more

virsh undefine delete guest configuration file in kvm

Sometimes you may execute “virsh undefine” command .. but if you really didnt meant to delete the guest configuration from disk, please make sure you have a backup of the guest configuraiton file in a location which is NOT default for libvirt ie /etc/libvirt/qemu. Otherwise you may wonder where it went after virsh undefine command. …

Read more

what is virt-v2v ? How to use it and troubleshoot issues ?

Virt-v2v is a tool provided from Red Hat to convert guests from foreign hypervisors ( Xen, VMware..etc) to KVM. This turning out to be mostly used tool nowadays. When it deals with lots of operations, also with different hypervisor stack there can be issues. How-ever having more idea about the issue you are facing , …

Read more

How to detect a guest system ? Or how to detect which virtualization technology is used by "virt-what" command ?

What is ‘virt-what’ and how is it useful ? Quite often people come to me with a question “how can we know which virtualization hypervisor is used for this guest “? Previously I used to point out couple of options (dmidecode..etc) to check whether it is a Xen guest or kvm guest ..etc. but now …

Read more

How can I increase a virtual image disk space if it is created on a file image

This is a very useful method in your real life.. I have come across to increase the space in virtual machine when it created on a file image .. You can try any of the below to increase the space depending on the virtual guest’s storage .. That being said , it is possible to …

Read more