From nobody Tue Nov 17 00:42:01 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jT5XT67wWz71MSx for ; Tue, 17 Nov 2026 00:42:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jT5XT3mv9z4smy for ; Tue, 17 Nov 2026 00:42:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794876121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ykeP/ZhVObr5amrAcJCZ5UQ5jg4h5jdfi1j8P7Fiju4=; b=HYAXurhV9sZgack7N2lGU+8LECC7/W5+cD6ccpebT6nyMp+Z67Rrh9Ne3Y/SBtMf0xu307 3BxRvkWrPGjvvfTOItow3FxzOonmNSYyYRY3JolLofmJaoONuvG2Nu617fjOBDfJe1XKPt 7LcwNxpB+Si6sSjTzGHPP4ttJNM/v76LRDYOfD6n27pONZMkbgFMQtUsGWMc8Cxrx/IlQY efALCHKkcQU5YVdgaU8wMCuij4IIYZ9VPdyAiPMbMBDPEsCaf/i+3KF6YjHV7KbrGr1vW8 U6Z1bg99/gfcw3GuhgXUqEq2+Q3A2fk/n8ftxQ1kYTBK1WMUrylidxThrCcHXg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794876121; b=eZYR5X6fmotjX3j71whbq9FfigJmwymQ0YjJtbdbUCLX5VZqw9u16fCkttUgmJ3Ez52ych NB0bmyFrrVnM3AY0WySB8zh59ytGD/pjwaRe0C5hewBvKBXdRoFCkC4S6gtw+spGNV7b4u 1z7+/PT9ESBhR/q9VtSbxmDZV3hyPqyodznvyVVVsxpM2BfjggMUlD4JEMxRK9JttebR7Q MqH26p5vQ6Q70UC5zIwcDs9Uq9j6XhgkkOpOXbajYebyuxDzf+6XlLmJtky8nD6IsPVRmY zX2RWacsrn1sgirJsXqJTq4JgsoYZAbXAADK9bEpIm8V+jSmzvDZH7ELjucqXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794876121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ykeP/ZhVObr5amrAcJCZ5UQ5jg4h5jdfi1j8P7Fiju4=; b=oJK+7FJrxwyubSo4AXNCBeJU68Dh/qfa+OcFZARAR+Ygo/HNwkaEWV//9v1wtNP9bDfGdD dqVYyTq5MbVe8gv4OtRbd9zsLJ/4j8vv4zIAyB0eAKUqOqchi6XYX8p7f8WeJV3fji3Ie3 6/hikA++1uNr+MFCHK0D1OxGlNEABbpEBKE4+oWP8+R0TiNBj3iu7rRztbDB6tX3x+RYK8 BBmZSbqZ65ztn4c6x2AI9EqQZvnNKcSUJjpZTISbZyh5QyFHQ7uRz/tPdN+VUz3eFP0Swa WA099oZUeWfHJ7tl9ZoYvNkJBcoSjAFP6oyZh7/A065EjVNevmEIFRqdx7eOJw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jT5XT3RRvzHDF for ; Tue, 17 Nov 2026 00:42:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f715 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 00:42:01 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hayzam Sherif Subject: git: 4ad4ddca0818 - main - bhyve: Reject unsupported checkpoints before saving RAM List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hayzam X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4ad4ddca08186d6a986655e4845bf0e29f93a961 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 00:42:01 +0000 Message-Id: <6afba2d9.1f715.68e81380@gitrepo.freebsd.org> The branch main has been updated by hayzam: URL: https://cgit.FreeBSD.org/src/commit/?id=4ad4ddca08186d6a986655e4845bf0e29f93a961 commit 4ad4ddca08186d6a986655e4845bf0e29f93a961 Author: Hayzam Sherif AuthorDate: 2026-11-16 23:28:45 +0000 Commit: Hayzam Sherif CommitDate: 2026-11-17 00:34:01 +0000 bhyve: Reject unsupported checkpoints before saving RAM pci_snapshot() rejects devices without a pe_snapshot callback, but vm_checkpoint() reaches that check only after truncating checkpoint files, pausing the VM, and saving RAM and kernel state. Check for unsupported PCI devices at the start of vm_checkpoint(), before creating files or pausing the VM. This preserves existing checkpoint files when the request cannot succeed. Add pci_can_snapshot() so that the new check and pci_snapshot() use the same test. Reviewed by: markj, kevans Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D61003 --- usr.sbin/bhyve/pci_emul.c | 9 ++++++++- usr.sbin/bhyve/pci_emul.h | 1 + usr.sbin/bhyve/snapshot.c | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 1ce9478bdebc..d9a0ef0ce3ee 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -2603,6 +2603,13 @@ done: return (ret); } +bool +pci_can_snapshot(const struct pci_devinst *pdi) +{ + + return (pdi->pi_d->pe_snapshot != NULL); +} + int pci_snapshot(struct vm_snapshot_meta *meta) { @@ -2615,7 +2622,7 @@ pci_snapshot(struct vm_snapshot_meta *meta) pdi = meta->dev_data; pde = pdi->pi_d; - if (pde->pe_snapshot == NULL) + if (!pci_can_snapshot(pdi)) return (ENOTSUP); ret = pci_snapshot_pci_dev(meta); diff --git a/usr.sbin/bhyve/pci_emul.h b/usr.sbin/bhyve/pci_emul.h index d536e53d01e3..fca96dbbae0f 100644 --- a/usr.sbin/bhyve/pci_emul.h +++ b/usr.sbin/bhyve/pci_emul.h @@ -267,6 +267,7 @@ int pci_bus_configured(int bus); #ifdef BHYVE_SNAPSHOT struct pci_devinst *pci_next(const struct pci_devinst *cursor); +bool pci_can_snapshot(const struct pci_devinst *pdi); int pci_snapshot(struct vm_snapshot_meta *meta); void pci_restore_prepare(void); int pci_pause(struct pci_devinst *pdi); diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index 067b05622e68..9f35ba3d5efa 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -1085,6 +1085,23 @@ vm_snapshot_device(vm_snapshot_dev_cb func, const char *dev_name, return (0); } +static bool +vm_can_snapshot_devices(void) +{ + struct pci_devinst *pdi; + + pdi = NULL; + while ((pdi = pci_next(pdi)) != NULL) { + if (!pci_can_snapshot(pdi)) { + EPRINTLN("%s does not support checkpointing", + pdi->pi_name); + return (false); + } + } + + return (true); +} + static int vm_snapshot_devices(int data_fd, xo_handle_t *xop) { @@ -1227,6 +1244,10 @@ vm_checkpoint(struct vmctx *ctx, int fddir, const char *checkpoint_file, char *kdata_filename = NULL; FILE *meta_file = NULL; + /* Reject unsupported devices before creating files or touching RAM. */ + if (!vm_can_snapshot_devices()) + return (ENOTSUP); + kdata_filename = strcat_extension(checkpoint_file, ".kern"); if (kdata_filename == NULL) { fprintf(stderr, "Failed to construct kernel data filename.\n");