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.

144 lines
4.7 KiB

6 years ago
# qvm
6 years ago
Trivial management of 64 bit virtual machines with qemu.
6 years ago
6 years ago
## What this script will do
6 years ago
It can handle:
6 years ago
- Virtual hard disk creation, backup and deletion.
- Basic network management: two ports are exposed to the host
machine (but you can add as many as you want). One of these
two ports is SSH (so admin gets simpler).
- Connection via SSH.
6 years ago
- Shared directory between host and guest.
- Last, but not least, running the virtual machine with a
combination of the previous options.
6 years ago
6 years ago
## Setup information and usage
- 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.
- Create a new VHD and complete the OS installation:
$ ./qvm -c
6 years ago
$ ./qvm -i
6 years ago
- Optionally enable the SSH daemon on the guest machine.
- Optionally create a new backup VHD:
$ ./qvm -b
6 years ago
- Now you can run the virtual machine either using the original or the backup
VHD. By deault if you run `./qvm` the virtual machine will run in graphics
mode using the backup hard disk.
- Optionally add the following in the gues machine's `/etc/fstab`, to enable
the shared directory automatically (no mount commands of any
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:
$ ./qvm -a
or, if you are working on another computer,
$ ./qvm --attach-remote
## 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.
For example, on the server side we could install the virtual machine remotely
like this:
$ ./qvm --install-vnc
And on the client side:
$ ./qvm -r
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
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:
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.
## Help
Usage: qvm [OPTION]
Trivial management of 64 bit virtual machines with qemu.
-a, --attach connect to SSH locally
--attach-remote connect to SSH remotely
-b, --backup backup vhd
-c, --create create new vhd
-d, --delete delete vhd backup
--delete-orig delete original vhd
-h, --help print this help
-i, --install install img on vhd
--install-vnc install img on vhd via vnc
-n, --run-nox run vm without opening a graphical window
(useful for background jobs like SSH)
--run-nox-orig run-orig and run-nox combined
-s, --mkdir-shared create shared directory
-r, --remote connect to a vnc instance via ssh
-x, --run run vm
--run-vnc run vm with vnc
--run-orig run from original vhd
--run-orig-vnc run from original vhd with vnc
Only a single option is accepted.
By default, the backup vhd is run.
Written in 2016 by Franco Masotti/frnmst <>
6 years ago
6 years ago
## License
6 years ago