From nobody Mon Feb 9 18:46:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=bitdefender.com ARC-Seal: i=1; a=rsa-sha256; t=1586912944; cv=none; d=zohomail.com; s=zohoarc; b=O8A+gtPwOJjmC7NICJYwjbtCvJsauIdYZQ2czwyVfF5/3UboIp1U7MRBP/SeRxvDBcxBdyIzeF+L/Hg6GCwQr/FCbg7efCNFqLJ2f9mwK2irpAeTSWJ3aPiRfkig2fyZ442801fHwRzH0pN/bdyOupTSr8VAblPdsxAlJObE3+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586912944; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ayn9OunoUeNtCi6VO8WvbDJcvaNebvxeIGlD/QK0iMA=; b=e+d4Ou7eOegnPeN4NgQ26s3l8aVDf2H2SBRPvZ4MmJbBb2Em7ULOG0w+hbP65eMOWcyKxAa5iU4oDQ6PTQnyahQl1V6kYDqrICrUGi72W5y13/iLSqIVir/PT1yhlxzE9YRxCDOkF/aMtytwN4zH6LbSZYcpqsi9jVYWLddYXZA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158691294447423.851630955942596; Tue, 14 Apr 2020 18:09:04 -0700 (PDT) Received: from localhost ([::1]:40952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOWY3-0002DR-3K for importer@patchew.org; Tue, 14 Apr 2020 21:09:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58477) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOWPA-0001Kf-6f for qemu-devel@nongnu.org; Tue, 14 Apr 2020 20:59:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jOWP8-0005Bu-QT for qemu-devel@nongnu.org; Tue, 14 Apr 2020 20:59:52 -0400 Received: from mx01.bbu.dsd.mx.bitdefender.com ([91.199.104.161]:49096) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jOWP8-00052I-Hl for qemu-devel@nongnu.org; Tue, 14 Apr 2020 20:59:50 -0400 Received: from smtp.bitdefender.com (smtp02.buh.bitdefender.net [10.17.80.76]) by mx01.bbu.dsd.mx.bitdefender.com (Postfix) with ESMTPS id 7E08530747CE; Wed, 15 Apr 2020 03:59:35 +0300 (EEST) Received: from localhost.localdomain (unknown [91.199.104.27]) by smtp.bitdefender.com (Postfix) with ESMTPSA id 6A050305B7A5; Wed, 15 Apr 2020 03:59:35 +0300 (EEST) From: =?UTF-8?q?Adalbert=20Laz=C4=83r?= To: qemu-devel@nongnu.org Subject: [RFC PATCH v1 15/26] kvm: vmi: reconnect the socket on reset Date: Wed, 15 Apr 2020 03:59:27 +0300 Message-Id: <20200415005938.23895-16-alazar@bitdefender.com> In-Reply-To: <20200415005938.23895-1-alazar@bitdefender.com> References: <20200415005938.23895-1-alazar@bitdefender.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 91.199.104.161 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Adalbert=20Laz=C4=83r?= , Marian Rotariu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Marian Rotariu 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 Signed-off-by: Adalbert Laz=C4=83r --- 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_INTROSPECTIO= N) =20 static Error *vm_introspection_init(VMIntrospection *i); +static void vm_introspection_reset(void *opaque); =20 static void machine_ready(Notifier *notifier, void *data) { @@ -122,6 +124,8 @@ static void complete(UserCreatable *uc, Error **errp) } =20 ic->uniq =3D i; + + qemu_register_reset(vm_introspection_reset, i); } =20 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 =3D NULL; } + + qemu_unregister_reset(vm_introspection_reset, i); } =20 static const TypeInfo info =3D { @@ -534,6 +540,18 @@ static void chr_event(void *opaque, QEMUChrEvent event) } } =20 +static void vm_introspection_reset(void *opaque) +{ + VMIntrospection *i =3D opaque; + + if (i->sock_fd !=3D -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) {