Monday, March 30, 2020

NetworkManager CLI and deployment KVM guests on Ubuntu 20.04

Right after setting up Ubuntu Focal Fossa instance on bare metal run following commands to setup bridge br1 linked to physical interface enp2s0 which was used as normal connection to office LAN during install 
$ nmcli con show 
$ sudo nmcli con add type bridge ifname br1

$ sudo nmcli con add type bridge-slave ifname \        
     enp2s0 master br1 
$ sudo reboot
At this point make sure that bridge br1 has been setup as expected

Now install KVM on Ubuntu 20.04 as usual
  $ sudo apt -y install qemu-kvm \
       libvirt-daemon bridge-utils \
      virtinst libvirt-daemon-system
  $ sudo apt -y install virt-top libguestfs-tools \
     libosinfo-bin  qemu-system virt-manager
===================================
Load "virt-host" and update /etc/modules. 
===================================
$ sudo modprobe vhost_net 
$ lsmod | grep vhost
vhost_net              32768  1
vhost                      49152  1 vhost_net
tap                         24576  1 vhost_net

$ echo vhost_net | sudo tee -a /etc/modules
$ sudo reboot
Deploy for instance KVM Guest Debian Buster 10.3 utilizing bridge br1 , in this case Guest is supposed to be launched to office LAN and to be available for yours teammates via ssh
   Guest run-time snapshot
   Remote connection verfication ( sshd daemon is running on remote VM )

  Web Admin console (cockpit) connected to CentOS 8 VM

 You might want to compare this post with
   https://computingforgeeks.com/install-kvm-hypervisor-on-ubuntu-focal-fossa/
in relation with providing access to guests from LAN it wouldn't  help either on Focal Fossa or on Debian 10.3
=======================================
Setup connection to Virthost from vitrt-manager running on remote Ubuntu 20.04 box
=======================================
Install on Virthost and start sshd service :-
sudo apt install policykit-1-gnome
$  sudo apt install openssh-server -y
$  sudo systemctl start sshd
$  sudo systemctl status  sshd



Install on remote Ubuntu 20.04 workstation
$ sudo apt-get install -y ssh-askpass
Create new connection to libvirtd daemon running on Virthost via virt-manager running remotely earlier this schema presumed VNC console on guests@Virthost , however in meantime it works for Spice console as well. Video and sound are delivered on workstation connected via ssh to Spice console of guest running on Virthost.


It's important to understand that virt-manager as a client of Libvirtd service might work remotely as well as locally , it is so called vnc&&ssh connection. See RH's original setup here
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/chap-virtualization-remote_management_of_virtualized_guests

To avoid annoying prompts of ssh-askpass just establish ssh trust between client 192.168.0.23 and KVM VirtServer  192.168.0.19 as follows utilizing admin account "boris" ( root is not needed in fact). On client side
 boris@boris-System-Product-HSW:~$  ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/boris/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/boris/.ssh/id_rsa
Your public key has been saved in /home/boris/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:zCXSpc9btGuSExhcCkjq03NQtbdmtUAkQhMp4bQX2is
  boris@boris-System-Product-HSW
The key's randomart image is:
+---[RSA 3072]----+
|   .++O+o.=           |
|   +o=.B O             |
|  . =.+ O + o          |
| . . o = O = o          |
|  o E o S B +          |
|   . +   o = .             |
|          = o                |
|           +                  | 
|                               |
+----[SHA256]-----+
boris@boris-System-Product-HSW:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub boris@192.168.0.19
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/boris/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s),
to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed --
if you are prompted now it is to install the new keys
boris@192.168.0.19's password:
    Number of key(s) added: 1
Now try logging into the machine, with:   "ssh 'boris@192.168.0.19'" and check to make sure that only the key(s) you wanted were added.


Regarding ssh-askpass see for instance 
https://fabianlee.org/2019/02/16/kvm-virt-manager-to-connect-to-a-remote-console-using-qemussh/



Friday, March 27, 2020

Just another KVM setup on Debian Buster 10.3

Sequence of steps and bridge network configuration on native Debian Buster 10.3 host seemed to me a bit different from manuals which are available in meantime on the Net. Specifically I've undertaken some additional steps to fix error with Radeon kernel modesetting enabling also configuration bridge to physical LAN is supposed to be done in the way different from how it works on LMDE 4.

We intend to start with adding two following lines to /etc/apt/sources.list
deb http://ftp.us.debian.org/debian/ testing main non-free contrib
deb-src http://ftp.us.debian.org/debian/ testing main non-free contrib
and afterwards run
  $ sudo apt-get update
  $ sudo apt-get install firmware-amd-graphics
It would resolve for myself two issues :-
1. Radeon kernel modesetting enabled
   [    1.583423] [drm] radeon kernel modesetting enabled.
   [    1.583588] [drm] initializing kernel modesetting (CAICOS     0x1002:0x6779 0x1458:0x22A3 0x00).
  [    1.583622] resource sanity check: requesting [mem         0x000c0000-0x000dffff], which spans more than PCI Bus   0000:00 [mem 0x000d0000-0x000d3fff window]
2. Makes core setup free from workarounds
   when installing "Virtualization Server"  
======================================
Now install required packages :-
======================================
$ sudo apt -y install qemu-kvm \
    libvirt-daemon bridge-utils \
    virtinst libvirt-daemon-system
$ sudo apt -y install virt-top libguestfs-tools \
   libosinfo-bin  qemu-system virt-manager
===================================
Load "virt-host" and update /etc/modules. 
===================================
$ sudo modprobe vhost_net 
$ lsmod | grep vhost
vhost_net              24576  0
tun                    49152   1 vhost_net
vhost                  49152  1 vhost_net
tap                    28672    1 vhost_net
$ echo vhost_net | sudo tee -a /etc/modules
=================================================================
At this point create bridge br1 on native Debian Buster 10.3
=================================================================
root@boris-pchsw:~# apt install bridge-utils
root@boris-pchsw:~# cd /etc/network
root@boris-pchsw:/etc/network# cat interfaces
    source-directory /etc/network/interfaces.d
root@boris-pchsw:/etc/network# cd interfaces.d
root@boris-pchsw:/etc/network/interfaces.d# cat br1
  #Primary network interface(enp3s0)
  auto enp3s0
  iface enp3s0 inet manual
  #Configure bridge and give it a static ip
  auto br1
  iface br1 inet static
        address 192.168.0.19
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        bridge_ports enp3s0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0
        dns-nameservers 8.8.8.8

Reboot the box


Deploy CentOS 8.1 KVM Guest attached to bridge br1 ( been setup on physical interface to office LAN )
   Deploy one more ManjaroGDM 19.02 guest and test connecting via ssh from office LAN

  

Monday, March 23, 2020

Setting up KVM on LMDE 4 in Debian Buster Style (Classic)

We would start via installs proposed for Ubuntu Focal Fossa and create file /etc/network/interfaces exactly as recommended in official Debian Buster manual to be able launch guests available over all office LAN.
Please be aware of LMDE aims to be as similar as possible to Linux Mint, but *without* using Ubuntu. The package base is provided by Debian instead. LMDE 4 is based on Debian Buster. See 
https://www.debian.org/releases/buster/amd64/release-notes/


$ sudo apt -y install qemu-kvm \
    libvirt-daemon bridge-utils \
    virtinst libvirt-daemon-system
$ sudo apt -y install virt-top libguestfs-tools \
   libosinfo-bin  qemu-system virt-manager

Load "virt-host" and update /etc/modules. 

$ sudo modprobe vhost_net 
$ lsmod | grep vhost
vhost_net              24576  0
tun                    49152   1 vhost_net
vhost                  49152  1 vhost_net
tap                    28672    1 vhost_net

$ echo vhost_net | sudo tee -a /etc/modules

Now create file /etc/network/interfaces per 
https://www.linuxtechi.com/install-configure-kvm-debian-10-buster/
as follows below , where enp3s0 is physical interface to office LAN.
***********************************************
#Primary network interface(enp3s0)
auto enp3s0
iface enp3s0 inet manual
#Configure bridge and give it a static ip
auto br1
iface br1 inet static
        address 192.168.0.19
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        bridge_ports enp3s0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0
        dns-nameservers 8.8.8.8
**********************************************
When done reboot the "Debian 10" box . This ad appears at login screen after adding file above in folder /etc/network.



It would result creating bridge "br1" which is supposed to be used instead of libvirt's "br0" to deploy VMs on your office LAN 192.168.0.0/24. Now proceed with launching F32(beta) guest :-



  When with done make sure that F32 Guest is on your private LAN and available for ssh from any PC in your office




  Connecting to F32 WKS Guest




Switching LMDE 4 to Gnome desktop via snap


Attempt of kernel upgrade on LMDE 4 via Debian Backports to Buster.
$ sudo apt-get install linux-image-5.4.0-0.bpo.4-amd64  \
   linux-headers-5.4.0-0.bpo.4-amd64


*****************************************************
Would we like to setup br1 on native Debian Buster 10.3
then configuration should look as follows
*****************************************************
root@boris-pchsw:~# cd /etc/network
root@boris-pchsw:/etc/network# cat interfaces
    source-directory /etc/network/interfaces.d
root@boris-pchsw:/etc/network# cd interfaces.d
root@boris-pchsw:/etc/network/interfaces.d# cat br1
  #Primary network interface(enp3s0)
  auto enp3s0
  iface enp3s0 inet manual
  #Configure bridge and give it a static ip
  auto br1
  iface br1 inet static
        address 192.168.0.19
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        bridge_ports enp3s0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0
        dns-nameservers 8.8.8.8
root@boris-pchsw:~#  systemctl restart network-manager
either reboot the box

Thursday, March 19, 2020

Dev branch Fedora 32 versus Dev branch Ubuntu 20.04 in relation with KVM Hypervisor

We intend to testify F32 KVM Hypervisor on Penryn's box with 8 GB RAM. However, after install KVM  on F32 WKS we appear to be able to launch Manjaro Gnome19.02 as KVM guest @F32 Workstation Virtualization Host as well as CentOS 8.1 Guest with no issues at all. This post is an immediate follow up 
http://lxer.com/module/newswire/view/283064/index.html

Install KVM on F32 WKS
$ sudo dnf -y install bridge-utils libvirt virt-install qemu-kvm
$ sudo dnf -y install virt-top libguestfs-tools
$ sudo systemctl start libvirtd
$ sudo systemctl eanble libvirtd
$ sudo dnf -y install virt-manager
Currently we have following reports on Fedora 32 (beta release)

[boris@localhost ~]$ uname -a
Linux localhost.localdomain 5.6.0-0.rc5.git0.2.fc32.x86_64 #1 SMP Tue Mar 10 19:09:42 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

[boris@localhost ~]$ sudo virsh --connect qemu:///system version
Compiled against library: libvirt 6.1.0
Using library: libvirt 6.1.0
Using API: QEMU 6.1.0
Running hypervisor: QEMU 4.2.0

[boris@localhost ~]$ sudo rpm -qa | grep seabios
seabios-bin-1.13.0-2.fc32.noarch


Starting Manjaro Gnome 19.02 guest via virsh CLI on Fedora 32 WKS.


  Now get access to Guest's desktop via Virt-manager


 Current status of Bug 
https://bugs.launchpad.net/qemu/+bug/1866870

   Launching CentOS 8.1 KVM Guest via local mirror  


Saturday, March 14, 2020

Nested KVM performance evaluation on Ubuntu 20.04 (Focal Fossa)

Update as of 03/24/2020 00:15 a.m.
   Issue has been fixed. KVM Guest 
   is installing on Q9550 box
End Update

Setup KVM on Ubuntu 20.04

Performance appraisal has been done via attempt to set up Ubuntu 20.04 (L0) as KVM virtualization host installing Qemu && Libvirt per
https://computingforgeeks.com/install-kvm-hypervisor-on-ubuntu-focal-fossa/
L1-ManjaroGDM 19.02 Guest is starting up CentOS 8.1 Server domain at Level L2. L1 and L2 guests got their XML profiles updated with <cpu mode='host-passthrough'> in virsh console of parent domains. Following below is the set commands setting up KVM Hypervisor  on Ubuntu 20.04 (beta) on bare metal :-

$ sudo apt -y install qemu-kvm \
    libvirt-daemon bridge-utils \
    virtinst libvirt-daemon-system
$ sudo apt -y install virt-top libguestfs-tools \
   libosinfo-bin  qemu-system virt-manager

$ sudo modprobe vhost_net 
$ lsmod | grep vhost
vhost_net              24576  0
tun                    49152  1 vhost_net
vhost                  49152  1 vhost_net
tap                    28672  1 vhost_net
$ echo vhost_net | sudo tee -a /etc/modules
$ sudo shutdown -r now

Please, be aware that successful install KVM on Ubuntu 20.04 might require in meantime CPU's generation Haswell at least.
See https://bugs.launchpad.net/qemu/+bug/1866870
Bug is pending at Launchpad.net regarding issues with Penryn's (2007) based boxes.

**********************************************
Setup KVM on Mangaro Gnome 19.02 L1 Guest
**********************************************
$ sudo pacman -S qemu virt-manager virt-viewer \
   dnsmasq vde2 bridge-utils openbsd-netcat  
 $ sudo pacman -S ebtables iptables
 $ sudo systemctl enable libvirtd.service
 $ sudo systemctl start libvirtd.service

Tune /etc/libvirt/libvirtd.conf :   unix_sock_group = "libvirt" (line 85)  unix_sock_rw_perms = "0770" (line 102) When done restart libvirtd daemon. Changes been done will suppress  prompt for root password at Virt-Manager startup. They are, actually, optional.

 $ sudo usermod -a -G libvirt $(whoami)
 $ newgrp libvirt
 $ sudo systemctl restart libvirtd.service


Define network openstackvms.xml on the Manjaro Guest
# cat openstackvms.xml
<network>
   <name>openstackvms</name>
   <uuid>d0e9964a-f91a-40c0-b769-a609aee41bf2</uuid>
   <forward mode='nat'>
     <nat>
       <port start='1024' end='65535'/>
     </nat>
   </forward>
   <bridge name='virbr1' stp='on' delay='0' />
   <mac address='52:54:00:60:f8:6d'/>
   <ip address='192.169.142.1' netmask='255.255.255.0'>
     <dhcp>
  <range start='192.169.142.2' end='192.169.142.254' />
     </dhcp>
   </ip>
 </network>


This network would allow to launch VM on Manjaro Gnome 19.02 guest.
$ sudo virsh --connect qemu:///system net-define \  /home/boris/openstackvms.xml
$ sudo virsh --connect qemu:///system net-start openstackvms
$ sudo virsh --connect qemu:///system  \
net-autostart openstackvms