[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH V7 1/2] libxl: Add support for Virtio disk configuration


  • To: Oleksandr Tyshchenko <olekstysh@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 22 Apr 2022 11:41:08 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+nhS6/yUoO05duGe91k/b2AFm/E14+Gs/VbvDYRzq9g=; b=XGFGnE0oOlC4OOTGTE3eQxgpFJ4gdU/hy2L4ZNNNlQbqSErYORsEXg0pa6rqY/vjan80U3+g8SqHhgnP7kMNHhoL8E6ixLLqW1gBG6+mYftG7i7c39B4+hEd0gJsZB/aRlkP0eXi4V/aJdVnZ24iG3ajfUr5dQvtl/qsxT+18UeKCz9glhNg/dh0pzg/FDVuKyaNOke4pQo66W9Gn9HKMLbeFlaD2kxIBfoZIvB2APIMiqHYi36fwUb/WzE3Whkg94PplwZ2d6OUwKRha71uQDSvsBPOl3xTpoXnMepGzrmAYpOJRjhhleGvJr/3k5tT5hmHb7XF589Up3paZ3+zKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DWlSF8cBTVRIpg0W6/wWZYT+VhUrI5YN8DjlNB8kJSE73ErkRwxbrSvJCyqeOhlZUe1UtlcQc8tl7x3X6jXCD7151wJ59/ArvEBCpqqeHZ2WAejhhzKlxTsZIN8pixbZf4utzZvAryoShiWuaWerIt9SVGB6t7vqYhAwuH8Forh9E6qM4L1bNsOsW8lGtYgN3Izts6v/ezMy5jQlroIhQYycxkJq+AhJypVMHZ/GTH2cM73R2GfEa7t5oVQtMLCIlFAD9PH23VNVPMEYB0rybGsPhuKJkNVk69d9A09BDaGaK1tXZDbZ40F6Shcmu9cM+1aEsr1TfTgctiaLYyqL3A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Nick Rosbrook <rosbrookn@xxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Fri, 22 Apr 2022 09:41:53 +0000
  • Ironport-data: A9a23:QuYROKh7QKYoT9AMowSqo24LX1618xEKZh0ujC45NGQN5FlHY01je htvXDiCa/fcNmShKd1yaty+oUJUvZ7cxoQxGQtsqCgwFSkb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oDJ9CU6jefSLlbFILas1hpZHGeIcw98z0M78wIFqtQw24LhX1nX4 YqaT/D3YzdJ5RYlagr41IrbwP9flKyaVOQw5wFWiVhj5TcyplFNZH4tDfjZw0jQG+G4KtWSV efbpIxVy0uCl/sb5nFJpZ6gGqECaua60QFjERO6UYD66vRJjnRaPqrWqJPwwKqY4tmEt4kZ9 TlDiXC/YV9xZZSQxeo+aj9dCwJ5OoZM9aPof1Hq5KR/z2WeG5ft69NHKRhseKc+qqNwC2wI8 uEEIjcQaBzFn/ix3L+wVuhrgIIkMdXvO4Qc/HpnyFk1D95/GcyFH/qMuIIehWhr7ixNNa+2i 84xcz1gYQ6GexRSElwWFIg/jK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UWqFhwdL5mUUtcPpZ0fSLlMB27ffrzWFjiUWjPJeUgB0/njaLRzfEc2NyKEaZ4v6fa3q 6xG29liQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Apr 08, 2022 at 09:21:04PM +0300, Oleksandr Tyshchenko wrote:
> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
> 
> This patch adds basic support for configuring and assisting virtio-mmio
> based virtio-disk backend (emualator) which is intended to run out of
> Qemu and could be run in any domain.
> Although the Virtio block device is quite different from traditional
> Xen PV block device (vbd) from the toolstack's point of view:
>  - as the frontend is virtio-blk which is not a Xenbus driver, nothing
>    written to Xenstore are fetched by the frontend (the vdev is not
>    passed to the frontend)
>  - the ring-ref/event-channel are not used for the backend<->frontend
>    communication, the proposed IPC for Virtio is IOREQ/DM
> it is still a "block device" and ought to be integrated in existing
> "disk" handling. So, re-use (and adapt) "disk" parsing/configuration
> logic to deal with Virtio devices as well.
> 
> For the immediate purpose and an ability to extend that support for
> other use-cases in future (Qemu, virtio-pci, etc) perform the following
> actions:
> - Add new disk backend type (LIBXL_DISK_BACKEND_OTHER) and reflect
>   that in the configuration
> - Introduce new disk protocol field to libxl_device_disk struct
>   (with LIBXL_DISK_PROTOCOL_XEN and LIBXL_DISK_PROTOCOL_VIRTIO_MMIO
>   types) and reflect that in the configuration (new "protocol" option
>   with "xen" protocol being default value)
> - Add new device kind (LIBXL__DEVICE_KIND_VIRTIO_DISK) as current
>   one (LIBXL__DEVICE_KIND_VBD) doesn't fit into Virtio disk model
> 
> An example of domain configuration for Virtio disk:
> disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, protocol=virtio-mmio']
> 
> Nothing has changed for default Xen disk configuration.
> 
> Please note, this patch is not enough for virtio-disk to work
> on Xen (Arm), as for every Virtio device (including disk) we need
> to allocate Virtio MMIO params (IRQ and memory region) and pass
> them to the backend, also update Guest device-tree. The subsequent
> patch will add these missing bits. For the current patch,
> the default "irq" and "base" are just written to the Xenstore.
> This is not an ideal splitting, but this way we avoid breaking
> the bisectability.
> 
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
> ---
> Changes RFC -> V1:
>    - no changes
> 
> Changes V1 -> V2:
>    - rebase according to the new location of libxl_virtio_disk.c
> 
> Changes V2 -> V3:
>    - no changes
> 
> Changes V3 -> V4:
>    - rebase according to the new argument for DEFINE_DEVICE_TYPE_STRUCT
> 
> Changes V4 -> V5:
>    - split the changes, change the order of the patches
>    - update patch description
>    - don't introduce new "vdisk" configuration option with own parsing logic,
>      re-use Xen PV block "disk" parsing/configuration logic for the 
> virtio-disk
>    - introduce "virtio" flag and document it's usage
>    - add LIBXL_HAVE_DEVICE_DISK_VIRTIO
>    - update libxlu_disk_l.[ch]
>    - drop num_disks variable/MAX_VIRTIO_DISKS
>    - drop Wei's T-b
> 
> Changes V5 -> V6:
>    - rebase on current staging
>    - use "%"PRIu64 instead of %lu for disk->base in device_disk_add()
>    - update *.gen.go files
> 
> Changes V6 -> V7:
>    - rebase on current staging
>    - update *.gen.go files and libxlu_disk_l.[ch] files
>    - update patch description
>    - rework significantly to support more flexible configuration
>      and have more generic basic implementation for being able to extend
>      that for other use-cases (virtio-pci, qemu, etc).
> ---
>  docs/man/xl-disk-configuration.5.pod.in   |  37 +-
>  tools/golang/xenlight/helpers.gen.go      |   6 +
>  tools/golang/xenlight/types.gen.go        |  11 +
>  tools/include/libxl.h                     |   6 +
>  tools/libs/light/libxl_device.c           |  57 +-
>  tools/libs/light/libxl_disk.c             | 111 +++-
>  tools/libs/light/libxl_internal.h         |   1 +
>  tools/libs/light/libxl_types.idl          |  10 +
>  tools/libs/light/libxl_types_internal.idl |   1 +
>  tools/libs/light/libxl_utils.c            |   2 +
>  tools/libs/util/libxlu_disk_l.c           | 952 
> +++++++++++++++---------------
>  tools/libs/util/libxlu_disk_l.h           |   2 +-
>  tools/libs/util/libxlu_disk_l.l           |   9 +
>  tools/xl/xl_block.c                       |  11 +
>  14 files changed, 736 insertions(+), 480 deletions(-)
> 
> diff --git a/docs/man/xl-disk-configuration.5.pod.in 
> b/docs/man/xl-disk-configuration.5.pod.in
> index 71d0e86..36c851f 100644
> --- a/docs/man/xl-disk-configuration.5.pod.in
> +++ b/docs/man/xl-disk-configuration.5.pod.in
> @@ -232,7 +232,7 @@ Specifies the backend implementation to use
>  
>  =item Supported values
>  
> -phy, qdisk
> +phy, qdisk, other
>  
>  =item Mandatory
>  
> @@ -244,11 +244,13 @@ Automatically determine which backend to use.
>  
>  =back
>  
> -This does not affect the guest's view of the device.  It controls
> -which software implementation of the Xen backend driver is used.
> +It controls which software implementation of the backend driver is used.
> +Depending on the "protocol" option this may affect the guest's view
> +of the device.
>  
>  Not all backend drivers support all combinations of other options.
> -For example, "phy" does not support formats other than "raw".
> +For example, "phy" and "other" do not support formats other than "raw" and
> +"other" does not support protocols other than "virtio-mmio".
>  Normally this option should not be specified, in which case libxl will
>  automatically determine the most suitable backend.
>  
> @@ -344,8 +346,35 @@ can be used to disable "hole punching" for file based 
> backends which
>  were intentionally created non-sparse to avoid fragmentation of the
>  file.
>  
> +=item B<protocol>=I<PROTOCOL>
> +
> +=over 4
> +
> +=item Description
> +
> +Specifies the communication protocol to use for the chosen "backendtype" 
> option
> +
> +=item Supported values
> +
> +xen, virtio-mmio

>From a user PoV, I think it would be better to just select xen or
virtio here, but not the underlying configuration mechanism used to
expose the devices to the guest.

We would likely need to add a different option to select mmio or pci
then, but that should be set by default based on architecture/guest
type.  For example on x86 it should default to pci, while on Arm I
guess it will depend on whether the guest has PCI or not?

In any case, I think we should offer an option that's selecting
between xen or virtio protocol, and the way to expose the
configuration of the device shouldn't need to be explicitly selected
by the user.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.