frnmst-archives
/
qvm
Archived
1
0
Fork 0
Browse Source

Added VNC options.

dev
frnmst/Franco Masotti 5 years ago
parent
commit
8e63a1e88c
  1. 24
      README.md
  2. 5
      configvmrc
  3. 42
      qvm

24
README.md

@ -31,6 +31,9 @@ It can handle:
- Basic software like `ls`, `cat`, etc...
- [QEMU](https://www.qemu.org/)
- The machine emulator
- [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:
@ -53,6 +56,23 @@ It can handle:
host_share /home/vm/shared 9p noauto,x-systemd.automount,trans=virtio,version=9p2000.L 0 0
## VNC options
The VNC options in this script allow you to connect
To do this you must run QVM with one of the VNC option on the server side.
On the client side you simply edit the `host_ip_address` and `host_username`
variables 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
## Help
@ -67,12 +87,16 @@ It can handle:
--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.

5
configvmrc

@ -30,3 +30,8 @@ ssh_guest_username="vm"
shared_data_path="/home/parabola/dev/unife/qvm/shared_host_guest"
mount_tag="host_share"
# VNC stuff
host_ip_address="192.168.1.1"
host_username="parabola"

42
qvm

@ -26,12 +26,16 @@ Options:
--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.
@ -82,8 +86,16 @@ delete()
installs()
{
local argc1="$1"
local enable_vnc=""
if [ "$argc1" = "vnc" ]; then
enable_vnc="-monitor pty -vnc 127.0.0.1:0"
fi
qemu-system-x86_64 -m "$vm_memory" \
-enable-kvm \
$enable_vnc \
-cdrom "$img_name" \
-boot order=d \
"$vhd_name" &
@ -100,6 +112,16 @@ run()
local argc2="$2"
local vhd=""
local display=""
local enable_vnc=""
if [ "$argc1" = "none" ]; then
display="none"
elif [ "$argc1" = "gtk" ]; then
display="gtk"
elif [ "$argc1" = "vnc" ]; then
display="none"
enable_vnc="-monitor pty -vnc 127.0.0.1:0"
fi
if [ "$argc2" = "orig" ]; then
vhd="$vhd_name"
@ -107,18 +129,13 @@ run()
vhd=""$vhd_name".mod"
fi
if [ "$argc1" = "none" ]; then
display="none"
else
display="gtk"
fi
export QEMU_AUDIO_DRV=alsa
if [ -f "$vhd" ]; then
qemu-system-x86_64 \
-m "$vm_memory" \
-enable-kvm \
$enable_vnc \
-device e1000,netdev=user.0 \
-netdev user,\
id=user.0,hostfwd=tcp::"$host_port"-:"$guest_port",\
@ -134,12 +151,18 @@ security_model=none,mount_tag="$mount_tag" \
fi
}
remote()
{
ssh -N -f -L 5901:127.0.0.1:5900 "$host_username"@"$host_ip_address"
vncviewer 127.0.0.1:1
}
main()
{
local argc="$1"
local options="abcdhinrx"
local long_options="attach,backup,create,delete,delete-orig\
,help,install,run,run-orig,run-nox,run-nox-orig"
,help,install,run,run-orig,run-nox,run-nox-orig,run-vnc,run-orig-vnc,remote,install-vnc"
local opts
local opt
@ -164,11 +187,16 @@ main()
--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
}