Unverified Commit 355d873d authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Restore previous device configuration (#1014)

parent e4983fa0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
#!/usr/bin/env bash
set -Eeuo pipefail

[[ "${BALLOONING:-}" != [Yy1]* ]] && return 0
: "${BALLOONING:="N"}"

[[ "$BALLOONING" != [Yy1]* ]] && return 0

# By default, the VM is allocated the full amount of RAM configured via RAM_SIZE for its entire lifetime, but if you want
# the container to dynamically reclaim unused guest RAM based on host memory pressure, you can enable memory ballooning.
+6 −2
Original line number Diff line number Diff line
@@ -28,10 +28,14 @@ if [[ "${MACHINE,,}" != "pc"* ]]; then
  DEV_OPTS="-object rng-random,id=objrng0,filename=/dev/urandom"
  DEV_OPTS+=" -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0"
  if [[ "${BOOT_MODE,,}" != "windows"* || "${BALLOONING:-}" == [Yy1]* ]]; then
    [[ "${BALLOONING:-}" == [Yy1]* ]] && MON_OPTS+=" -qmp unix:${QEMU_DIR}/qemu-qmp-ballooning.sock,server,nowait"
    if [[ "${BALLOONING:-}" != [Yy1]* ]]; then
      DEV_OPTS+=" -device virtio-balloon-pci,id=balloon0,bus=pcie.0"
    else
      MON_OPTS+=" -qmp unix:${QEMU_DIR}/qemu-qmp-ballooning.sock,server,nowait"
      DEV_OPTS+=" -device virtio-balloon-pci,free-page-reporting=on,guest-stats-polling-interval=1,id=balloon0,bus=pcie.0"
    fi
  fi
fi

if [ -d "/shared" ] && [[ "${BOOT_MODE,,}" != "windows"* ]]; then
  DEV_OPTS+=" -fsdev local,id=fsdev0,path=/shared,security_model=none"