User virtual machines on VLAB servers: Difference between revisions

From techdocs
Jump to navigation Jump to search
Line 50: Line 50:
  qemu-img -f qcow2 -b <base_file_path> <disk_file_path>
  qemu-img -f qcow2 -b <base_file_path> <disk_file_path>


creates a disk whose initial contents are based on the given base disk image (such as in a class account).
creates a disk whose initial contents are based on the given base disk image (such as in a class account). The size of the created disk will be that specified when the '''base file''' was created.


== <code>vmrun</code> ==
== <code>vmrun</code> ==

Revision as of 10:18, 8 Haziran 2023

Proposed user-defined virtual machine setup for VLAB servers. Not operational.

Implement and run user-defined virtual machines (VM).

TL;DR

  • VMs run as X86_64 Kernel Virtual Machines (KVM) under qemu.
  • Virtual hard disk files and and CD/ISO image files *must* be in user subdirectories somewhere under the directory listed below.
  • Virtual hard disk files must be in qcow2 format.
  • qemu-img is used to create virtual hard disk files.
  • vmexecmkdir is used to create a user subdirectory on a host if one doesn't already exist.
  • vmexec VMs on a host.

CD/ISO files and virtual hard disk files location

The CD/ISO files and virtual hard disk files used by the user-created virtual machines must actually be located somewhere under:

  • /usr/local/uservms

on the host where the VMs will be run. If not, vmexec will give an error when trying to run the VM. Symlink-ing to locations outside of this directory will cause the same error.

Typically, users will have their own subdirectories under this directory.

Programs

Program name Description
qemu-img Create a virtual hard disk (file). Can use a pre-existing disk file, say from a class account, as a starting point.
vmexecmkdir Create a user subdirectory for VM disk images and ISO files.
vmexec Run a virtual machines, booting either from a supplied CD/ISO image or from virtual hard disk.

qemu-img

See the man page, but...

qemu-img -f qcow2 <disk_file_path> 20G

will create an empty 20G QCOW2 disk.

And:

qemu-img -f qcow2 -b <base_file_path> <disk_file_path>

creates a disk whose initial contents are based on the given base disk image (such as in a class account). The size of the created disk will be that specified when the base file was created.

vmrun

Usage: vexec [options] [<disk0> [<disk1> ...]]

-h Display this help
-m RAM megabytes (128/2048 - default 1024)
-n virtual CPUs (1/2 - default 1)
-i CD/ISO file path
-I boot from CD/ISO instead of virtual hard disk

<diskn> virtual hard disk path

vmrun runs a user-defined virtual machine using qemu/KVM.

  • The machine will be configured for "user" networking, meaning it will be on its own private subnetwork. It will be able to connect externally using Network Address Translation (NAT) but will not be reachable itself from external hosts (including from the server the virtual machine is running on). The VM will see the network interfaces as an Intel E1000 card.
  • It will have a graphical console.
  • The [virtual] CPU will be Intel. There can be a maximum of TWO per VM.

Scribbles

Installing qemu-system-x86_64 package on nw-syd-armvx1:

Start-Date: 2023-06-01  14:04:59
Commandline: apt-get install qemu-system-x86
Install: qemu-system-x86:arm64 (1:5.2+dfsg-11+deb11u2), ovmf:arm64 (2020.11-2+deb11u1, automatic), libcapstone4:arm64 (4.0.2-3, automatic), libvdeplug2:arm64 (4.0.1-2, automatic), libbrlapi0.8:arm64 (6.3+dfsg-1+deb11u1, automatic), libexecs0:arm64 (1.3-1, automatic), libspice-server1:arm64 (0.14.3-2.1, automatic), ipxe-qemu:arm64 (1.0.0+git-20190125.36a4c85-5.1, automatic), libusbredirparser1:arm64 (0.8.0-1+b1, automatic), seabios:arm64 (1.14.0-2, automatic), libcacard0:arm64 (1:2.8.0-3, automatic), qemu-system-common:arm64 (1:5.2+dfsg-11+deb11u2, automatic), libvirglrenderer1:arm64 (0.8.2-5+deb11u1, automatic), qemu-system-data:arm64 (1:5.2+dfsg-11+deb11u2, automatic), qemu-system-gui:arm64 (1:5.2+dfsg-11+deb11u2, automatic)
End-Date: 2023-06-01  14:05:04