From patchwork Mon Jun 1 15:46:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 479091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A5A65140FDF for ; Tue, 2 Jun 2015 01:48:12 +1000 (AEST) Received: from localhost ([::1]:53110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzRwg-0001qJ-HL for incoming@patchwork.ozlabs.org; Mon, 01 Jun 2015 11:48:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzRwN-0001TU-AV for qemu-devel@nongnu.org; Mon, 01 Jun 2015 11:47:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YzRwK-00041v-4F for qemu-devel@nongnu.org; Mon, 01 Jun 2015 11:47:51 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:14878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzRwJ-00041l-TC for qemu-devel@nongnu.org; Mon, 01 Jun 2015 11:47:48 -0400 X-IronPort-AV: E=Sophos;i="5.13,533,1427760000"; d="scan'208";a="270517918" From: Stefano Stabellini To: Date: Mon, 1 Jun 2015 16:46:53 +0100 Message-ID: <1433173614-19716-1-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 Cc: xen-devel@lists.xensource.com, Ian.Jackson@eu.citrix.com, Ian.Campbell@citrix.com, Stefano Stabellini Subject: [Qemu-devel] [PATCH 1/2] xen: separate the xenstore_record_dm_state calls for pv and hvm machines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The following patch will introduce a new option to restrict the privilege of the xenstore connection. In that case, we do not want to use multiple xenstore connections, but just the one, with lower privileges. For this reason, split the xenstore_record_dm_state calls for pv and hvm machines, so that in the hvm case QEMU will reuse the same xenstore connection. (At the moment it opens two and uses the second one for the xenstore_record_dm_state call.) Signed-off-by: Stefano Stabellini --- hw/xenpv/xen_machine_pv.c | 11 +++++++++++ include/hw/xen/xen.h | 2 ++ xen-common-stub.c | 4 ++++ xen-common.c | 15 +-------------- xen-hvm.c | 1 + 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/hw/xenpv/xen_machine_pv.c b/hw/xenpv/xen_machine_pv.c index 2e545d2..5ad22e3 100644 --- a/hw/xenpv/xen_machine_pv.c +++ b/hw/xenpv/xen_machine_pv.c @@ -28,6 +28,15 @@ #include "xen_domainbuild.h" #include "sysemu/block-backend.h" +static void xen_change_state_handler(void *opaque, int running, + RunState state) +{ + if (running) { + /* record state running */ + xenstore_record_dm_state(xenstore, "running"); + } +} + static void xen_init_pv(MachineState *machine) { const char *kernel_filename = machine->kernel_filename; @@ -91,6 +100,8 @@ static void xen_init_pv(MachineState *machine) /* setup framebuffer */ xen_init_display(xen_domid); + + qemu_add_vm_change_state_handler(xen_change_state_handler, NULL); } static QEMUMachine xenpv_machine = { diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index b0ed04c..d118b56 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -37,6 +37,8 @@ void xen_cmos_set_s3_resume(void *opaque, int irq, int level); qemu_irq *xen_interrupt_controller_init(void); void xenstore_store_pv_console_info(int i, struct CharDriverState *chr); +extern struct xs_handle *xs; +void xenstore_record_dm_state(struct xs_handle *xs, const char *state); #if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY) int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size, diff --git a/xen-common-stub.c b/xen-common-stub.c index 906f991..6fcfc96 100644 --- a/xen-common-stub.c +++ b/xen-common-stub.c @@ -11,3 +11,7 @@ void xenstore_store_pv_console_info(int i, CharDriverState *chr) { } + +void xenstore_record_dm_state(struct xs_handle *xs, const char *state) +{ +} diff --git a/xen-common.c b/xen-common.c index 56359ca..97fc312 100644 --- a/xen-common.c +++ b/xen-common.c @@ -83,8 +83,7 @@ void xenstore_store_pv_console_info(int i, CharDriverState *chr) } } - -static void xenstore_record_dm_state(struct xs_handle *xs, const char *state) +void xenstore_record_dm_state(struct xs_handle *xs, const char *state) { char path[50]; @@ -100,16 +99,6 @@ static void xenstore_record_dm_state(struct xs_handle *xs, const char *state) } } - -static void xen_change_state_handler(void *opaque, int running, - RunState state) -{ - if (running) { - /* record state running */ - xenstore_record_dm_state(xenstore, "running"); - } -} - static int xen_init(MachineState *ms) { xen_xc = xen_xc_interface_open(0, 0, 0); @@ -117,8 +106,6 @@ static int xen_init(MachineState *ms) xen_be_printf(NULL, 0, "can't open xen interface\n"); return -1; } - qemu_add_vm_change_state_handler(xen_change_state_handler, NULL); - return 0; } diff --git a/xen-hvm.c b/xen-hvm.c index 315864c..1ea567d 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -1108,6 +1108,7 @@ static void xen_hvm_change_state_handler(void *opaque, int running, if (running) { xen_main_loop_prepare(state); + xenstore_record_dm_state(state->xenstore, "running"); } xen_set_ioreq_server_state(xen_xc, xen_domid,