Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qemu-guest-agent for advanced VM shutdown options #2309

Merged

Conversation

gStart9
Copy link
Member

@gStart9 gStart9 commented Jun 18, 2023

This may help anybody running StartOS in a VM to:

  • properly shutdown the guest, instead of relying on ACPI commands
  • freeze the guest file system when making a backup/snapshot, entering suspend, and thawing filesystems
  • In the phase when the guest (VM) is resumed after pause (for example after shapshot) it immediately synchronizes its time with the hypervisor using qemu-guest-agent (as first step).

More info:
https://wiki.libvirt.org/Qemu_guest_agent.html
https://pve.proxmox.com/wiki/Qemu-guest-agent

@gStart9 gStart9 requested a review from dr-bonez June 18, 2023 18:56
@gStart9
Copy link
Member Author

gStart9 commented Jun 18, 2023

As an initial test I added qemu-guest-agent via /usr/lib/embassy/scripts/chroot-and-upgrade.sh

Installing qemu-guest-agent also installs 1 dependency: liburing1

When the VM came back up, ps auxfw shows the new process running:
root 458 0.0 0.0 80076 3316 ? Ssl 19:31 0:00 /usr/sbin/qemu-ga

Which is controlled through a new systemd service:

root@prepaid-pleats:~# systemctl status qemu-guest-agent
● qemu-guest-agent.service - QEMU Guest Agent
     Loaded: loaded (/lib/systemd/system/qemu-guest-agent.service; static)
     Active: active (running) since Sun 2023-06-18 19:31:10 UTC; 11min ago
   Main PID: 458 (qemu-ga)
      Tasks: 2 (limit: 23925)
     Memory: 1.4M
        CPU: 379ms
     CGroup: /system.slice/qemu-guest-agent.service
             └─458 /usr/sbin/qemu-ga

Notice: journal has been rotated since unit was started, output may be incomplete.

I wonder if there's a way we can detect if the installation is running as a VM and optionally turn qemu-guest-agent on or off, since it doesn't need to be running on a bare metal server. Will research.

@k0gen
Copy link
Member

k0gen commented Jun 19, 2023

I wonder if there's a way we can detect if the installation is running as a VM and optionally turn qemu-guest-agent on or off, since it doesn't need to be running on a bare metal server. Will research.

Sure we can, by using sudo dmidecode -s system-product-name
Though on RPi this will not output anything (there is no SMBIOS nor DMI entry point on RPi) but on anything else it will work. Some examples:

Start9 Pure

sudo dmidecode -s system-product-name
librem_mini_v2

StartOS on M1 Mac in UTM

sudo dmidecode -s system-product-name
QEMU Virtual Machine

@dr-bonez dr-bonez changed the base branch from master to integration/0.3.4.3 June 19, 2023 17:33
@MattDHill MattDHill force-pushed the feat/qemu-guest-agent_for_vm_operations branch from 5b0c917 to 4f41490 Compare June 19, 2023 17:43
@dr-bonez
Copy link
Member

I have tested that the agent does not activate on non-virtualized hardware

@dr-bonez dr-bonez merged commit 2d3e206 into integration/0.3.4.3 Jun 20, 2023
@gStart9 gStart9 deleted the feat/qemu-guest-agent_for_vm_operations branch June 21, 2023 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants