From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 7B38B1FF142 for ; Fri, 03 Jul 2026 16:12:59 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9847B21495; Fri, 03 Jul 2026 16:12:38 +0200 (CEST) From: Jakob Klocker To: pve-devel@lists.proxmox.com Subject: [PATCH guest-common/manager/qemu-server v4 0/3] fix #5032: add guest time sync via QGA Date: Fri, 3 Jul 2026 16:12:29 +0200 Message-ID: <20260703141232.272895-1-j.klocker@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.455 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: P6DYBBB5LE24KSXKGQ6EP4HF4DC4NFRR X-Message-ID-Hash: P6DYBBB5LE24KSXKGQ6EP4HF4DC4NFRR X-MailFrom: jklocker@dev.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Jakob Klocker X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This series adds a new agent option 'sync-time-on-resume' to automatically synchronize the guest clock via the QEMU Guest Agent after operations that can leave the guest time stale. The option is disabled by default and only takes effect when the QEMU Guest Agent is enabled. When a VM resumes with a restored RAM state (waking from hibernation or rolling back to a snapshot that includes RAM), the guest clock continues from the point the state was saved and no longer matches wall-clock time. Skew also appears whenever the guest is briefly frozen and resumed - after creating a snapshot, an ordinary pause/resume, or the resume step of a live migration. When enabled, the option triggers a guest-set-time call: * after resuming from hibernation (suspend-to-disk) * after rolling back to a snapshot that includes RAM * after a live migration * after an ordinary pause/resume * after taking a snapshot The start, resume and rollback API endpoints also accept a 'sync-time-on-resume' parameter that overrides the configured value for a single operation. The option is exposed in the VM configuration GUI so it can be toggled per guest. A version check was added for migration to display a clear error message in case 'sync-time-on-resume' is enabled and the target doesn't support 'sync-time-on-resume'. Link: https://bugzilla.proxmox.com/show_bug.cgi?id=5032 changes from v3 to v4 (thanks @Maximiliano & @Fiona) - qemu-server: add version check for migration - qemu-server: add `verbose_description` - qemu-server: display clearer logging & error messages - pve-manager: reword GUI checkbox label changes from v2 to v3 (thanks @Fiona) - add sync on pause/resume - add override options - add print task - adapt formating and naming changes from v1 to v2 (thanks @Arthur) - qemu: adapt warning message in the resume-from-saved-state path - ui: reword the agent option label for clarity Tested scenarios: * test script covering: guest agent enabled with QGA running, guest agent enabled with QGA not running (not installed in guest) and guest agent disabled in the VM config * live migration from a node with the feature to a node too old to support it (verified it aborts in prepare with a clear error, before any disk/config changes) * snapshot rollback with RAM on a Windows guest (verified guest-set-time works via the explicit-host-time path, since the RTC-less form is unsupported on Windows) test script: ` #!/usr/bin/env bash vmid=100 echo "=== in-memory suspend, resume with sync=1 (should sync) ===" qm suspend "$vmid" qm resume "$vmid" --sync-time-on-resume 1 echo "=== in-memory suspend, resume with sync=0 (should NOT sync) ===" qm suspend "$vmid" qm resume "$vmid" --sync-time-on-resume 0 echo "=== suspend to disk, resume with sync=1 (should sync) ===" qm suspend "$vmid" --todisk 1 qm resume "$vmid" --sync-time-on-resume 1 echo "=== suspend to disk, resume with sync=0 (should NOT sync) ===" qm suspend "$vmid" --todisk 1 qm resume "$vmid" --sync-time-on-resume 0 echo "=== suspend to disk, start with sync=1 (should sync) ===" qm suspend "$vmid" --todisk 1 qm start "$vmid" --sync-time-on-resume 1 echo "=== suspend to disk, start with sync=0 (should NOT sync) ===" qm suspend "$vmid" --todisk 1 qm start "$vmid" --sync-time-on-resume 0 echo "=== create snapshot (should sync)===" qm snapshot "$vmid" testing --vmstate true echo "=== rollback with sync=0 (should NOT sync) ===" qm rollback "$vmid" testing --sync-time-on-resume 0 echo "=== rollback with sync=1 (should sync) ===" qm rollback "$vmid" testing --sync-time-on-resume 1 ` pve-guest-common: Jakob Klocker (1): AbstractConfig: allow passing options to snapshot_rollback src/PVE/AbstractConfig.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) pve-manager: Jakob Klocker (1): fix #5032: ui: qemu agent: add sync-time-on-resume option www/manager6/form/AgentFeatureSelector.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) qemu-server: Jakob Klocker (1): fix #5032: agent: sync guest time via QGA when the clock falls behind src/PVE/API2/Qemu.pm | 75 ++++++++++++++++++++++++++++++++-- src/PVE/CLI/qm.pm | 2 +- src/PVE/QemuConfig.pm | 12 +++++- src/PVE/QemuMigrate.pm | 13 ++++++ src/PVE/QemuServer.pm | 18 +++++++- src/PVE/QemuServer/Agent.pm | 61 +++++++++++++++++++++++++++ src/PVE/QemuServer/RunState.pm | 11 ++++- 7 files changed, 183 insertions(+), 9 deletions(-) Summary over all repositories: 9 files changed, 204 insertions(+), 11 deletions(-) -- Generated by murpp 0.12.0