- Installing KVM/QEMU/virt-manager on Manjaro Linux(Arch Linux)
- 1. QEMU Installation #
- 2. Virt-Manager and libvirtd Service Install #
- 3. Start the Services #
- Lean Approach
- 4. Configure the KVM #
- 5. Creating an New Network Bridge for VM. #
- 5.1 Create the Bridge description file #
- 5.2. Register the Bridge Network: #
- 5.3. Start the Bridge #
- Lean Approach
- 6. Permissions for Current User #
- 7. Reboot #
- More Notes #
- Windows — Guest — Copy & Paste Clipboard #
- Remote Connection to Display of VM #
- Multiple Monitors for a VM #
- Adding more USB devices to a VM #
- CPU Pinning Video — Easy #
- CPU Pinning Detail #
- Wish you All the Best #
- Install arch linux qemu
- Contents
- Checking support for KVM
- Hardware support
- Kernel support
- Para-virtualization with Virtio
- Kernel support
- List of para-virtualized devices
- How to use KVM
- Tips and tricks
- Nested virtualization
- Enabling huge pages
- diffficult / installing_virt_manager.md
- QEMU-KVM on Arch Linux Guide
- What is QEMU?
- System Requirements
- Setup and Installation
- Step 1: Enable VT-d/AMD-v
Installing KVM/QEMU/virt-manager on Manjaro Linux(Arch Linux)
08 Sep 2020, 10:01am TZ +05:30
KVM is an inherently better way to work with Virtual Machines. It sands for Kernel Virtual Machine.
After many tries, I finally managed to get it right.
UPDATED: 12th Oct 2020 — Bridge Network fix and added more details on remote viewing.
Let’s Look at what steps I followed.
1. QEMU Installation #
- ovmf helps to do the UEFI Bios and Secure Boot setups.
- bridge-utils for network bridge needed for VMs
- vde2 for QEMU distributed ethernet emulation
- dnsmasq the DNS forwarder and DHCP server
- openbsd-netcat network testing tool (Optional)
- ebtables and iptables to create packet routing and firewalls
2. Virt-Manager and libvirtd Service Install #
Virt-manager is a UI that helps to create and organize the VM’s. And virt-viewer is used to open remote window into the VM instance.
3. Start the Services #
To Autostart the services at boot:
In case you wish to see if the libvirtd.service has actually started or not:
Lean Approach
Note: In order to reduce the system Load you can skip the Autostart part. And do it every time you wish to use the service.
Just run, whenever you wish to work with KVM:
4. Configure the KVM #
Open the /etc/libvirt/libvirtd.conf for editing
The -cl in the nano would help you see line numbers and how many lines are actually remaining.
Here are the Lines to Edit:
- Uncomment the line 81 or so:
Make sure to save the file before you exit.
5. Creating an New Network Bridge for VM. #
A new network bridge is needed allow a separate IP subnet for Guest OS’s in VM.
5.1 Create the Bridge description file #
Create a new file like br10.xml :
And type the content in br10.xml :
This would help to register a new bridge network for the Guest OS’s. Here we are changing the default IP Address 192.168.72.X and also allowing the specific ports 1024-65535 to be forwarded over NAT. This helps to easily communicate with the Guest OS in the VM’s.
5.2. Register the Bridge Network: #
Now we have the network registered in the libvirtd .
5.3. Start the Bridge #
To Start this network bridge:
If you want to permanently enable the new network bridge, so that it Autostart at boot:
Lean Approach
Note: Permanently enabling this network would take resources. Hence the start command must be given every time before starting virt-manager .
6. Permissions for Current User #
In-order to be able to use the virt-manager as normal user, we need to add the user to the libvirt group.
Reboot the PC or Computer after changing the options.
7. Reboot #
Yes, for all this to take effect we need to reboot the computer.
More Notes #
Here are few insights that I found while using the virt-manager .
Windows — Guest — Copy & Paste Clipboard #
In order to make sure that the copy & paste works between the host and guest, we need to install Windows guest tools = spice-guest-tools .
Note This only works if your Display is set to spice Server .
Remote Connection to Display of VM #
Typically the VM’s in KVM are destined to run like head-less unit. Hence the remote viewer = virt-viewer is needed.
In order to connect to VM use the address
Thats the default port on which the virt-manager hosts the VM display output.
Multiple Monitors for a VM #
This is possible by adding few instances of Video QXL .
This can be done in the configuration mode of the VM’s (a.k.a i or show hardware details after opening the VM).
Adding more USB devices to a VM #
Some times we need to mount more than 1 USB device to our Guest OS. This can be easily achieved by adding more USB Redirector to the VM.
This can be done in the configuration mode of the VM’s (a.k.a i or show hardware details after opening the VM).
CPU Pinning Video — Easy #
Use this command to check the Topology and CPU numbers.
CPU Pinning Detail #
When thinking about CPUs, there are three concepts — socket, cores, and threads. 1
A socket (NUMA node) is a physical socket where the physical CPU capsules are placed. A normal PC only has one socket.
Cores are the number of CPU-cores per CPU. A modern standard CPU for a standard PC usually has two to four cores. Some CPUs can run more than one parallel thread per CPU-core. Intel has either one or two threads per core depending on the CPU model.
When lscpu says CPU(s) , it means Socket(s) * Core(s) per socket * Thread(s) per core . virt-manager ’s Logical host CPUs also means the same thing.
The default behavior of KVM guests is to run operations coming from the guest as a number of threads representing virtual processors. 2 Those threads are managed by the Linux scheduler.
CPU pinning limits which physical CPU cores the virtual CPUs are allowed to run on.
The ideal setup is one-to-one mapping such that virtual CPU cores match physical CPU cores while taking hyperthreading/SMT into account.
Hyperthreading/SMT is simply a very efficient way of running two threads on one CPU core at any given time.
The topology of the processor can be found out using lscpu -e . Column CORE shows the association of the physical/logical CPU cores.
In case of ThinkPad we have the following.
So CORE 0 has CPU 0, 2 and CORE 1 has CPU 1, 3.
So, if we want to allocate CORE 1 to the VM, we would have to do virsh edit vmname and do the following.
Wish you All the Best #
Hope this would helpful to get you stared on KVM using QEMU and virt-manager as the front-end.
As always, I look forward to your suggestion and comments. DM me on Mastodon .
Источник
Install arch linux qemu
KVM, Kernel-based Virtual Machine, is a hypervisor built into the Linux kernel. It is similar to Xen in purpose but much simpler to get running. Unlike native QEMU, which uses emulation, KVM is a special operating mode of QEMU that uses CPU extensions (HVM) for virtualization via a kernel module.
Using KVM, one can run multiple virtual machines running unmodified GNU/Linux, Windows, or any other operating system. (See Guest Support Status for more information.) Each virtual machine has private virtualized hardware: a network card, disk, graphics card, etc.
Differences between KVM and Xen, VMware, or QEMU can be found at the KVM FAQ.
This article does not cover features common to multiple emulators using KVM as a backend. You should see related articles for such information.
Contents
Checking support for KVM
Hardware support
KVM requires that the virtual machine host’s processor has virtualization support (named VT-x for Intel processors and AMD-V for AMD processors). You can check whether your processor supports hardware virtualization with the following command:
If nothing is displayed after running either command, then your processor does not support hardware virtualization, and you will not be able to use KVM.
Kernel support
Arch Linux kernels provide the required kernel modules to support KVM.
- One can check if the necessary modules, kvm and either kvm_amd or kvm_intel , are available in the kernel with the following command:
The module is available only if it is set to either y or m .
- Then, ensure that the kernel modules are automatically loaded, with the command:
If the command returns nothing, the module needs to be loaded manually, see Kernel modules#Manual module handling.
Para-virtualization with Virtio
Para-virtualization provides a fast and efficient means of communication for guests to use devices on the host machine. KVM provides para-virtualized devices to virtual machines using the Virtio API as a layer between the hypervisor and guest.
All Virtio devices have two parts: the host device and the guest driver.
Kernel support
Use the following command to check if the VIRTIO modules are available in the kernel inside the virtual machine:
Then, check if the kernel modules are automatically loaded with the command:
In case the above commands return nothing, you need to load the kernel modules manually.
List of para-virtualized devices
- network device (virtio-net)
- block device (virtio-blk)
- controller device (virtio-scsi)
- serial device (virtio-serial)
- balloon device (virtio-balloon)
How to use KVM
See the main article: QEMU.
Tips and tricks
Nested virtualization
Nested virtualization enables existing virtual machines to be run on third-party hypervisors and on other clouds without any modifications to the original virtual machines or their networking.
On host, enable nested feature for kvm_intel :
Verify that feature is activated:
Enable the «host passthrough» mode to forward all CPU features to the guest system:
- If using QEMU, run the guest virtual machine with the following command: qemu-system-x86_64 -enable-kvm -cpu host .
- If using virt-manager, change the CPU model to host-passthrough .
- If using virsh, use virsh edit vm-name and change the CPU line to
Boot VM and check if vmx flag is present:
Enabling huge pages
This article or section is a candidate for merging with QEMU.
You may also want to enable hugepages to improve the performance of your virtual machine. With an up to date Arch Linux and a running KVM you probably already have everything you need. Check if you have the directory /dev/hugepages . If not, create it. Now we need the right permissions to use this directory. The default permission is root’s uid and gid with 0755, but we want anyone in the kvm group to have access to hugepages.
Add to your /etc/fstab :
Of course the gid must match that of the kvm group or specify the group name directly with gid=kvm . The mode of 1770 allows anyone in the group to create files but not unlink or rename each other’s files. Make sure /dev/hugepages is mounted properly:
Now you can calculate how many hugepages you need. Check how large your hugepages are:
Normally that should be 2048 kB ≙ 2 MB. Let us say you want to run your virtual machine with 1024 MB. 1024 / 2 = 512. Add a few extra so we can round this up to 550. Now tell your machine how many hugepages you want:
If you had enough free memory you should see:
If the number is smaller, close some applications or start your virtual machine with less memory (number_of_pages x 2):
Note the -mem-path parameter. This will make use of the hugepages.
Now you can check, while your virtual machine is running, how many pages are used:
Источник
diffficult / installing_virt_manager.md
Easy instructions to get QEMU/KVM and virt-manager up and running on Arch
Make sure your cpu support kvm with below command:
Make sure BIOS have enable “Virtualization Technology”.
User access to /dev/kvm so add your account into kvm(78) group:
Loading kernel modules kvm_intel or kvm_amd depend on your CPU, Add module name in /etc/modules-load.d/kvm.conf :
Install qemu , virt-manager , dnsmasq and iptables :
Run and enable boot up start libvirtd daemon:
Use PolicyKit authorization create /etc/polkit-1/rules.d/50-libvirt.rules (before /etc/polkit-1/rules.d/50-org.libvirt.unix.manage.rules ) as below context:
You will need to create the libvirt group and add any users you want to have access to libvirt to that group:
Check network interface status:
If it is inactive start it using:
- Now you can use virt-manager manager your virtual machine.
What to do if default network interface is not listed
If virsh net-list is not listing any network interface just reinitialize it with,
Then just autostart it like so,
- Things to do after installing a Windows VM.
- Check and install drivers on your guest Windows VM, probably virtio-win is a nice place to start.
How to extend / increase a Windows Partition on KVM QEMU VM
We have a Windows 7 VM running on Ubuntu KVM. I needed to give the Windows 7 machine more disk space. This turns out to be really easy (when you know how).
Shutdown the VM
Increase the qcow2 image
Find the qcow2 file of the VM and take a backup (just in case).
Extend the partition in Window
Windows has a really good partition management utility built into it. Search for disk management
Источник
QEMU-KVM on Arch Linux Guide
Oh yes! No more dual-booting baby! I still cannot believe it! I was really looking forward to it and it’s finally here also for me! I really love working under Linux: everything feels smooth, stable, secure and the power of customization is in your hands! Qualities that you cannot find in Windows. Not up until now at least. Windows are however a necessity: if you are a gamer or your bound to windows-only programs you know what I mean!
In this guide I will show you how you can setup QEMU-KVM to achieve GPU passthrough and ultimately get rid of dual booting. This guide will cover the case of using identical GPUs and is a bit different from the most guides out there which go via the pci-stub module. We will directly use the vfio-pci !
What is QEMU?
QEMU is a generic and open source machine emulator and virtualizer. […] When used as a virtualizer, QEMU achieves near native performance by executing the guest code directly on the host CPU. QEMU supports virtualization when executing under the Xen hypervisor or using the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86, server and embedded PowerPC, and S390 guests.
System Requirements
Your systems needs to satisfy the following requirements:
- CPU VT-d (Intel) or AMD-v (AMD) support
- Motherboard can enable VT-d/AMD-v support
- Number of GPUs >= 2
Once you made clear that the above requirements are satisfied you may proceed! Otherwise, I am sorry… 🙁
Setup and Installation
Step 1: Enable VT-d/AMD-v
The first thing we need to do is enable VT-d/AMD-v and ensure functionality.
Источник