From patchwork Fri Mar 13 12:19:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11436815 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 427931668 for ; Fri, 13 Mar 2020 12:20:56 +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 1F81120746 for ; Fri, 13 Mar 2020 12:20:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="zPoxL+qp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F81120746 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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 1jCjI5-0004a6-C3; Fri, 13 Mar 2020 12:19:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCjI3-0004Zv-QG for xen-devel@lists.xenproject.org; Fri, 13 Mar 2020 12:19:47 +0000 X-Inumbo-ID: eddb6c90-6524-11ea-a6c1-bc764e2007e4 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id eddb6c90-6524-11ea-a6c1-bc764e2007e4; Fri, 13 Mar 2020 12:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=F3v8xDkGCyHYWhAoZOryYOwBcqnWAisS+RPsL8Ed5+8=; b=zPoxL+qpJJHjtiPL/Msvt9ZgPH cI3jUm3VeVBfeHQ/BUr73PSXnyfWICCnGVQ0ZaXB6nTRXrLNYZqo+obc4eqGjtHa4lU6i/SeSoQZB 56yVSAXhsWqB/UXp4EcVieGGa5v7l5RjyLrVcdtQDk/A4Tznr/17g8KhLEwO12zToOkM=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCjI2-0003gX-FN; Fri, 13 Mar 2020 12:19:46 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=u2f063a87eabd5f.cbg10.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jCjI2-0005yq-5Q; Fri, 13 Mar 2020 12:19:46 +0000 From: paul@xen.org To: xen-devel@lists.xenproject.org Date: Fri, 13 Mar 2020 12:19:41 +0000 Message-Id: <20200313121942.1213-2-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200313121942.1213-1-paul@xen.org> References: <20200313121942.1213-1-paul@xen.org> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 1/2] libxl: create domain 'error' node in xenstore 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , Andrew Cooper , Paul Durrant , Ian Jackson , George Dunlap , Jan Beulich , Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Paul Durrant Several PV drivers (both historically and currently [1]) report errors by writing text into /local/domain/$DOMID/error. This patch creates the node in libxl and makes it writable by the domain, and also adds some text into xenstore-paths.pandoc to state what the node is for. [1] https://xenbits.xen.org/gitweb/?p=pvdrivers/win/xenvif.git;a=blob;f=src/xenvif/frontend.c;hb=HEAD#l459 Signed-off-by: Paul Durrant Acked-by: Ian Jackson --- Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Wei Liu Cc: Anthony PERARD --- docs/misc/xenstore-paths.pandoc | 5 +++++ tools/libxl/libxl_create.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/docs/misc/xenstore-paths.pandoc b/docs/misc/xenstore-paths.pandoc index 0a6b36146e..e2ab5da54e 100644 --- a/docs/misc/xenstore-paths.pandoc +++ b/docs/misc/xenstore-paths.pandoc @@ -539,6 +539,11 @@ address written in one of these paths to, for example, establish a VNC session to the guest (although clearly some level of trust is placed in the value supplied by the guest in this case). +#### ~/error [w] + +A domain writable path used by some PV drivers to pass error messages +to the toolstack. + ### Paths private to the toolstack #### ~/device-model/$DOMID/state [w] diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 7891fae426..fb7b3999ae 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -797,6 +797,9 @@ retry_transaction: libxl__xs_mknod(gc, t, GCSPRINTF("%s/attr", dom_path), rwperm, ARRAY_SIZE(rwperm)); + libxl__xs_mknod(gc, t, + GCSPRINTF("%s/error", dom_path), + rwperm, ARRAY_SIZE(rwperm)); if (libxl_defbool_val(info->driver_domain)) { /* From patchwork Fri Mar 13 12:19:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11436813 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 1005F1392 for ; Fri, 13 Mar 2020 12:20:55 +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 D63F320749 for ; Fri, 13 Mar 2020 12:20:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="UrlPzNHA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D63F320749 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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 1jCjI9-0004ac-Kg; Fri, 13 Mar 2020 12:19:53 +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 1jCjI8-0004aP-7B for xen-devel@lists.xenproject.org; Fri, 13 Mar 2020 12:19:52 +0000 X-Inumbo-ID: eebf34ac-6524-11ea-b2da-12813bfff9fa Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id eebf34ac-6524-11ea-b2da-12813bfff9fa; Fri, 13 Mar 2020 12:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=TjblVi8FpPW+wylGkXka4/iSytmO+3aHcX+cgHexHmM=; b=UrlPzNHAn5zUrH6jHUHFtTwY0i +0mYd/ZJ2sI+P6tml+xORHz4dRwvrSTg+HJBx38IvqLWJ8AQia+FeuViQSncV4eX+TKmSntSdcIx3 4s4MJj3s9XL72CUBkhFGOS8LPP01noyhMs16pIfForVYcBW4mIcUenazX323ZkYDBsyY=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jCjI4-0003gd-2O; Fri, 13 Mar 2020 12:19:48 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=u2f063a87eabd5f.cbg10.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jCjI3-0005yq-PJ; Fri, 13 Mar 2020 12:19:48 +0000 From: paul@xen.org To: xen-devel@lists.xenproject.org Date: Fri, 13 Mar 2020 12:19:42 +0000 Message-Id: <20200313121942.1213-3-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200313121942.1213-1-paul@xen.org> References: <20200313121942.1213-1-paul@xen.org> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 2/2] libxl: make creation of xenstore 'suspend event channel' node optional... 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: Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Paul Durrant , Ian Jackson , George Dunlap , Jan Beulich , Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Paul Durrant ... and make the top level 'device' node in xenstore writable by the guest The purpose and semantics of the suspend event channel node are explained in xenstore-paths.pandoc [1]. It was originally introduced in xend by commit 17636f47a474 "Teach xc_save to use event-channel-based domain suspend if available.". Note that, because, the top-level frontend 'device' node was created writable by the guest in xend, there was no need to explicitly create the 'suspend-event-channel' node as writable node. However, libxl creates the 'device' node as read-only by the guest and so explicit creation of the 'suspend-event-channel' node is necessary to make it usable. This unfortunately has the side-effect of making some old Windows PV drivers [2] cease to function. This is because they scan the top level 'device' node, find the 'suspend' node and expect it to contain the usual sub-nodes describing a PV frontend. When this is found not to be the case, enumeration ceases and (because the 'suspend' node is observed before the 'vbd' node) no system disk is enumerated. Windows will then crash with bugcheck code 0x7B. This patch adds a boolean 'suspend_event_channel' field into libxl_create_info to control whether the xenstore node is created and a similarly named option in xl.cfg which, for compatibility with previous libxl behaviour, defaults to true. It also makes the top level device node writable, as xend did, and updates xenstore-paths.pandoc to say that the suspend event channel node may not exist and that the guest may create it if it does not exist. [1] https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/misc/xenstore-paths.pandoc;hb=HEAD#l177 [2] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/para-virtualized_windows_drivers_guide/sect-para-virtualized_windows_drivers_guide-installing_and_configuring_the_para_virtualized_drivers-installing_the_para_virtualized_drivers NOTE: While adding the new LIBXL_HAVE_CREATEINFO_SUSPEND_EVENT_CHANNEL definition into libxl.h, this patch corrects the previous stanza which erroneously implies libxl_domain_create_info is a function. Signed-off-by: Paul Durrant --- Cc: Ian Jackson Cc: Wei Liu Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Anthony PERARD v3: - Actually define LIBXL_HAVE_CREATEINFO_SUSPEND_EVENT_CHANNEL as well as commenting on it v2: - Update xenstore-paths.pandoc and squash patch #3 --- docs/man/xl.cfg.5.pod.in | 7 +++++++ docs/misc/xenstore-paths.pandoc | 7 ++++--- tools/libxl/libxl.h | 14 +++++++++++++- tools/libxl/libxl_create.c | 14 ++++++++++---- tools/libxl/libxl_types.idl | 1 + tools/xl/xl_parse.c | 3 +++ 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 0cad561375..5f476f1e1d 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -668,6 +668,13 @@ file. =back +=item B + +Create the xenstore path for the domain's suspend event channel. The +existence of this path can cause problems with older PV drivers running +in the guest. If this option is not specified then it will default to +B. + =back =head2 Devices diff --git a/docs/misc/xenstore-paths.pandoc b/docs/misc/xenstore-paths.pandoc index e2ab5da54e..a8eecdb7ed 100644 --- a/docs/misc/xenstore-paths.pandoc +++ b/docs/misc/xenstore-paths.pandoc @@ -176,10 +176,11 @@ The size of the video RAM this domain is configured with. #### ~/device/suspend/event-channel = ""|EVTCHN [w] -The domain's suspend event channel. The toolstack will create this -path with an empty value which the guest may choose to overwrite. +The domain's suspend event channel. The toolstack may create this +path with an empty value which the guest may choose to overwrite. If +the path does not exist then the guest may create it. -If the guest overwrites this, it will be with the number of an unbound +If the guest writes this, it will be with the number of an unbound event channel port it has acquired. The toolstack is expected to use an interdomain bind, and then, when it wishes to ask the guest to suspend, to signal the event channel. diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 35e13428b2..b97823823b 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -1272,10 +1272,22 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src); * LIBXL_HAVE_CREATEINFO_DOMID * * libxl_domain_create_new() and libxl_domain_create_restore() will use - * a domid specified in libxl_domain_create_info(). + * a domid specified in libxl_domain_create_info. */ #define LIBXL_HAVE_CREATEINFO_DOMID +/* + * LIBXL_HAVE_CREATEINFO_SUSPEND_EVENT_CHANNEL + * + * libxl_domain_create_info contains a boolean 'suspend_event_channel' + * value to control whether the xenstore path: + * + * /local/domain/$DOMID/device/suspend/event-channel (RW) + * + * is created. + */ +#define LIBXL_HAVE_CREATEINFO_SUSPEND_EVENT_CHANNEL + typedef char **libxl_string_list; void libxl_string_list_dispose(libxl_string_list *sl); int libxl_string_list_length(const libxl_string_list *sl); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index fb7b3999ae..8afb0ce2be 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -57,6 +57,8 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, if (!c_info->ssidref) c_info->ssidref = SECINITSID_DOMU; + libxl_defbool_setdefault(&c_info->suspend_event_channel, true); + return 0; } @@ -750,7 +752,7 @@ retry_transaction: roperm, ARRAY_SIZE(roperm)); libxl__xs_mknod(gc, t, GCSPRINTF("%s/device", dom_path), - roperm, ARRAY_SIZE(roperm)); + rwperm, ARRAY_SIZE(rwperm)); libxl__xs_mknod(gc, t, GCSPRINTF("%s/control", dom_path), roperm, ARRAY_SIZE(roperm)); @@ -782,9 +784,13 @@ retry_transaction: libxl__xs_mknod(gc, t, GCSPRINTF("%s/control/sysrq", dom_path), rwperm, ARRAY_SIZE(rwperm)); - libxl__xs_mknod(gc, t, - GCSPRINTF("%s/device/suspend/event-channel", dom_path), - rwperm, ARRAY_SIZE(rwperm)); + + if (libxl_defbool_val(info->suspend_event_channel)) + libxl__xs_mknod(gc, t, + GCSPRINTF("%s/device/suspend/event-channel", + dom_path), + rwperm, ARRAY_SIZE(rwperm)); + libxl__xs_mknod(gc, t, GCSPRINTF("%s/data", dom_path), rwperm, ARRAY_SIZE(rwperm)); diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index d0d431614f..2bce19bcf0 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -418,6 +418,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ ("run_hotplug_scripts",libxl_defbool), ("driver_domain",libxl_defbool), ("passthrough", libxl_passthrough), + ("suspend_event_channel",libxl_defbool), ], dir=DIR_IN) libxl_domain_restore_params = Struct("domain_restore_params", [ diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index b881184804..122c6eb641 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2725,6 +2725,9 @@ skip_usbdev: parse_vkb_list(config, d_config); + xlu_cfg_get_defbool(config, "suspend_event_channel", + &c_info->suspend_event_channel, 0); + xlu_cfg_destroy(config); }