Virtio support for toolstack on Arm (Was "IOREQ feature (+ virtio-mmio) on Arm")
v10 cover Virtio support for toolstack on Arm (Was "IOREQ feature (+ virtio-mmio) on Arm")
From: Oleksandr Tyshchenko <[email protected]>
Hello all.
The purpose of this patch series is to add missing virtio-mmio bits to Xen toolstack on Arm. The Virtio support for toolstack [1] was postponed as the main target was to upstream IOREQ/DM support on Arm in the first place. Now, we already have IOREQ support in, so we can resume Virtio enabling work. You can find previous discussions at [2].
Patch series [3] is based on recent "staging" branch
(c9a707df83aad17a6fcf2e8330ab3b5bead6fb8b xen/arm: mm: Re-implement setup_frame_table_mappings() with map_pages_to_xen()) and tested on Renesas Salvator-X board + H3 ES3.0 SoC (Arm64) with virtio-mmio based virtio-disk backend [4] running in Dom0 (or Driver domain) and unmodified Linux Guest running on existing virtio-blk driver (frontend). No issues were observed. Guest domain 'reboot/destroy' use-cases work properly.
!!! Please note, for V10 I included commit "libxl/arm: Create specific IOMMU node to be referred by virtio-mmio devices" which depends on the current series [5]. All patches except "libxl: Add support for Virtio disk configuration" have Stefano's and Anthony's R-b tags.
Any feedback/help would be highly appreciated.
[1]
https://lore.kernel.org/xen-devel/[email protected]/
https://lore.kernel.org/xen-devel/[email protected]/
[2]
https://lists.xenproject.org/archives/html/xen-devel/2021-01/msg02403.html
https://lists.xenproject.org/archives/html/xen-devel/2021-01/msg02536.html
https://lore.kernel.org/xen-devel/[email protected]/
https://lore.kernel.org/xen-devel/[email protected]/
https://lore.kernel.org/xen-devel/[email protected]/
https://lore.kernel.org/xen-devel/[email protected]/
https://lore.kernel.org/xen-devel/[email protected]/
[3] https://github.com/otyshchenko1/xen/commits/libxl_virtio_next3
[4] https://github.com/otyshchenko1/virtio-disk/commits/virtio_grant
[5] https://lore.kernel.org/xen-devel/[email protected]/
https://lore.kernel.org/xen-devel/[email protected]/
Julien Grall (1):
libxl: Introduce basic virtio-mmio support on Arm
Oleksandr Tyshchenko (2):
libxl: Add support for Virtio disk configuration libxl/arm: Create specific IOMMU node to be referred by virtio-mmio
device
docs/man/xl-disk-configuration.5.pod.in | 38 +- tools/golang/xenlight/helpers.gen.go | 8 + tools/golang/xenlight/types.gen.go | 18 + tools/include/libxl.h | 7 + tools/libs/light/libxl_arm.c | 164 ++++- tools/libs/light/libxl_device.c | 62 +- tools/libs/light/libxl_disk.c | 140 ++++- tools/libs/light/libxl_internal.h | 2 + tools/libs/light/libxl_types.idl | 18 + tools/libs/light/libxl_types_internal.idl | 1 + tools/libs/light/libxl_utils.c | 2 + tools/libs/util/libxlu_disk_l.c | 959 +++++++++++++++--------------- tools/libs/util/libxlu_disk_l.h | 2 +- tools/libs/util/libxlu_disk_l.l | 9 + tools/xl/xl_block.c | 11 + xen/include/public/arch-arm.h | 7 + xen/include/public/device_tree_defs.h | 3 +- 17 files changed, 968 insertions(+), 483 deletions(-)
Signature · 1 line
2.7.4
PATCH v10 1/3 libxl: Add support for Virtio disk configuration
From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to struct libxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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, specification=virtio']
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.
---
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).
Changes V7 -> V8:
- update *.gen.go files and libxlu_disk_l.[ch] files
- update patch description and comments in the code
- use "specification" config option instead of "protocol"
- update libxl_types.idl and code according to new fields in libxl_device_disk
Changes V8 -> V9:
- update (and harden) checks in libxl__device_disk_setdefault(), return error in case of incorrect settings of specification
and transport
- remove both asserts in device_disk_add()
- update virtio related code in libxl__disk_from_xenstore(),
do not fail if specification node is absent, replace
open-coded checks of fetched specification and transport by libxl_disk_specification_from_string() and libxl_disk_transport_from_string() respectively
- s/libxl_device_disk_get_path/libxl__device_disk_get_path
- add a comment for virtio-mmio parameters in struct libxl_device_disk
Changes V9 -> V10:
- s/ERROR_FAIL/ERROR_INVAL in both places in libxl__device_disk_setdefault()
- rework libxl__device_disk_get_path()
--- docs/man/xl-disk-configuration.5.pod.in | 38 +- tools/golang/xenlight/helpers.gen.go | 8 + tools/golang/xenlight/types.gen.go | 18 + tools/include/libxl.h | 7 + tools/libs/light/libxl_device.c | 62 +- tools/libs/light/libxl_disk.c | 140 ++++- tools/libs/light/libxl_internal.h | 2 + tools/libs/light/libxl_types.idl | 18 + tools/libs/light/libxl_types_internal.idl | 1 + tools/libs/light/libxl_utils.c | 2 + tools/libs/util/libxlu_disk_l.c | 959 +++++++++++++++--------------- 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, 797 insertions(+), 480 deletions(-)
docs/man/xl-disk-configuration.5.pod.in +34 -4
@@ -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 "specification" 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 specifications other than "virtio". Normally this option should not be specified, in which case libxl will automatically determine the most suitable backend.
@@ -344,8 +346,36 @@ 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<specification>=I<SPECIFICATION> + +=over 4 + +=item Description + +Specifies the communication protocol (specification) to use for the chosen +"backendtype" option + +=item Supported values + +xen, virtio + +=item Mandatory + +No + +=item Default value + +xen + =back +Besides forcing toolstack to use specific backend implementation, this also +affects the guest's view of the device. For example, "virtio" requires +Virtio frontend driver (virtio-blk) to be used. Please note, the virtual +device (vdev) is not passed to the guest in that case, but it still must be +specified for the internal purposes. + +=back =head1 COLO Parameters
tools/golang/xenlight/helpers.gen.go +8 -0
@@ -1751,6 +1751,10 @@ x.DirectIoSafe = bool(xc.direct_io_safe) if err := x.DiscardEnable.fromC(&xc.discard_enable);err != nil { return fmt.Errorf("converting field DiscardEnable: %v", err) } +x.Specification = DiskSpecification(xc.specification) +x.Transport = DiskTransport(xc.transport) +x.Irq = uint32(xc.irq) +x.Base = uint64(xc.base) if err := x.ColoEnable.fromC(&xc.colo_enable);err != nil { return fmt.Errorf("converting field ColoEnable: %v", err) }
@@ -1788,6 +1792,10 @@ xc.direct_io_safe = C.bool(x.DirectIoSafe) if err := x.DiscardEnable.toC(&xc.discard_enable); err != nil { return fmt.Errorf("converting field DiscardEnable: %v", err) } +xc.specification = C.libxl_disk_specification(x.Specification) +xc.transport = C.libxl_disk_transport(x.Transport) +xc.irq = C.uint32_t(x.Irq) +xc.base = C.uint64_t(x.Base) if err := x.ColoEnable.toC(&xc.colo_enable); err != nil { return fmt.Errorf("converting field ColoEnable: %v", err) }
tools/golang/xenlight/types.gen.go +18 -0
@@ -99,6 +99,20 @@ DiskBackendUnknown DiskBackend = 0 DiskBackendPhy DiskBackend = 1 DiskBackendTap DiskBackend = 2 DiskBackendQdisk DiskBackend = 3 +DiskBackendOther DiskBackend = 4 +) + +type DiskSpecification int +const( +DiskSpecificationUnknown DiskSpecification = 0 +DiskSpecificationXen DiskSpecification = 1 +DiskSpecificationVirtio DiskSpecification = 2 +) + +type DiskTransport int +const( +DiskTransportUnknown DiskTransport = 0 +DiskTransportMmio DiskTransport = 1 ) type NicType int
@@ -643,6 +657,10 @@ Readwrite int IsCdrom int DirectIoSafe bool DiscardEnable Defbool +Specification DiskSpecification +Transport DiskTransport +Irq uint32 +Base uint64 ColoEnable Defbool ColoRestoreEnable Defbool ColoHost string
tools/include/libxl.h +7 -0
@@ -528,6 +528,13 @@#define LIBXL_HAVE_MAX_GRANT_VERSION 1/* +* LIBXL_HAVE_DEVICE_DISK_SPECIFICATION indicates that 'specification' and +* 'transport' fields (of libxl_disk_specification and libxl_disk_transport +* types respectively) are present in libxl_device_disk. +*/ +#define LIBXL_HAVE_DEVICE_DISK_SPECIFICATION 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility
tools/libs/light/libxl_device.c +58 -4
111 lines not on this page · raw message
tools/libs/light/libxl_disk.c +133 -7
209 lines not on this page · raw message
tools/libs/light/libxl_internal.h +2 -0
@@ -1493,6 +1493,8 @@ _hidden char * libxl__domain_pvcontrol_read(libxl__gc *gc,/* from xl_device */ _hidden char *libxl__device_disk_string_of_backend(libxl_disk_backend backend); +_hidden char *libxl__device_disk_string_of_specification(libxl_disk_specification specification); +_hidden char *libxl__device_disk_string_of_transport(libxl_disk_transport transport); _hidden char *libxl__device_disk_string_of_format(libxl_disk_format format); _hidden const char *libxl__qemu_disk_format_string(libxl_disk_format format); _hidden int libxl__device_disk_set_backend(libxl__gc*, libxl_device_disk*);
tools/libs/light/libxl_types.idl +18 -0
@@ -130,6 +130,18 @@ libxl_disk_backend = Enumeration("disk_backend", [ (1, "PHY"), (2, "TAP"), (3, "QDISK"), + (4, "OTHER"), + ]) + +libxl_disk_specification = Enumeration("disk_specification", [ + (0, "UNKNOWN"), + (1, "XEN"), + (2, "VIRTIO"), + ]) + +libxl_disk_transport = Enumeration("disk_transport", [ + (0, "UNKNOWN"), + (1, "MMIO"), ]) libxl_nic_type = Enumeration("nic_type", [
@@ -704,6 +716,12 @@ libxl_device_disk = Struct("device_disk", [ ("is_cdrom", integer), ("direct_io_safe", bool), ("discard_enable", libxl_defbool), + ("specification", libxl_disk_specification), + ("transport", libxl_disk_transport), + # Note that virtio-mmio parameters (irq and base) are for internal use + # by libxl and can't be modified. + ("irq", uint32), + ("base", uint64), # Note that the COLO configuration settings should be considered unstable. # They may change incompatibly in future versions of Xen. ("colo_enable", libxl_defbool),
tools/libs/light/libxl_types_internal.idl +1 -0
@@ -32,6 +32,7 @@ libxl__device_kind = Enumeration("device_kind", [ (14, "PVCALLS"), (15, "VSND"), (16, "VINPUT"), + (17, "VIRTIO_DISK"), ]) libxl__console_backend = Enumeration("console_backend", [
tools/libs/light/libxl_utils.c +2 -0
@@ -297,6 +297,8 @@ int libxl_string_to_backend(libxl_ctx *ctx, char *s, libxl_disk_backend *backend *backend =LIBXL_DISK_BACKEND_TAP ; }else if (!strcmp (s,"qdisk" )) { *backend =LIBXL_DISK_BACKEND_QDISK ; + }else if (!strcmp (s,"other" )) { + *backend =LIBXL_DISK_BACKEND_OTHER ; }else if (!strcmp (s,"tap" )) { p =strchr (s,':' );if (!p) {
tools/libs/util/libxlu_disk_l.c +495 -464
1,244 lines not on this page · raw message
tools/libs/util/libxlu_disk_l.h +1 -1
@@ -694,7 +694,7 @@ extern int yylex (yyscan_t yyscanner);#undef yyTABLES_NAME#endif -#line 291 "libxlu_disk_l.l" +#line 300 "libxlu_disk_l.l"#line 699 "libxlu_disk_l.h"#undef xlu__disk_yyIN_HEADER
tools/libs/util/libxlu_disk_l.l +9 -0
@@ -122,9 +122,17 @@ static void setbackendtype(DiskParseContext *dpc, const char *str) { if ( !strcmp(str,"phy")) DSET(dpc,backend,BACKEND,str,PHY); else if (!strcmp(str,"tap")) DSET(dpc,backend,BACKEND,str,TAP); else if (!strcmp(str,"qdisk")) DSET(dpc,backend,BACKEND,str,QDISK); + else if (!strcmp(str,"other")) DSET(dpc,backend,BACKEND,str,OTHER); else xlu__disk_err(dpc,str,"unknown value for backendtype"); } +/* Sets ->specification from the string. IDL should provide something for this. */ +static void setspecification(DiskParseContext *dpc, const char *str) { + if (!strcmp(str,"xen")) DSET(dpc,specification,SPECIFICATION,str,XEN); + else if (!strcmp(str,"virtio")) DSET(dpc,specification,SPECIFICATION,str,VIRTIO); + else xlu__disk_err(dpc,str,"unknown value for specification"); +} + /* Sets ->colo-port from the string. COLO need this. */ static void setcoloport(DiskParseContext *dpc, const char *str) { int port = atoi(str);
@@ -192,6 +200,7 @@ devtype=[^,]*,? { xlu__disk_err(DPC,yytext,"unknown value for type"); } access=[^,]*,? { STRIP(','); setaccess(DPC, FROMEQUALS); } backend=[^,]*,? { STRIP(','); SAVESTRING("backend", backend_domname, FROMEQUALS); } backendtype=[^,]*,? { STRIP(','); setbackendtype(DPC,FROMEQUALS); } +specification=[^,]*,? { STRIP(','); setspecification(DPC,FROMEQUALS); } vdev=[^,]*,? { STRIP(','); SAVESTRING("vdev", vdev, FROMEQUALS); } script=[^,]*,? { STRIP(','); SAVESTRING("script", script, FROMEQUALS); }
tools/xl/xl_block.c +11 -0
@@ -50,6 +50,11 @@ int main_blockattach(int argc, char **argv)return 0 ; } +if (disk.specification !=LIBXL_DISK_SPECIFICATION_XEN ) { +fprintf (stderr,"block-attach is only supported for specification xen\n" ); +return 1 ; + } +if (libxl_device_disk_add (ctx, fe_domid, &disk,0 )) {fprintf (stderr,"libxl_device_disk_add failed.\n" );return 1 ;
@@ -119,6 +124,12 @@ int main_blockdetach(int argc, char **argv)fprintf (stderr,"Error: Device %s not connected.\n" , argv[optind+1 ]);return 1 ; } + +if (disk.specification !=LIBXL_DISK_SPECIFICATION_XEN ) { +fprintf (stderr,"block-detach is only supported for specification xen\n" ); +return 1 ; + } + rc = !force ?libxl_device_disk_safe_remove (ctx, domid, &disk,0 ) :libxl_device_disk_destroy (ctx, domid, &disk,0 );if (rc) {
Signature · 1 line
2.7.4
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
Quoted 29 lines · Oleksandr Tyshchenko
tools/libs/light/libxl_disk.c +21
-0@@ -575,6 +660,41 @@ cleanup:return rc; } +static int libxl__device_disk_get_path (libxl__gc *gc,uint32_t domid, +char **path) +{ +const char *xen_dir, *virtio_dir; +char *xen_path, *virtio_path; +int rc; + +/* default path */ + xen_path =GCSPRINTF ("%s/device/%s" , +libxl__xs_libxl_path (gc, domid), +libxl__device_kind_to_string (LIBXL__DEVICE_KIND_VBD )); + + rc =libxl__xs_read_checked (gc,XBT_NULL , xen_path, &xen_dir); +if (rc) +return rc; + + virtio_path =GCSPRINTF ("%s/device/%s" , +libxl__xs_libxl_path (gc, domid), +libxl__device_kind_to_string (LIBXL__DEVICE_KIND_VIRTIO_DISK )); + + rc =libxl__xs_read_checked (gc,XBT_NULL , virtio_path, &virtio_dir);
tools/libs/light/libxl_disk.c cleanup: · line 693
Quoted 10 lines
tools/libs/light/libxl_disk.c +10
-0+if (rc) +return rc; + +if (xen_dir && virtio_dir) { +LOGD (ERROR , domid,"Invalid configuration, both xen and virtio paths are present" ); +return ERROR_INVAL ; + }else if (virtio_dir) + *path = virtio_path; +else + *path = xen_path;
Small coding style issue, could you use blocks {} on all part of the if...else, since you are using them on one of the block? This is described in tools/libs/light/CODING_STYLE (5. Block structure).
tools/xl/xl_block.c int main_blockattach(int argc, char **argv) · line 54
Quoted 10 lines
tools/xl/xl_block.c +2
-0@@ -50,6 +50,11 @@ int main_blockattach(int argc, char **argv)return 0 ; } +if (disk.specification !=LIBXL_DISK_SPECIFICATION_XEN ) { +fprintf (stderr,"block-attach is only supported for specification xen\n" );
This check prevents a previously working block-attach command line from working.
# xl -Tvvv block-attach 0 /dev/vg/guest_disk,raw,hda
block-attach is only supported for specification xenAt least, that works by adding ",specification=xen", but it should work without it as "xen" is the default (from the man page).
Maybe the check is done too soon, or maybe a better place to do it would be in libxl.
libxl__device_disk_setdefault() is called much later, while executing libxl_device_disk_add(), so xl can't use the default been done there to "disk.specification".
xl block-attach calls libxl_device_disk_add() which I think is only called for hotplug of disk. If I recall correctly, libxl__add_disks() is called instead at guest creation. So maybe it is possible to do something in libxl_device_disk_add(), but that a function defined by a macro, and the macro is using the same libxl__device_disk_add() that libxl_device_disk_add(). On the other hand, there is a "hotplug" parameter to libxl__device_disk_setdefault(), maybe that could be use?
Cheers,
Signature · 1 line
Anthony PERARD
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
On 15.06.22 17:23, Anthony PERARD wrote:
Hello Anthony
Quoted 35 lines · Oleksandr Tyshchenko
Quoted 34 lines
tools/libs/light/libxl_disk.c +26
-0@@ -575,6 +660,41 @@ cleanup:return rc; } +static int libxl__device_disk_get_path (libxl__gc *gc,uint32_t domid, +char **path) +{ +const char *xen_dir, *virtio_dir; +char *xen_path, *virtio_path; +int rc; + +/* default path */ + xen_path =GCSPRINTF ("%s/device/%s" , +libxl__xs_libxl_path (gc, domid), +libxl__device_kind_to_string (LIBXL__DEVICE_KIND_VBD )); + + rc =libxl__xs_read_checked (gc,XBT_NULL , xen_path, &xen_dir); +if (rc) +return rc; + + virtio_path =GCSPRINTF ("%s/device/%s" , +libxl__xs_libxl_path (gc, domid), +libxl__device_kind_to_string (LIBXL__DEVICE_KIND_VIRTIO_DISK )); + + rc =libxl__xs_read_checked (gc,XBT_NULL , virtio_path, &virtio_dir); +if (rc) +return rc; + +if (xen_dir && virtio_dir) { +LOGD (ERROR , domid,"Invalid configuration, both xen and virtio paths are present" );
Quoted 8 lines
tools/libs/light/libxl_disk.c cleanup: · line 693
Quoted 5 lines
tools/libs/light/libxl_disk.c +5
-0+return ERROR_INVAL ; + }else if (virtio_dir) + *path = virtio_path; +else + *path = xen_path;Small coding style issue, could you use blocks {} on all part of the if...else, since you are using them on one of the block? This is described in
tools/libs/light/CODING_STYLE(5. Block structure).
yes, will do
Quoted 14 lines
tools/xl/xl_block.c int main_blockattach(int argc, char **argv) · line 54
Quoted 11 lines
tools/xl/xl_block.c +2
-0@@ -50,6 +50,11 @@ int main_blockattach(int argc, char **argv)return 0 ; } +if (disk.specification !=LIBXL_DISK_SPECIFICATION_XEN ) { +fprintf (stderr,"block-attach is only supported for specification xen\n" );This check prevents a previously working
block-attachcommand line from working.
Quoted 5 lines
# xl -Tvvv block-attach 0 /dev/vg/guest_disk,raw,hda block-attach is only supported for specification xenAt least, that works by adding ",specification=xen", but it should work without it as "xen" is the default (from the man page).
yes, you are right. thank you for pointing this out.
Quoted 7 lines
Maybe the check is done too soon, or maybe a better place to do it would be in libxl.
libxl__device_disk_setdefault()is called much later, while executinglibxl_device_disk_add(), soxlcan't use the default been done there to "disk.specification".
I got it.
Quoted 8 lines
xl block-attachcallslibxl_device_disk_add()which I think is only called for hotplug of disk. If I recall correctly,libxl__add_disks()is called instead at guest creation. So maybe it is possible to do something inlibxl_device_disk_add(), but that a function defined by a macro, and the macro is using the samelibxl__device_disk_add()thatlibxl_device_disk_add(). On the other hand, there is a "hotplug" parameter tolibxl__device_disk_setdefault(), maybe that could be use?
Thank you for digging into the details here.
If I understood correctly your suggestion we simply can drop checks in main_blockattach() (and likely main_blockdetach() ?) and add it to libxl__device_disk_setdefault().
tools/libs/light/libxl_disk.c +0 -0
@@ -182,6 +182,11 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid,
disk->transport = LIBXL_DISK_TRANSPORT_MMIO; }
+ if (hotplug && disk->specification != LIBXL_DISK_SPECIFICATION_XEN) { + LOGD(ERROR, domid, "Hotplug is only supported for specification xen"); + return ERROR_FAIL;
+ }
+
/* Force Qdisk backend for CDROM devices of guests with a device model. */ if (disk->is_cdrom != 0 &&
libxl__domain_type(gc, domid) == LIBXL_DOMAIN_TYPE_HVM) {
Is my understanding correct?
I have checked, it works:
root@generic-armv8-xt-dom0:~# xl block-attach DomU /dev/loop0,raw,xvda3 [ 762.062874] xen-blkback: backend/vbd/3/51715: using 4 queues, protocol 1 (arm-abi)
root@generic-armv8-xt-dom0:~# xl block-attach DomU /dev/loop0,raw,xvda3,specification=virtio libxl: error: libxl_disk.c:186:libxl__device_disk_setdefault: Domain 3:Hotplug is only supported for specification xen libxl: error: libxl_device.c:1468:device_addrm_aocomplete: unable to add device
Quoted 4 lines
Cheers,
Signature · 3 lines
Regards, Oleksandr Tyshchenko
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
Quoted 55 lines · Oleksandr
Quoted 13 lines · Anthony PERARD
tools/xl/xl_block.c int main_blockattach(int argc, char **argv) · line 53
Quoted 9 lines · Oleksandr Tyshchenko
tools/xl/xl_block.c +2
-0@@ -50,6 +50,11 @@ int main_blockattach(int argc, char **argv)return 0 ; } +if (disk.specification !=LIBXL_DISK_SPECIFICATION_XEN ) { +fprintf (stderr,"block-attach is only supported for specification xen\n" );This check prevents a previously working
block-attachcommand line from working.Quoted 5 lines
# xl -Tvvv block-attach 0 /dev/vg/guest_disk,raw,hda block-attach is only supported for specification xenAt least, that works by adding ",specification=xen", but it should work without it as "xen" is the default (from the man page).
yes, you are right. thank you for pointing this out.
Quoted 7 lines
Maybe the check is done too soon, or maybe a better place to do it would be in libxl.
libxl__device_disk_setdefault()is called much later, while executinglibxl_device_disk_add(), soxlcan't use the default been done there to "disk.specification".I got it.
Quoted 8 lines
xl block-attachcallslibxl_device_disk_add()which I think is only called for hotplug of disk. If I recall correctly,libxl__add_disks()is called instead at guest creation. So maybe it is possible to do something inlibxl_device_disk_add(), but that a function defined by a macro, and the macro is using the samelibxl__device_disk_add()thatlibxl_device_disk_add(). On the other hand, there is a "hotplug" parameter tolibxl__device_disk_setdefault(), maybe that could be use?Thank you for digging into the details here.
If I understood correctly your suggestion we simply can drop checks in
main_blockattach()(and likelymain_blockdetach()?) and add it tolibxl__device_disk_setdefault().tools/libs/light/libxl_disk.c +0
-0
tools/libs/light/libxl_disk.c static int libxl__device_disk_setdefault(libxl__gc *gc, · line 188
Quoted 7 lines
tools/libs/light/libxl_disk.c +2
-0@@ -182,6 +182,11 @@ static int libxl__device_disk_setdefault(libxl__gc *gc,uint32_t domid, disk->transport = LIBXL_DISK_TRANSPORT_MMIO; } + if (hotplug && disk->specification != LIBXL_DISK_SPECIFICATION_XEN) { + LOGD(ERROR, domid, "Hotplug is only supported for specification xen");
Maybe check for specification == VIRTIO instead, and report that hotplug isn't supported in virtio's case.
Quoted 10 lines
tools/libs/light/libxl_disk.c +3
-0+ return ERROR_FAIL; + } + /* Force Qdisk backend for CDROM devices of guests with a device model.*/
if (disk->is_cdrom!= 0 &&
libxl__domain_type(gc, domid)==LIBXL_DOMAIN_TYPE_HVM) {Is my understanding correct?
Yes, that looks correct.
But I didn't look at the block-detach, and it seems that this part only use generic functions to remove a disk. So there is no easy way to prevent hotunplug from libxl. But xl does have access to a fully initialised "disk" so can check the value of "specification", I guess the check can stay in main_blockdetach().
Cheers,
Signature · 1 line
Anthony PERARD
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
On 17.06.22 17:29, Anthony PERARD wrote:
Hello Anthony
Quoted 55 lines · Oleksandr
Quoted 54 lines · Anthony PERARD
Quoted 13 lines · Oleksandr Tyshchenko
tools/xl/xl_block.c int main_blockattach(int argc, char **argv) · line 53
Quoted 9 lines
tools/xl/xl_block.c +2
-0@@ -50,6 +50,11 @@ int main_blockattach(int argc, char **argv)return 0 ; } +if (disk.specification !=LIBXL_DISK_SPECIFICATION_XEN ) { +fprintf (stderr,"block-attach is only supported for specification xen\n" );This check prevents a previously working
block-attachcommand line from working.Quoted 5 lines
# xl -Tvvv block-attach 0 /dev/vg/guest_disk,raw,hda block-attach is only supported for specification xenAt least, that works by adding ",specification=xen", but it should work without it as "xen" is the default (from the man page).
yes, you are right. thank you for pointing this out.
Quoted 6 lines
Maybe the check is done too soon, or maybe a better place to do it would be in libxl.
libxl__device_disk_setdefault()is called much later, while executinglibxl_device_disk_add(), soxlcan't use the default been done there to "disk.specification".I got it.
Quoted 7 lines
xl block-attachcallslibxl_device_disk_add()which I think is only called for hotplug of disk. If I recall correctly,libxl__add_disks()is called instead at guest creation. So maybe it is possible to do something inlibxl_device_disk_add(), but that a function defined by a macro, and the macro is using the samelibxl__device_disk_add()thatlibxl_device_disk_add(). On the other hand, there is a "hotplug" parameter tolibxl__device_disk_setdefault(), maybe that could be use?Thank you for digging into the details here.
If I understood correctly your suggestion we simply can drop checks in
main_blockattach()(and likelymain_blockdetach()?) and add it tolibxl__device_disk_setdefault().tools/libs/light/libxl_disk.c +0
-0@@ -182,6 +182,11 @@ static int libxl__device_disk_setdefault(libxl__gc *gc,uint32_t domid, disk->transport = LIBXL_DISK_TRANSPORT_MMIO; }
Quoted 5 lines
tools/libs/light/libxl_disk.c static int libxl__device_disk_setdefault(libxl__gc *gc, · line 188
Quoted 3 lines
tools/libs/light/libxl_disk.c +2
-0+ if (hotplug && disk->specification != LIBXL_DISK_SPECIFICATION_XEN) { + LOGD(ERROR, domid, "Hotplug is only supported for specification xen");Maybe check for
specification == VIRTIOinstead, and report that hotplug isn't supported in virtio's case.
ok, will do
Quoted 10 lines
Quoted 10 lines
tools/libs/light/libxl_disk.c +3
-0+ return ERROR_FAIL; + } + /* Force Qdisk backend for CDROM devices of guests with a device model.*/
if (disk->is_cdrom!= 0 &&
libxl__domain_type(gc, domid)==LIBXL_DOMAIN_TYPE_HVM) {
Quoted 2 lines
Quoted 1 line
Is my understanding correct?
Yes, that looks correct.
thank you for the confirmation
Quoted 6 lines
But I didn't look at the block-detach, and it seems that this part only use generic functions to remove a disk. So there is no easy way to prevent hotunplug from libxl. But
xldoes have access to a fully initialised "disk" so can check the value of "specification", I guess the check can stay inmain_blockdetach().
ok, I got it
So, it works
root@generic-armv8-xt-dom0:~# xl block-attach DomU /dev/loop0,raw,xvda3,specification=virtio libxl: error: libxl_disk.c:186:libxl__device_disk_setdefault: Domain 2:Hotplug isn't supported for specification virtio libxl: error: libxl_device.c:1468:device_addrm_aocomplete: unable to add device libxl_device_disk_add failed.
root@generic-armv8-xt-dom0:~# xl block-detach DomU 51713 Hotunplug isn't supported for specification virtio
**********
root@generic-armv8-xt-dom0:~# xl block-attach DomU /dev/loop0,raw,xvda3 [ 364.656091] xen-blkback: backend/vbd/3/51715: using 4 queues, protocol 1 (arm-abi)
Quoted 3 lines
Cheers,
Signature · 3 lines
Regards, Oleksandr Tyshchenko
PATCH v10 1/3 libxl: Add support for Virtio disk configuration
From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to struct libxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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, specification=virtio']
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.
---
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).
Changes V7 -> V8:
- update *.gen.go files and libxlu_disk_l.[ch] files
- update patch description and comments in the code
- use "specification" config option instead of "protocol"
- update libxl_types.idl and code according to new fields in libxl_device_disk
Changes V8 -> V9:
- update (and harden) checks in libxl__device_disk_setdefault(), return error in case of incorrect settings of specification
and transport
- remove both asserts in device_disk_add()
- update virtio related code in libxl__disk_from_xenstore(),
do not fail if specification node is absent, replace
open-coded checks of fetched specification and transport by libxl_disk_specification_from_string() and libxl_disk_transport_from_string() respectively
- s/libxl_device_disk_get_path/libxl__device_disk_get_path
- add a comment for virtio-mmio parameters in struct libxl_device_disk
Changes V9 -> V10:
- s/ERROR_FAIL/ERROR_INVAL in both places in libxl__device_disk_setdefault()
- rework libxl__device_disk_get_path()
Changes V10 -> V10.1:
- fix small coding style issue in libxl__device_disk_get_path()
- drop specification check in main_blockattach() and add required check in libxl__device_disk_setdefault()
- update specification check in main_blockdetach()
--- docs/man/xl-disk-configuration.5.pod.in | 38 +- tools/golang/xenlight/helpers.gen.go | 8 + tools/golang/xenlight/types.gen.go | 18 + tools/include/libxl.h | 7 + tools/libs/light/libxl_device.c | 62 +- tools/libs/light/libxl_disk.c | 146 ++++- tools/libs/light/libxl_internal.h | 2 + tools/libs/light/libxl_types.idl | 18 + tools/libs/light/libxl_types_internal.idl | 1 + tools/libs/light/libxl_utils.c | 2 + tools/libs/util/libxlu_disk_l.c | 959 +++++++++++++++--------------- tools/libs/util/libxlu_disk_l.h | 2 +- tools/libs/util/libxlu_disk_l.l | 9 + tools/xl/xl_block.c | 6 + 14 files changed, 798 insertions(+), 480 deletions(-)
docs/man/xl-disk-configuration.5.pod.in +34 -4
@@ -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 "specification" 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 specifications other than "virtio". Normally this option should not be specified, in which case libxl will automatically determine the most suitable backend.
@@ -344,8 +346,36 @@ 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<specification>=I<SPECIFICATION> + +=over 4 + +=item Description + +Specifies the communication protocol (specification) to use for the chosen +"backendtype" option + +=item Supported values + +xen, virtio + +=item Mandatory + +No + +=item Default value + +xen + =back +Besides forcing toolstack to use specific backend implementation, this also +affects the guest's view of the device. For example, "virtio" requires +Virtio frontend driver (virtio-blk) to be used. Please note, the virtual +device (vdev) is not passed to the guest in that case, but it still must be +specified for the internal purposes. + +=back =head1 COLO Parameters
tools/golang/xenlight/helpers.gen.go +8 -0
@@ -1751,6 +1751,10 @@ x.DirectIoSafe = bool(xc.direct_io_safe) if err := x.DiscardEnable.fromC(&xc.discard_enable);err != nil { return fmt.Errorf("converting field DiscardEnable: %v", err) } +x.Specification = DiskSpecification(xc.specification) +x.Transport = DiskTransport(xc.transport) +x.Irq = uint32(xc.irq) +x.Base = uint64(xc.base) if err := x.ColoEnable.fromC(&xc.colo_enable);err != nil { return fmt.Errorf("converting field ColoEnable: %v", err) }
@@ -1788,6 +1792,10 @@ xc.direct_io_safe = C.bool(x.DirectIoSafe) if err := x.DiscardEnable.toC(&xc.discard_enable); err != nil { return fmt.Errorf("converting field DiscardEnable: %v", err) } +xc.specification = C.libxl_disk_specification(x.Specification) +xc.transport = C.libxl_disk_transport(x.Transport) +xc.irq = C.uint32_t(x.Irq) +xc.base = C.uint64_t(x.Base) if err := x.ColoEnable.toC(&xc.colo_enable); err != nil { return fmt.Errorf("converting field ColoEnable: %v", err) }
tools/golang/xenlight/types.gen.go +18 -0
@@ -99,6 +99,20 @@ DiskBackendUnknown DiskBackend = 0 DiskBackendPhy DiskBackend = 1 DiskBackendTap DiskBackend = 2 DiskBackendQdisk DiskBackend = 3 +DiskBackendOther DiskBackend = 4 +) + +type DiskSpecification int +const( +DiskSpecificationUnknown DiskSpecification = 0 +DiskSpecificationXen DiskSpecification = 1 +DiskSpecificationVirtio DiskSpecification = 2 +) + +type DiskTransport int +const( +DiskTransportUnknown DiskTransport = 0 +DiskTransportMmio DiskTransport = 1 ) type NicType int
@@ -643,6 +657,10 @@ Readwrite int IsCdrom int DirectIoSafe bool DiscardEnable Defbool +Specification DiskSpecification +Transport DiskTransport +Irq uint32 +Base uint64 ColoEnable Defbool ColoRestoreEnable Defbool ColoHost string
tools/include/libxl.h +7 -0
@@ -528,6 +528,13 @@#define LIBXL_HAVE_MAX_GRANT_VERSION 1/* +* LIBXL_HAVE_DEVICE_DISK_SPECIFICATION indicates that 'specification' and +* 'transport' fields (of libxl_disk_specification and libxl_disk_transport +* types respectively) are present in libxl_device_disk. +*/ +#define LIBXL_HAVE_DEVICE_DISK_SPECIFICATION 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility
tools/libs/light/libxl_device.c +58 -4
111 lines not on this page · raw message
tools/libs/light/libxl_disk.c +139 -7
215 lines not on this page · raw message
tools/libs/light/libxl_internal.h +2 -0
@@ -1493,6 +1493,8 @@ _hidden char * libxl__domain_pvcontrol_read(libxl__gc *gc,/* from xl_device */ _hidden char *libxl__device_disk_string_of_backend(libxl_disk_backend backend); +_hidden char *libxl__device_disk_string_of_specification(libxl_disk_specification specification); +_hidden char *libxl__device_disk_string_of_transport(libxl_disk_transport transport); _hidden char *libxl__device_disk_string_of_format(libxl_disk_format format); _hidden const char *libxl__qemu_disk_format_string(libxl_disk_format format); _hidden int libxl__device_disk_set_backend(libxl__gc*, libxl_device_disk*);
tools/libs/light/libxl_types.idl +18 -0
@@ -130,6 +130,18 @@ libxl_disk_backend = Enumeration("disk_backend", [ (1, "PHY"), (2, "TAP"), (3, "QDISK"), + (4, "OTHER"), + ]) + +libxl_disk_specification = Enumeration("disk_specification", [ + (0, "UNKNOWN"), + (1, "XEN"), + (2, "VIRTIO"), + ]) + +libxl_disk_transport = Enumeration("disk_transport", [ + (0, "UNKNOWN"), + (1, "MMIO"), ]) libxl_nic_type = Enumeration("nic_type", [
@@ -704,6 +716,12 @@ libxl_device_disk = Struct("device_disk", [ ("is_cdrom", integer), ("direct_io_safe", bool), ("discard_enable", libxl_defbool), + ("specification", libxl_disk_specification), + ("transport", libxl_disk_transport), + # Note that virtio-mmio parameters (irq and base) are for internal use + # by libxl and can't be modified. + ("irq", uint32), + ("base", uint64), # Note that the COLO configuration settings should be considered unstable. # They may change incompatibly in future versions of Xen. ("colo_enable", libxl_defbool),
tools/libs/light/libxl_types_internal.idl +1 -0
@@ -32,6 +32,7 @@ libxl__device_kind = Enumeration("device_kind", [ (14, "PVCALLS"), (15, "VSND"), (16, "VINPUT"), + (17, "VIRTIO_DISK"), ]) libxl__console_backend = Enumeration("console_backend", [
tools/libs/light/libxl_utils.c +2 -0
@@ -297,6 +297,8 @@ int libxl_string_to_backend(libxl_ctx *ctx, char *s, libxl_disk_backend *backend *backend =LIBXL_DISK_BACKEND_TAP ; }else if (!strcmp (s,"qdisk" )) { *backend =LIBXL_DISK_BACKEND_QDISK ; + }else if (!strcmp (s,"other" )) { + *backend =LIBXL_DISK_BACKEND_OTHER ; }else if (!strcmp (s,"tap" )) { p =strchr (s,':' );if (!p) {
tools/libs/util/libxlu_disk_l.c +495 -464
1,244 lines not on this page · raw message
tools/libs/util/libxlu_disk_l.h +1 -1
@@ -694,7 +694,7 @@ extern int yylex (yyscan_t yyscanner);#undef yyTABLES_NAME#endif -#line 291 "libxlu_disk_l.l" +#line 300 "libxlu_disk_l.l"#line 699 "libxlu_disk_l.h"#undef xlu__disk_yyIN_HEADER
tools/libs/util/libxlu_disk_l.l +9 -0
@@ -122,9 +122,17 @@ static void setbackendtype(DiskParseContext *dpc, const char *str) { if ( !strcmp(str,"phy")) DSET(dpc,backend,BACKEND,str,PHY); else if (!strcmp(str,"tap")) DSET(dpc,backend,BACKEND,str,TAP); else if (!strcmp(str,"qdisk")) DSET(dpc,backend,BACKEND,str,QDISK); + else if (!strcmp(str,"other")) DSET(dpc,backend,BACKEND,str,OTHER); else xlu__disk_err(dpc,str,"unknown value for backendtype"); } +/* Sets ->specification from the string. IDL should provide something for this. */ +static void setspecification(DiskParseContext *dpc, const char *str) { + if (!strcmp(str,"xen")) DSET(dpc,specification,SPECIFICATION,str,XEN); + else if (!strcmp(str,"virtio")) DSET(dpc,specification,SPECIFICATION,str,VIRTIO); + else xlu__disk_err(dpc,str,"unknown value for specification"); +} + /* Sets ->colo-port from the string. COLO need this. */ static void setcoloport(DiskParseContext *dpc, const char *str) { int port = atoi(str);
@@ -192,6 +200,7 @@ devtype=[^,]*,? { xlu__disk_err(DPC,yytext,"unknown value for type"); } access=[^,]*,? { STRIP(','); setaccess(DPC, FROMEQUALS); } backend=[^,]*,? { STRIP(','); SAVESTRING("backend", backend_domname, FROMEQUALS); } backendtype=[^,]*,? { STRIP(','); setbackendtype(DPC,FROMEQUALS); } +specification=[^,]*,? { STRIP(','); setspecification(DPC,FROMEQUALS); } vdev=[^,]*,? { STRIP(','); SAVESTRING("vdev", vdev, FROMEQUALS); } script=[^,]*,? { STRIP(','); SAVESTRING("script", script, FROMEQUALS); }
tools/xl/xl_block.c +6 -0
@@ -119,6 +119,12 @@ int main_blockdetach(int argc, char **argv)fprintf (stderr,"Error: Device %s not connected.\n" , argv[optind+1 ]);return 1 ; } + +if (disk.specification ==LIBXL_DISK_SPECIFICATION_VIRTIO ) { +fprintf (stderr,"Hotunplug isn't supported for specification virtio\n" ); +return 1 ; + } + rc = !force ?libxl_device_disk_safe_remove (ctx, domid, &disk,0 ) :libxl_device_disk_destroy (ctx, domid, &disk,0 );if (rc) {
Signature · 1 line
2.7.4
Re: [PATCH V10.1 1/3] libxl: Add support for Virtio disk configuration
Quoted 47 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelAn example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, specification=virtio']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.
Quoted 7 lines
Signed-off-by Oleksandr Tyshchenko <[email protected]>---
Changes V10 -> V10.1:
- fix small coding style issue inlibxl__device_disk_get_path()
- drop specification check inmain_blockattach()and add required check inlibxl__device_disk_setdefault()
- update specification check inmain_blockdetach()
For this v10.1: Reviewed-by: Anthony PERARD <[email protected]>
BTW, the subject of this updated patch still state "v10" instead of "v10.1", hopefully committers can pick the right version.
Cheers,
Signature · 1 line
Anthony PERARD
Re: [PATCH V10.1 1/3] libxl: Add support for Virtio disk configuration
Hello Anthony
[sorry for the possible format issues]
Quoted 57 lines · Anthony PERARD
Quoted 33 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelQuoted 2 lines
An example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other,specification=virtio']
Quoted 12 lines
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.
Quoted 7 lines
Signed-off-by Oleksandr Tyshchenko <[email protected]>---
Changes V10 -> V10.1:
- fix small coding style issue inlibxl__device_disk_get_path()
- drop specification check inmain_blockattach()and add required check inlibxl__device_disk_setdefault()
- update specification check inmain_blockdetach()
Quoted 2 lines
For this v10.1: Reviewed-by: Anthony PERARD <[email protected]>
perfect, thanks!
Quoted 4 lines
BTW, the subject of this updated patch still state "v10" instead of "v10.1", hopefully committers can pick the right version.
Oh, sorry, I was thinking to use "v10.1", but I wasn't sure that commit with updated subject would properly appear in the current thread if being sent using git send-email --in-reply-to))
Quoted 6 lines
Cheers,
--
Anthony PERARD
Signature · 3 lines
Regards, Oleksandr Tyshchenko
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
In reply to Oleksandr TyshchenkoQuoted 51 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelAn example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, specification=virtio']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.
Quoted 1 line
Signed-off-by Oleksandr Tyshchenko <[email protected]>
OK, I am *really* sorry for coming in here at the last minute and quibbling about things. But this introduces a public interface which looks really wrong to me. I’ve replied to the mail from December where Juergen proposed the “Other” protocol.
Hopefully this will be a simple matter of finding a better name than “other”. (Or you guys convincing me that “other” is really the best name for this value; or even Anthony asserting his right as a maintainer to overrule my objection if he thinks I’m out of line.)
FWIW the Golang changes look fine.
-George
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
On 24.06.22 15:59, George Dunlap wrote:
Hello George
Quoted 50 lines
Quoted 50 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelAn example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, specification=virtio']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.
Quoted 2 lines
Quoted 1 line
Signed-off-by Oleksandr Tyshchenko <[email protected]>OK, I am *really* sorry for coming in here at the last minute and quibbling about things.
no problem
Quoted 3 lines
But this introduces a public interface which looks really wrong to me. I’ve replied to the mail from December where Juergen proposed the “Other” protocol.
Hopefully this will be a simple matter of finding a better name than “other”. (Or you guys convincing me that “other” is really the best name for this value; or even Anthony asserting his right as a maintainer to overrule my objection if he thinks I’m out of line.)
I saw your reply to V6 and Juergen's answer. I share Juergen's opinion as well as I understand your concern. I think, this is exactly the situation when finding a perfect name (obvious, short, etc) for the backendtype (in our particular case) is really difficult.
Personally I tend to leave "other", because there is no better alternative from my PoV. Also I might be completely wrong here, but I don't think we will have to extend the "backendtype" for supporting other possible virtio backend implementations in the foreseeable future:
- when Qemu gains the required support we will choose qdisk: backendtype qdisk specification virtio
- for the possible virtio alternative of the blkback we will choose phy: backendtype phy specification virtio
If there will be a need to keep various implementation, we will be able to describe that by using "transport" (mmio, pci, xenbus, argo, whatever). Actually this is why we also introduced "specification" and "transport".
IIRC, there were other (suggested?) names except "other" which are "external" and "daemon". If you think that one of them is better than "other", I will happy to use it.
Quoted 5 lines
FWIW the Golang changes look fine.
-George
Signature · 3 lines
Regards, Oleksandr Tyshchenko
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
Dear all.
Quoted 76 lines · Oleksandr
On 24.06.22 15:59, George Dunlap wrote:
Hello George
Quoted 50 lines
Quoted 50 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelAn example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, specification=virtio']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.
Quoted 2 lines
Quoted 1 line
Signed-off-by Oleksandr Tyshchenko <[email protected]>OK, I am *really* sorry for coming in here at the last minute and quibbling about things.
no problem
Quoted 3 lines
But this introduces a public interface which looks really wrong to me. I’ve replied to the mail from December where Juergen proposed the “Other” protocol.
Hopefully this will be a simple matter of finding a better name than “other”. (Or you guys convincing me that “other” is really the best name for this value; or even Anthony asserting his right as a maintainer to overrule my objection if he thinks I’m out of line.)
I saw your reply to V6 and Juergen's answer. I share Juergen's opinion as well as I understand your concern. I think, this is exactly the situation when finding a perfect name (obvious, short, etc) for the backendtype (in our particular case) is really difficult.
Personally I tend to leave "other", because there is no better alternative from my PoV. Also I might be completely wrong here, but I don't think we will have to extend the "backendtype" for supporting other possible virtio backend implementations in the foreseeable future:
- when Qemu gains the required support we will choose qdisk:
backendtype qdisk specification virtio
- for the possible virtio alternative of the blkback we will choose
phy: backendtype phy specification virtio
Quoted 4 lines
If there will be a need to keep various implementation, we will be able to describe that by using "transport" (mmio, pci, xenbus, argo, whatever). Actually this is why we also introduced "specification" and "transport".
IIRC, there were other (suggested?) names except "other" which are "external" and "daemon". If you think that one of them is better than "other", I will happy to use it.
Could we please make a decision on this?
If "other" is not unambiguous, then maybe we could choose "daemon" to describe arbitrary user-level backends, any thought?
Quoted 5 lines
Quoted 5 lines
FWIW the Golang changes look fine.
Thanks.
Quoted 3 lines
Quoted 3 lines
-George
Signature · 3 lines
Regards, Oleksandr Tyshchenko
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
Quoted 84 lines · Oleksandr
Dear all.
Quoted 79 lines · Oleksandr
On 24.06.22 15:59, George Dunlap wrote:
Hello George
Quoted 50 lines
Quoted 50 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelAn example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, specification=virtio']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.
Quoted 2 lines
Quoted 1 line
Signed-off-by Oleksandr Tyshchenko <[email protected]>OK, I am *really* sorry for coming in here at the last minute and quibbling about things.
no problem
Quoted 3 lines
But this introduces a public interface which looks really wrong to me. I’ve replied to the mail from December where Juergen proposed the “Other” protocol.
Hopefully this will be a simple matter of finding a better name than “other”. (Or you guys convincing me that “other” is really the best name for this value; or even Anthony asserting his right as a maintainer to overrule my objection if he thinks I’m out of line.)
I saw your reply to V6 and Juergen's answer. I share Juergen's opinion as well as I understand your concern. I think, this is exactly the situation when finding a perfect name (obvious, short, etc) for the backendtype (in our particular case) is really difficult.
Personally I tend to leave "other", because there is no better alternative from my PoV. Also I might be completely wrong here, but I don't think we will have to extend the "backendtype" for supporting other possible virtio backend implementations in the foreseeable future:
- when Qemu gains the required support we will choose qdisk: backendtype qdisk specification virtio
- for the possible virtio alternative of the blkback we will choose phy:
backendtype phy specification virtioIf there will be a need to keep various implementation, we will be able to describe that by using "transport" (mmio, pci, xenbus, argo, whatever). Actually this is why we also introduced "specification" and "transport".
Quoted 6 lines
Quoted 1 line
IIRC, there were other (suggested?) names except "other" which are "external" and "daemon". If you think that one of them is better than "other", I will happy to use it.
Could we please make a decision on this?
If "other" is not unambiguous, then maybe we could choose "daemon" to describe arbitrary user-level backends, any thought?
IMO this would exclude other cases, like special kernel drivers.
Maybe "standalone"? "only-relying-on-xenstore-data" would be a bit exaggerated, while conveying the idea quite nicely.
Juergen
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
On 30.06.22 15:24, Juergen Gross wrote:
Hello Juergen
Quoted 85 lines · Oleksandr
Quoted 84 lines
Dear all.
Quoted 79 lines · Oleksandr
On 24.06.22 15:59, George Dunlap wrote:
Hello George
Quoted 50 lines
Quoted 50 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelAn example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, specification=virtio']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.
Quoted 2 lines
Quoted 1 line
Signed-off-by Oleksandr Tyshchenko <[email protected]>OK, I am *really* sorry for coming in here at the last minute and quibbling about things.
no problem
Quoted 3 lines
But this introduces a public interface which looks really wrong to me. I’ve replied to the mail from December where Juergen proposed the “Other” protocol.
Hopefully this will be a simple matter of finding a better name than “other”. (Or you guys convincing me that “other” is really the best name for this value; or even Anthony asserting his right as a maintainer to overrule my objection if he thinks I’m out of line.)
I saw your reply to V6 and Juergen's answer. I share Juergen's opinion as well as I understand your concern. I think, this is exactly the situation when finding a perfect name (obvious, short, etc) for the backendtype (in our particular case) is really difficult.
Personally I tend to leave "other", because there is no better alternative from my PoV. Also I might be completely wrong here, but I don't think we will have to extend the "backendtype" for supporting other possible virtio backend implementations in the foreseeable future:
- when Qemu gains the required support we will choose qdisk:
backendtype qdisk specification virtio
- for the possible virtio alternative of the blkback we will choose
phy: backendtype phy specification virtioIf there will be a need to keep various implementation, we will be able to describe that by using "transport" (mmio, pci, xenbus, argo, whatever). Actually this is why we also introduced "specification" and "transport".
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
IIRC, there were other (suggested?) names except "other" which are "external" and "daemon". If you think that one of them is better than "other", I will happy to use it.
Could we please make a decision on this?
If "other" is not unambiguous, then maybe we could choose "daemon" to describe arbitrary user-level backends, any thought?
IMO this would exclude other cases, like special kernel drivers.
I got it.
Quoted 4 lines
Maybe "standalone"? "only-relying-on-xenstore-data" would be a bit exaggerated, while conveying the idea quite nicely.
"standalone" sounds good to me, thank you. I will wait a little bit for other opinions before making changes.
Quoted 3 lines
Juergen
Signature · 3 lines
Regards, Oleksandr Tyshchenko
George Dunlap
Acked-byRe: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
In reply to OleksandrQuoted 86 lines · Oleksandr
Dear all.
Quoted 77 lines · Oleksandr
On 24.06.22 15:59, George Dunlap wrote:
Hello George
Quoted 50 lines
Quoted 50 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelAn example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, specification=virtio']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.
Quoted 2 lines
Quoted 1 line
Signed-off-by Oleksandr Tyshchenko <[email protected]>OK, I am *really* sorry for coming in here at the last minute and quibbling about things.
no problem
Quoted 3 lines
But this introduces a public interface which looks really wrong to me. I’ve replied to the mail from December where Juergen proposed the “Other” protocol.
Hopefully this will be a simple matter of finding a better name than “other”. (Or you guys convincing me that “other” is really the best name for this value; or even Anthony asserting his right as a maintainer to overrule my objection if he thinks I’m out of line.)
I saw your reply to V6 and Juergen's answer. I share Juergen's opinion as well as I understand your concern. I think, this is exactly the situation when finding a perfect name (obvious, short, etc) for the backendtype (in our particular case) is really difficult.
Personally I tend to leave "other", because there is no better alternative from my PoV. Also I might be completely wrong here, but I don't think we will have to extend the "backendtype" for supporting other possible virtio backend implementations in the foreseeable future:
- when Qemu gains the required support we will choose qdisk: backendtype qdisk specification virtio
- for the possible virtio alternative of the blkback we will choose phy: backendtype phy specification virtioIf there will be a need to keep various implementation, we will be able to describe that by using "transport" (mmio, pci, xenbus, argo, whatever). Actually this is why we also introduced "specification" and "transport".
Quoted 6 lines
Quoted 1 line
IIRC, there were other (suggested?) names except "other" which are "external" and "daemon". If you think that one of them is better than "other", I will happy to use it.
Could we please make a decision on this?
If "other" is not unambiguous, then maybe we could choose "daemon" to describe arbitrary user-level backends, any thought?
Unfortunately I didn’t have time to dig into this; I’m just going to have to withdraw my objection, and let you & Juergen decide what to call it.
Re the golang changes:
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
On 13.07.22 03:01, George Dunlap wrote:
Hello George, Anthony
Quoted 112 lines
Quoted 112 lines · Oleksandr
Dear all.
Quoted 101 lines · Oleksandr
On 24.06.22 15:59, George Dunlap wrote:
Hello George
Quoted 54 lines
Quoted 54 lines
On 17 Jun 2022, at 17:14, Oleksandr Tyshchenko
<[email protected]> wrote:From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio
based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelAn example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, specification=virtio']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.
Quoted 3 lines
Quoted 1 line
Signed-off-by Oleksandr Tyshchenko <[email protected]>OK, I am *really* sorry for coming in here at the last minute and quibbling about things.
no problem
Quoted 8 lines
But this introduces a public interface which looks really wrong to me. I’ve replied to the mail from December where Juergen proposed the “Other” protocol.
Hopefully this will be a simple matter of finding a better name than “other”. (Or you guys convincing me that “other” is really the best name for this value; or even Anthony asserting his right as a maintainer to overrule my objection if he thinks I’m out of line.)
I saw your reply to V6 and Juergen's answer. I share Juergen's opinion as well as I understand your concern. I think, this is exactly the situation when finding a perfect name (obvious, short, etc) for the backendtype (in our particular case) is really difficult.
Personally I tend to leave "other", because there is no better alternative from my PoV. Also I might be completely wrong here, but I don't think we will have to extend the "backendtype" for supporting other possible virtio backend implementations in the foreseeable future:
- when Qemu gains the required support we will choose qdisk:
backendtype qdisk specification virtio
- for the possible virtio alternative of the blkback we will choose
phy: backendtype phy specification virtioIf there will be a need to keep various implementation, we will be able to describe that by using "transport" (mmio, pci, xenbus, argo, whatever).
Actually this is why we also introduced "specification" and "transport".IIRC, there were other (suggested?) names except "other" which are "external" and "daemon". If you think that one of them is better than "other", I will happy to use it.
Quoted 8 lines
Quoted 4 lines
Could we please make a decision on this?
If "other" is not unambiguous, then maybe we could choose "daemon" to describe arbitrary user-level backends, any thought?
Unfortunately I didn’t have time to dig into this; I’m just going to have to withdraw my objection, and let you & Juergen decide what to call it.
George, thanks for letting me know. Juergen proposed to use "standalone" for the new backendtype name which is far more specific. I agree with that.
Anthony, would you be happy with that renaming?
Quoted 4 lines
Re the golang changes:
Acked-by George Dunlap <[email protected]>
Thanks.
Signature · 3 lines
Regards, Oleksandr Tyshchenko
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
Quoted 126 lines · Oleksandr Tyshchenko
On 13.07.22 03:01, George Dunlap wrote:
Hello George, Anthony
Quoted 112 lines
Quoted 112 lines · Oleksandr
Dear all.
Quoted 101 lines · Oleksandr
On 24.06.22 15:59, George Dunlap wrote:
Hello George
Quoted 54 lines
Quoted 54 lines
On 17 Jun 2022, at 17:14, Oleksandr Tyshchenko
<[email protected]> wrote:From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio
based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelAn example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, specification=virtio']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.
Quoted 3 lines
Quoted 1 line
Signed-off-by Oleksandr Tyshchenko <[email protected]>OK, I am *really* sorry for coming in here at the last minute and quibbling about things.
no problem
Quoted 8 lines
But this introduces a public interface which looks really wrong to me. I’ve replied to the mail from December where Juergen proposed the “Other” protocol.
Hopefully this will be a simple matter of finding a better name than “other”. (Or you guys convincing me that “other” is really the best name for this value; or even Anthony asserting his right as a maintainer to overrule my objection if he thinks I’m out of line.)
I saw your reply to V6 and Juergen's answer. I share Juergen's opinion as well as I understand your concern. I think, this is exactly the situation when finding a perfect name (obvious, short, etc) for the backendtype (in our particular case) is really difficult.
Personally I tend to leave "other", because there is no better alternative from my PoV. Also I might be completely wrong here, but I don't think we will have to extend the "backendtype" for supporting other possible virtio backend implementations in the foreseeable future:
- when Qemu gains the required support we will choose qdisk:
backendtype qdisk specification virtio
- for the possible virtio alternative of the blkback we will choose
phy: backendtype phy specification virtioIf there will be a need to keep various implementation, we will be able to describe that by using "transport" (mmio, pci, xenbus, argo, whatever).
Actually this is why we also introduced "specification" and "transport".IIRC, there were other (suggested?) names except "other" which are "external" and "daemon". If you think that one of them is better than "other", I will happy to use it.
Quoted 8 lines
Quoted 4 lines
Could we please make a decision on this?
If "other" is not unambiguous, then maybe we could choose "daemon" to describe arbitrary user-level backends, any thought?
Unfortunately I didn’t have time to dig into this; I’m just going to have to withdraw my objection, and let you & Juergen decide what to call it.
Quoted 5 lines
George, thanks for letting me know. Juergen proposed to use "standalone" for the new backendtype name which is far more specific. I agree with that.
Anthony, would you be happy with that renaming?
I tried to figure out what backendtype is supposed to mean, how it's used. I feel it's quite messy at the moment.
Man page xl-disk-configuration says it's a backend implementation to use. Beside 'phy', which I guess is the kernel or blkback, the two other point to QEMU ('qdisk') and tapdisk ('tap').
The, backendtype is used throughout libxl to deal with the different backend implementation, and the value is stored in the xenstore key "type". From "blkif.h", "type" should be 'file' or 'phy' or 'tap', but we store 'qdisk' for 'qdisk'... so the "type" note in xenstore is probably useless for qdisk, but maybe useful for 'phy'? (This "type" node is only for the backend, so probably useless for a front end.)
Anyway, it seems to me that backendtype should be the name of the implementation of the backend we want to use. It is just a parameter to tell libxl how to communicate with the backend. At the moment libxl uses xenstore to communicates with all backends even if that's not required, because libxl works this way and it's hard to change. (We could communicate with QEMU via QMP rather than xenstore for example.)
So I guess either you have a name for your implementation, or something generic will do. So "standalone" is fine.
(We probably want to document somewhere that this new type would simply mean "only-relying-on-xenstore-data" like Juergen is putting it, and isn't blkback or QEMU.)
Thanks,
Signature · 1 line
Anthony PERARD
Re: [PATCH V10 1/3] libxl: Add support for Virtio disk configuration
On 15.07.22 18:24, Anthony PERARD wrote:
Hello Anthony
Quoted 130 lines · Oleksandr Tyshchenko
Quoted 114 lines · George Dunlap
Hello George, Anthony
Quoted 110 lines
Quoted 110 lines · Oleksandr
Dear all.
Quoted 89 lines · Oleksandr
On 24.06.22 15:59, George Dunlap wrote:
Hello George
Quoted 53 lines
Quoted 53 lines
On 17 Jun 2022, at 17:14, Oleksandr Tyshchenko
<[email protected]> wrote:From: Oleksandr Tyshchenko <[email protected]>
This patch adds basic support for configuring and assisting virtio-mmio
based virtio-disk backend (emulator) 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 currently ("vdev" is not passed to the frontend). But this might need to be revised in future, so frontend data might be written to Xenstore in order to support hotplugging virtio devices or passing the backend domain id on arch where the device-tree is not available.
- 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 "specification" and "transport" fields to structlibxl_device_disk. Both are written to the Xenstore. The transport field is only used for the specification "virtio" and it assumes only "mmio" value for now.
- Introduce new "specification" option with "xen" communication 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 modelAn example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=other, specification=virtio']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.
Quoted 3 lines
Quoted 1 line
Signed-off-by Oleksandr Tyshchenko <[email protected]>OK, I am *really* sorry for coming in here at the last minute and quibbling about things.
no problem
Quoted 8 lines
But this introduces a public interface which looks really wrong to me. I’ve replied to the mail from December where Juergen proposed the “Other” protocol.
Hopefully this will be a simple matter of finding a better name than “other”. (Or you guys convincing me that “other” is really the best name for this value; or even Anthony asserting his right as a maintainer to overrule my objection if he thinks I’m out of line.)
I saw your reply to V6 and Juergen's answer. I share Juergen's opinion as well as I understand your concern. I think, this is exactly the situation when finding a perfect name (obvious, short, etc) for the backendtype (in our particular case) is really difficult.
Personally I tend to leave "other", because there is no better alternative from my PoV. Also I might be completely wrong here, but I don't think we will have to extend the "backendtype" for supporting other possible virtio backend implementations in the foreseeable future:
- when Qemu gains the required support we will choose qdisk:
backendtype qdisk specification virtio
- for the possible virtio alternative of the blkback we will choose
phy: backendtype phy specification virtioQuoted 8 lines
If there will be a need to keep various implementation, we will be able to describe that by using "transport" (mmio, pci, xenbus, argo, whatever).
Actually this is why we also introduced "specification" and "transport".IIRC, there were other (suggested?) names except "other" which are "external" and "daemon". If you think that one of them is better than "other", I will happy to use it.
Could we please make a decision on this?
If "other" is not unambiguous, then maybe we could choose "daemon" to describe arbitrary user-level backends, any thought?
Quoted 8 lines
Quoted 3 lines
Unfortunately I didn’t have time to dig into this; I’m just going to have to withdraw my objection, and let you & Juergen decide what to call it.
George, thanks for letting me know. Juergen proposed to use "standalone" for the new backendtype name which is far more specific. I agree with that.
Anthony, would you be happy with that renaming?
I tried to figure out what backendtype is supposed to mean, how it's used. I feel it's quite messy at the moment.
Man page xl-disk-configuration says it's a backend implementation to use. Beside 'phy', which I guess is the kernel or blkback, the two other point to QEMU ('qdisk') and tapdisk ('tap').
Quoted 6 lines
The, backendtype is used throughout libxl to deal with the different backend implementation, and the value is stored in the xenstore key "type". From "
blkif.h", "type" should be 'file' or 'phy' or 'tap', but we store 'qdisk' for 'qdisk'... so the "type" note in xenstore is probably useless for qdisk, but maybe useful for 'phy'? (This "type" node is only for the backend, so probably useless for a front end.)
I might mistake, but even the presence of "type" node (or other nodes) in Xenstore is useless for some backend implementations,
this provides us an ability to retrieve almost whole libxl_device_disk instance from the Xenstore (please see libxl__disk_from_xenstore()).
Quoted 4 lines
Anyway, it seems to me that backendtype should be the name of the implementation of the backend we want to use. It is just a parameter to tell libxl how to communicate with the backend.
I also think the same
Quoted 7 lines
At the moment libxl
uses xenstore to communicates with all backends even if that's not required, because libxl works this way and it's hard to change. (We could communicate with QEMU via QMP rather than xenstore for example.)So I guess either you have a name for your implementation, or something generic will do. So "standalone" is fine.
Thanks for the confirmation!
Quoted 4 lines
(We probably want to document somewhere that this new type would simply mean "only-relying-on-xenstore-data" like Juergen is putting it, and isn't blkback or QEMU.)
I will add a comment in libxl_types.idl where "STANDALONE" enum item is introduced.
Quoted 3 lines
Thanks,
Signature · 3 lines
Regards, Oleksandr Tyshchenko
PATCH v10 2/3 libxl: Introduce basic virtio-mmio support on Arm
In reply to Oleksandr TyshchenkoFrom: Julien Grall <[email protected]>
This patch introduces helpers to allocate Virtio MMIO params (IRQ and memory region) and create specific device node in the Guest device-tree with allocated params. In order to deal with multiple Virtio devices, reserve corresponding ranges. For now, we reserve 1MB for memory regions and 10 SPIs.
As these helpers should be used for every Virtio device attached to the Guest, call them for Virtio disk(s).
Please note, with statically allocated Virtio IRQs there is a risk of a clash with a physical IRQs of passthrough devices. For the first version, it's fine, but we should consider allocating the Virtio IRQs automatically. Thankfully, we know in advance which IRQs will be used for passthrough to be able to choose non-clashed ones.
---
Please note, this is a split/cleanup/hardening of Julien's PoC:
"Add support for Guest IO forwarding to a device emulator"
Changes RFC -> V1:
- was squashed with:
"[RFC PATCH V1 09/12] libxl: Handle virtio-mmio irq in more correct way" "[RFC PATCH V1 11/12] libxl: Insert "dma-coherent" property into virtio-mmio device node" "[RFC PATCH V1 12/12] libxl: Fix duplicate memory node in DT"
- move VirtIO MMIO #define-s to xen/include/public/arch-arm.h
Changes V1 -> V2:
- update the author of a patch
Changes V2 -> V3:
- no changes
Changes V3 -> V4:
- no changes
Changes V4 -> V5:
- split the changes, change the order of the patches
- drop an extra "virtio" configuration option
- update patch description
- use CONTAINER_OF instead of own implementation
- reserve ranges for Virtio MMIO params and put them in correct location
- create helpers to allocate Virtio MMIO params, add corresponding sanity-сhecks
- add comment why MMIO size 0x200 is chosen
- update debug print
- drop Wei's T-b
Changes V5 -> V6:
- rebase on current staging
Changes V6 -> V7:
- rebase on current staging
- add T-b and R-b tags
- update according to the recent changes to "libxl: Add support for Virtio disk configuration"
Changes V7 -> V8:
- drop T-b and R-b tags
- make virtio_mmio_base/irq global variables to be local in libxl__arch_domain_prepare_config() and initialize them at the beginning of the function, then rework alloc_virtio_mmio_base/irq() to take a pointer to virtio_mmio_base/irq variables as an argument
- update according to the recent changes to
"libxl: Add support for Virtio disk configuration"
Changes V8 -> V9:
- Stefano already gave his Reviewed-by, I dropped it due to the changes
- remove the second set of parentheses for check in alloc_virtio_mmio_base()
- clarify the updating of "nr_spis" right after num_disks loop in libxl__arch_domain_prepare_config() and add a comment on top of it
- use GCSPRINTF() instead of using a buffer of a static size calculated by hand in make_virtio_mmio_node()
Changes V9 -> V10:
- add Stefano's and Anthony's R-b
--- tools/libs/light/libxl_arm.c | 121 +++++++++++++++++++++++++++++++++++++++++- xen/include/public/arch-arm.h | 7 +++ 2 files changed, 126 insertions(+), 2 deletions(-)
tools/libs/light/libxl_arm.c +119 -2
@@ -8,6 +8,46 @@#include <assert.h> #include <xen/device_tree_defs.h> +/* +* There is no clear requirements for the total size of Virtio MMIO region. +* The size of control registers is 0x100 and device-specific configuration +* registers starts at the offset 0x100, however it's size depends on the device +* and the driver. Pick the biggest known size at the moment to cover most +* of the devices (also consider allowing the user to configure the size via +* config file for the one not conforming with the proposed value). +*/ +#define VIRTIO_MMIO_DEV_SIZE xen_mk_ullong(0x200) + +static uint64_t alloc_virtio_mmio_base (libxl__gc *gc,uint64_t *virtio_mmio_base) +{ +uint64_t base = *virtio_mmio_base; + +/* Make sure we have enough reserved resources */ +if (base +VIRTIO_MMIO_DEV_SIZE > +GUEST_VIRTIO_MMIO_BASE +GUEST_VIRTIO_MMIO_SIZE ) { +LOG (ERROR ,"Ran out of reserved range for Virtio MMIO BASE 0x%" PRIx64"\n" , + base); +return 0 ; + } + *virtio_mmio_base +=VIRTIO_MMIO_DEV_SIZE ; + +return base; +} + +static uint32_t alloc_virtio_mmio_irq (libxl__gc *gc,uint32_t *virtio_mmio_irq) +{ +uint32_t irq = *virtio_mmio_irq; + +/* Make sure we have enough reserved resources */ +if (irq >GUEST_VIRTIO_MMIO_SPI_LAST ) { +LOG (ERROR ,"Ran out of reserved range for Virtio MMIO IRQ %u\n" , irq); +return 0 ; + } + (*virtio_mmio_irq)++; + +return irq; +} +static const char *gicv_to_string (libxl_gic_version gic_version) {switch (gic_version) {
@@ -26,8 +66,10 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, {uint32_t nr_spis =0 ;unsigned int i; -uint32_t vuart_irq; -bool vuart_enabled = false; +uint32_t vuart_irq, virtio_irq =0 ; +bool vuart_enabled = false, virtio_enabled = false; +uint64_t virtio_mmio_base =GUEST_VIRTIO_MMIO_BASE ; +uint32_t virtio_mmio_irq =GUEST_VIRTIO_MMIO_SPI_FIRST ;/* * If pl011 vuart is enabled then increment the nr_spis to allow allocation
@@ -39,6 +81,35 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, vuart_enabled = true; } +for (i =0 ; i < d_config->num_disks; i++) { +libxl_device_disk *disk = &d_config->disks[i]; + +if (disk->specification ==LIBXL_DISK_SPECIFICATION_VIRTIO ) { + disk->base =alloc_virtio_mmio_base (gc, &virtio_mmio_base); +if (!disk->base) +return ERROR_FAIL ; + + disk->irq =alloc_virtio_mmio_irq (gc, &virtio_mmio_irq); +if (!disk->irq) +return ERROR_FAIL ; + +if (virtio_irq < disk->irq) + virtio_irq = disk->irq; + virtio_enabled = true; + +LOG (DEBUG ,"Allocate Virtio MMIO params for Vdev %s: IRQ %u BASE 0x%" PRIx64, + disk->vdev, disk->irq, disk->base); + } + } + +/* +* Every virtio-mmio device uses one emulated SPI. If Virtio devices are +* present, make sure that we allocate enough SPIs for them. +* The resulting "nr_spis" needs to cover the highest possible SPI. +*/ +if (virtio_enabled) + nr_spis =max (nr_spis, virtio_irq -32 +1 ); +for (i =0 ; i < d_config->b_info.num_irqs; i++) {uint32_t irq = d_config->b_info.irqs[i];uint32_t spi;
@@ -58,6 +129,13 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,return ERROR_FAIL ; } +/* The same check as for vpl011 */ +if (virtio_enabled && + (irq >=GUEST_VIRTIO_MMIO_SPI_FIRST && irq <= virtio_irq)) { +LOG (ERROR ,"Physical IRQ %u conflicting with Virtio MMIO IRQ range\n" , irq); +return ERROR_FAIL ; + } +if (irq <32 )continue ;
@@ -787,6 +865,37 @@ static int make_vpci_node(libxl__gc *gc, void *fdt,return 0 ; } + +static int make_virtio_mmio_node (libxl__gc *gc,void *fdt, +uint64_t base,uint32_t irq) +{ +int res; +gic_interrupt intr; +const char *name =GCSPRINTF ("virtio@%" PRIx64, base); + + res =fdt_begin_node (fdt, name); +if (res)return res; + + res =fdt_property_compat (gc, fdt,1 ,"virtio,mmio" ); +if (res)return res; + + res =fdt_property_regs (gc, fdt,GUEST_ROOT_ADDRESS_CELLS ,GUEST_ROOT_SIZE_CELLS , +1 , base,VIRTIO_MMIO_DEV_SIZE ); +if (res)return res; + +set_interrupt (intr, irq,0xf ,DT_IRQ_TYPE_EDGE_RISING ); + res =fdt_property_interrupts (gc, fdt, &intr,1 ); +if (res)return res; + + res =fdt_property (fdt,"dma-coherent" ,NULL ,0 ); +if (res)return res; + + res =fdt_end_node (fdt); +if (res)return res; + +return 0 ; +} +static const struct arch_info *get_arch_info (libxl__gc *gc,const struct xc_dom_image *dom) {
@@ -988,6 +1097,7 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_config *d_config,size_t fdt_size =0 ;int pfdt_size =0 ;libxl_domain_build_info *const info = &d_config->b_info; +unsigned int i;const libxl_version_info *vers;const struct arch_info *ainfo;
@@ -1094,6 +1204,13 @@ next_resize:if (d_config->num_pcidevs)FDT (make_vpci_node (gc, fdt, ainfo, dom) ); +for (i =0 ; i < d_config->num_disks; i++) { +libxl_device_disk *disk = &d_config->disks[i]; + +if (disk->specification ==LIBXL_DISK_SPECIFICATION_VIRTIO ) +FDT (make_virtio_mmio_node (gc, fdt, disk->base, disk->irq) ); + } +if (pfdt)FDT (copy_partial_fdt (gc, fdt, pfdt) );
xen/include/public/arch-arm.h +7 -0
@@ -407,6 +407,10 @@ typedef uint64_t xen_callback_t;/* Physical Address Space */ +/* Virtio MMIO mappings */ +#define GUEST_VIRTIO_MMIO_BASE xen_mk_ullong(0x02000000) +#define GUEST_VIRTIO_MMIO_SIZE xen_mk_ullong(0x00100000) +/* * vGIC mappings: Only one set of mapping is used by the guest. * Therefore they can overlap.
@@ -493,6 +497,9 @@ typedef uint64_t xen_callback_t;#define GUEST_VPL011_SPI 32 +#define GUEST_VIRTIO_MMIO_SPI_FIRST 33 +#define GUEST_VIRTIO_MMIO_SPI_LAST 43 +/* PSCI functions */ #define PSCI_cpu_suspend 0#define PSCI_cpu_off 1
Signature · 1 line
2.7.4
PATCH v10 3/3 libxl/arm: Create specific IOMMU node to be referred by virtio-mmio device
In reply to Oleksandr TyshchenkoFrom: Oleksandr Tyshchenko <[email protected]>
Reuse generic IOMMU device tree bindings to communicate Xen specific information for the virtio devices for which the restricted memory access using Xen grant mappings need to be enabled.
Insert "iommus" property pointed to the IOMMU node with "xen,grant-dma" compatible to all virtio devices which backends are going to run in non-hardware domains (which are non-trusted by default).
Based on device-tree binding from Linux:Documentation/devicetree/bindings/iommu/xen,grant-dma.yaml
The example of generated nodes:
xen_iommu {
compatible = "xen,grant-dma";
#iommu-cells = <0x01>;
phandle = <0xfde9>;
};virtio@2000000 {
compatible = "virtio,mmio";
reg = <0x00 0x2000000 0x00 0x200>;
interrupts = <0x00 0x01 0xf01>;
interrupt-parent = <0xfde8>;
dma-coherent;
iommus = <0xfde9 0x01>;
};virtio@2000200 {
compatible = "virtio,mmio";
reg = <0x00 0x2000200 0x00 0x200>;
interrupts = <0x00 0x02 0xf01>;
interrupt-parent = <0xfde8>;
dma-coherent;
iommus = <0xfde9 0x01>;
};---
The related series https://lore.kernel.org/xen-devel/[email protected]/
is already in the mainline Linux.
Changes RFC -> V1:
- update commit description
- rebase according to the recent changes to "libxl: Introduce basic virtio-mmio support on Arm"
Changes V1 -> V2:
- Henry already gave his Reviewed-by, I dropped it due to the changes
- use generic IOMMU device tree bindings instead of custom property
"xen,dev-domid"
- change commit subject and description, was
"libxl/arm: Insert "xen,dev-domid" property to virtio-mmio device node"
Changes V2 -> V3:
- add Stefano's and Anthony's R-b
- send together with the series it depends on and update post commit remark that described dependencies
- update a comment on top of #define GUEST_PHANDLE_GIC
--- tools/libs/light/libxl_arm.c | 49 ++++++++++++++++++++++++++++++++--- xen/include/public/device_tree_defs.h | 3 ++- 2 files changed, 48 insertions(+), 4 deletions(-)
tools/libs/light/libxl_arm.c +46 -3
@@ -865,9 +865,32 @@ static int make_vpci_node(libxl__gc *gc, void *fdt,return 0 ; } +static int make_xen_iommu_node (libxl__gc *gc,void *fdt) +{ +int res; + +/* See Linux Documentation/devicetree/bindings/iommu/xen,grant-dma.yaml */ + res =fdt_begin_node (fdt,"xen_iommu" ); +if (res)return res; + + res =fdt_property_compat (gc, fdt,1 ,"xen,grant-dma" ); +if (res)return res; + + res =fdt_property_cell (fdt,"#iommu-cells" ,1 ); +if (res)return res; + + res =fdt_property_cell (fdt,"phandle" ,GUEST_PHANDLE_IOMMU ); +if (res)return res; + + res =fdt_end_node (fdt); +if (res)return res; + +return 0 ; +}static int make_virtio_mmio_node (libxl__gc *gc,void *fdt, -uint64_t base,uint32_t irq) +uint64_t base,uint32_t irq, +uint32_t backend_domid) {int res;gic_interrupt intr;
@@ -890,6 +913,16 @@ static int make_virtio_mmio_node(libxl__gc *gc, void *fdt, res =fdt_property (fdt,"dma-coherent" ,NULL ,0 );if (res)return res; +if (backend_domid !=LIBXL_TOOLSTACK_DOMID ) { +uint32_t iommus_prop[2 ]; + + iommus_prop[0 ] =cpu_to_fdt32 (GUEST_PHANDLE_IOMMU ); + iommus_prop[1 ] =cpu_to_fdt32 (backend_domid); + + res =fdt_property (fdt,"iommus" , iommus_prop,sizeof (iommus_prop)); +if (res)return res; + } + res =fdt_end_node (fdt);if (res)return res;
@@ -1097,6 +1130,7 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_config *d_config,size_t fdt_size =0 ;int pfdt_size =0 ;libxl_domain_build_info *const info = &d_config->b_info; +bool iommu_created;unsigned int i;const libxl_version_info *vers;
@@ -1204,11 +1238,20 @@ next_resize:if (d_config->num_pcidevs)FDT (make_vpci_node (gc, fdt, ainfo, dom) ); + iommu_created = false;for (i =0 ; i < d_config->num_disks; i++) {libxl_device_disk *disk = &d_config->disks[i]; -if (disk->specification ==LIBXL_DISK_SPECIFICATION_VIRTIO ) -FDT (make_virtio_mmio_node (gc, fdt, disk->base, disk->irq) ); +if (disk->specification ==LIBXL_DISK_SPECIFICATION_VIRTIO ) { +if (disk->backend_domid !=LIBXL_TOOLSTACK_DOMID && + !iommu_created) { +FDT (make_xen_iommu_node (gc, fdt) ); + iommu_created = true; + } + +FDT (make_virtio_mmio_node (gc, fdt, disk->base, disk->irq, + disk->backend_domid) ); + } }if (pfdt)
xen/include/public/device_tree_defs.h +2 -1
@@ -4,9 +4,10 @@#if defined(__XEN__) || defined(__XEN_TOOLS__)/* * The device tree compiler (DTC) is allocating the phandle from 1 to -* onwards. Reserve a high value for the GIC phandle. +* onwards. Reserve high values for the specific phandles. */ #define GUEST_PHANDLE_GIC (65000) +#define GUEST_PHANDLE_IOMMU (GUEST_PHANDLE_GIC + 1)#define GUEST_ROOT_ADDRESS_CELLS 2#define GUEST_ROOT_SIZE_CELLS 2
Signature · 1 line
2.7.4