Fork 0
Trivial management of 64 bit virtual machines with qemu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

161 lines
5.1 KiB

6 years ago
# qvm
6 years ago
Trivial management of 64 bit virtual machines with qemu.
6 years ago
4 years ago
## Table of contents
- [qvm](#qvm)
- [Table of contents](#table-of-contents)
- [What this script will do](#what-this-script-will-do)
- [Setup information and usage](#setup-information-and-usage)
- [VNC options](#vnc-options)
- [Interesting applications](#interesting-applications)
- [Virtual machine hard disk over a network protocol](#virtual-machine-hard-disk-over-a-network-protocol)
- [Automatical remote startup](#automatical-remote-startup)
- [Help](#help)
5 years ago
- [](#qvmsh)
- [](#automatical_remote_startupsh)
- [License](#license)
4 years ago
## What this script will do
6 years ago
It can handle:
6 years ago
- Virtual hard disk creation, backup and deletion.
4 years ago
- Basic network management: three ports are exposed to the host
machine (but you can add as many as you want). One of these two ports is
6 years ago
- Shared directory between host and guest.
4 years ago
- Running the virtual machine with a combination of the previous options.
6 years ago
4 years ago
## Setup information and usage
4 years ago
### Prerequisites
- You need a 64 bit machine with virtualization technology and more than 4 GB
of RAM.
6 years ago
- Modify `configvmrc` based on your needs.
Variables are self-explanatory and I have kept mine
as an example.
5 years ago
- Install the following dependencies
- [GNU Bash](
- Scipting language interpreter
- [GNU Core Utilities](
- Basic software like `ls`, `cat`, etc...
- [QEMU](
- The machine emulator
- [TigerVNC](
- If you need to use the vm remotely from a coumputer which does not
support virtualization.
4 years ago
### Setup
- Create a new virtual hard disk and complete the OS installation which
can also be done via SSH.
4 years ago
$ ./qvm --create && ./qvm --install
6 years ago
- Optionally enable the SSH daemon on the guest machine.
- Optionally create a new backup VHD:
4 years ago
$ ./qvm --backup
6 years ago
- Now you can run the virtual machine either using the original or the backup
4 years ago
virtual hard disk. If you run `./qvm -x` the virtual machine will run in
graphics mode using the backup hard disk.
4 years ago
- Optionally add the following in the guest machine fstab file (`/etc/fstab`),
to enable the shared directory automatically. This avoids entering mount
commands by hand.
4 years ago
host_share /home/vm/shared 9p noauto,x-systemd.automount,trans=virtio,version=9p2000.L 0 0
- You can also access the virtual machine through SSH:
4 years ago
$ ./qvm --attach
or, if you are working on another computer,
4 years ago
$ ./qvm --attach --remote
4 years ago
## VNC options
5 years ago
The VNC options in this script allow you to connect to a remote instance of
QEMU. This is particularly useful, for example, if your local machine
processor does not support virtualization. The only thing to do is to make
the server's port (`5900`) reachable from the clients.
5 years ago
You must then run QVM with one of the VNC options on the server side.
On the client side you must simply edit the `host_ip_address` and
`host_username` variables in the configuration file.
4 years ago
For example, on the server side you could install the virtual machine remotely
like this:
4 years ago
$ ./qvm --install --vnc
And on the client side:
4 years ago
$ ./qvm --attach --remote --vnc
5 years ago
At this point you should see your virtual machine running in a TigerVNC window.
5 years ago
Note: the VNC traffic goes through SSH TCP forwarding, so it is encrypted.
# Interesting applications
## Virtual machine hard disk over a network protocol
If you happen to use a form of network filesystem, such as
you can keep the machine hard disk off the host and put it on another computer.
There might be a some form of lag depending on the hardware, protocol and
network connections.
An example with GlusterFS might be:
4 years ago
This will work provided that you install the QEMU GlusterFS block module
package (if it's not already present in the QEMU package itself).
You should consult the QEMU's manual to learn about all possible compatible
network filesystems.
4 years ago
### Automatic remote startup
To automatically start the virtual machine from a non-host computer you can
use the `` script. Make sure that both the local
non-host and the remote host computer have a copy of the QVM repository with
the variables correctly set in the `configrc` file.
This script will start the virtual machine if on the host computer no other
virtual machine is running. You can use either the VNC or the headless
connection. Both of them require that SSH is configured correctly on the
computers: the host must be reachable from the client via SSH.
This can be verified by using the `--attach-remote` option.
Once you have checked that everyting works, you can add a command alias in
your shell configuration file (e.g: `~/.bashrc`), something like:
alias vm='/home/user/scripts/qvm/'
4 years ago
## Help
4 years ago
### qvm
4 years ago
6 years ago
4 years ago
4 years ago
4 years ago
## License
Creative Commons Zero (CC0).