[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 27/32] vhost+postcopy: Wire up POSTCOPY_END notify
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [RFC v2 27/32] vhost+postcopy: Wire up POSTCOPY_END notify |
Date: |
Thu, 24 Aug 2017 20:27:25 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Wire up a call to VHOST_USER_POSTCOPY_END message to the vhost clients
right before we ask the listener thread to shutdown.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
hw/virtio/trace-events | 2 ++
hw/virtio/vhost-user.c | 30 ++++++++++++++++++++++++++++++
migration/postcopy-ram.c | 5 +++++
migration/postcopy-ram.h | 1 +
4 files changed, 38 insertions(+)
diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
index 065822c70a..5b599617a1 100644
--- a/hw/virtio/trace-events
+++ b/hw/virtio/trace-events
@@ -1,6 +1,8 @@
# See docs/devel/tracing.txt for syntax documentation.
# hw/virtio/vhost-user.c
+vhost_user_postcopy_end_entry(void) ""
+vhost_user_postcopy_end_exit(void) ""
vhost_user_postcopy_fault_handler(const char *name, uint64_t fault_address,
int nregions) "%s: @0x%"PRIx64" nregions:%d"
vhost_user_postcopy_fault_handler_loop(int i, uint64_t client_base, uint64_t
size) "%d: client 0x%"PRIx64" +0x%"PRIx64
vhost_user_postcopy_fault_handler_found(int i, uint64_t region_offset,
uint64_t rb_offset) "%d: region_offset: 0x%"PRIx64" rb_offset:0x%"PRIx64
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index c2e55be0fd..d4461459fe 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -965,6 +965,33 @@ static int vhost_user_postcopy_listen(struct vhost_dev
*dev, Error **errp)
return 0;
}
+/*
+ * Called at the end of postcopy
+ */
+static int vhost_user_postcopy_end(struct vhost_dev *dev, Error **errp)
+{
+ VhostUserMsg msg = {
+ .request = VHOST_USER_POSTCOPY_END,
+ .flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK,
+ };
+ int ret;
+
+ trace_vhost_user_postcopy_end_entry();
+ if (vhost_user_write(dev, &msg, NULL, 0) < 0) {
+ error_setg(errp, "Failed to send postcopy_end to vhost");
+ return -1;
+ }
+
+ ret = process_message_reply(dev, &msg);
+ if (ret) {
+ error_setg(errp, "Failed to receive reply to postcopy_end");
+ return ret;
+ }
+ trace_vhost_user_postcopy_end_exit();
+
+ return 0;
+}
+
static int vhost_user_postcopy_notifier(NotifierWithReturn *notifier,
void *opaque)
{
@@ -990,6 +1017,9 @@ static int vhost_user_postcopy_notifier(NotifierWithReturn
*notifier,
case POSTCOPY_NOTIFY_INBOUND_LISTEN:
return vhost_user_postcopy_listen(dev, pnd->errp);
+ case POSTCOPY_NOTIFY_INBOUND_END:
+ return vhost_user_postcopy_end(dev, pnd->errp);
+
default:
/* We ignore notifications we don't know */
break;
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 7d0786ff04..28791cf1f1 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -337,7 +337,12 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState
*mis)
if (mis->have_fault_thread) {
uint64_t tmp64;
+ Error *local_err = NULL;
+ if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_END, &local_err)) {
+ error_report_err(local_err);
+ return -1;
+ }
if (qemu_ram_foreach_block(cleanup_range, mis)) {
return -1;
}
diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h
index ecf731c689..d0dc838001 100644
--- a/migration/postcopy-ram.h
+++ b/migration/postcopy-ram.h
@@ -130,6 +130,7 @@ enum PostcopyNotifyReason {
POSTCOPY_NOTIFY_PROBE = 0,
POSTCOPY_NOTIFY_INBOUND_ADVISE,
POSTCOPY_NOTIFY_INBOUND_LISTEN,
+ POSTCOPY_NOTIFY_INBOUND_END,
};
struct PostcopyNotifyData {
--
2.13.5
- [Qemu-devel] [RFC v2 21/32] postcopy: postcopy_notify_shared_wake, (continued)
- [Qemu-devel] [RFC v2 21/32] postcopy: postcopy_notify_shared_wake, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 22/32] vhost+postcopy: Add vhost waker, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 23/32] vhost+postcopy: Call wakeups, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 24/32] vub+postcopy: madvises, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 25/32] vhost+postcopy: Lock around set_mem_table, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 26/32] vhost: Add VHOST_USER_POSTCOPY_END message, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 27/32] vhost+postcopy: Wire up POSTCOPY_END notify,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [RFC v2 28/32] postcopy: Allow shared memory, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 29/32] vhost-user: Claim support for postcopy, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 30/32] vhost: Merge neighbouring hugepage regions where appropriate, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 31/32] vhost: Don't break merged regions on small remove/non-adds, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 32/32] postcopy shared docs, Dr. David Alan Gilbert (git), 2017/08/24