git: 6d4d4e531d74 - stable/13 - bhyve: Only snapshot initialized VirtIO queues

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 27 Dec 2021 00:15:35 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=6d4d4e531d74493634135988c9eaaeffd393ff53

commit 6d4d4e531d74493634135988c9eaaeffd393ff53
Author:     Vitaliy Gusev <gusev.vitaliy@gmail.com>
AuthorDate: 2021-12-16 16:06:08 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-12-27 00:15:00 +0000

    bhyve: Only snapshot initialized VirtIO queues
    
    If the virtio device is not fully initialized, then suspend fails with:
    
      vi_pci_snapshot_queues: invalid address: vq->vq_desc
      Failed to snapshot virtio-rnd; ret=14
    
    Reviewed by:    jhb
    
    (cherry picked from commit d079fc197aca951c7918276922038852167dd39f)
---
 usr.sbin/bhyve/virtio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/usr.sbin/bhyve/virtio.c b/usr.sbin/bhyve/virtio.c
index 7f0485cbb826..13a274a03c0c 100644
--- a/usr.sbin/bhyve/virtio.c
+++ b/usr.sbin/bhyve/virtio.c
@@ -895,6 +895,9 @@ vi_pci_snapshot_queues(struct virtio_softc *vs, struct vm_snapshot_meta *meta)
 
 		SNAPSHOT_VAR_OR_LEAVE(vq->vq_pfn, meta, ret, done);
 
+		if (!vq_ring_ready(vq))
+			continue;
+
 		addr_size = vq->vq_qsize * sizeof(struct vring_desc);
 		SNAPSHOT_GUEST2HOST_ADDR_OR_LEAVE(vq->vq_desc, addr_size,
 			false, meta, ret, done);