Skip to content

Add qemu-guest-agent over vsock for time sync and host-guest features#238

Open
Honny1 wants to merge 1 commit into
containers:mainfrom
Honny1:add-qemu-agent
Open

Add qemu-guest-agent over vsock for time sync and host-guest features#238
Honny1 wants to merge 1 commit into
containers:mainfrom
Honny1:add-qemu-agent

Conversation

@Honny1
Copy link
Copy Markdown
Member

@Honny1 Honny1 commented May 5, 2026

Install qemu-guest-agent and configure it to listen on vsock port 1234 (matching the constant in containers/podman). The service is gated by a DMI sys_vendor check (ExecCondition) so it only runs on Podman machine providers that expose the vsock channel: vfkit (Apple Inc.), libkrun (Libkrun), and qemu (QEMU). A custom SELinux module allows virt_qemu_ga_t to use vsock sockets.

Related PR: containers/podman#28527
Replace: #175

Added qemu-guest-agent (vsock) to machine images for host-guest time sync on macOS (vfkit, libkrun) and Linux (qemu).

@Honny1 Honny1 marked this pull request as ready for review May 5, 2026 15:10
@Honny1
Copy link
Copy Markdown
Member Author

Honny1 commented May 5, 2026

PTAL @l0rd @vyasgun @Luap99 @ninja-quokka

Comment thread podman-image/qemu-guest-agent.service Outdated
Comment on lines +6 to +8
# ConditionVirtualization= cannot distinguish our target providers: vfkit is `apple`,
# libkrun is `vm-other`, and `kvm` would overmatch. Gate on DMI sys_vendor instead.
ExecCondition=/usr/local/bin/qemu-guest-agent-exec-condition.sh
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why kvm would overmatch, there is also "qemu" as option we could use?!

It seems like we could check this (untested):

ConditionVirtualization=|qemu
ConditionVirtualization=|apple
ConditionFirmware=|smbios-field(sys_vendor = Libkrun)`

https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#ConditionFirmware=

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I will test that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work. I tested it with AppleHV and libkrun, but I haven't tested it with QEMU because I don't have a machine ready for it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok we will need to match kvm not qemu

$ systemd-detect-virt
kvm

per docs kvm should be fine and no overmatch other things

Linux KVM kernel virtual machine, in combination with QEMU. Not used for other virtualizers using the KVM interfaces, such as Oracle VirtualBox or Amazon EC2 Nitro, see below.

https://www.freedesktop.org/software/systemd/man/latest/systemd-detect-virt.html

Comment thread podman-image/qemu-guest-agent.service
Comment thread podman-image/Containerfile.COREOS Outdated
Comment on lines +6 to +9
RUN dnf install -y checkpolicy policycoreutils && dnf clean all
COPY qemu_guest_agent_vsock.te /qemu_guest_agent_vsock.te
RUN checkmodule -M -m -o /qemu_guest_agent_vsock.mod /qemu_guest_agent_vsock.te && \
semodule_package -o /qemu_guest_agent_vsock.pp -m /qemu_guest_agent_vsock.mod
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you copy first and then two all command in one RUN instruction,
it is just a minor thing but it is best to keep the RUN instructions to a minimum IMO

Comment on lines +60 to +64
RUN semodule -i /tmp/qemu_guest_agent_vsock.pp && rm -f /tmp/qemu_guest_agent_vsock.pp
COPY qemu-guest-agent-exec-condition.sh /usr/local/bin/qemu-guest-agent-exec-condition.sh
RUN chmod +x /usr/local/bin/qemu-guest-agent-exec-condition.sh && \
chcon --reference=/bin/sh /usr/local/bin/qemu-guest-agent-exec-condition.sh
COPY qemu-guest-agent.service /etc/systemd/system/qemu-guest-agent.service
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here, lets group this into one RUN instruction

@Honny1 Honny1 force-pushed the add-qemu-agent branch from e93da16 to 1a7a893 Compare May 6, 2026 11:43
Comment thread podman-image/00-podman-machine.preset Outdated
# Disable coreos chrony config, we do provide our own.
disable coreos-platform-chrony-config.service

# qemu-guest-agent (vsock) for macOS (vfkit, libkrun) and Linux (qemu); gated by DMI ExecCondition.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment needs to be updated

Comment thread verify/image_test.go
Expect(catSession).To(Exit(0))
out := catSession.outputToString()
Expect(out).To(ContainSubstring("vsock-listen"))
Expect(out).To(ContainSubstring("--path=3:1234"))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a check here that the service is also actually active for linux and macos?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added test.

@Honny1 Honny1 force-pushed the add-qemu-agent branch 2 times, most recently from 33f2d2b to 0c85a03 Compare May 6, 2026 12:19
@Honny1 Honny1 force-pushed the add-qemu-agent branch from 0c85a03 to 5c9aa39 Compare May 6, 2026 13:05
Install qemu-guest-agent and configure it to listen on vsock port 1234
(matching the constant in containers/podman). The service is gated by a
DMI sys_vendor check (ExecCondition) so it only runs on Podman machine
providers that expose the vsock channel: vfkit (Apple Inc.), libkrun
(Libkrun), and qemu (QEMU). A custom SELinux module allows
virt_qemu_ga_t to use vsock sockets.

Related PR: containers/podman#28527
Replace: containers#175

Signed-off-by: Jan Rodák <[email protected]>
@Honny1 Honny1 force-pushed the add-qemu-agent branch from 5c9aa39 to faf5dfd Compare May 6, 2026 14:32
@Honny1
Copy link
Copy Markdown
Member Author

Honny1 commented May 7, 2026

PTAL @containers/podman-maintainers I think this is ready for merge. I am not sure about timing with containers/podman#28527

@Luap99
Copy link
Copy Markdown
Member

Luap99 commented May 7, 2026

I am fine merging this if we commit to having the podman side also merged for 6.0 and fully integrated with this.
Having a restart loop in the service should not happen in the final release version.

@Honny1
Copy link
Copy Markdown
Member Author

Honny1 commented May 7, 2026

I am fine merging this if we commit to having the podman side also merged for 6.0 and fully integrated with this. Having a restart loop in the service should not happen in the final release version.

Agree

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