This commit is contained in:
Franco Masotti 2018-12-28 19:35:40 +01:00
parent e63d0ba607
commit d9e13628be
3 changed files with 35 additions and 41 deletions

View File

@ -6,21 +6,6 @@ Trivial management of 64 bit virtual machines with qemu.
[](TOC)
- [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)
- [qvm.sh](#qvmsh)
- [automatical_remote_startup.sh](#automatical_remote_startupsh)
- [License](#license)
[](TOC)
## What this script will do
It can handle:
@ -73,6 +58,8 @@ It can handle:
host_share /home/vm/shared 9p noauto,x-systemd.automount,trans=virtio,version=9p2000.L 0 0
## Connection to the machine
- You can also access the virtual machine through SSH:
$ ./qvm --attach
@ -105,27 +92,7 @@ At this point you should see your virtual machine running in a TigerVNC window.
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
[GlusterFS](http://docs.gluster.org/en/latest/),
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:
VHD_NAME="gluster+tcp://server-address/gluster-volume/"${IMG_NAME}"."${VHD_TYPE}""
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.
### Automatic remote startup
## Automatic remote startup
# FIXME
@ -145,6 +112,26 @@ your shell configuration file (e.g: `~/.bashrc`), something like:
alias vm='/home/user/scripts/qvm/automatic_remote_startup.sh'
## Interesting applications
### Virtual machine hard disk over a network protocol
If you happen to use a form of network filesystem, such as
[GlusterFS](http://docs.gluster.org/en/latest/),
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:
VHD_NAME="gluster+tcp://server-address/gluster-volume/"${IMG_NAME}"."${VHD_TYPE}""
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
### qvm

View File

@ -66,16 +66,21 @@ SSH_GUEST_USERNAME='vm'
# Shared directory.
#
# The path that holds the shared files in the guest machine.
SHARED_DATA_PATH='/home/user/qvm/shared_host_guest'
# See the relevant readme section.
MOUNT_TAG='host_share'
#
# VNC stuff and automatic remote startup stuff
#
# The ip address of the host machine. Useful for the attach action
# or for starting up the vm from a different computer.
HOST_IP_ADDRESS='192.168.1.1'
# See the previous comment.
HOST_USERNAME='parabola'
#
@ -83,6 +88,7 @@ HOST_USERNAME='parabola'
#
# The port used to connecting directly to the host computer.
# This may differ from SSH_HOST_PORT.
SSH_EXPOSED_PORT=22
# The directory where the qvm script lies.

11
fbopt
View File

@ -16,8 +16,6 @@
# See also https://frnmst.gitlab.io/notes/my-bash-option-parsing-template.html
#
set -x
show_help()
{
cat <<-EOF
@ -36,7 +34,7 @@ Options:
-i, --install install img on vhd
-n, --nox run vm without opening a graphical window
which is useful for background jobs like SSH
-o, --orig run from original vhd
-o, --orig run from the original vhd
-s, --mkdir-shared create shared directory
-r, --remote connect to a vnc instance via ssh
-x, --run run vm
@ -78,9 +76,9 @@ main()
declare -a argc=("${!1}")
# Set the options.
local getopt_short_options='abcdhimnrvx'
local getopt_short_options='abcdhimnorvx'
local getopt_long_options='attach,backup,create,delete,help,install,run,\
remote,vnc,mkdir-shared,nox'
remote,vnc,mkdir-shared,nox,print-flags'
# Set the default values for the flags.
local attach='false'
@ -131,6 +129,8 @@ remote,vnc,mkdir-shared,nox'
-o | --origin ) origin='origin' ;;
--print-flags ) print_flags='true' ;;
-r | --remote ) remote='remote' ;;
-v | --vnc ) vnc='vnc' ;;
@ -176,6 +176,7 @@ remote,vnc,mkdir-shared,nox'
local place=''
local display=''
check_dependencies || exit ${?}
if [ "${attach}" = 'true' ]; then
[ "${remote}" = 'true' ] && place='remote' || place='local'
[ "${vnc}" = 'true' ] && display='vnc' || display=''