From patchwork Wed Nov 1 15:05:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 10036465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 59EE6602B5 for ; Wed, 1 Nov 2017 15:07:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E69552843B for ; Wed, 1 Nov 2017 15:07:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB68628C51; Wed, 1 Nov 2017 15:07:33 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7079B28C44 for ; Wed, 1 Nov 2017 15:07:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9ua1-0005IU-5y; Wed, 01 Nov 2017 15:05:21 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9ua0-0005FS-7x for xen-devel@lists.xenproject.org; Wed, 01 Nov 2017 15:05:20 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id 3B/44-08608-0B2E9F95; Wed, 01 Nov 2017 15:05:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNIsWRWlGSWpSXmKPExsVyMfS6o+76Rz8 jDZZuFbX4vmUykwOjx+EPV1gCGKNYM/OS8isSWDM2vJ/AXjBHoeLE9JXsDYwNkl2MXBxCAtMY JSaf2s0O4rAIvGSROLRmIwuIIyHQzyqxb/J5xi5GTiAnS+L1vmZWCDtN4uKGFywQdonEzkcbm EFsIQF5iYMtl9khxk5lkpgxexdYEZuAlsT92yvYQGwRASWJe6smM4HYzAIpEnvXtYEtEBawlZ g1oRnMZhFQldj5+BWYzStgLzHxyFJ2iGVyEjfPdYIt4xRwkDjSMpMJYrG9xM9Zs9gmMAouYGR YxahRnFpUllqka2Sml1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kRGHQMQLCD8cyC wEOMkhxMSqK8mvd/RgrxJeWnVGYkFmfEF5XmpBYfYtTg4BD4+fRvC6MUS15+XqqSBO/xh0B1g kWp6akVaZk5wLiAKZXg4FES4d0IkuYtLkjMLc5Mh0idYrTnuHDn0h8mjgN7bgHJjpt3geSzma 8bmIXApkqJ8zIAI1FIAKQtozQPbigsji8xykoJ8zICnSzEU5BalJtZgir/ilGcg1FJmPc0yHK ezLwSuN2vgM5iAjrLS+IHyFkliQgpqQbGA85G7+ovpUVm9svUb/dT2Lpqgd8C4ZW9G6YeKBbr mni6qPN42c3M6BtiZcmKx17/ihfwKdt/qCVv0TbPj/JvN+y4zMP+Le/K6x01Lvs6nnz5Mrs1L uHZao2MC0oyFx62RtR+Oee7fg3zEvcmeY1jWTWrszyNTyl86DUvjitY8XfF53SVU4/8lViKMx INtZiLihMBpMDt0d4CAAA= X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1509548718!69692020!1 X-Originating-IP: [209.85.215.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49456 invoked from network); 1 Nov 2017 15:05:19 -0000 Received: from mail-lf0-f65.google.com (HELO mail-lf0-f65.google.com) (209.85.215.65) by server-5.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Nov 2017 15:05:19 -0000 Received: by mail-lf0-f65.google.com with SMTP id 75so2894649lfx.1 for ; Wed, 01 Nov 2017 08:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rS1nu3vz9hD3JUC1CsqmbfzwWvakLVqy8FgJxhze5Q4=; b=kNNNNid4XB+ldBIcfbuS5pfjppiSe3oDnlrxRRliIxLc0yj8faiIdpJk5kNcavMLB/ bEmx3F482TF+7J9Yir4Iry3c2bJkLgJYUmPtKME+MTGLoAY2BKAYfebdw9YBod4+Sq9y W92jNcKN4CPF8o25v5ZppvahAbkCAayfmKSxhFZaMY72yv+WCFV7ZS5CW312afphiWx8 Fyvjc8X+mevNk5YXObUNbTiMxH1LBNI4OmadvTXX+P/zMi9QP5nHF6enFvnNUWO3+hl6 cEcPubccLC8QUVXPtb+gjw5tbA478CTr/zskVz8eSdCfnC7GUOlUUiO3wr4xeL6Y5hps Sdeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rS1nu3vz9hD3JUC1CsqmbfzwWvakLVqy8FgJxhze5Q4=; b=qgNv779HlI5DgRwl28yjyxkrFukLuXFPK/jUK3V/D1VL6J5WBQrxsH7e7LEiOzzTdC SQHKgyb7yOVe4ctFllsst8kgBqP1gLk0uLpGF9WkPSOerzLpqLlT6hqpvQUiK0k7XAck QyGO6tb4KtUyUoaQPE6pUFBqqhoJqVWnyxVtYjUr9NC1CjCMZAeaGLCi56UQ3Ok93C4t qxLwC6fMoseq4FpuWPPSXnwHeShjXYP69rixohhNBCxw31DDsCyw86oVY+ONVoce7fWA sMZuNLvcam6+wsRMCp03FeC4pzgwaSwSWcDsF8IAuoFw2iK3syIOTYAM3vuh3QHYCMvn rS9w== X-Gm-Message-State: AMCzsaUAZkP51YCe+pjwseudguvu4mck95MSurJqsi67UadNIE8zd5X1 Ht6CYI/n4P+WEm0nOAyYWwvm4Q== X-Google-Smtp-Source: ABhQp+RptWnmB0hPl8HDKo270Pz2mq12YUgQO6gOTmaZ0OC2O2VFH6MOjQi9HeqvXQDqQ3O0MgSHgQ== X-Received: by 10.46.4.206 with SMTP id a75mr78259ljf.6.1509548718436; Wed, 01 Nov 2017 08:05:18 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-59.209.223.85.sovam.net.ua. [85.223.209.59]) by smtp.gmail.com with ESMTPSA id o88sm139569lfk.33.2017.11.01.08.05.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Nov 2017 08:05:17 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Wed, 1 Nov 2017 17:05:04 +0200 Message-Id: <1509548707-6134-4-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509548707-6134-1-git-send-email-al1img@gmail.com> References: <1509548707-6134-1-git-send-email-al1img@gmail.com> Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH v1 3/6] libxl: add backend type and id to vkb X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Grytsov New field backend_type is added to vkb device in order to have QEMU and user space backend simultaneously. Each vkb backend shall read appropriate XS entry and service only own frontends. Id is a string field which used by the backend to indentify the frontend. Signed-off-by: Oleksandr Grytsov --- tools/libxl/libxl_create.c | 3 +++ tools/libxl/libxl_dm.c | 1 + tools/libxl/libxl_types.idl | 8 ++++++++ tools/libxl/libxl_vkb.c | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index f813114..60d8686 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1376,6 +1376,9 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, for (i = 0; i < d_config->num_vfbs; i++) { libxl__device_add(gc, domid, &libxl__vfb_devtype, &d_config->vfbs[i]); + } + + for (i = 0; i < d_config->num_vkbs; i++) { libxl__device_add(gc, domid, &libxl__vkb_devtype, &d_config->vkbs[i]); } diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 98f89a9..f07de35 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1728,6 +1728,7 @@ static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc, vkb->backend_domid = 0; vkb->devid = 0; + return 0; } diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index cd0c06f..c3876a2 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -240,6 +240,12 @@ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [ (2, "COLO"), ]) +libxl_vkb_backend = Enumeration("vkb_backend", [ + (0, "UNKNOWN"), + (1, "QEMU"), + (2, "LINUX") + ]) + # # Complex libxl types # @@ -603,6 +609,8 @@ libxl_device_vkb = Struct("device_vkb", [ ("backend_domid", libxl_domid), ("backend_domname", string), ("devid", libxl_devid), + ("backend_type", libxl_vkb_backend), + ("id", string) ]) libxl_device_disk = Struct("device_disk", [ diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c index ea6fca8..88ab186 100644 --- a/tools/libxl/libxl_vkb.c +++ b/tools/libxl/libxl_vkb.c @@ -17,6 +17,10 @@ static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid, libxl_device_vkb *vkb, bool hotplug) { + if (vkb->backend_type == LIBXL_VKB_BACKEND_UNKNOWN) { + vkb->backend_type = LIBXL_VKB_BACKEND_QEMU; + } + return libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid); } @@ -34,6 +38,30 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, return 0; } +static int libxl__device_vkb_dm_needed(libxl_device_vkb *vkb, uint32_t domid) +{ + if (vkb->backend_type == LIBXL_VKB_BACKEND_QEMU) { + return 1; + } + + return 0; +} + +static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t domid, + libxl_device_vkb *vkb, + flexarray_t *back, flexarray_t *front, + flexarray_t *ro_front) +{ + if (vkb->id) { + flexarray_append_pair(front, "id", vkb->id); + } + + flexarray_append_pair(back, "backend-type", + (char *)libxl_vkb_backend_to_string(vkb->backend_type)); + + return 0; +} + int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb, const libxl_asyncop_how *ao_how) { @@ -60,7 +88,10 @@ static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkbd") LIBXL_DEFINE_DEVICE_REMOVE(vkb) DEFINE_DEVICE_TYPE_STRUCT_X(vkb, vkb, vkbd - .skip_attach = 1 + .skip_attach = 1, + .dm_needed = (device_dm_needed_fn_t)libxl__device_vkb_dm_needed, + .set_xenstore_config = (device_set_xenstore_config_fn_t) + libxl__set_xenstore_vkb ); /*