SlackVirt QEMU host system Contents 1. introduction 2. install 3. setup 4. network 5. management 6. x11 --------------------------- 1. Introduction --------------------------- SlackVirt is a cloud pocket system intended to be simple, versatile and efficient. It's mented to provided a virtualization solution for Slackware hosts with minimal system modifications. The pocket idea came from the ability of create initram disks for mantaining different setups. That can fits into portable storage devices. Therefore, a unique host machine can be booted with different initram disks with custom configuration that can bring virtual machines from external storage devices. SlackVirt isn't a real emulator or a virtualization solution, but a virtualization platform for maintain a Slackware based virtual machine host. Which includes compatible tools to its aimed Linux distribution that can handle typical administrative operations on a set of virtualized machines that can be connected through an ethernet virtualized network. SlackVirt do not maintain a strict package dependency list, but according to some premises it was decided which Slackware package series shall be installed as following: - Required: a, ap, l, tcl - Recommended: f, n, x, xap - Optional: e, d, k, kde, kdei, xfce, y NOTE: package series "d, k" is required if you want to build SlackVirt packages, such as: qemu and spice-gtk or compiling other softwares. The "x, xap" series are recomended if you want to use and access the desktop instance localy. Nonetheless SlackVirt installer tool will ask to install the required packages from one of the slackpkg templates: small or full. Therefore slackpkg is required for the installation procedure. The templates are made as following: - small, will include the basic requirements for running SlackVirt instances, without X server. - full, this installs all the packages from small plus the required packages for running X server. SlackVirt includes two qemu packages, such as: qemu-server and qemu-desktop. They are compiled different according to the premises of each machine type, been a server and a desktop machine, disabling functions of the generated binary files allowing them to be independent of some host libraries. They mainly diffences are the following: - qemu-server, no spice, no audio backend and without usb redirection. - qemu-desktop, support for spice, compiled audio backends and support for usb redirection. Let's suppose that a video card has to be changed in a desktop from our "computer park", there is no need to shutdown the server in the datacenter. Therefore making easy for maintaining the slackvirt host machine and running virtual instances. There are a few sniplets that are compatible to libvirt at least those that are related to SlackVirt structure and operating mode. SlackVirt also includes an usrlocal "disk" for the server and the desktop instances. That can be used to creates img files that can be attached to the VMs. The set of scripts helps to easily deploy/configure the instances according: - server: dhcpd daemons, manipulate LXCs - desktop: vncserver daemon for different users. --------------------------- 2. Install --------------------------- SlackVirt version 14.2 requires a Slackware host system running the same architecture and version, for example: - SlackVirt 14.2 shall be installed at a Slackware 14.2 (32-bit) - SlackVirt64 14.2 shall be installed at a Slackware64 14.2 (64-bit) The system requirements for installing SlackVirt will depends of the final use of each virtual machine. Nonetheless let's present some recommended hardware configuration: - RAM: 2GB - Disk storage: 30GB If wanted, the storage can be splited as following - 14GB ( for SlackVirt server rootfs ) - 16GB ( using 8GB to each instance default instance ) Slackvirt package series are divided as following: - a The basic SlackVirt system packages, contains SlackVirt core. - ap Aditional application that do not require X Window System. - d Development packages. - l System libraries. - n Network tools. - qemu The QEMU program and related tools. - x X11 basic enviroment tools. - xap X11 applications. SlackVirt custom packages are installed at /usr/local and the other SBo packages from slackbuils.org are installed at / host rootfs. There is two install methods of SlackVirt custom packages, volatile and static. The installation setup will prompt which one to use. The static one is straighforward, will setup the system at /usr/local in the same rootfs of Slackware host. The volatile one requires aditional preparations, will create a custom initrd image including a temporary /usr/local. NOTE: Any modification made to the slackvirt system files requires to rebuilding the initrd. To recreate the initrd image use: /usr/local/sbin/create-initrd-slackvirt.sh # installing slackvirt root@darkstar:/mnt/cdrom# ./installer/slackvirt-install # using custom kernel KVERSION=4.14.166 ./installer/slackvirt-install General system modifications for all SlackVirt installation types: Include at /etc/rc.d/rc.local, the following: # if [ -x /usr/local/etc/rc.d/rc.S.slackvirt ]; then # /usr/local/etc/rc.d/rc.S.slackvirt # fi Or if you want to strict the startup time of SlackVirt and keep logging the initialization procedure, use this: # CDATE=$(date +%d%H%Y-%H%M) # TIMEOUT=300 # if [ -x /usr/local/etc/rc.d/rc.S.slackvirt ]; then # timeout $TIMEOUT /usr/local/etc/rc.d/rc.S.slackvirt > \ # /var/log/boot-slackvirt$CDATE.log # fi Configure the shutdown script as following: # if [ -x /usr/local/etc/rc.d/rc.6.slackvirt ]; then # /usr/local/etc/rc.d/rc.6.slackvirt | tee /var/log/shutdown-slackvirt.log # fi Finally make them executable: # chmod 754 /usr/local/etc/rc.d/rc.S.slackvirt # chmod 754 /usr/local/etc/rc.d/rc.6.slackvirt --------------------------- 3. Setup --------------------------- By default SlackVirt has configured two default computer instances, a server and a desktop. Let's presume here that SlackVirt intents to follow the Slackware way/development/educational philosofy. Defining that SlackVirt, it's just a virtualization host and will be referenced here as a machine too, the other two computers cited will be the "server" and the "desktop", having in mind that they are virtual machines. Therefore the machines, are delivered according to some premises, which are: - The server, a displayless computer machine, of a data center. - The desktop, a visual enhanced computer machine, at home. By default both machines, have serial connections that can be used at the bootup procedure or/and as normal consoles. However the desktop presents two graphic cards for enhanced visual experiences, that are not intended to be done at server machines which used to lacks graphic hardware support. Slackvirt takes that idea for defining its default machines. The full characteristcs of the machines can be found at the flat files that holds it's configurations, which are saved at: /usr/local/etc/slackvirt. The configuration files just defines the virtual machine hardware and do not include a bootable disk with a Slackware installation on it. Thereby, it's required that users creates the disks and perform the system installation. Let's see some notes about a pratical system configuration. The default server SM is configured as following: - CPU = Broadwell-IBRS - RAM = 1G - VIDEO = none - DISK = 7 disks (3 IDE and 4 SATA) - NETWORK = three interfaces - USB = USB 2.0 (internal only) - AUDIO = none The default desktop SM, is configured as following: - CPU = Broadwell-IBRS - RAM = 1G - VIDEO = vmware - DISK = 4 disks (3 IDE and 2 SATA) - NETWORK = three interfaces - USB = USB 3.0 (with host bind) - AUDIO = Intel HD Audio Creating a qcow2 image: # qemu-img create -f qcow2 /mnt/hd/slackware/14.2/slackware-14.2.img 15G Then partitioning the disk with one partition # fdisk /mnt/hd/slackware/14.2/slackware-14.2.img (n, enter, enter, enter, enter, w) Creating the file system # losetup -P loop0 /mnt/hd/slackware/14.2/slackware-14.2.img # mkfs.ext4 /dev/loop0p1 SlackVirt includes an automated installation procedure to make easy Slackware system installations. The method can be used, as following: Automated Slackware install: # PKG_SERIES="A#AP#D#L#N#" \ # DISK0=/var/lib/slackvirt/slackware/14.2/slackware-14.2.img \ # slackware-qemu-vmserver.sh install \ # /usr/local/etc/slackvirt/machines/slackware/slackware-14.2/slackware.qemu The above lines will execute the installation of packages: A,AP,D,L,N. User permissions, users shall been in the - group console for sending signals to the console.sockets. - netgroup for controlling host wifi --------------------------- 4. network --------------------------- SlackVirt default SMs comes with three network IF cards configured attached to the host bridges: qemubr0, qemubr1 and qemubr2. slackvirt - network - ascii +--------+----------+----+----------+---------+ | | | | | | | | wlan0-sta| | wlan0-ap | | | +----------+ +----------+ | | | | | | | | | | slackvirt | | host | | | | | | | | +----------+ +----------+ +----------+ | | | | | | | | | | | qemubr0 | | qemubr1 | | qemubr2 | | +--+----------+---+----------+---+----------+-+ 4.1 - configuration The host system can be manually configured over: /usr/local/etc/rc.d/rc.inet1.conf To configure network address of slackvirt host, server and desktop SMs, use the tool: netconfig.slackvirt can be used for generating the configuration files. By default the tool will just prompt for the host setup. However, the enviroment variable MACHINES is used to define extra configuration options for the SMs, either "server", "desktop" or "server desktop". This will generate the according inet1\_\{server|desktop\}.conf for the SMs, that can be uploaded manualy or using the tool update-slackvirt-machines.sh located at /usr/local/libexec, which requires a logged-in console. 4.2 - wireless If host wireless adapter supports virtual radio interfaces it can be used to create two wireless IFs, one as an access point (AP) and other as station. For configuring wireless network, the setup tool can be used: /usr/local/var/log/setup/setup.70.local-wireless It will prompt to choose one of the detected wireless network IF for been configured. NOTE: for using wireless in AP mode it's required to install hostapd from extra packages. 4.3 - iptables There are some examples of iptables rules included that will be installed at: /usr/local/etc/iptables They can be enabled and loaded at the system startup from rc.iptables The default rules allows to redirect http and ftp traffic to the server and allows nat from the wlan ap interface. --------------------------- 5. Management --------------------------- slackware-qemu-vmserver.sh command [vmfile.qemu] Commands: - list: list running VMs - install "vmfile.qemu" automated slackware installation - start "vmfile.qemu" starts a SM - stop "vmfile.qemu" stops a SM - Send a ACPI powerdown signal, then waits specific timeout variable then send a SIGKILL to QEMU process. - powerdown "vmfile.qemu" send ACPI powerdown signal - wakeup "vmfile.qemu" send ACPI wakeup signal - resume "vmfile.qemu" QEMU resume command - pause "vmfile.qemu" QEMU pause command - save: - load: - configure "vmfile.qemu" configure VM parameters - status "vmfile.qemu" check VM status slackvirt-mon.sh first window system process second window storage third window network server desktop --------------------------- 6. x11 --------------------------- SlackVirt comes with support for x11, including customized XDM sessions and tools for managing and controlling the host system and the SMs. 6.1 - xdm There is two XDM sessions, configured as following: - The first one is intended to be used for monitoring the host resources and do not start any window manager. By default will starts two windows connected to the SM (server/desktop) serial lines. - The second one is intended to be used for accessing the SMs, including support for backbox and fluxbox window managers. This one do not allow root login. The second xdm session has built-in customizations, some of them are the following: - blackbox (ctrl+return), slackvirt menu entry, bbkeys started at background. - fluxbox (return), slackvirt menu entry, autostart xnotemon and two monitoring tools (xterms scripted, for qemu-ls and ping SMs). - fluxbox (shift+return), slackvirt menu entry, autostart xnotemon and two monitoring tools (xterms scripted, for qemu-ls and ping SMs) and disabled a few shortcuts for a enhanced user experience using a windowed VNC connection. To see the detailed customizations of each session consults the configuration files at: /usr/local/etc/X11/xdm and /usr/local/share/{blackbox,fluxbox} 6.2 - xaps There are some custom applications that can be used at X11 for monitoring the slackvirt qemu machine status, network and the host system. - xnotemon, monitor for brightness and power state. - xbacklight-ctrl.sh, host backlight control. - xaudio-ctrl.sh, host volume control. - xslackvirt-powerpanel.sh, a window power panel for SMs. - xwireless-ctrl.sh, enable disable host wireless IFs. - gkrellms-split.sh, three configurable gkrellms instances --- Slack well. - William PC