[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v1 15/26] kvm: vmi: reconnect the socket on reset
From: |
Adalbert Lazăr |
Subject: |
[RFC PATCH v1 15/26] kvm: vmi: reconnect the socket on reset |
Date: |
Wed, 15 Apr 2020 03:59:27 +0300 |
From: Marian Rotariu <address@hidden>
The guest could be reset from various reasons and by disconnecting the
socket (which would reconnect), KVM and the introspection tool will be
notified and can clean up the introspection structures.
Signed-off-by: Marian Rotariu <address@hidden>
Signed-off-by: Adalbert Lazăr <address@hidden>
---
accel/kvm/vmi.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/accel/kvm/vmi.c b/accel/kvm/vmi.c
index 54c56c6e13..5beec2b091 100644
--- a/accel/kvm/vmi.c
+++ b/accel/kvm/vmi.c
@@ -13,6 +13,7 @@
#include "qemu/error-report.h"
#include "qom/object_interfaces.h"
#include "sysemu/sysemu.h"
+#include "sysemu/reset.h"
#include "sysemu/kvm.h"
#include "crypto/secret.h"
#include "crypto/hash.h"
@@ -66,6 +67,7 @@ typedef struct VMIntrospectionClass {
OBJECT_CLASS_CHECK(VMIntrospectionClass, (class), TYPE_VM_INTROSPECTION)
static Error *vm_introspection_init(VMIntrospection *i);
+static void vm_introspection_reset(void *opaque);
static void machine_ready(Notifier *notifier, void *data)
{
@@ -122,6 +124,8 @@ static void complete(UserCreatable *uc, Error **errp)
}
ic->uniq = i;
+
+ qemu_register_reset(vm_introspection_reset, i);
}
static void prop_set_chardev(Object *obj, const char *value, Error **errp)
@@ -273,6 +277,8 @@ static void instance_finalize(Object *obj)
if (!ic->instance_counter) {
ic->uniq = NULL;
}
+
+ qemu_unregister_reset(vm_introspection_reset, i);
}
static const TypeInfo info = {
@@ -534,6 +540,18 @@ static void chr_event(void *opaque, QEMUChrEvent event)
}
}
+static void vm_introspection_reset(void *opaque)
+{
+ VMIntrospection *i = opaque;
+
+ if (i->sock_fd != -1) {
+ info_report("VMI: Reset detected. Closing the socket...");
+ disconnect_and_unhook_kvmi(i);
+ }
+
+ update_vm_start_time(i);
+}
+
static bool make_cookie_hash(const char *key_id, uint8_t *cookie_hash,
Error **errp)
{
- Re: [RFC PATCH v1 05/26] char-socket: add 'fd' property, (continued)
- [RFC PATCH v1 13/26] kvm: vmi: block the object destruction if the chardev is connected, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 09/26] kvm: introduce the VM introspection object, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 02/26] char-socket: allow vsock parameters (cid, port), Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 01/26] chardev: tcp: allow to change the reconnect timer, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 14/26] kvm: vmi: allow only one instance of the introspection object, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 11/26] kvm: vmi: add 'handshake_timeout' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 15/26] kvm: vmi: reconnect the socket on reset,
Adalbert Lazăr <=
- [RFC PATCH v1 19/26] kvm: vmi: intercept force-reset, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 22/26] kvm: vmi: add 'async_unhook' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 17/26] kvm: vmi: add 'unhook_timeout' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 24/26] kvm: vmi: add 'unhook_on_shutdown' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 12/26] kvm: vmi: add 'key' property, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 21/26] kvm: vmi: postpone the OK response from qmp_stop(), Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 18/26] kvm: vmi: store/restore 'vm_start_time' on migrate/snapshot, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 23/26] kvm: vmi: intercept shutdown, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 16/26] kvm: vmi: intercept pause/resume, Adalbert Lazăr, 2020/04/14
- [RFC PATCH v1 25/26] kvm: vmi: extend handshake to include the e820 table, Adalbert Lazăr, 2020/04/14