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

Added options "discard=unmap,detect-zeroes=unmap" to QEMU in order to handle...

Added options "discard=unmap,detect-zeroes=unmap" to QEMU in order to handle sparse files to save disk space.
Updated template_creator, update_disk and vm_run scripts in consequence.
parent a29d0ae2
No related branches found
No related tags found
No related merge requests found
......@@ -567,7 +567,7 @@ The `vm_run` script, located in `/usr/local/nexus-server/bin/`, is a convenience
vm_run - launch a VM on the specified disk image(s).
The VM is configured with 4 CPUs and 4G of RAM.
Usage: vm_run -d disk -c iso
Usage: vm_run -d disk -i iso
disk the disk image to use (typically a .qcow file)
iso the CD/DVD-ROM image to use (typically an .iso file)
......
......@@ -57,7 +57,7 @@ func NewQemuSystem(qgaSock string, cpus int, ram int, nic string, diskFile strin
// - In the guest: mkdir shared && sudo mount -t 9p sharedfs shared
// 4) For QEMU Guest Agent support:
// -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
cmd := exec.Command(qemusystemBinary, "-enable-kvm", "-cpu", "host", "-smp", "cpus="+strconv.Itoa(cpus), "-m", strconv.Itoa(ram), "-drive", "file="+diskFile+",index=0,media=disk,format=qcow2,if=virtio", "-vga", "virtio", "-device", "virtio-serial-pci", "-object", "secret,id=sec,file="+secretPwdFile+",format=base64", "-spice", "tls-port="+strconv.Itoa(spicePort)+",password-secret=sec,x509-dir="+certDir, "-device", "virtserialport,chardev=spicechannel0,name=com.redhat.spice.0", "-chardev", "spicevmc,id=spicechannel0,name=vdagent", "-nic", nicArgs, "-device", "virtio-serial", "-device", "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0", "-chardev", "socket,path="+qgaSock+",server=on,wait=off,id=qga0")
cmd := exec.Command(qemusystemBinary, "-enable-kvm", "-cpu", "host", "-smp", "cpus="+strconv.Itoa(cpus), "-m", strconv.Itoa(ram), "-drive", "file="+diskFile+",index=0,media=disk,format=qcow2,discard=unmap,detect-zeroes=unmap,if=virtio", "-vga", "virtio", "-device", "virtio-serial-pci", "-object", "secret,id=sec,file="+secretPwdFile+",format=base64", "-spice", "tls-port="+strconv.Itoa(spicePort)+",password-secret=sec,x509-dir="+certDir, "-device", "virtserialport,chardev=spicechannel0,name=com.redhat.spice.0", "-chardev", "spicevmc,id=spicechannel0,name=vdagent", "-nic", nicArgs, "-device", "virtio-serial", "-device", "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0", "-chardev", "socket,path="+qgaSock+",server=on,wait=off,id=qga0")
return cmd, nil
}
......@@ -18,7 +18,7 @@ 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,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 ; }
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 ; }
}
# Args: id, name, owner, visibility
......
......@@ -25,4 +25,4 @@ if ! [ -f $DISK ]; then
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,if=virtio -vga virtio -device virtio-serial-pci -nic user,model=virtio-net-pci
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
......@@ -13,7 +13,7 @@ function usage {
echoerr "$APP - launch a VM on the specified disk image(s)."
echoerr "The VM is configured with $CPUS CPUs and $RAM of RAM."
echoerr ""
echoerr "Usage: $APP -d disk -c iso"
echoerr "Usage: $APP -d disk -i iso"
echoerr "disk the disk image to use (typically a .qcow file)"
echoerr "iso the CD/DVD-ROM image to use (typically an .iso file)"
echoerr ""
......@@ -32,7 +32,7 @@ while [[ $# -gt 0 ]]; do
shift # past argument
shift # past value
;;
-c)
-i)
iso="$2"
shift # past argument
shift # past value
......@@ -45,7 +45,7 @@ while [[ $# -gt 0 ]]; do
done
if [ ! -z $disk ]; then
disk_drive="-drive file=$disk,index=0,media=disk,format=qcow2,if=virtio"
disk_drive="-drive file=$disk,index=0,media=disk,format=qcow2,discard=unmap,detect-zeroes=unmap,if=virtio"
fi
if [ ! -z $iso ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment