From patchwork Wed Jan 15 02:39:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= X-Patchwork-Id: 11333205 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 B800592A for ; Wed, 15 Jan 2020 02:41: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 93CBC222C3 for ; Wed, 15 Jan 2020 02:41:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rUC2YxIF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93CBC222C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=invisiblethingslab.com 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 1irYbu-00057L-DJ; Wed, 15 Jan 2020 02:40:46 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1irYbt-00055h-8Q for xen-devel@lists.xenproject.org; Wed, 15 Jan 2020 02:40:45 +0000 X-Inumbo-ID: 5fb597c3-3740-11ea-84bb-12813bfff9fa Received: from out2-smtp.messagingengine.com (unknown [66.111.4.26]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5fb597c3-3740-11ea-84bb-12813bfff9fa; Wed, 15 Jan 2020 02:40:21 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 1B2C121FE5; Tue, 14 Jan 2020 21:40:21 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Tue, 14 Jan 2020 21:40:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=aWY4Ovzkm/CoWLS9XJcYhEWWwKS8NNPJ4rrxMcAV7 zE=; b=rUC2YxIFp1tWh6pfAa9hBJHQN4vdDo8GeH8/K2V+16Wq4a30vyEryLTQQ iaAjvMhalBlgV1c4IAFMTvk2sN0VScfzaIa2FXhwMGatkWHenH70HtpxUlnRfpSR mXV9V4VkVRNOYsOvVSsC78842blTl4N5yZROXVD6NrpRlfgkpwG3bnSveHcVtUgL /wnx7tnaxpcUrCGssLOSscbMlQOivYvOaPAgBv0AldXGKgde5JPUa4LmIPvqbzJ4 nSe6XrqPce4W4w8mmKoAhy3mODgxz50SNct2kfieXF1IgjHs2Z+cLlIMhOKuHOSt Oy0kHOiaKsWua0LXr5VTPaxoXggCw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrtddvgdegkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpeeh X-ME-Proxy: Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id CAE11306080E; Tue, 14 Jan 2020 21:40:19 -0500 (EST) From: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Wed, 15 Jan 2020 03:39:48 +0100 Message-Id: <69e9fee9c192d8ea77b1d618f4e25d8b59534346.1579055705.git-series.marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 09/16] libxl: add save/restore support for qemu-xen in stubdomain X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , =?utf-8?q?Marek_Marczykowski-G?= =?utf-8?q?=C3=B3recki?= , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Rely on a wrapper script in stubdomain to attach FD 3/4 of qemu to relevant consoles. Signed-off-by: Marek Marczykowski-Górecki --- Changes in v3: - adjust for qmp_ev* - assume specific fdset id in qemu set in stubdomain --- tools/libxl/libxl_dm.c | 23 +++++++++++------------ tools/libxl/libxl_qmp.c | 25 ++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index bf49262..528ca3e 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1728,10 +1728,17 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, } if (state->saved_state) { - /* This file descriptor is meant to be used by QEMU */ - *dm_state_fd = open(state->saved_state, O_RDONLY); - flexarray_append(dm_args, "-incoming"); - flexarray_append(dm_args, GCSPRINTF("fd:%d",*dm_state_fd)); + if (is_stubdom) { + /* Linux stubdomain connects specific FD to STUBDOM_CONSOLE_RESTORE + */ + flexarray_append(dm_args, "-incoming"); + flexarray_append(dm_args, "fd:3"); + } else { + /* This file descriptor is meant to be used by QEMU */ + *dm_state_fd = open(state->saved_state, O_RDONLY); + flexarray_append(dm_args, "-incoming"); + flexarray_append(dm_args, GCSPRINTF("fd:%d",*dm_state_fd)); + } } for (i = 0; b_info->extra && b_info->extra[i] != NULL; i++) flexarray_append(dm_args, b_info->extra[i]); @@ -2202,14 +2209,6 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) assert(libxl_defbool_val(guest_config->b_info.device_model_stubdomain)); - if (libxl__stubdomain_is_linux(&guest_config->b_info)) { - if (d_state->saved_state) { - LOG(ERROR, "Save/Restore not supported yet with Linux Stubdom."); - ret = -1; - goto out; - } - } - sdss->pvqemu.guest_domid = 0; libxl_domain_create_info_init(&dm_config->c_info); diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index efaba91..0f38546 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -962,6 +962,7 @@ static void dm_stopped(libxl__egc *egc, libxl__ev_qmp *ev, const libxl__json_object *response, int rc); static void dm_state_fd_ready(libxl__egc *egc, libxl__ev_qmp *ev, const libxl__json_object *response, int rc); +static void dm_state_save_to_fdset(libxl__egc *egc, libxl__ev_qmp *ev, int fdset); static void dm_state_saved(libxl__egc *egc, libxl__ev_qmp *ev, const libxl__json_object *response, int rc); @@ -994,10 +995,17 @@ static void dm_stopped(libxl__egc *egc, libxl__ev_qmp *ev, EGC_GC; libxl__domain_suspend_state *dsps = CONTAINER_OF(ev, *dsps, qmp); const char *const filename = dsps->dm_savefile; + uint32_t dm_domid = libxl_get_stubdom_id(CTX, dsps->domid); if (rc) goto error; + if (dm_domid) { + /* see Linux stubdom interface in docs/stubdom.txt */ + dm_state_save_to_fdset(egc, ev, 1); + return; + } + ev->payload_fd = open(filename, O_WRONLY | O_CREAT, 0600); if (ev->payload_fd < 0) { LOGED(ERROR, ev->domid, @@ -1028,7 +1036,6 @@ static void dm_state_fd_ready(libxl__egc *egc, libxl__ev_qmp *ev, EGC_GC; int fdset; const libxl__json_object *o; - libxl__json_object *args = NULL; libxl__domain_suspend_state *dsps = CONTAINER_OF(ev, *dsps, qmp); close(ev->payload_fd); @@ -1043,6 +1050,21 @@ static void dm_state_fd_ready(libxl__egc *egc, libxl__ev_qmp *ev, goto error; } fdset = libxl__json_object_get_integer(o); + dm_state_save_to_fdset(egc, ev, fdset); + return; + +error: + assert(rc); + libxl__remove_file(gc, dsps->dm_savefile); + dsps->callback_device_model_done(egc, dsps, rc); +} + +static void dm_state_save_to_fdset(libxl__egc *egc, libxl__ev_qmp *ev, int fdset) +{ + EGC_GC; + int rc; + libxl__json_object *args = NULL; + libxl__domain_suspend_state *dsps = CONTAINER_OF(ev, *dsps, qmp); ev->callback = dm_state_saved; @@ -1060,6 +1082,7 @@ static void dm_state_fd_ready(libxl__egc *egc, libxl__ev_qmp *ev, error: assert(rc); + /* TODO: only in non-stubdom case */ libxl__remove_file(gc, dsps->dm_savefile); dsps->callback_device_model_done(egc, dsps, rc); }