aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xkvmx16
-rwxr-xr-xkvmx-create14
-rw-r--r--kvmxfile4
3 files changed, 25 insertions, 9 deletions
diff --git a/kvmx b/kvmx
index ccf39ad..38ddfba 100755
--- a/kvmx
+++ b/kvmx
@@ -35,10 +35,14 @@ function kvmx_up {
exit 1
fi
- if [ "$shared_folder" ]; then
+ if [ ! -z "$shared_folder" ]; then
local shared="-fsdev local,id=shared,path=$shared_folder,security_model=none -device virtio-9p-pci,fsdev=shared,mount_tag=shared"
fi
+ if [ ! -z "$port_mapping" ]; then
+ local hostfwd=",$port_mapping"
+ fi
+
# Check if image exists, create otherwise
if [ ! -e "$image" ]; then
if [ ! -z "$basebox" ]; then
@@ -66,7 +70,7 @@ function kvmx_up {
-chardev spicevmc,id=spicechannel0,name=vdagent \
-smp 2 -soundhw ac97 -cpu host -balloon virtio \
-net nic,model=virtio \
- -net user,hostfwd=tcp:127.0.0.1:$SSH-:22 &> $LOGFILE &
+ -net user,hostfwd=tcp:127.0.0.1:$SSH-:22$hostfwd &> $LOGFILE &
PID="$!"
@@ -138,7 +142,14 @@ function kvmx_resume {
# Poweroff the guest
function kvmx_poweroff {
+ if ! kvmx_running; then
+ echo "$BASENAME: guest $VM is not running"
+ exit 1
+ fi
+
echo /usr/bin/sudo poweroff | kvmx_ssh &> /dev/null
+ sleep 3
+ kvmx_status
}
# Rsync files to the guest
@@ -318,6 +329,7 @@ function kvmx_destroy {
rm -f $PIDFILE
rm -f $SSHFILE
rm -f $PORTFILE
+ rm -f $LOGFILE
echo "$BASENAME: please inspect and remove `dirname $image` manually."
}
diff --git a/kvmx-create b/kvmx-create
index b460705..f2709f6 100755
--- a/kvmx-create
+++ b/kvmx-create
@@ -185,7 +185,6 @@ function kvmx_create_custom {
kvmx_sudo_run mount none -t proc $WORK/proc
kvmx_sudo_run mount none -t sysfs $WORK/sys
kvmx_sudo_run mount -o bind /dev/ $WORK/dev
- echo LANG=C | $SUDO tee $WORK/etc/default/locale > /dev/null
# Hostname configuration.
echo $hostname.$domain | $SUDO tee $WORK/etc/hostname > /dev/null
@@ -201,6 +200,12 @@ function kvmx_create_custom {
# Fstab
echo "/dev/vda2 / ext4 errors=remount-ro 0 1" | $SUDO tee $WORK/etc/fstab > /dev/null
+ # Locale
+ $APT_INSTALL locales
+ echo "LANG=$LANG" | $SUDO tee $WORK/etc/default/locale > /dev/null
+ echo "$LANG UTF-8" | $SUDO tee -a $WORK/etc/locale.gen > /dev/null
+ kvmx_sudo_run chroot $WORK/ locale-gen
+
# Initial upgrade
echo "Applying initial upgrades..."
kvmx_sudo_run chroot $WORK/ apt-get update
@@ -213,7 +218,6 @@ function kvmx_create_custom {
fi
# Basic packages
- $APT_INSTALL locales
$APT_INSTALL screen cron lsb-release openssl -y
$APT_INSTALL spice-vdagent qemu-guest-agent
@@ -249,9 +253,9 @@ function kvmx_create_custom {
/usr/sbin/service spice-vdagent start
# Ensure file sharing between host and guest
-if [ ! -z "$shared_mountpoint" ]; then
- /bin/mkdir -p $shared_mountpoint
- /bin/mount -t 9p -o trans=virtio shared $shared_mountpoint -oversion=9p2000.L,posixacl,cache=loose
+if [ ! -z "$shared_folder_mountpoint" ]; then
+ /bin/mkdir -p $shared_folder_mountpoint
+ /bin/mount -t 9p -o trans=virtio shared $shared_folder_mountpoint -oversion=9p2000.L,posixacl,cache=loose
fi
exit 0
diff --git a/kvmxfile b/kvmxfile
index f3b0498..32d2600 100644
--- a/kvmxfile
+++ b/kvmxfile
@@ -16,8 +16,8 @@ shared_folder_mountpoint="/media/shared"
# boots.
run_spice_client="1"
-# Set host_port-:guest_port mapping pairs.
-#port_mapping="8080-:80,8443-:443"
+# Set additional hostfwd mappings
+#port_mapping="hostfwd=tcp:127.0.0.1:8080-:80,hostfwd=tcp:127.0.0.1:8443-:443"
# Where the guest image is stored
image="$HOME/.local/share/kvmx/$VM/box.img"