From patchwork Thu Mar 8 19:03:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 883267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=eu.citrix.com 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 3zy0Ll0JWmz9s23 for ; Fri, 9 Mar 2018 06:04:47 +1100 (AEDT) Received: from localhost ([::1]:41033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eu0qK-0000r6-Sp for incoming@patchwork.ozlabs.org; Thu, 08 Mar 2018 14:04:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eu0pP-0000mN-Dm for qemu-devel@nongnu.org; Thu, 08 Mar 2018 14:03:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eu0pN-0002dQ-Ia for qemu-devel@nongnu.org; Thu, 08 Mar 2018 14:03:47 -0500 Received: from smtp.citrix.com ([66.165.176.89]:27694) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1eu0pN-0002cK-Bg for qemu-devel@nongnu.org; Thu, 08 Mar 2018 14:03:45 -0500 X-IronPort-AV: E=Sophos;i="5.47,441,1515456000"; d="scan'208";a="467121773" From: Ian Jackson To: Date: Thu, 8 Mar 2018 19:03:06 +0000 Message-ID: <1520535787-6223-12-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1520535787-6223-1-git-send-email-ian.jackson@eu.citrix.com> References: <1520535787-6223-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.89 Subject: [Qemu-devel] [PATCH 11/12] xen: Expect xenstore write to fail when restricted X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Ian Jackson , Ross Lagerwall , Anthony PERARD , xen-devel@lists.xenproject.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ross Lagerwall Saving the current state to xenstore may fail when running restricted (in particular, after a migration). Therefore, don't report the error or exit when running restricted. Toolstacks that want to allow running QEMU restricted should instead make use of QMP events to listen for state changes. CC: Ian Jackson Signed-off-by: Ross Lagerwall Reviewed-by: Ian Jackson Acked-by: Anthony PERARD --- v6: New patch in this version of the series --- hw/xen/xen-common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c index f73b416..8ede246 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -101,7 +101,12 @@ static void xenstore_record_dm_state(struct xs_handle *xs, const char *state) } snprintf(path, sizeof (path), "device-model/%u/state", xen_domid); - if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) { + /* + * This call may fail when running restricted so don't make it fatal in + * that case. Toolstacks should instead use QMP to listen for state changes. + */ + if (!xs_write(xs, XBT_NULL, path, state, strlen(state)) && + !xen_domid_restrict) { error_report("error recording dm state"); exit(1); }