[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 46/50] vhost+postcopy: Wire up POSTCOPY_END notify
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 46/50] vhost+postcopy: Wire up POSTCOPY_END notify |
Date: |
Tue, 20 Mar 2018 05:17:59 +0200 |
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>
Reviewed-by: Marc-André Lureau <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
migration/postcopy-ram.h | 1 +
hw/virtio/vhost-user.c | 34 ++++++++++++++++++++++++++++++++++
migration/postcopy-ram.c | 7 +++++++
hw/virtio/trace-events | 2 ++
4 files changed, 44 insertions(+)
diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h
index 2c73d77..d900d9c 100644
--- a/migration/postcopy-ram.h
+++ b/migration/postcopy-ram.h
@@ -132,6 +132,7 @@ enum PostcopyNotifyReason {
POSTCOPY_NOTIFY_PROBE = 0,
POSTCOPY_NOTIFY_INBOUND_ADVISE,
POSTCOPY_NOTIFY_INBOUND_LISTEN,
+ POSTCOPY_NOTIFY_INBOUND_END,
};
struct PostcopyNotifyData {
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 230f2f9..44aea5c 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1114,6 +1114,37 @@ 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 = {
+ .hdr.request = VHOST_USER_POSTCOPY_END,
+ .hdr.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK,
+ };
+ int ret;
+ struct vhost_user *u = dev->opaque;
+
+ 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;
+ }
+ postcopy_unregister_shared_ufd(&u->postcopy_fd);
+ u->postcopy_fd.handler = NULL;
+
+ trace_vhost_user_postcopy_end_exit();
+
+ return 0;
+}
+
static int vhost_user_postcopy_notifier(NotifierWithReturn *notifier,
void *opaque)
{
@@ -1139,6 +1170,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 7754913..9cdee0f 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -413,6 +413,13 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState
*mis)
trace_postcopy_ram_incoming_cleanup_entry();
if (mis->have_fault_thread) {
+ 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/hw/virtio/trace-events b/hw/virtio/trace-events
index fe5e0ff..857c495 100644
--- a/hw/virtio/trace-events
+++ b/hw/virtio/trace-events
@@ -7,6 +7,8 @@ vhost_region_add_section_abut(const char *name, uint64_t
new_size) "%s: 0x%"PRIx
vhost_section(const char *name, int r) "%s:%d"
# 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
--
MST
- [Qemu-devel] [PULL v2 31/50] vhost+postcopy: Register shared ufd with postcopy, (continued)
- [Qemu-devel] [PULL v2 31/50] vhost+postcopy: Register shared ufd with postcopy, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 32/50] vhost+postcopy: Transmit 'listen' to slave, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 33/50] postcopy+vhost-user: Split set_mem_table for postcopy, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 34/50] migration/ram: ramblock_recv_bitmap_test_byte_offset, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 37/50] vhost+postcopy: Stash RAMBlock and offset, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 36/50] vhost+postcopy: Send address back to qemu, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 38/50] vhost+postcopy: Helper to send requests to source for shared pages, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 39/50] vhost+postcopy: Resolve client address, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 30/50] postcopy: Allow registering of fd handler, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 40/50] postcopy: helper for waking shared, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 46/50] vhost+postcopy: Wire up POSTCOPY_END notify,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 43/50] vhost+postcopy: Call wakeups, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 44/50] libvhost-user: mprotect & madvises for postcopy, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 35/50] libvhost-user+postcopy: Register new regions with the ufd, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 48/50] postcopy: Allow shared memory, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 42/50] vhost+postcopy: Add vhost waker, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 45/50] vhost-user: Add VHOST_USER_POSTCOPY_END message, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 50/50] postcopy shared docs, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 41/50] postcopy: postcopy_notify_shared_wake, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 47/50] vhost: Huge page align and merge, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 49/50] libvhost-user: Claim support for postcopy, Michael S. Tsirkin, 2018/03/19