@@ -384,3 +384,14 @@ void qemu_chr_fe_disconnect(CharBackend *be)
CHARDEV_GET_CLASS(chr)->chr_disconnect(chr);
}
}
+
+int qemu_chr_fe_reconnect_time(CharBackend *be, int secs)
+{
+ Chardev *chr = be->chr;
+
+ if (chr && CHARDEV_GET_CLASS(chr)->chr_reconnect_time) {
+ return CHARDEV_GET_CLASS(chr)->chr_reconnect_time(chr, secs);
+ }
+
+ return -1;
+}
@@ -1471,6 +1471,19 @@ char_socket_get_connected(Object *obj, Error **errp)
return s->state == TCP_CHARDEV_STATE_CONNECTED;
}
+static int tcp_chr_reconnect_time(Chardev *chr, int secs)
+{
+ SocketChardev *s = SOCKET_CHARDEV(chr);
+
+ int old = s->reconnect_time;
+
+ if (secs >= 0) {
+ s->reconnect_time = secs;
+ }
+
+ return old;
+}
+
static void char_socket_class_init(ObjectClass *oc, void *data)
{
ChardevClass *cc = CHARDEV_CLASS(oc);
@@ -1481,6 +1494,7 @@ static void char_socket_class_init(ObjectClass *oc, void *data)
cc->chr_write = tcp_chr_write;
cc->chr_sync_read = tcp_chr_sync_read;
cc->chr_disconnect = tcp_chr_disconnect;
+ cc->chr_reconnect_time = tcp_chr_reconnect_time;
cc->get_msgfds = tcp_get_msgfds;
cc->set_msgfds = tcp_set_msgfds;
cc->chr_add_client = tcp_chr_add_client;
@@ -135,6 +135,13 @@ void qemu_chr_fe_accept_input(CharBackend *be);
*/
void qemu_chr_fe_disconnect(CharBackend *be);
+/**
+ * qemu_chr_fe_reconnect_time:
+ *
+ * Change the reconnect time and return the old value.
+ */
+int qemu_chr_fe_reconnect_time(CharBackend *be, int secs);
+
/**
* qemu_chr_fe_wait_connected:
*
@@ -270,6 +270,7 @@ typedef struct ChardevClass {
int (*chr_add_client)(Chardev *chr, int fd);
int (*chr_wait_connected)(Chardev *chr, Error **errp);
void (*chr_disconnect)(Chardev *chr);
+ int (*chr_reconnect_time)(Chardev *be, int secs);
void (*chr_accept_input)(Chardev *chr);
void (*chr_set_echo)(Chardev *chr, bool echo);
void (*chr_set_fe_open)(Chardev *chr, int fe_open);
When the introspected VM is paused/suspended/migrated, the introspection tool removes its hooks from the guest and closes the connection. This is detected by KVM, which in turn will clean the introspection structures. Thanks to the reconnect parameter, the chardev will reconnect with the introspection tool, which will try to hook the VM again, assuming that the pause/suspend/migration operation has ended. With this new feature, we can suspend the reconnection. CC: "Marc-André Lureau" <marcandre.lureau@redhat.com> CC: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com> --- chardev/char-fe.c | 11 +++++++++++ chardev/char-socket.c | 14 ++++++++++++++ include/chardev/char-fe.h | 7 +++++++ include/chardev/char.h | 1 + 4 files changed, 33 insertions(+)