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 CD4891FF0AF for ; Fri, 06 Nov 2026 11:36:38 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 5E0FA21611; Fri, 06 Nov 2026 11:36:36 +0100 (CET) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 06 Nov 2026 11:36:14 +0100 Message-Id: Subject: Re: [PATCH qemu-server v5 3/3] fix #5032: agent: sync guest time via QGA when the clock falls behind From: "Jakob Klocker" To: "Thomas Lamprecht" , X-Mailer: aerc 0.20.0 References: <20260813135713.380802-1-j.klocker@proxmox.com> <20260813135713.380802-4-j.klocker@proxmox.com> In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793961374726 X-SPAM-LEVEL: Spam detection results: 0 AWL 1.430 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) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: IE7FOAX2N3VISYPJ56MP7ZYDTF5H42XP X-Message-ID-Hash: IE7FOAX2N3VISYPJ56MP7ZYDTF5H42XP X-MailFrom: j.klocker@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 X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu Nov 5, 2026 at 9:16 PM CET, Thomas Lamprecht wrote: > Am 13.08.26 um 15:57 schrieb Jakob Klocker: >> Add a 'sync-time-on-resume' agent config property (default off) that, >> when enabled, issues the guest-set-time QGA command to set the guest >> clock to the host's current time after operations that leave the clock >> behind: >> - resuming from hibernation (suspend-to-disk) >> - resuming from pause/suspend >> - rolling back to a snapshot that includes RAM >> - live migration >> - taking a snapshot, during which the guest is briefly frozen >>=20 >> The start, resume and rollback API endpoints gain a >> 'sync-time-on-resume' parameter (e.g. 'qm start >> --sync-time-on-resume 0') that overrides the configured agent value for >> a single operation, forcing the sync on or off regardless of config. >>=20 >> guest_set_time prints a confirmation line to stdout on success. During >> live migration the resume step runs over the migration tunnel, which >> also uses stdout, so an unconditional print corrupts the tunnel >> protocol. vm_resume therefore takes a 'quiet' parameter to suppress the >> print on the migration path; the confirmation is logged by the migration >> code instead. >>=20 >> 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 the 'sync-time-on-resume' the option. >>=20 >> Signed-off-by: Jakob Klocker >> --- >> 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(-) > >> diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm >> index 8da6f15d..ae40195c 100644 >> --- a/src/PVE/QemuMigrate.pm >> +++ b/src/PVE/QemuMigrate.pm >> @@ -312,6 +312,16 @@ sub prepare { >> } >> } >> =20 >> + my $target_version =3D PVE::QemuServer::Helpers::get_node_pvecfg_ve= rsion($self->{node}); > > not sure if this is all worth it, we normally require all nodes to be the= same level > and existing VMs do not automatically gain this on upgrade, one has to ex= plicitly > configure it first. We could also avoid it for now for migration (and pro= bably taking > a snapshot) those are milliseconds at max anyway (else it would not reall= y be live > anymore). Could be enabled later for that and then potentially backup sna= pshots too? > There's also a brief pause there I think? > > @Daniel mentioned [0] that time sync after taking a snapshot has been requested in enterprise support before. After checking with another=20 colleague, the last request for the snapshot sync in enterprise support=20 was just a week ago. Some users report time skews up to a few seconds when taking snapshots, therefore I'd opt for not deffering it. If you prefer, we can drop the migration and I'll add it in a follow up including backup syncs as well. I wouldn't mind sending a v6 including backups either. Let me know what you prefer. Ack about dropping the version guards. [0] https://bugzilla.proxmox.com/show_bug.cgi?id=3D5032#c6 > But if we indeed want to add this check then it needs two changes... > > >> + if ( >> + $target_version >> + && !PVE::QemuServer::Helpers::pvecfg_min_version($target_versio= n, 9, 2, 5) > > ... this new call to PVE::QemuServer::Helpers::pvecfg_min_version(...) co= uld be > swapped with the new location of that, i.e. PVE::Tools::pvecfg_min_versio= n(...) > and the version updated (or at least a prominent NOTE in the diffstat sec= tion of > this patch added as reminder to update it on applying. > >> + && PVE::QemuServer::Agent::get_qga_key($conf, 'sync-time-on-res= ume') > > This misses one explicitly setting the property to 0, in which case the o= ther > node still needs to support it. Would need a definedness check here. > >> + ) { >> + die "target node '$self->{node}' is too old to support 'sync-ti= me-on-resume'" >> + . " (needs pve-manager >=3D 9.2.5); disable the option befo= re migrating\n"; >> + } >> + >> my $vollist =3D PVE::QemuServer::get_vm_volumes($conf); >> =20 >> my $storages =3D {};