What is the function of QEMU?Qemu is a virtualization platform application that works as an emulator that emulates an existing system to run more than one operating system together at the same time. It has its own configuration and it is easy to install and use. It is used to emulate many subsystems like hardware and softwares. It emulates the processors as well like multiprocessing systems.
What are the different modes of operations performed by QEMU?Qemu has two modes of operations and they are as follows:
- User mode emulation: this allow the process execution from one CPU to another CPU. It performs dynamic translation of instructions for host CPU.
- System mode emulation: this allow the emulation of the complete system that includes hardware as well as peripheral related components.
What is the function of dynamic translator in context with the QEMU?Dynamic translator translates the instructions that is being given by the guest system to the host system language. It translates the instructions at runtime to provide the emulation between the host CPU and guest CPU. To translate the instructions it maps the instructions that are passed from one CPU to another CPU. In this case there remains always the possibility that the behavior or additional instructions might be required by the architecture for translations.
What is the function of QEMU accelerator?To achieve high performance and using QEMU emulation environment there is a requirement to use QEMU accelerator that allows the execution of emulated codes and the libraries attached to it directly on the host CPU using the kernel module. It accelerates the translation of instructions from one CPU to another CPU without delaying the output to the user.
How can you achieve dynamic translation using QEMU?Dynamic translation can be achieved by first converting the target into micro-operations. Micro-operations in this case are in the form of C code that gets compiled into objects. A core translator is required that maps the target instructions into micro-operations instructions. It is an efficient and portable way to achieve translation using Qemu. It removes the overhead by caching the translated code. It supports self modification by making the translated block invalidate in cache.
What are the supported peripherals used by QEMU?QEMU provides a long range of peripheral support for example:
- Hardware video graphics array emulator
- Mouse and keyword support
- Hard disk
- CD-ROM interface
- floppy disk emulation.
- PCI network adapter
- Serial ports
- PCI universal Host controller Interface
What is the use of the command qemu-img?
Qemu as an emulator allow the user to enjoy the virtualization on their system without the need to install a OS separately. Qemu provides qemu-img command to create the hard disk. This command is used to create images of various formats like qcow (QEMU copy-on-write). This format allows the size of the disk image is different from the file that is physically present. It creates a compact image such that the size decreases and the image that gets produced is compressed to make it protable. For example
: to create a disk image of 128 MB the following code will be written.
Qemu-img create -f qcow disk.img 128MB
How to setup TAP network using QEMU?QEMU runs on user mode network that is being setup between host and guest operating systems. QEMU provides the emulation to manage the network interface internally and for the application as well. It provides a way to manage DHCP host IPs that assigns the IP dynamically to the guest OS. The protocols that are used to be redirected from host to guest OS is done by TCP and UDP. TCP and UDP are the only connections that are present by default. To setup TAP networking, first the connection with the guest OS has to be established by using Ethernet connection connected to the host OS that is using TAP network bridge. The script that is called by qemu for network configuration is /etc/qemu-ifup script, this script sets up the bridge network.
How QEMU speeds up the performance of the system?QEMU increases the speed and performance by using the dynamic translators and virtualization technique that is being used on different operating system. It provides high performance by executing the guest code directly on the host CPU. It gives high performance when executing under the Xen hypervisor or KVM.
How QEMU uses hardware virtualization extensions?QEMU is in the process of creating a kernel based virtual machine that uses modified QEMU to provide the extensions for different technologies. The two most processors that are used are Intel and AMD-V processors for which QEMU is creating this extensions. VT (virtualization technology) is disabled by BIOS by default but it can be enabled from BIOS menu to turn on all the functionalities of QEMU.
Where can I find the configuration if tuntap network mode is being set by QEMU?The place where you can find tuntap network mode configuration settings is /dev/tap0 or in the fle /dev/net/tap0. The tuntap network mode can be seen by using the command ifconfig -a. For tuntap mode to exist QEMU should be running and when it shuts down then the devices which are attached to it automatically gets shut down. During shut down it removes the tuntap devices as well.
What is the purpose of using tun0 instead of tap0 in QEMU?QEMU uses a tap device only the tun0 name which is being given allows the user to connect in the networking. The kernel of the system create a tap device named as tun0 and a tap device with name tap0. It just uses the name to differentiate its own configuration but it uses tap device only for networking methods. It uses Ethernet frames for the configuration to be stored.
What is the process of setup up tuntap network mode without using VDE?
To setup tuntap networking mode it requires the implication of tap networking device on the host system. It provides good performance overall and can be configured to create virtual network topology. At the same time, it requires high end configuration of the network topology in host that tends to differ from one operating system to another operating system.
The command that allows it to run tap networking mode is
To change the network configuration for the user it requires
The device option in the command is used to plug in the particular network device like
-netdeve type=user, id=mynet0 -device e2000, netdev= mynet0
How to connect many VLAN to tap devices using QEMU?
To connect VLANs to tap devices the requirement is of vlan that should be available in the host operating system. Any frame that appears on this device can be attached using the QEMU process. This process request is received by another interfaces on VLAN and then frames are received by device.
The command that is used to configure the networking mode:
qemu -net nic -net tap,ifname=qtap0 …
QEMU needs tuntap device driver that allow the user-space application to obtain different file discriptors that are connected to a network device. The tap devices can be seen by going to the directory file /dev/net/tun or else calling the function TUNSETIFF ioctl() that is allowed only to the user who are privileged.
How to make bridging possible in QEMU?
To build bridges in QEMU the configuration files has to be changed and the firewall has to be set up such that it doesn't interfere in between the process. If firewall creates problem then there is a possibility of loosing the network connection to QEMU virtual machines. So, to enable the firewall to all the traffic to the servers configure the IP addresses by using the command like:
# allow incoming packets for qemu
IPTABLES -A FORWARD -d $IPADDR_FROM_CLIENT_OS -j ACCEPT
# allow outgoing packets from qemu
IPTABLES -A FORWARD -s $IPADDR_FROM_CLIENT_OS -j ACCEPT
These commands will take care of the firewall settings and will help in allowing the traffic to flow to the virtual machine's IP address. To add a range add the network address and netmask in the configuration file.