Page MenuHomeFreeBSD

D61003.1795499930.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D61003.1795499930.diff

diff --git a/usr.sbin/bhyve/pci_emul.h b/usr.sbin/bhyve/pci_emul.h
--- a/usr.sbin/bhyve/pci_emul.h
+++ b/usr.sbin/bhyve/pci_emul.h
@@ -267,6 +267,7 @@
#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/pci_emul.c b/usr.sbin/bhyve/pci_emul.c
--- a/usr.sbin/bhyve/pci_emul.c
+++ b/usr.sbin/bhyve/pci_emul.c
@@ -2603,6 +2603,13 @@
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 @@
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/snapshot.c b/usr.sbin/bhyve/snapshot.c
--- a/usr.sbin/bhyve/snapshot.c
+++ b/usr.sbin/bhyve/snapshot.c
@@ -1085,6 +1085,23 @@
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 @@
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");

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 24, 5:58 AM (2 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41948672
Default Alt Text
D61003.1795499930.diff (1 KB)

Event Timeline