frnmst-archives
/
qvm
Archived
1
0
Fork 0
Franco Masotti 4 years ago
parent
commit
52ee771822
  1. 33
      README.md
  2. 78
      qvm

33
README.md

@ -2,7 +2,7 @@
Trivial management of 64 bit virtual machines with qemu.
# Table of contents
## Table of contents
[](TOC)
@ -21,7 +21,7 @@ Trivial management of 64 bit virtual machines with qemu.
[](TOC)
# What this script will do
## What this script will do
It can handle:
@ -34,15 +34,13 @@ It can handle:
- Last, but not least, running the virtual machine with a
combination of the previous options.
# Setup information and usage
## Setup information and usage
- You need a 64 bit machine with virtualization technology and more than 4 GB
of RAM.
- Modify `configvmrc` based on your needs.
Variables are self-explanatory and I have kept mine
as an example.
- Install the following dependencies
- [GNU Bash](http://www.gnu.org/software/bash/bash.html)
- Scipting language interpreter
@ -53,25 +51,22 @@ It can handle:
- [TigerVNC](http://www.tigervnc.org)
- 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
$ ./qvm -i
- Optionally enable the SSH daemon on the guest machine.
- Optionally create a new backup VHD:
$ ./qvm -b
- 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
VHD. If you run `./qvm -x` 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
sort).
- 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.
host_share /home/vm/shared 9p noauto,x-systemd.automount,trans=virtio,version=9p2000.L 0 0
@ -83,7 +78,7 @@ It can handle:
$ ./qvm --attach-remote
# VNC options
## VNC options
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
@ -127,7 +122,7 @@ 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.
## Automatic remote startup
### Automatic remote startup
To automatically start the virtual machine from a non-host computer you can
use the `automatic_remote_startup.sh` script. Make sure that both the local
@ -145,9 +140,9 @@ your shell configuration file (e.g: `~/.bashrc`), something like:
alias vm='/home/user/scripts/qvm/automatic_remote_startup.sh'
# Help
## Help
## qvm.sh
### qvm
Usage: qvm [OPTION]
Trivial management of 64 bit virtual machines with qemu.
@ -179,9 +174,9 @@ your shell configuration file (e.g: `~/.bashrc`), something like:
CC0
Written in 2016 by Franco Masotti/frnmst <franco.masotti@student.unife.it>
## automatical_remote_startup.sh
### automatic_remote_startup.sh
Usage: automatical_remote_startup.sh [OPTION]
Usage: automatic_remote_startup.sh [OPTION]
Start QEMU on a remote host computer and connect to it
Options:
@ -200,6 +195,6 @@ your shell configuration file (e.g: `~/.bashrc`), something like:
CC0
Written in 2018 by Franco Masotti/frnmst <franco.masotti@student.unife.it>
# License
## License
Creative Commons Zero (CC0).

78
qvm

@ -12,44 +12,6 @@
# with this software. If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.
program_name="${0}"
local_path="${program_name%/qvm}"
help()
{
cat <<-EOF
Usage: qvm [OPTION]
Trivial management of 64 bit virtual machines with qemu.
Options:
-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
which is 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.
CC0 License
Written in 2016 by Franco Masotti/frnmst <franco.masotti@student.unife.it>
EOF
}
check_dependencies()
{
which \
@ -148,39 +110,7 @@ remote()
vncviewer 127.0.0.1:1
}
main()
{
local options="abcdhinrx"
local long_options="attach,backup,create,delete,delete-orig,\
help,install,run,run-orig,run-nox,run-nox-orig,run-vnc,run-orig-vnc,remote,install-vnc,\
attach-remote"
[ -z "$argc" ] && argc='-x'
# Source variables globally.
. "${local_path}"/configvmrc
for opt in $opts; do
case "$opt" in
-- ) ;;
-a | --attach ) attach locally ;;
--attach-remote ) attach remotely ;;
-b | --backup ) backup ;;
-c | --create ) create ;;
-d | --delete ) delete ;;
--delete-orig ) delete orig ;;
-h | --help ) help ;;
-i | --install ) installs ;;
--install-vnc ) installs vnc ;;
-n | --run-nox ) run none ;;
--run-nox-orig ) run none orig ;;
-r | --remote ) remote ;;
-s | --mkdir-shared ) shared ;;
-x | --run ) run gtk ;;
--run-orig ) run gtk orig ;;
--run-vnc ) run vnc ;;
--run-orig-vnc ) run vnc orig ;;
esac
done
}
program_name="${0}"
local_path="${program_name%/qvm}"
. "${local_path}"/fbopt