git: d079fc197aca - main - bhyve: Only snapshot initialized VirtIO queues

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 17 Dec 2021 18:11:44 UTC
The branch main has been updated by markj:

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

commit d079fc197aca951c7918276922038852167dd39f
Author:     Vitaliy Gusev <gusev.vitaliy@gmail.com>
AuthorDate: 2021-12-16 16:06:08 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-12-17 18:06:53 +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
    
    MFC after:      1 week
    Reviewed by:    jhb
    Differential Revision:  https://reviews.freebsd.org/D26268
---
 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 a08964e28563..ec7ddfe38f2e 100644
--- a/usr.sbin/bhyve/virtio.c
+++ b/usr.sbin/bhyve/virtio.c
@@ -901,6 +901,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);