User virtual machines on VLAB servers: Difference between revisions

From techdocs
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
<p style="color: red;">'''Proposed''' user-defined virtual machine setup for VLAB servers. Not operational.</p>
<p style="color: red;">'''Proposed''' user-defined virtual machine setup for VLAB servers. Not operational.</p>


Implement and run a user-defined virtual machine (VM).
Implement and run user-defined virtual machines (VM).
 
== TL;DR ==
 
* VMs run as X86_64 Kernel Virtual Machines (KVM) under <code>qemu</code>.
* 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 <code>qcow2</code> format.
* <code>qemu-img</code> is used to create virtual hard disk files.
* <code>vmexecmkdir</code> is used to create a user subdirectory on a host.
* <code>vmexec</code> VMs on a host.


== CD/ISO files and virtual hard disk files location ==
== CD/ISO files and virtual hard disk files location ==
Line 10: Line 19:


on the host where the VMs will be run. If not, <code>vmexec</code> will give an error when trying to run the VM. Symlink-ing to locations outside of this directory will cause the same error.
on the host where the VMs will be run. If not, <code>vmexec</code> 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 ==
== Programs ==
Line 18: Line 29:
|-
|-
|qemu-img
|qemu-img
|Create a virtual hard disk (file).
|Create a virtual hard disk (file). Can use a pre-existing disk file, say from a class account, as a starting point.
|-
|-
|vmexecmkdir
|vmexecmkdir
|Create a directory for the user in <code>/usr/local/uservms</code>.
|Create a user subdirectory for VM disk images and ISO files.
|-
|-
|vmexec
|vmexec
Line 27: Line 38:
|}
|}


== <code>vmcreatedisk</code> ==
== <code>qemu-img</code> ==
 
See the <code>man</code> page, but...
 
qemu-img -f qcow2 &lt;disk_file_path&gt; 20G
 
Create an empty 20G QCOW2 disk.


Do we really need this? Can't users just run <code>qemu-img</code> instead?
qemu-img -f qcow2 -b &lt;base_file_path&gt; &lt;disk_file_path&gt;


Usage: vmcreatedisk [options] &lt;disk0&gt;
Creates a disk whose initial contents are based on the given base disk image (such as in a class account).
-h Display this help
-s Size of new virtual hard disk in megabytes. Conflicts with -b
-b Backing image for virtual hard disk. Conflicts with -s
&lt;disk0&gt; virtual hard disk path for new disk


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

Revision as of 10:15, 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.
  • 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

Create an empty 20G QCOW2 disk.

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).

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