Skip to content
Snippets Groups Projects
Commit 7bb33bf3 authored by Florent Gluck's avatar Florent Gluck
Browse files

Removed update_disk script as vm_run is more generic and can be used for the same purpose.

Added guest agent settings to vm_run and template_creator
parent 8bcf7ef4
Branches
No related tags found
No related merge requests found
......@@ -89,7 +89,6 @@ create_files:
@cp -n src/nexus-server $(BASEDIR)/bin
@cp -n tools/genpwd/src/genpwd $(BASEDIR)/bin
@cp -n tools/template_creator $(BASEDIR)/bin
@cp -n tools/update_disk $(BASEDIR)/bin
@cp -n tools/vm_run $(BASEDIR)/bin
@echo "OK"
......
......@@ -548,21 +548,7 @@ Feel free to repeat the operation above with as many templates as you like.
### Update a template
The `update_disk` script, located in `/usr/local/nexus-server/bin/`, can be used to update a template's disk image:
```
update_disk - a tool to update a template's disk image.
Beware this tool must ONLY be used on templates that are not
being used by any VMs, otherwise their disks will be corrupted!
Usage: update_disk disk
disk the disk image to update which must be a .qcow file
```
As mentioned in the script's help, make absolutely sure that the **template's disk to update IS NOT used by any VMs**, otherwise their disks will be corrupted!
### vm_run script
The `vm_run` script, located in `/usr/local/nexus-server/bin/`, is a convenience script that runs a VM on the specified image file:
The `vm_run` script, located in `/usr/local/nexus-server/bin/`, is a convenience script that runs a VM on the specified image file(s) and it can be used to update a template's disk image. Here is its usage:
```
vm_run - launch a VM on the specified disk image(s).
The VM is configured with 4 CPUs and 4G of RAM.
......@@ -574,6 +560,8 @@ iso the CD/DVD-ROM image to use (typically an .iso file)
At least one image must be specified.
```
Before updating a template's disk image, **make absolutely sure that it IS NOT used by any VMs**, otherwise all VMs based on this template will be corrupted!
### Control nexus-server with systemd
The nexus-server service can now be started with:
......
......@@ -18,7 +18,12 @@ function create_disk {
# Args: id, cpus, ram, disk, iso
function run_qemu {
dir=$1
qemu-system-x86_64 -enable-kvm -cpu host -smp cpus=$2 -m $3 -drive file=$dir/$4,index=0,media=disk,format=qcow2,discard=unmap,detect-zeroes=unmap,if=virtio -vga virtio -device virtio-serial-pci -nic user,model=virtio-net-pci -drive file=$5,index=1,media=cdrom,format=raw,read-only=on || { rm -rf $dir ; exit 1 ; }
network="-nic user,model=virtio-net-pci"
guest_agent="-device virtio-serial -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 -chardev socket,path=path_to_sock_file,server=on,wait=off,id=qga0"
qemu-system-x86_64 -enable-kvm -cpu host -smp cpus=$2 -m $3 -drive file=$dir/$4,index=0,media=disk,format=qcow2,discard=unmap,detect-zeroes=unmap,if=virtio -drive file=$5,index=1,media=cdrom,format=raw,read-only=on -vga virtio -device virtio-serial-pci $network $guest_agent || { rm -rf $dir ; exit 1 ; }
}
# Args: id, name, owner, visibility
......
#!/bin/bash
CPU=4
RAM=4096
function echoerr {
echo "$@" >&2
}
if [ $# -ne 1 ]; then
appname=`basename $0`
echoerr "$appname - a tool to update a template's disk image."
echoerr "Beware this tool must ONLY be used on templates that are not"
echoerr "being used by any VMs, otherwise their disks will be corrupted!"
echoerr ""
echoerr "Usage: $appname disk"
echoerr "disk the disk image to update which must be a .qcow file"
exit 1
fi
DISK=$1
if ! [ -f $DISK ]; then
echoerr "Disk image \"$DISK\" not found!"
exit 1
fi
qemu-system-x86_64 -enable-kvm -cpu host -smp cpus=$CPU -m $RAM -drive file=$DISK,index=0,media=disk,format=qcow2,discard=unmap,detect-zeroes=unmap,if=virtio -vga virtio -device virtio-serial-pci -nic user,model=virtio-net-pci
......@@ -52,5 +52,9 @@ if [ ! -z $iso ]; then
cdrom_drive="-drive file=$iso,index=1,media=cdrom,format=raw,read-only=on"
fi
network="-nic user,model=virtio-net-pci"
guest_agent="-device virtio-serial -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 -chardev socket,path=path_to_sock_file,server=on,wait=off,id=qga0"
# -boot order=d tells QEMU to boot to CDROM first
qemu-system-x86_64 -enable-kvm -cpu host -smp cpus=$CPUS -m $RAM -boot order=d $disk_drive $cdrom_drive -vga virtio -device virtio-serial-pci -nic user,model=virtio-net-pci
qemu-system-x86_64 -enable-kvm -cpu host -smp cpus=$CPUS -m $RAM -boot order=d $disk_drive $cdrom_drive -vga virtio -device virtio-serial-pci $network $guest_agent
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment