From patchwork Mon Aug 23 09:50:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 62468 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CB1AAB70CB for ; Mon, 23 Aug 2010 20:07:37 +1000 (EST) Received: from localhost ([127.0.0.1]:37247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnTwE-00046H-Nq for incoming@patchwork.ozlabs.org; Mon, 23 Aug 2010 06:07:34 -0400 Received: from [140.186.70.92] (port=36539 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnTg0-00079X-Tu for qemu-devel@nongnu.org; Mon, 23 Aug 2010 05:50:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnTfz-00006T-GO for qemu-devel@nongnu.org; Mon, 23 Aug 2010 05:50:48 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:59698) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnTfz-0008VE-B2 for qemu-devel@nongnu.org; Mon, 23 Aug 2010 05:50:47 -0400 X-IronPort-AV: E=Sophos;i="4.56,256,1280721600"; d="scan'208";a="110803821" Received: from ftlpexchmx01.citrite.net ([10.9.154.126]) by FTLPIPO02.CITRIX.COM with ESMTP; 23 Aug 2010 05:50:47 -0400 Received: from smtp01.ad.xensource.com ([10.219.128.104]) by FTLPEXCHMX01.citrite.net with Microsoft SMTPSVC(6.0.3790.4675); Mon, 23 Aug 2010 05:50:46 -0400 Received: from localhost.localdomain (kaball.uk.xensource.com [10.80.2.59]) by smtp01.ad.xensource.com (8.13.1/8.13.1) with ESMTP id o7N9oTHn011158; Mon, 23 Aug 2010 02:50:45 -0700 From: stefano.stabellini@eu.citrix.com To: qemu-devel@nongnu.org Date: Mon, 23 Aug 2010 10:50:44 +0100 Message-Id: <1282557052-14285-7-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: X-OriginalArrivalTime: 23 Aug 2010 09:50:46.0178 (UTC) FILETIME=[A8A90820:01CB42A8] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Anthony.Perard@citrix.com, Anthony PERARD , xen-devel@lists.xensource.com, stefano.stabellini@eu.citrix.com Subject: [Qemu-devel] [PATCH 07/15] xen: handle xenstore events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Anthony PERARD Add an handler to process xenstore events. Signed-off-by: Anthony PERARD Signed-off-by: Stefano Stabellini --- target-xen/xenstore.c | 30 +++++++++++++++++++++++++++++- 1 files changed, 29 insertions(+), 1 deletions(-) diff --git a/target-xen/xenstore.c b/target-xen/xenstore.c index bd74787..331b25f 100644 --- a/target-xen/xenstore.c +++ b/target-xen/xenstore.c @@ -1,13 +1,41 @@ #include "hw/xen_backend.h" #include "xenstore.h" +static void xenstore_process_event(void *opaque) +{ + char **vec; + unsigned int num; + + vec = xs_read_watch(xenstore, &num); + if (!vec) + return; + + free(vec); +} + int xen_dm_init(void) { + xenstore = xs_daemon_open(); + if (!xenstore) { + xen_be_printf(NULL, 0, "can't connect to xenstored\n"); + return -1; + } + + if (qemu_set_fd_handler(xs_fileno(xenstore), xenstore_process_event, NULL, NULL) < 0) + goto err; + xen_xc = xc_interface_open(NULL, NULL, 0); if (xen_xc == NULL) { xen_be_printf(NULL, 0, "can't open xen interface\n"); - return -1; + goto err; } return 0; + +err: + qemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL); + xs_daemon_close(xenstore); + xenstore = NULL; + + return -1; }