QEMU

Contents

QEMU#

Client#

Use declarative configuration to connect to a server running QEMU

  1. install these packages

    apt-get install tigervnc-viewer openssh-client
    
  2. create the jobs directories. See reference

    mkdir -p /home/jobs/scripts/by-user/myuser
    
  3. follow the instructions from the QEMU server section

  4. create the qvm script in /home/jobs/scripts/by-user/myuser/qvm.py

  5. create the configuration file

    /home/jobs/scripts/by-user/myuser/qvm.yaml#
     1#
     2# qvm.yaml
     3#
     4# Copyright (C) 2021 Franco Masotti (franco \D\o\T masotti {-A-T-} tutanota \D\o\T com)
     5#
     6# This program is free software: you can redistribute it and/or modify
     7# it under the terms of the GNU General Public License as published by
     8# the Free Software Foundation, either version 3 of the License, or
     9# (at your option) any later version.
    10#
    11# This program is distributed in the hope that it will be useful,
    12# but WITHOUT ANY WARRANTY; without even the implied warranty of
    13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14# GNU General Public License for more details.
    15#
    16# You should have received a copy of the GNU General Public License
    17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18#
    19#
    20# Original license header:
    21#
    22# qvm - Trivial management of 64 bit virtual machines with qemu.
    23#
    24# Written in 2016 by Franco Masotti/frnmst (franco \D\o\T masotti {-A-T-} student \D\o\T unife \D\o\T it)
    25#
    26# To the extent possible under law, the author(s) have dedicated all
    27# copyright and related and neighboring rights to this software to the public
    28# domain worldwide. This software is distributed without any warranty.
    29#
    30# You should have received a copy of the CC0 Public Domain Dedication along
    31# with this software. If not, see
    32# <http://creativecommons.org/publicdomain/zero/1.0/>.
    33
    34
    35# Note all vnc ports must start from 5900.
    36remote:
    37    test:
    38        enabled: true
    39
    40        executables:
    41            qemu: '/usr/bin/qemu-system-x86_64'
    42            ssh: '/usr/bin/ssh'
    43
    44        system:
    45
    46            users:
    47                host: 'admin'
    48                guest:  'vm'
    49
    50            # enable VNC otherwise use SSH.
    51            display:
    52                enabled: true
    53
    54            network:
    55                addresses:
    56                    host: '192.168.0.1'
    57
    58                ports:
    59                    guest:
    60                        ssh: '2222'
    61                    host:
    62                        ssh: '22'
    63                        vnc: '5900'
    64                    local:
    65                        vnc: '5901'
    
  6. fix the permissions

    chown -R myuser:myuser /home/jobs/scripts/by-user/myuser
    chmod 700 -R /home/jobs/scripts/by-user/myuser
    
  7. go back to the desktop user

    exit
    
  8. connect to the server via SSH or VNC (see remote.test.system.display.enabled option)

    pushd /home/jobs/scripts/by-user/myuser
    ./qvm.py ./qvm.yaml remote test
    

    Note

    You can also create a shell alias such as this (works for GNU Bash)

    alias test='/home/jobs/scripts/by-user/myuser/qvm.py /home/jobs/scripts/by-user/myuser/qvm.yaml remote test'