📜 ⬆️ ⬇️

Howto Qemu-kvm Debian 8

In this howto, we will simply and quickly, step by step, launch the Qemu-KVM hypervisor in debian 8.

image

We will run the virtual machine in qemu-kvm from the user username using spice, qxl and virtio.
It is assumed that Debian 8 amd64 is installed, with standard utilities and an SSH server selected in the tasksel. Install it.
')
aptitude install -y firmware-linux bridge-utils etckeeper 


Check if our processor supports virtualization:
 egrep '(vmx|svm)' /proc/cpuinfo 

Enable forwarding, net.ipv4.ip_forward = 1
 vim /etc/sysctl.conf 

Create bridge br0
Approximate view of / etc / network / interfaces
 # The loopback network interface auto lo iface lo inet loopback # The primary network interface #auto eth0 #allow-hotplug eth0 #iface eth0 inet dhcp auto br0 iface br0 inet dhcp bridge_ports eth0 bridge_stp off bridge_fd 0 bridge_maxwait 0 

 /etc/init.d/networking restart 

Check, it should be like "br0 8000.08608ee7dc58 no eth0"
 brctl show 

Using the bridge, at start of the virtual computer vnetX interfaces will rise
 tcpdump -i vnet0 -n 

Install kvm:
 aptitude install qemu-kvm libvirt-bin 

Add a user to kvm groups:
 adduser username kvm adduser username libvirt 

Let us allow access for spice and change the user under which everything will work:
 vim /etc/libvirt/qemu.conf 

spice_listen = "0.0.0.0"
user = "username"
group = "username"

By and large everything is ready to work.
Without running virtual machines, the host system takes up ~ 150 mb ram

You can skip - option for advanced
GUI manager for performing a basic set of tasks when working with kvm.
Creating, starting / stopping, cloning is almost :) everything you need.

On another computer, install:
 aptitude install ssh-askpass virt-manager virt-viewer spice-client-gtk 

Run virt-manager.
File -> add connection -> Hypervisor: QEMU / KVM and connect to the remote host under our user username. Authorization uses openssh-askpass.
Edit -> Connection Properties - Storage
Here you can manage storage - for example, create qemu-iso-storage and put distributions there for further needs. For example, gparted

It is possible to connect to the created virtual machine with a simple weaver with all the functionality that spice provides.
For this you need to know the domain URI / virt.mashiny on kvm
 virsh domdisplay corn 

On the client, run:
 remote-viewer spice://10.1.1.8:5905 


Same as the other weaver, which is spice-client-gtk:
 spicy -h 10.1.1.8 -p 5905 


In the advanced version, when creating a new virtual machine, there is a bug.
In the settings where we select a spice server or a vnc server, you cannot select a spice without enabling TLS.
By itself, TLS in qemu is not used by default and, therefore, off.
If TLS is not yet needed, you can temporarily start a virtual machine with a vnc server, so that corn.xml is created in / etc / libvirt / qemu / and replace the <graphics ... /> section with a spice with TLS turned off.
  <graphics type='spice' port='5905' autoport='no' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics> 

How to make friends TLS is written here - habrahabr.ru/post/221693


We continue to configure as root

We define pools - where everything will lie
storage configurations are stored here / etc / libvirt / storage /
the default is default.xml - the storage on the file system in / var / lib / libvirt / images
Add your qemu-test-storage:
* -as creates a storage similar to the default, i.e. configuration is the same as in default.xml
 virsh pool-define-as qemu-test-storage dir --target /home/username/qemu-test-storage/ 

By default, the pool is not running, let's start:
 virsh pool-start qemu-test-storage 

Add the created pool to the autostart:
 virsh pool-autostart qemu-test-storage 

View all pools:
 virsh pool-list --all 

All domains:
 virsh list --all 


Register a domain (virtual machine) with the configuration described in the file corn.xml
Creating xml with a configuration (for example, for a template) is easier via virt-manager than describing each option in virt-install.
All virtual machine configurations are stored in / etc / libvirt / qemu /
In general, it is assumed that we have this file.
 virsh define /home/username/anyfolder/corn.xml 

Add domain to autoload:
 virsh autostart corn 

Current domain configuration:
 virsh dumpxml corn 

Editing domain:
 virsh edit corn 

We start the domain, look at the URI and connect in any way possible.
 virsh start corn virsh domdisplay corn 


To install windows on the VirtIO partition, the installer requires a driver from the viostor folder of the virtio for windows driver set.
On linux-kvm.org are the sources, on fedoraproject.org you can find the collected virt-win.iso
After installation, you will most likely need spice windows guest tools

Now we will expand the domain volume.
We use qemu-img - QEMU disk image utility. In our case, that corn.qcow2
Observation - windows 7 is not enough 10GB, which would at once pump everything out of the update center and install them correctly.
It can be useful to first install the “Update for Windows 7 (KB2852386)” - this allows at least (read, nothing) to clear C: \ Windows \ winxsx through the standard “disk cleaning” and between reboots, and then use the update center.

Check section:
 cd /home/username/qemu-qcow2-storage/ qemu-img info corn.qcow2 qemu-img check corn.qcow2 

The following is minimal:
 qemu-img resize corn.qcow2 +10GB 

Then we add a CD-ROM device, “insert gparted there” and everything is as usual. Russian language - 24.
For good, you should use libguestfs-tools or resize2fs

For Windows 8.1 you need a wddm driver, QXL will be very slow, it is better to forward the host video card
About OEM activation of Windows is very well written here - habrahabr.ru/post/247597

Thanks to all.

Source: https://habr.com/ru/post/260791/


All Articles