From patchwork Thu Nov 21 18:12:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 11256723 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 BB8DE930 for ; Thu, 21 Nov 2019 18:14:21 +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 96984206CC for ; Thu, 21 Nov 2019 18:14:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O4QyPFMD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96984206CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 1iXqxG-0003h8-Ef; Thu, 21 Nov 2019 18:13:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXqxE-0003h0-Fu for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:13:20 +0000 X-Inumbo-ID: 960fc6b6-0c8a-11ea-b678-bc764e2007e4 Received: from mail-lj1-x241.google.com (unknown [2a00:1450:4864:20::241]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 960fc6b6-0c8a-11ea-b678-bc764e2007e4; Thu, 21 Nov 2019 18:13:15 +0000 (UTC) Received: by mail-lj1-x241.google.com with SMTP id n21so4259026ljg.12 for ; Thu, 21 Nov 2019 10:13:15 -0800 (PST) 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=vmHjM/yNQDVb3d99oqBTxU/+bM3gnk43l/8H0I2tmtU=; b=O4QyPFMDRX9OVEZdz0G3896rv+IK37ZbbdTkzI3ySL35+N4GVD++Yeo9xooBbqKmvN iyb0DL02thxr4Zgj8GSD6HKbg1B07PW+/TFqsH5KViX8gk7/XHM4os0xp4h/2+yXqtem HIAfgAPJxPoSJ4EWygld0kMrTzCofGKUR6g4LxMbddsw++5jsEb7sIO2AGReOhqIv99M EVhRFGWBf2w8A8TzvCLSIGcUG9WsNfXcrVPjvrqayZPcNQoQYVZHvADJ8qeaeowYCa5J 8ayOWcoJKSoHnbj8YyOInEO/EavV+whQVG1X3EgKeHGBCC8lltXfrL0SkdtzsIjxoRtp LL7Q== 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=vmHjM/yNQDVb3d99oqBTxU/+bM3gnk43l/8H0I2tmtU=; b=Pd7xQVnD/C1+MCrCn+2PRi8/lkL9wWV+i1SAFCr1cLqKRj4flcIbMrtTzqyZllIEfq 8qaPE9hq05CtrtcTyiWD8WbgbpO0F5Jfv7jrwaMCMi9F0kiKhL3BeIUYuM7BUf4niYhy z6Y2UZWbXAMEMwXhkRqDnW+w44UxxsJGGNGwYAdX85prCoPwsQtfrCwUtvhPth/cszjH h8MPoHIPD6bIqe7mmdT3JnOwc+z5OnFy4WFW8/yu9gWGS8ATK7eKHm2OMMqDzW/gyPvv HbuULewvEMhFm+3tcstJqY7kJYxW/Fzcl5T7LAapb2DjrmMa+WK4E9bi3gotzRLnDc7H 6uiw== X-Gm-Message-State: APjAAAXMbh066dA4XAfIytVED8Yj39ECtPz4pxhTPX29UYYisTFcVLr4 9h0L15Us4+L+vpl3eFCp8/jneYo26nGUxA== X-Google-Smtp-Source: APXvYqwsNLAYhMrP8Xmxwu7zD00lD1RYqbG5kAgRvhecoowEbwwrHPxvWyqickkOmJbjPDtVNgQosQ== X-Received: by 2002:a2e:22c1:: with SMTP id i184mr8998683lji.1.1574359994401; Thu, 21 Nov 2019 10:13:14 -0800 (PST) Received: from al1-pc.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id v12sm1855473lfb.47.2019.11.21.10.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:13:13 -0800 (PST) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Thu, 21 Nov 2019 20:12:58 +0200 Message-Id: <20191121181300.6497-2-al1img@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191121181300.6497-1-al1img@gmail.com> References: <20191121181300.6497-1-al1img@gmail.com> Subject: [Xen-devel] [PATCH v2 1/3] libxl: introduce new backend type VINPUT 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@citrix.com, Oleksandr Grytsov , ian.jackson@eu.citrix.com, wl@xen.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Grytsov There are two kind of VKBD devices: with QEMU backend and user space PV backend. In current implementation they can't be distinguished as both use VKBD backend type. As result, user space PV KBD backend is started and stopped as QEMU backend. This commit adds new device kind VINPUT to be used as backend type for user space PV KBD backend. Signed-off-by: Oleksandr Grytsov Acked-by: Ian Jackson Acked-by: Anthony PERARD --- tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vkb.c | 29 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tools/libxl/libxl_types_internal.idl b/tools/libxl/libxl_types_internal.idl index cb85c3b37f..3593e21dbb 100644 --- a/tools/libxl/libxl_types_internal.idl +++ b/tools/libxl/libxl_types_internal.idl @@ -31,6 +31,7 @@ libxl__device_kind = Enumeration("device_kind", [ (13, "VUART"), (14, "PVCALLS"), (15, "VSND"), + (16, "VINPUT"), ]) libxl__console_backend = Enumeration("console_backend", [ diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c index 26376a7eef..4c44a813c1 100644 --- a/tools/libxl/libxl_vkb.c +++ b/tools/libxl/libxl_vkb.c @@ -38,9 +38,6 @@ static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t domid, flexarray_t *back, flexarray_t *front, flexarray_t *ro_front) { - flexarray_append_pair(back, "backend-type", - (char *)libxl_vkb_backend_to_string(vkb->backend_type)); - if (vkb->unique_id) { flexarray_append_pair(back, XENKBD_FIELD_UNIQUE_ID, vkb->unique_id); } @@ -93,7 +90,8 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path, libxl_devid devid, libxl_device_vkb *vkb) { - const char *be_path, *be_type, *fe_path, *tmp; + const char *be_path, *fe_path, *tmp; + libxl__device dev; int rc; vkb->devid = devid; @@ -111,13 +109,11 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path, rc = libxl__backendpath_parse_domid(gc, be_path, &vkb->backend_domid); if (rc) goto out; - rc = libxl__xs_read_mandatory(gc, XBT_NULL, - GCSPRINTF("%s/backend-type", be_path), - &be_type); + rc = libxl__parse_backend_path(gc, be_path, &dev); if (rc) goto out; - rc = libxl_vkb_backend_from_string(be_type, &vkb->backend_type); - if (rc) goto out; + vkb->backend_type = dev.backend_kind == LIBXL__DEVICE_KIND_VINPUT ? + LIBXL_VKB_BACKEND_LINUX : LIBXL_VKB_BACKEND_QEMU; vkb->unique_id = xs_read(CTX->xsh, XBT_NULL, GCSPRINTF("%s/"XENKBD_FIELD_UNIQUE_ID, be_path), NULL); @@ -218,6 +214,20 @@ out: return rc; } +static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, + libxl_device_vkb *type, libxl__device *device) +{ + device->backend_devid = type->devid; + device->backend_domid = type->backend_domid; + device->backend_kind = type->backend_type == LIBXL_VKB_BACKEND_LINUX ? + LIBXL__DEVICE_KIND_VINPUT : LIBXL__DEVICE_KIND_VKBD; + device->devid = type->devid; + device->domid = domid; + device->kind = LIBXL__DEVICE_KIND_VKBD; + + return 0; +} + int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb, const libxl_asyncop_how *ao_how) { @@ -318,7 +328,6 @@ out: return rc; } -static LIBXL_DEFINE_DEVICE_FROM_TYPE(vkb) static LIBXL_DEFINE_UPDATE_DEVID(vkb) #define libxl__add_vkbs NULL From patchwork Thu Nov 21 18:12:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 11256725 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 BE6A01593 for ; Thu, 21 Nov 2019 18:14:21 +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 9694F206CB for ; Thu, 21 Nov 2019 18:14:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ugd7ysV1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9694F206CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 1iXqxK-0003hN-PW; Thu, 21 Nov 2019 18:13:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXqxJ-0003hI-FJ for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:13:25 +0000 X-Inumbo-ID: 96eea124-0c8a-11ea-adbe-bc764e2007e4 Received: from mail-lj1-x242.google.com (unknown [2a00:1450:4864:20::242]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 96eea124-0c8a-11ea-adbe-bc764e2007e4; Thu, 21 Nov 2019 18:13:17 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id g3so4265107ljl.11 for ; Thu, 21 Nov 2019 10:13:17 -0800 (PST) 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=2nFxr7Xu/diPrmiZ2lQwCKQk5pMVYzc6UewNtSI1se0=; b=ugd7ysV1LVrqfy6km/l+1ydSr1CV2PO8jyDfQ7jITO2vC4urK0zMvu1wi+SFjZ7VG9 /z1kLI+Z3nPLWX6VfkZlTMfrkSx8s8rb70lFhpos/RnbdWibnPtUUxNMDvD/fDmq5mJp 2rm6cCvwn/FGT60NGUreikQt3S1q0Oa4MDTXDVA3niSMno6hHlLr4eaGwMOmRabAVKp/ HT8Zp1xFrBwS37lAp5OXmJtoR74JpuiB6fSvXcIou0yTUfl0fVjX2gH0oBA7T+zbmLxV nm4VEEaL21f2rxv+3FdgwuMRDCNOYYWCBKyai7KP6piz37PTdqdFETHqM5FYOh8xYX+A +PeQ== 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=2nFxr7Xu/diPrmiZ2lQwCKQk5pMVYzc6UewNtSI1se0=; b=g3bgkhxUses/v9ncXgNvRY1d7LzQfbFy2ljwKPUvAM1lItkCyuGZiEPvImTrUaCgnd yBT71s6bRJerAhG0NoePMbRd/pAbX+MAt6joqjrwby5bEk8zakEG3VgmzSUaFmwEvYDq kVQ4Pt7xY0xgtipOezfNOCpgBGCYp4D+CsRoLdgWmvvUDZyKCtnANgZGK7HRSCyw8zbe lei8wHu7FG/plHiYJPN3KR4vlGS+u06ZSrlK+p6zuyTXYgZzt/ZvHkOJlxtaCi6zN8nl KWNf8QxehQgf5YS3YiIkhz6WBcn1o8VV4JfAYcMIAK9HF4K8Yq7PTiS3t2IgIekInHDL adHQ== X-Gm-Message-State: APjAAAVD+XktZyDb4i1EWRActHURrgwP8XMKHJTSSuI15xCFAi7z/O8c t51q4QVq8aqVqAn4sm34JLjPTDpU2JS/rQ== X-Google-Smtp-Source: APXvYqwk86NoCAioN94QRGrbIfV6ymVgjwJIuWYsPgWk+z4uVM2CPvGJTbcOY2lMcIaRxugHdmn9Hw== X-Received: by 2002:a2e:8e27:: with SMTP id r7mr9134266ljk.101.1574359995845; Thu, 21 Nov 2019 10:13:15 -0800 (PST) Received: from al1-pc.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id v12sm1855473lfb.47.2019.11.21.10.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:13:15 -0800 (PST) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Thu, 21 Nov 2019 20:12:59 +0200 Message-Id: <20191121181300.6497-3-al1img@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191121181300.6497-1-al1img@gmail.com> References: <20191121181300.6497-1-al1img@gmail.com> Subject: [Xen-devel] [PATCH v2 2/3] libxl: rename VKB backend type "linux" to "pv" 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@citrix.com, Oleksandr Grytsov , ian.jackson@eu.citrix.com, wl@xen.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Grytsov There are two kind of VKB backends: QEMU and user space PV backend. For PV backend "linux" enum is used but this name is confused. Rename "linux" enum to "pv" as it better matches user space PV backend. Signed-off-by: Oleksandr Grytsov Acked-by: Ian Jackson --- docs/man/xl.cfg.5.pod.in | 4 ++-- tools/libxl/libxl_types.idl | 2 +- tools/libxl/libxl_vkb.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 245d3f9472..37bdc595d3 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1562,8 +1562,8 @@ Specifies the backend domain name or id. =item B -Specifies the backend type: qemu - for QEMU backend or linux - for Linux PV -domain. +Specifies the backend type: qemu - for QEMU backend or pv - for PV +backend. =item B diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 0546d7865a..751dad8870 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -260,7 +260,7 @@ libxl_vuart_type = Enumeration("vuart_type", [ libxl_vkb_backend = Enumeration("vkb_backend", [ (0, "UNKNOWN"), (1, "QEMU"), - (2, "LINUX") + (2, "PV") ]) libxl_passthrough = Enumeration("passthrough", [ diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c index 4c44a813c1..5f018f55b7 100644 --- a/tools/libxl/libxl_vkb.c +++ b/tools/libxl/libxl_vkb.c @@ -113,7 +113,7 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path, if (rc) goto out; vkb->backend_type = dev.backend_kind == LIBXL__DEVICE_KIND_VINPUT ? - LIBXL_VKB_BACKEND_LINUX : LIBXL_VKB_BACKEND_QEMU; + LIBXL_VKB_BACKEND_PV : LIBXL_VKB_BACKEND_QEMU; vkb->unique_id = xs_read(CTX->xsh, XBT_NULL, GCSPRINTF("%s/"XENKBD_FIELD_UNIQUE_ID, be_path), NULL); @@ -219,7 +219,7 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, { device->backend_devid = type->devid; device->backend_domid = type->backend_domid; - device->backend_kind = type->backend_type == LIBXL_VKB_BACKEND_LINUX ? + device->backend_kind = type->backend_type == LIBXL_VKB_BACKEND_PV ? LIBXL__DEVICE_KIND_VINPUT : LIBXL__DEVICE_KIND_VKBD; device->devid = type->devid; device->domid = domid; From patchwork Thu Nov 21 18:13:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 11256729 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 CE35C14DB for ; Thu, 21 Nov 2019 18:14:23 +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 A60082068E for ; Thu, 21 Nov 2019 18:14:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RXzx9/Q1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A60082068E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 1iXqxP-0003ik-2m; Thu, 21 Nov 2019 18:13:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXqxO-0003iR-FV for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:13:30 +0000 X-Inumbo-ID: 97bea9d2-0c8a-11ea-b678-bc764e2007e4 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 97bea9d2-0c8a-11ea-b678-bc764e2007e4; Thu, 21 Nov 2019 18:13:18 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id n21so4259191ljg.12 for ; Thu, 21 Nov 2019 10:13:18 -0800 (PST) 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=PCT5CX2D/qI3pj3Q/bbzvWBes5x8xliwvVl0q/Ba/Tg=; b=RXzx9/Q10nU8klt3oKsRUxLIG5R5KarKEtAKJMNb1twNbA9W+mXzGpgh8IZCGAFkGh aQ3H4tOrNHBdlmo6/4L3UauiKdNmN7YkLxRGM2Rv4JKB5hiWaOlInFOFGlrgW68utS8q jQNavALO3meB2btwVFBzIQqUEcfEmKORhT7hDTMpBI433RgK1xoxNEw0WJtPbB/JlsnK x5HSQpfTu89ffLLVF8Tdve54QDEXeuAiTVz9d/2fyENHTn1zC1OgIGjnDjnV5bJjJ2gS C6RxwsE3wTY09VIlcQ7OZzl/kserPoApUvNq6alu0s3ozJbB4E+CM6DteqcNTekNwWq2 LZwA== 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=PCT5CX2D/qI3pj3Q/bbzvWBes5x8xliwvVl0q/Ba/Tg=; b=MAD2xkyTcixpqSXcsZgy+wHrGwuKRaEfei+n85Zvmx/CKcXFh5nU+FDlr/qZK57xjf KXDfnlX+K03glHroBiRr8UuQygLW6JjG6XQkjM6XwG6gVq2wbYY18Tgxh97kwUyNgLjd ZlFVKKaElPwkdvTVQG4iL2bvQ6txeHBHi0zoQJdqs+tKxpaw+qn7i4fbKymZH/xHYya7 BY7acol5ZP4ypNOB8jZ2THTsf162tTOTzh6yWwetlsOmXvJo0+02bEtVv6+tzZsU1HUA z9tnLTwvLVeBMfpdMNziZi0hQia3xitQqVhHSGcz+9Ogaxwnsff44me0I75Kap+J2s+W hHHw== X-Gm-Message-State: APjAAAXlK1dDqsVo+7TIGQ2aHbW1Ou69HKNNOyrMB7E6lvdQnXW4MFl/ 64Qv300qwChGtw4zejGm8+6WHP1U3E8ULg== X-Google-Smtp-Source: APXvYqz2pPFC0s4d1oCnWRNXJO76vmvLqFx5iHpyrJWTCfOg8+z3RY0bGTqAcZLO58g8uRLZCQPKhg== X-Received: by 2002:a2e:97d3:: with SMTP id m19mr8804136ljj.56.1574359997197; Thu, 21 Nov 2019 10:13:17 -0800 (PST) Received: from al1-pc.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id v12sm1855473lfb.47.2019.11.21.10.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:13:16 -0800 (PST) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Thu, 21 Nov 2019 20:13:00 +0200 Message-Id: <20191121181300.6497-4-al1img@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191121181300.6497-1-al1img@gmail.com> References: <20191121181300.6497-1-al1img@gmail.com> Subject: [Xen-devel] [PATCH v2 3/3] libxl: make default path to add/remove all PV devices 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@citrix.com, Oleksandr Grytsov , ian.jackson@eu.citrix.com, wl@xen.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Grytsov Adding/removing device is handled for specific devices only: VBD, VIF, QDISK. This commit adds default case to handle adding/removing for all PV devices by default, except QDISK device, which requires special handling. If any other device is required a special handling it should be done by implementing separate case (similar to QDISK device). The default behaviour for adding device is to wait when the backend goes to XenbusStateInitWait and the default behaviour on removing device is to start generic device remove procedure. Also this commit fixes removing guest function: before the guest was removed when all VIF and VBD devices are removed. The fix removes guest when all created devices are removed. This is done by checking the guest device list instead of checking num_vifs and num_vbds. num_vifs and num_vbds variables are removed as redundant in this case. Signed-off-by: Oleksandr Grytsov Acked-by: Ian Jackson Acked-by: Wei Liu --- tools/libxl/libxl_device.c | 63 +++++++++++++++----------------------- 1 file changed, 24 insertions(+), 39 deletions(-) diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 1402b61a81..9d05d2fd13 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -1477,7 +1477,7 @@ typedef struct libxl__ddomain_device { */ typedef struct libxl__ddomain_guest { uint32_t domid; - int num_vifs, num_vbds, num_qdisks; + int num_qdisks; LIBXL_SLIST_HEAD(, struct libxl__ddomain_device) devices; LIBXL_SLIST_ENTRY(struct libxl__ddomain_guest) next; } libxl__ddomain_guest; @@ -1530,8 +1530,7 @@ static void check_and_maybe_remove_guest(libxl__gc *gc, { assert(ddomain); - if (dguest != NULL && - dguest->num_vifs + dguest->num_vbds + dguest->num_qdisks == 0) { + if (dguest != NULL && LIBXL_SLIST_FIRST(&dguest->devices) == NULL) { LIBXL_SLIST_REMOVE(&ddomain->guests, dguest, libxl__ddomain_guest, next); LOGD(DEBUG, dguest->domid, "Removed domain from the list of active guests"); @@ -1571,24 +1570,6 @@ static int add_device(libxl__egc *egc, libxl__ao *ao, libxl__device_backend_path(gc, dev)); switch(dev->backend_kind) { - case LIBXL__DEVICE_KIND_VBD: - case LIBXL__DEVICE_KIND_VIF: - if (dev->backend_kind == LIBXL__DEVICE_KIND_VBD) dguest->num_vbds++; - if (dev->backend_kind == LIBXL__DEVICE_KIND_VIF) dguest->num_vifs++; - - GCNEW(aodev); - libxl__prepare_ao_device(ao, aodev); - /* - * Clone the libxl__device to avoid races if remove_device is called - * before the device addition has finished. - */ - GCNEW(aodev->dev); - *aodev->dev = *dev; - aodev->action = LIBXL__DEVICE_ACTION_ADD; - aodev->callback = device_complete; - libxl__wait_device_connection(egc, aodev); - - break; case LIBXL__DEVICE_KIND_QDISK: if (dguest->num_qdisks == 0) { GCNEW(dmss); @@ -1599,10 +1580,19 @@ static int add_device(libxl__egc *egc, libxl__ao *ao, libxl__spawn_qdisk_backend(egc, dmss); } dguest->num_qdisks++; - break; default: - rc = 1; + GCNEW(aodev); + libxl__prepare_ao_device(ao, aodev); + /* + * Clone the libxl__device to avoid races if remove_device is called + * before the device addition has finished. + */ + GCNEW(aodev->dev); + *aodev->dev = *dev; + aodev->action = LIBXL__DEVICE_ACTION_ADD; + aodev->callback = device_complete; + libxl__wait_device_connection(egc, aodev); break; } @@ -1619,11 +1609,17 @@ static int remove_device(libxl__egc *egc, libxl__ao *ao, int rc = 0; switch(ddev->dev->backend_kind) { - case LIBXL__DEVICE_KIND_VBD: - case LIBXL__DEVICE_KIND_VIF: - if (dev->backend_kind == LIBXL__DEVICE_KIND_VBD) dguest->num_vbds--; - if (dev->backend_kind == LIBXL__DEVICE_KIND_VIF) dguest->num_vifs--; - + case LIBXL__DEVICE_KIND_QDISK: + if (--dguest->num_qdisks == 0) { + rc = libxl__destroy_qdisk_backend(gc, dev->domid); + if (rc) + goto out; + } + libxl__device_destroy(gc, dev); + /* Return > 0, no ao has been dispatched */ + rc = 1; + break; + default: GCNEW(aodev); libxl__prepare_ao_device(ao, aodev); /* @@ -1636,17 +1632,6 @@ static int remove_device(libxl__egc *egc, libxl__ao *ao, aodev->callback = device_complete; libxl__initiate_device_generic_remove(egc, aodev); break; - case LIBXL__DEVICE_KIND_QDISK: - if (--dguest->num_qdisks == 0) { - rc = libxl__destroy_qdisk_backend(gc, dev->domid); - if (rc) - goto out; - } - libxl__device_destroy(gc, dev); - /* Fall through to return > 0, no ao has been dispatched */ - default: - rc = 1; - break; } /*