From patchwork Fri Mar 13 12:33:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Heyne X-Patchwork-Id: 11436845 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AEFF692A for ; Fri, 13 Mar 2020 12:35:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B68420724 for ; Fri, 13 Mar 2020 12:35:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="WHTWrSgy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B68420724 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCjW6-0006VO-H6; Fri, 13 Mar 2020 12:34:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCjVR-0006Sr-Vr for xen-devel@lists.xenproject.org; Fri, 13 Mar 2020 12:33:38 +0000 X-Inumbo-ID: d454c49a-6526-11ea-bec1-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d454c49a-6526-11ea-bec1-bc764e2007e4; Fri, 13 Mar 2020 12:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1584102804; x=1615638804; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=/fya+BUW395U9TLzGT2hJK0Q5V3PVgjLhCkueg8SXWM=; b=WHTWrSgysw5+kYDMapmP42uaipgRSLnbnVHnqTMjyES0WydlO9VB38bm xaOU842avfogBWPWcJIw+A9mQbv1AGyUiD7ExM3sxLik6RAtDApPDW5UD poAcxF+Eny0pR9yDpNFuuaDJKvgawZl91izXGfSVSpkwYFcHVF6K9kGr8 Y=; IronPort-SDR: mY8lsV8TYLGhb+H/4UKwIj4NuZ6iv/RVBbrk7enU2Y8oUzT8CkdBubgawTIAy331gCfPgDj2O2 UiOF40BwnDIg== X-IronPort-AV: E=Sophos;i="5.70,548,1574121600"; d="scan'208";a="32421122" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 13 Mar 2020 12:33:21 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com (Postfix) with ESMTPS id 0B978A2C4E; Fri, 13 Mar 2020 12:33:20 +0000 (UTC) Received: from EX13D08EUC004.ant.amazon.com (10.43.164.176) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Fri, 13 Mar 2020 12:33:20 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D08EUC004.ant.amazon.com (10.43.164.176) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 13 Mar 2020 12:33:19 +0000 Received: from dev-dsk-mheyne-60001.pdx1.corp.amazon.com (10.184.85.242) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 13 Mar 2020 12:33:17 +0000 Received: by dev-dsk-mheyne-60001.pdx1.corp.amazon.com (Postfix, from userid 5466572) id 87DE1222D7; Fri, 13 Mar 2020 12:33:16 +0000 (UTC) From: Maximilian Heyne To: Date: Fri, 13 Mar 2020 12:33:14 +0000 Message-ID: <20200313123316.122003-2-mheyne@amazon.de> X-Mailer: git-send-email 2.16.6 In-Reply-To: <20200313123316.122003-1-mheyne@amazon.de> References: <20200313123316.122003-1-mheyne@amazon.de> MIME-Version: 1.0 Precedence: Bulk X-Mailman-Approved-At: Fri, 13 Mar 2020 12:34:17 +0000 Subject: [Xen-devel] [PATCH 1/3] Add support for generic notifier lists X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Paul Durrant Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Anthony Liguori Notifiers are data-less callbacks and a notifier list is a list of registered notifiers that all are interested in a particular event. We'll use this in a few patches to implement mouse change notification. Signed-off-by: Anthony Liguori Reviewed-by: Paul Durrant --- v1 -> v2 - Do not do memory allocations by placing list nodes in notifier [cherry-picked from d1e70c5e6d1472856c52969301247fe8c3c8389d conflicts: used the sys-qeue interface and added required LIST_REMOVE_SAFE function to that] Signed-off-by: Maximilian Heyne --- Makefile | 1 + notify.c | 39 +++++++++++++++++++++++++++++++++++++++ notify.h | 43 +++++++++++++++++++++++++++++++++++++++++++ sys-queue.h | 5 +++++ 4 files changed, 88 insertions(+) create mode 100644 notify.c create mode 100644 notify.h diff --git a/Makefile b/Makefile index 0fbec990b..d921bcdf8 100644 --- a/Makefile +++ b/Makefile @@ -93,6 +93,7 @@ OBJS+=sd.o ssi-sd.o OBJS+=bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o OBJS+=buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o OBJS+=qemu-char.o aio.o net-checksum.o savevm.o cache-utils.o +OBJS+=notify.o ifdef CONFIG_BRLAPI OBJS+= baum.o diff --git a/notify.c b/notify.c new file mode 100644 index 000000000..59e1e7c7d --- /dev/null +++ b/notify.c @@ -0,0 +1,39 @@ +/* + * Notifier lists + * + * Copyright IBM, Corp. 2010 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#include "qemu-common.h" +#include "notify.h" + +void notifier_list_init(NotifierList *list) +{ + LIST_INIT(&list->notifiers); +} + +void notifier_list_add(NotifierList *list, Notifier *notifier) +{ + LIST_INSERT_HEAD(&list->notifiers, notifier, node); +} + +void notifier_list_remove(Notifier *notifier) +{ + LIST_REMOVE(notifier, node); +} + +void notifier_list_notify(NotifierList *list) +{ + Notifier *notifier, *next; + + LIST_FOREACH_SAFE(notifier, &list->notifiers, node, next) { + notifier->notify(notifier); + } +} diff --git a/notify.h b/notify.h new file mode 100644 index 000000000..093c63f19 --- /dev/null +++ b/notify.h @@ -0,0 +1,43 @@ +/* + * Notifier lists + * + * Copyright IBM, Corp. 2010 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_NOTIFY_H +#define QEMU_NOTIFY_H + +#include "sys-queue.h" + +typedef struct Notifier Notifier; + +struct Notifier +{ + void (*notify)(Notifier *notifier); + LIST_ENTRY(Notifier) node; +}; + +typedef struct NotifierList +{ + LIST_HEAD(, Notifier) notifiers; +} NotifierList; + +#define NOTIFIER_LIST_INITIALIZER(head) \ + { LIST_HEAD_INITIALIZER((head).notifiers) } + +void notifier_list_init(NotifierList *list); + +void notifier_list_add(NotifierList *list, Notifier *notifier); + +void notifier_list_remove(Notifier *notifier); + +void notifier_list_notify(NotifierList *list); + +#endif diff --git a/sys-queue.h b/sys-queue.h index 55c26fe7f..81ab044a8 100644 --- a/sys-queue.h +++ b/sys-queue.h @@ -132,6 +132,11 @@ struct { \ (var); \ (var) = ((var)->field.le_next)) +#define LIST_FOREACH_SAFE(var, head, field, next_var) \ + for ((var) = ((head)->lh_first); \ + (var) && ((next_var) = ((var)->field.le_next), 1); \ + (var) = (next_var)) + /* * List access methods. */ From patchwork Fri Mar 13 12:33:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Heyne X-Patchwork-Id: 11436849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D624C92C for ; Fri, 13 Mar 2020 12:35:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B33FE20724 for ; Fri, 13 Mar 2020 12:35:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="oCHEmouf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B33FE20724 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCjW6-0006VI-8Y; Fri, 13 Mar 2020 12:34:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCjVN-0006SW-0P for xen-devel@lists.xenproject.org; Fri, 13 Mar 2020 12:33:33 +0000 X-Inumbo-ID: d3fe9c14-6526-11ea-92cf-bc764e2007e4 Received: from smtp-fw-9101.amazon.com (unknown [207.171.184.25]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d3fe9c14-6526-11ea-92cf-bc764e2007e4; Fri, 13 Mar 2020 12:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1584102804; x=1615638804; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=BChTlQBLR5Hi7t+3wQCEI1Do3gF52UgIeaC1oWVTedE=; b=oCHEmouf9k8ZQ2uZkEiWAdSHsLxik3kPwLKr79KeKl6hFR0SQ0SUjo4E +CTq4R6/LAtkgvZaGKlc5hajq0GYAN4awsT44A9swDFk8bO29Nbs0rtEJ 94cGRjmfQ8L/mjSSM2FRDlvvEJFRxvyh++Q3sxJkx21xcieixEzAh04y4 8=; IronPort-SDR: wRaDgsisarsoZYkLJvW8dTehwKbheRz/m1VJ3n2NI+miGACj9vclYxnhTHZIaZ7OS+cZgcliJ2 KCnvfzQ1keug== X-IronPort-AV: E=Sophos;i="5.70,548,1574121600"; d="scan'208";a="22665808" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 13 Mar 2020 12:33:21 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com (Postfix) with ESMTPS id 3C6D0A2C41; Fri, 13 Mar 2020 12:33:19 +0000 (UTC) Received: from EX13D08EUB001.ant.amazon.com (10.43.166.236) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Fri, 13 Mar 2020 12:33:19 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D08EUB001.ant.amazon.com (10.43.166.236) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 13 Mar 2020 12:33:18 +0000 Received: from dev-dsk-mheyne-60001.pdx1.corp.amazon.com (10.184.85.242) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 13 Mar 2020 12:33:17 +0000 Received: by dev-dsk-mheyne-60001.pdx1.corp.amazon.com (Postfix, from userid 5466572) id 86A0421CA2; Fri, 13 Mar 2020 12:33:16 +0000 (UTC) From: Maximilian Heyne To: Date: Fri, 13 Mar 2020 12:33:15 +0000 Message-ID: <20200313123316.122003-3-mheyne@amazon.de> X-Mailer: git-send-email 2.16.6 In-Reply-To: <20200313123316.122003-1-mheyne@amazon.de> References: <20200313123316.122003-1-mheyne@amazon.de> MIME-Version: 1.0 Precedence: Bulk X-Mailman-Approved-At: Fri, 13 Mar 2020 12:34:17 +0000 Subject: [Xen-devel] [PATCH 2/3] Add exit notifiers. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Paul Durrant Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Gerd Hoffmann Hook up any cleanup work which needs to be done here. Advantages over using atexit(3): (1) You get passed in a pointer to the notifier. If you embed that into your state struct you can use container_of() to get get your state info. (2) You can unregister, say when un-plugging a device. [ v2: move code out of #ifndef _WIN32 ] Signed-off-by: Anthony Liguori (cherry picked from commit fd42deeb4cb42f90084046e3ebdb4383953195e3) Signed-off-by: Maximilian Heyne Reviewed-by: Paul Durrant --- sysemu.h | 5 +++++ vl.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/sysemu.h b/sysemu.h index 968258a84..759d0e9d5 100644 --- a/sysemu.h +++ b/sysemu.h @@ -2,6 +2,8 @@ #define SYSEMU_H /* Misc. things related to the system emulator. */ +#include "notify.h" + /* vl.c */ extern const char *bios_name; extern const char *bios_dir; @@ -39,6 +41,9 @@ void qemu_system_powerdown(void); #endif void qemu_system_reset(void); +void qemu_add_exit_notifier(Notifier *notify); +void qemu_remove_exit_notifier(Notifier *notify); + void do_savevm(const char *name); void do_loadvm(const char *name); void do_delvm(const char *name); diff --git a/vl.c b/vl.c index c3c5d630e..2163217ec 100644 --- a/vl.c +++ b/vl.c @@ -282,6 +282,9 @@ uint8_t qemu_uuid[16]; #include "xen-vl-extra.c" +static NotifierList exit_notifiers = + NOTIFIER_LIST_INITIALIZER(exit_notifiers); + /***********************************************************/ /* x86 ISA bus support */ @@ -4843,6 +4846,21 @@ static void vcpu_hex_str_to_bitmap(const char *optarg) } } +void qemu_add_exit_notifier(Notifier *notify) +{ + notifier_list_add(&exit_notifiers, notify); +} + +void qemu_remove_exit_notifier(Notifier *notify) +{ + notifier_list_remove(notify); +} + +static void qemu_run_exit_notifiers(void) +{ + notifier_list_notify(&exit_notifiers); +} + int main(int argc, char **argv, char **envp) { #ifdef CONFIG_GDBSTUB @@ -4887,6 +4905,8 @@ int main(int argc, char **argv, char **envp) const char *chroot_dir = NULL; const char *run_as = NULL; + atexit(qemu_run_exit_notifiers); + qemu_cache_utils_init(envp); logfile = stderr; /* initial value */ From patchwork Fri Mar 13 12:33:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Heyne X-Patchwork-Id: 11436847 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 169BF139A for ; Fri, 13 Mar 2020 12:35:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E781F20724 for ; Fri, 13 Mar 2020 12:35:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="m1kBGk/M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E781F20724 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCjW5-0006VC-WD; Fri, 13 Mar 2020 12:34:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCjVH-0006SD-W8 for xen-devel@lists.xenproject.org; Fri, 13 Mar 2020 12:33:28 +0000 X-Inumbo-ID: d411e7ba-6526-11ea-a6c1-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d411e7ba-6526-11ea-a6c1-bc764e2007e4; Fri, 13 Mar 2020 12:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1584102803; x=1615638803; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=6O8VBOGvr5WUoEfBKPbnEZdWawUmQ5qWCa/btGpiBco=; b=m1kBGk/MxDmT629Qwq9j1BkLftLC6ori0RXixxqfD71z9edkh9Oi3Tls Wlp0aC/2VhcoYTzaOkANZYKJ6Ax5ftKgjGl8szLZ5uBOv/zcn+s9HEPT8 XzvjZaj4Dl/gCJmCgnsZMD0yGkCtJ3jJ32gbpQD9Xpe5NkuqaNwqQkMNR k=; IronPort-SDR: PBjDWD+72t0Sgt36kfYExy7ggBjstxkcoHY7UpdiScYpdcU/lbCxSeZQMk3GYtrBBmy5uQgrpA FxqKMcpNHJlQ== X-IronPort-AV: E=Sophos;i="5.70,548,1574121600"; d="scan'208";a="31028704" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1a-67b371d8.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 13 Mar 2020 12:33:21 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-67b371d8.us-east-1.amazon.com (Postfix) with ESMTPS id A1A66A2275; Fri, 13 Mar 2020 12:33:20 +0000 (UTC) Received: from EX13D08EUC002.ant.amazon.com (10.43.164.124) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Fri, 13 Mar 2020 12:33:20 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D08EUC002.ant.amazon.com (10.43.164.124) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 13 Mar 2020 12:33:19 +0000 Received: from dev-dsk-mheyne-60001.pdx1.corp.amazon.com (10.184.85.242) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 13 Mar 2020 12:33:17 +0000 Received: by dev-dsk-mheyne-60001.pdx1.corp.amazon.com (Postfix, from userid 5466572) id 87454222D6; Fri, 13 Mar 2020 12:33:16 +0000 (UTC) From: Maximilian Heyne To: Date: Fri, 13 Mar 2020 12:33:16 +0000 Message-ID: <20200313123316.122003-4-mheyne@amazon.de> X-Mailer: git-send-email 2.16.6 In-Reply-To: <20200313123316.122003-1-mheyne@amazon.de> References: <20200313123316.122003-1-mheyne@amazon.de> MIME-Version: 1.0 Precedence: Bulk X-Mailman-Approved-At: Fri, 13 Mar 2020 12:34:16 +0000 Subject: [Xen-devel] [PATCH 3/3] xen: cleanup IOREQ server on exit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Paul Durrant Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Use the backported Notifier interface to register an atexit handler to cleanup the IOREQ server. This is required since Xen commit a5a180f9 ("x86/domain: don't destroy IOREQ servers on soft reset") is introduced which requires Qemu to explicitly close the IOREQ server. This is can be seen as a backport of ba7fdd64 ("xen: cleanup IOREQ server on exit"). Signed-off-by: Maximilian Heyne Reviewed-by: Paul Durrant --- hw/xen_machine_fv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c index f0989fad4..66eb4a1eb 100644 --- a/hw/xen_machine_fv.c +++ b/hw/xen_machine_fv.c @@ -31,6 +31,7 @@ #include "qemu-aio.h" #include "xen_backend.h" #include "pci.h" +#include "sysemu.h" #include #include @@ -67,6 +68,8 @@ TAILQ_HEAD(map_cache_head, map_cache_rev) locked_entries = TAILQ_HEAD_INITIALIZE static unsigned long last_address_page = ~0UL; static uint8_t *last_address_vaddr; +static Notifier exit_notifier; + static int qemu_map_cache_init(void) { unsigned long size; @@ -283,6 +286,11 @@ void xen_disable_io(void) xc_hvm_set_ioreq_server_state(xc_handle, domid, ioservid, 0); } +static void xen_exit_notifier(Notifier *n) +{ + xc_hvm_destroy_ioreq_server(xc_handle, domid, ioservid); +} + static void xen_init_fv(ram_addr_t ram_size, int vga_ram_size, const char *boot_device, const char *kernel_filename,const char *kernel_cmdline, @@ -317,6 +325,9 @@ static void xen_init_fv(ram_addr_t ram_size, int vga_ram_size, exit(-1); } + exit_notifier.notify = xen_exit_notifier; + qemu_add_exit_notifier(&exit_notifier); + if (xc_hvm_get_ioreq_server_info(xc_handle, domid, ioservid, &ioreq_pfn, &bufioreq_pfn, &bufioreq_evtchn)) {