aboutgitcodebugslistschat
path: root/vu_common.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2025-02-12 18:07:13 +1100
committerStefano Brivio <sbrivio@redhat.com>2025-02-12 19:47:07 +0100
commit5911e08c0f53e46547e7eeb1dd824c8ab96e512e (patch)
tree2bd1f11eda2501cff2d3a983eb144d26c1c66a4e /vu_common.c
parent836fe215e049ee423750d3315a02742d8224eab2 (diff)
downloadpasst-5911e08c0f53e46547e7eeb1dd824c8ab96e512e.tar
passt-5911e08c0f53e46547e7eeb1dd824c8ab96e512e.tar.gz
passt-5911e08c0f53e46547e7eeb1dd824c8ab96e512e.tar.bz2
passt-5911e08c0f53e46547e7eeb1dd824c8ab96e512e.tar.lz
passt-5911e08c0f53e46547e7eeb1dd824c8ab96e512e.tar.xz
passt-5911e08c0f53e46547e7eeb1dd824c8ab96e512e.tar.zst
passt-5911e08c0f53e46547e7eeb1dd824c8ab96e512e.zip
migrate: Skeleton of live migration logic
Introduce facilities for guest migration on top of vhost-user infrastructure. Add migration facilities based on top of the current vhost-user infrastructure, moving vu_migrate() and related functions to migrate.c. Versioned migration stages define function pointers to be called on source or target, or data sections that need to be transferred. The migration header consists of a magic number, a version number for the encoding, and a "compat_version" which represents the oldest version which is compatible with the current one. We don't use it yet, but that allows for the future possibility of backwards compatible protocol extensions. Co-authored-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'vu_common.c')
-rw-r--r--vu_common.c49
1 files changed, 2 insertions, 47 deletions
diff --git a/vu_common.c b/vu_common.c
index ab04d31..48826b1 100644
--- a/vu_common.c
+++ b/vu_common.c
@@ -5,6 +5,7 @@
* common_vu.c - vhost-user common UDP and TCP functions
*/
+#include <errno.h>
#include <unistd.h>
#include <sys/uio.h>
#include <sys/eventfd.h>
@@ -17,6 +18,7 @@
#include "vhost_user.h"
#include "pcap.h"
#include "vu_common.h"
+#include "migrate.h"
#define VU_MAX_TX_BUFFER_NB 2
@@ -303,50 +305,3 @@ err:
return -1;
}
-
-/**
- * vu_migrate() - Send/receive passt insternal state to/from QEMU
- * @vdev: vhost-user device
- * @events: epoll events
- */
-void vu_migrate(struct vu_dev *vdev, uint32_t events)
-{
- int ret;
-
- /* TODO: collect/set passt internal state
- * and use vdev->device_state_fd to send/receive it
- */
- debug("vu_migrate fd %d events %x", vdev->device_state_fd, events);
- if (events & EPOLLOUT) {
- debug("Saving backend state");
-
- /* send some stuff */
- ret = write(vdev->device_state_fd, "PASST", 6);
- /* value to be returned by VHOST_USER_CHECK_DEVICE_STATE */
- vdev->device_state_result = ret == -1 ? -1 : 0;
- /* Closing the file descriptor signals the end of transfer */
- epoll_del(vdev->context, vdev->device_state_fd);
- close(vdev->device_state_fd);
- vdev->device_state_fd = -1;
- } else if (events & EPOLLIN) {
- char buf[6];
-
- debug("Loading backend state");
- /* read some stuff */
- ret = read(vdev->device_state_fd, buf, sizeof(buf));
- /* value to be returned by VHOST_USER_CHECK_DEVICE_STATE */
- if (ret != sizeof(buf)) {
- vdev->device_state_result = -1;
- } else {
- ret = strncmp(buf, "PASST", sizeof(buf));
- vdev->device_state_result = ret == 0 ? 0 : -1;
- }
- } else if (events & EPOLLHUP) {
- debug("Closing migration channel");
-
- /* The end of file signals the end of the transfer. */
- epoll_del(vdev->context, vdev->device_state_fd);
- close(vdev->device_state_fd);
- vdev->device_state_fd = -1;
- }
-}