From patchwork Tue May 14 08:43:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eslam Elnikety X-Patchwork-Id: 10942491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 96250924 for ; Tue, 14 May 2019 08:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85940284C8 for ; Tue, 14 May 2019 08:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78DCA284E8; Tue, 14 May 2019 08:45:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 074EB284C8 for ; Tue, 14 May 2019 08:45:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hQT28-0003Fo-91; Tue, 14 May 2019 08:43:36 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hQT27-0003Fj-7f for xen-devel@lists.xenproject.org; Tue, 14 May 2019 08:43:35 +0000 X-Inumbo-ID: 5b4a7933-7624-11e9-8980-bc764e045a96 Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 5b4a7933-7624-11e9-8980-bc764e045a96; Tue, 14 May 2019 08:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1557823413; x=1589359413; h=from:to:cc:subject:date:message-id:mime-version; bh=oEs3tmuUdFVTWo0F+kGSOEH0GiYDsh7jceXRWTPtAYc=; b=ssUvh2DfRD9EKB7/Jp62FfCDrXmpuG4NasFrAcPurIB+ErDb9Rcd3jkJ 5Yb8sd8AqGOKqgKW5njV+xoE7EOViR4scRVmV4x7Y23jWxBow3ssAcXyX obecpxBp1azkFfRnxVUDB0zRaO0ZF6tynt9bg/gwkZVZS/4ZUwu57E0eX w=; X-IronPort-AV: E=Sophos;i="5.60,468,1549929600"; d="scan'208";a="396391737" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 14 May 2019 08:43:32 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-17c49630.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id x4E8hVe9018951 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Tue, 14 May 2019 08:43:32 GMT Received: from EX13D03EUC004.ant.amazon.com (10.43.164.33) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 14 May 2019 08:43:31 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D03EUC004.ant.amazon.com (10.43.164.33) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 14 May 2019 08:43:30 +0000 Received: from dev-dsk-elnikety-1c-28a13cba.eu-west-1.amazon.com (10.15.5.186) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 14 May 2019 08:43:29 +0000 Received: by dev-dsk-elnikety-1c-28a13cba.eu-west-1.amazon.com (Postfix, from userid 6438462) id 66960465BA; Tue, 14 May 2019 08:43:29 +0000 (UTC) From: Eslam Elnikety To: Date: Tue, 14 May 2019 08:43:25 +0000 Message-ID: <20190514084325.43928-1-elnikety@amazon.com> X-Mailer: git-send-email 2.15.3.AMZN MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v3] libxl: make vkbd tunable for HVM guests X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Ian Jackson , Eslam Elnikety , Amit Shah Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Each HVM guest currently gets a vkbd frontend/backend pair (c/s ebbd2561b4c). This consumes host resources unnecessarily for guests that have no use for vkbd. Make this behaviour tunable to allow an administrator to choose. The commit retains the current behaviour -- HVM guests still get vkdb unless specified otherwise. Signed-off-by: Eslam Elnikety Acked-by: Wei Liu Signed-off-by: Eslam Elnikety > --- Changes in v2: - Added a missing hunk / setting vkb_device per config Changes in v3: - Added entries in libxl.h and in documentation --- docs/man/xl.cfg.pod.5.in | 4 ++++ tools/libxl/libxl.h | 9 +++++++++ tools/libxl/libxl_create.c | 9 ++++++--- tools/libxl/libxl_types.idl | 1 + tools/xl/xl_parse.c | 1 + tools/xl/xl_sxp.c | 2 ++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in index 47d88243b1..c3641c7a57 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -2286,6 +2286,10 @@ devices are defined by the device model configuration, please see the B manpage for details. The default is not to export any sound device. +=item B + +Specifies that the HVM guest gets a vkdb. The default is true (1). + =item B Enables or disables an emulated USB bus in the guest. diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index a09d069358..6884c1492a 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -616,6 +616,15 @@ typedef struct libxl__ctx libxl_ctx; */ #define LIBXL_HAVE_BUILDINFO_VCPU_AFFINITY_ARRAYS 1 +/* + * LIBXL_HAVE_BUILDINFO_VKB_DEVICE + * + * If this is defined, then the libxl_domain_build_info structure will + * contain a boolean hvm.vkb_device which instructs libxl whether to include + * a vkbd at build time or not. + */ +#define LIBXL_HAVE_BUILDINFO_VKB_DEVICE 1 + /* * LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST * diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 5c9dd4cd21..8aecb9cfba 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -308,6 +308,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_defbool_setdefault(&b_info->u.hvm.vpt_align, true); libxl_defbool_setdefault(&b_info->u.hvm.altp2m, false); libxl_defbool_setdefault(&b_info->u.hvm.usb, false); + libxl_defbool_setdefault(&b_info->u.hvm.vkb_device, true); libxl_defbool_setdefault(&b_info->u.hvm.xen_platform_pci, true); libxl_defbool_setdefault(&b_info->u.hvm.spice.enable, false); @@ -1393,9 +1394,11 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, libxl__device_console_add(gc, domid, &console, state, &device); libxl__device_console_dispose(&console); - libxl_device_vkb_init(&vkb); - libxl__device_add(gc, domid, &libxl__vkb_devtype, &vkb); - libxl_device_vkb_dispose(&vkb); + if (libxl_defbool_val(d_config->b_info.u.hvm.vkb_device)) { + libxl_device_vkb_init(&vkb); + libxl__device_add(gc, domid, &libxl__vkb_devtype, &vkb); + libxl_device_vkb_dispose(&vkb); + } dcs->sdss.dm.guest_domid = domid; if (libxl_defbool_val(d_config->b_info.device_model_stubdomain)) diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 01ec1d1afa..1d436aa8bb 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -571,6 +571,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ # - "tablet" for absolute mouse, # - "mouse" for PS/2 protocol relative mouse ("usbdevice", string), + ("vkb_device", libxl_defbool), ("soundhw", string), ("xen_platform_pci", libxl_defbool), ("usbdevice_list", libxl_string_list), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index e6c54483e0..37bc13bd83 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2295,6 +2295,7 @@ skip_usbdev: fprintf(stderr,"xl: Unable to parse usbdevice.\n"); exit(-ERROR_FAIL); } + xlu_cfg_get_defbool(config, "vkb_device", &b_info->u.hvm.vkb_device, 0); xlu_cfg_replace_string (config, "soundhw", &b_info->u.hvm.soundhw, 0); xlu_cfg_get_defbool(config, "xen_platform_pci", &b_info->u.hvm.xen_platform_pci, 0); diff --git a/tools/xl/xl_sxp.c b/tools/xl/xl_sxp.c index 3e6117d0cd..359a001570 100644 --- a/tools/xl/xl_sxp.c +++ b/tools/xl/xl_sxp.c @@ -138,6 +138,8 @@ void printf_info_sexp(int domid, libxl_domain_config *d_config, FILE *fh) fprintf(fh, "\t\t\t(boot %s)\n", b_info->u.hvm.boot); fprintf(fh, "\t\t\t(usb %s)\n", libxl_defbool_to_string(b_info->u.hvm.usb)); fprintf(fh, "\t\t\t(usbdevice %s)\n", b_info->u.hvm.usbdevice); + fprintf(fh, "\t\t\t(vkb_device %s)\n", + libxl_defbool_to_string(b_info->u.hvm.vkb_device)); fprintf(fh, "\t\t)\n"); break; case LIBXL_DOMAIN_TYPE_PV: