在 2022/7/18 18:29, Eugenio Pérez 写道:
Since the vhost-vdpa device is exposing _F_LOG, adding a migration blocker if
it uses CVQ.
Signed-off-by: Eugenio Pérez <epere...@redhat.com>
---
include/hw/virtio/vhost-vdpa.h | 1 +
hw/virtio/vhost-vdpa.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index 1111d85643..d10a89303e 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -35,6 +35,7 @@ typedef struct vhost_vdpa {
bool shadow_vqs_enabled;
/* IOVA mapping used by the Shadow Virtqueue */
VhostIOVATree *iova_tree;
+ Error *migration_blocker;
GPtrArray *shadow_vqs;
const VhostShadowVirtqueueOps *shadow_vq_ops;
void *shadow_vq_ops_opaque;
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index beaaa7049a..795ed5a049 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -20,6 +20,7 @@
#include "hw/virtio/vhost-shadow-virtqueue.h"
#include "hw/virtio/vhost-vdpa.h"
#include "exec/address-spaces.h"
+#include "migration/blocker.h"
#include "qemu/cutils.h"
#include "qemu/main-loop.h"
#include "cpu.h"
@@ -1022,6 +1023,13 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
return true;
}
+ if (v->migration_blocker) {
+ int r = migrate_add_blocker(v->migration_blocker, &err);
+ if (unlikely(r < 0)) {
+ goto err_migration_blocker;
+ }
+ }
+
for (i = 0; i < v->shadow_vqs->len; ++i) {
VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
@@ -1064,6 +1072,9 @@ err:
vhost_svq_stop(svq);
}
+err_migration_blocker:
+ error_reportf_err(err, "Cannot setup SVQ %u: ", i);
So I got this:
FAILED: libqemu-x86_64-softmmu.fa.p/hw_virtio_vhost-vdpa.c.o
cc -m64 -mcx16 -Ilibqemu-x86_64-softmmu.fa.p -I. -I.. -Itarget/i386
-I../target/i386 -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/pixman-1
-I/usr/include/capstone -I/usr/include/glib-2.0
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fdiagnostics-color=auto
-Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -isystem
/home/devel/git/qemu/linux-headers -isystem linux-headers -iquote .
-iquote /home/devel/git/qemu -iquote /home/devel/git/qemu/include
-iquote /home/devel/git/qemu/tcg/i386 -pthread -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef
-Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common
-fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits
-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers
-Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined
-Wimplicit-fallthrough=2 -Wno-missing-include-dirs
-Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIE
-isystem../linux-headers -isystemlinux-headers -DNEED_CPU_H
'-DCONFIG_TARGET="x86_64-softmmu-config-target.h"'
'-DCONFIG_DEVICES="x86_64-softmmu-config-devices.h"' -MD -MQ
libqemu-x86_64-softmmu.fa.p/hw_virtio_vhost-vdpa.c.o -MF
libqemu-x86_64-softmmu.fa.p/hw_virtio_vhost-vdpa.c.o.d -o
libqemu-x86_64-softmmu.fa.p/hw_virtio_vhost-vdpa.c.o -c
../hw/virtio/vhost-vdpa.c
../hw/virtio/vhost-vdpa.c: In function ‘vhost_vdpa_dev_start’:
../hw/virtio/vhost-vdpa.c:1076:5: error: ‘i’ may be used uninitialized
in this function [-Werror=maybe-uninitialized]
1076 | error_reportf_err(err, "Cannot setup SVQ %u: ", i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../hw/virtio/vhost-vdpa.c:1020:14: note: ‘i’ was declared here
1020 | unsigned i;
| ^
cc1: all warnings being treated as errors
And this error is kind of duplicated with the one that is reported in
label "err" above.
Thanks
+
return false;
}
@@ -1083,6 +1094,9 @@ static bool vhost_vdpa_svqs_stop(struct vhost_dev *dev)
}
}
+ if (v->migration_blocker) {
+ migrate_del_blocker(v->migration_blocker);
+ }
return true;
}