Skip to content

Instantly share code, notes, and snippets.

@jimklimov
Last active October 27, 2026 15:32
Show Gist options
  • Select an option

  • Save jimklimov/b79ef519add34af96e1fcc59de58165c to your computer and use it in GitHub Desktop.

Select an option

Save jimklimov/b79ef519add34af96e1fcc59de58165c to your computer and use it in GitHub Desktop.
QEMU-GA on OmniOS and OpenIndiana
  • Install the qemu package which contains a .../bin/qemu-ga(OOCE Extra repo in case of OmniOS) among the server implementation
:; pkg install qemu

# On OmniOS also:
:; ln -s ../../opt/ooce/bin/qemu-ga /usr/bin
  • Edit config file; note that the method and path depend on hypervisor-provided device (virtio-agent or ISA -- without a dedicated driver package, only the latter is actually supported), e.g.:
:; prtdiag | grep -E 'pci1af4,3|isa|asy'
:; dmesg | grep asy

### Populate config with one of examples below based on HW output above
:; mkdir -p /etc/qemu
:; vi /etc/qemu/qemu-ga.conf
  • Provide an SMF service:
# Populate with text below
:; vi /lib/svc/manifest/system/qemu-ga.xml

:; svccfg import /lib/svc/manifest/system/qemu-ga.xml

:; tail -F /var/svc/log/*qemu-ga*g &

:; svcadm enable qemu-ga
:; svcadm clear qemu-ga
  • Check from host, e.g. for VM ID 123:
:; qm agent 123 ping && echo OK
[general]
method=isa-serial
path=/devices/pci@0,0/isa@1/asy@1,3f8:a
#MAYBE# path=/dev/ttya
#MAYBE# path=/devices/pci@0,0/isa@1/asy@1,2f8:b
#MAYBE# path=/dev/ttyb
daemon=false
pidfile=/var/run/qemu-ga.pid
logfile=/var/log/qemu-ga.log
statedir=/var/run
verbose=false
blacklist=
[general]
method=virtio-serial
### May need a kernel driver for virtio, would be something like:
path=/devices/pci@0,0/pci1b36,1@5/pci1af4,3@1:a
daemon=false
pidfile=/var/run/qemu-ga.pid
logfile=/var/log/qemu-ga.log
statedir=/var/run
verbose=false
blacklist=
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='system/qemu-ga' type='service' version='0'>
<dependency name='fs-local' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<!-- NOTE: OmniOS has a built-in OOCE-based path to config, but can use
exec='/usr/bin/qemu-ga -c /etc/qemu/qemu-ga.conf'
while OpenIndiana has an older qemu-ga without "-c" option and the
default built-in config location named above.
-->
<exec_method
type='method'
name='start'
exec='/usr/bin/qemu-ga'
timeout_seconds='600'>
<method_context>
<method_credential user='root' group='root' />
</method_context>
</exec_method>
<exec_method
type='method'
name='stop'
exec=':kill'
timeout_seconds='60' />
<property_group name='startd' type='framework'>
<propval name='ignore_error' type='astring'
value='core,signal' />
<propval name='duration' type='astring'
value='child' />
</property_group>
<instance name='default' enabled='true'/>
<stability value='Evolving' />
<template>
<common_name>
<loctext xml:lang='C'>QEMU Guest Agent</loctext>
</common_name>
</template>
</service>
</service_bundle>
@yvoinov

yvoinov commented Sep 1, 2025

Copy link
Copy Markdown

Just a small addition - on OmniOS SMF does not see the config file and in the manifest in line exec='/usr/bin/qemu-ga' you need to add it: exec='/usr/bin/qemu-ga -с /etc/qemu/qemu-ga.conf'.

@jimklimov

Copy link
Copy Markdown
Author

Yes, that was in the comment of the XML - but thanks for highlighting anyhow ;)

@jimklimov

jimklimov commented Sep 22, 2026 •

Copy link
Copy Markdown
Author

New finding in QEMU 11.1.0 sources (./qga/commands-posix.c):

#define POWEROFF_CMD_PATH "/sbin/poweroff"
#define HALT_CMD_PATH "/sbin/halt"
#define REBOOT_CMD_PATH "/sbin/reboot"

This is similar in older packages of QEMU 7.2.0, same file:

#ifdef CONFIG_SOLARIS
        execl("/sbin/shutdown", "shutdown", shutdown_flag, "-g0", "-y",
              "hypervisor initiated shutdown", (char *)NULL);
#elif defined(CONFIG_BSD)
....

In OmniOS and OpenIndiana (as of 2026) these programs are in /usr/sbin which is a separate directory. Packaging of qemu might have to be tuned to take this into account (patch files?) but in the meanwhile this symlinking hack helps fix guest VM shutdowns:

:; for F in poweroff reboot halt shutdown ifconfig ; do [ -e /sbin/$F ] || { [ -e /usr/sbin/$F ] && ln -s  ../usr/sbin/$F /sbin/$F ; } ; done

Alternately, ACPI must be enabled and QEMU-GA hardware disabled (or changed to virtio that does not seem to work) for the power-button event to happen. With a properly working (recognized as attached) qemu-ga client service that can not run the shutdown program, the illumos VM never goes down (at least, Proxmox 9.x does not fall back to ACPI button despite what the docs suggest) and is eventually rudely killed off.

@jimklimov

Copy link
Copy Markdown
Author

Also at least once I was bit by host-side QGA queries happening during very early boot, and the ISA Serial port being used by the console so the VM fell into the ok> prompt posting those queries. A split-second race (before the Loader menu appears), but did happen. Probably need to eeprom limit which tty* nodes are consoles and which are not (on that VM, at least one virtual serial port is intentionally a backup console).

@jimklimov

jimklimov commented Oct 7, 2026 •

Copy link
Copy Markdown
Author

NOTE: Posting the packaging update to OI at OpenIndiana/oi-userland#27723 (split qemu into qemu-server + qemu-ga), while OpenIndiana/oi-userland#27772 addresses the previously absent support for getifaddrs reporting.

These were merged a couple of weeks ago, and current package version in OI packaging thus "just works" :)

omniosorg/omnios-extra#1841 is a differently developed OmniOS equivalent.

@jimklimov

Copy link
Copy Markdown
Author

And on a tangential note, for MacOS VMs there is https://github.com/mav2287/mac-guest-agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment