xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Oleksandr <olekstysh@gmail.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
	Anthony PERARD <anthony.perard@citrix.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [RFC PATCH V1 10/12] libxl: Add support for virtio-disk configuration
Date: Wed, 5 Aug 2020 17:37:36 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.21.2008051419370.5748@sstabellini-ThinkPad-T480s> (raw)
In-Reply-To: <19fd2966-6e54-4f68-7f37-b2d8bb910d93@gmail.com>

On Thu, 6 Aug 2020, Oleksandr wrote:
> On 05.08.20 02:23, Stefano Stabellini wrote:
> > On Mon, 3 Aug 2020, Oleksandr Tyshchenko wrote:
> > > From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> > > 
> > > This patch adds basic support for configuring and assisting virtio-disk
> > > backend (emualator) which is intended to run out of Qemu and could be run
> > > in any domain.
> > > 
> > > Xenstore was chosen as a communication interface for the emulator running
> > > in non-toolstack domain to be able to get configuration either by reading
> > > Xenstore directly or by receiving command line parameters (an updated 'xl
> > > devd'
> > > running in the same domain would read Xenstore beforehand and call backend
> > > executable with the required arguments).
> > > 
> > > An example of domain configuration (two disks are assigned to the guest,
> > > the latter is in readonly mode):
> > > 
> > > vdisk = [ 'backend=DomD, disks=rw:/dev/mmcblk0p3;ro:/dev/mmcblk1p3' ]
> > > 
> > > Where per-disk Xenstore entries are:
> > > - filename and readonly flag (configured via "vdisk" property)
> > > - base and irq (allocated dynamically)
> > > 
> > > Besides handling 'visible' params described in configuration file,
> > > patch also allocates virtio-mmio specific ones for each device and
> > > writes them into Xenstore. virtio-mmio params (irq and base) are
> > > unique per guest domain, they allocated at the domain creation time
> > > and passed through to the emulator. Each VirtIO device has at least
> > > one pair of these params.
> > > 
> > > TODO:
> > > 1. An extra "virtio" property could be removed.
> > > 2. Update documentation.
> > > 
> > > Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> > > ---
> > >   tools/libxl/Makefile                 |   4 +-
> > >   tools/libxl/libxl_arm.c              |  63 +++++++++++++++----
> > >   tools/libxl/libxl_create.c           |   1 +
> > >   tools/libxl/libxl_internal.h         |   1 +
> > >   tools/libxl/libxl_types.idl          |  15 +++++
> > >   tools/libxl/libxl_types_internal.idl |   1 +
> > >   tools/libxl/libxl_virtio_disk.c      | 109
> > > +++++++++++++++++++++++++++++++++
> > >   tools/xl/Makefile                    |   2 +-
> > >   tools/xl/xl.h                        |   3 +
> > >   tools/xl/xl_cmdtable.c               |  15 +++++
> > >   tools/xl/xl_parse.c                  | 115
> > > +++++++++++++++++++++++++++++++++++
> > >   tools/xl/xl_virtio_disk.c            |  46 ++++++++++++++
> > >   12 files changed, 360 insertions(+), 15 deletions(-)
> > >   create mode 100644 tools/libxl/libxl_virtio_disk.c
> > >   create mode 100644 tools/xl/xl_virtio_disk.c
> > > 
> > > diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
> > > index 38cd43a..df94b13 100644
> > > --- a/tools/libxl/Makefile
> > > +++ b/tools/libxl/Makefile
> > > @@ -141,7 +141,9 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o
> > > libxl_dm.o libxl_pci.o \
> > >   			libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o
> > > \
> > >   			libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o
> > > \
> > >   			libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
> > > -			libxl_pvcalls.o libxl_vsnd.o libxl_vkb.o
> > > $(LIBXL_OBJS-y)
> > > +			libxl_pvcalls.o libxl_vsnd.o libxl_vkb.o \
> > > +			libxl_virtio_disk.o $(LIBXL_OBJS-y)
> > > +
> > >   LIBXL_OBJS += libxl_genid.o
> > >   LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
> > >   diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
> > > index 4f748e3..469a8b0 100644
> > > --- a/tools/libxl/libxl_arm.c
> > > +++ b/tools/libxl/libxl_arm.c
> > > @@ -13,6 +13,12 @@
> > >   #define GUEST_VIRTIO_MMIO_SIZE  xen_mk_ullong(0x200)
> > >   #define GUEST_VIRTIO_MMIO_SPI   33
> > >   +#ifndef container_of
> > > +#define container_of(ptr, type, member) ({			\
> > > +        typeof( ((type *)0)->member ) *__mptr = (ptr);	\
> > > +        (type *)( (char *)__mptr - offsetof(type,member) );})
> > > +#endif
> > > +
> > >   static const char *gicv_to_string(libxl_gic_version gic_version)
> > >   {
> > >       switch (gic_version) {
> > > @@ -44,14 +50,32 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
> > >           vuart_enabled = true;
> > >       }
> > >   -    /*
> > > -     * XXX: Handle properly virtio
> > > -     * A proper solution would be the toolstack to allocate the
> > > interrupts
> > > -     * used by each virtio backend and let the backend now which one is
> > > used
> > > -     */
> > >       if (libxl_defbool_val(d_config->b_info.arch_arm.virtio)) {
> > > -        nr_spis += (GUEST_VIRTIO_MMIO_SPI - 32) + 1;
> > > +        uint64_t virtio_base;
> > > +        libxl_device_virtio_disk *virtio_disk;
> > > +
> > > +        virtio_base = GUEST_VIRTIO_MMIO_BASE;
> > >           virtio_irq = GUEST_VIRTIO_MMIO_SPI;
> > > +
> > > +        if (!d_config->num_virtio_disks) {
> > > +            LOG(ERROR, "Virtio is enabled, but no Virtio devices
> > > present\n");
> > > +            return ERROR_FAIL;
> > > +        }
> > > +        virtio_disk = &d_config->virtio_disks[0];
> > > +
> > > +        for (i = 0; i < virtio_disk->num_disks; i++) {
> > > +            virtio_disk->disks[i].base = virtio_base;
> > > +            virtio_disk->disks[i].irq = virtio_irq;
> > > +
> > > +            LOG(DEBUG, "Allocate Virtio MMIO params: IRQ %u BASE
> > > 0x%"PRIx64,
> > > +                virtio_irq, virtio_base);
> > > +
> > > +            virtio_irq ++;
> > > +            virtio_base += GUEST_VIRTIO_MMIO_SIZE;
> > > +        }
> > > +        virtio_irq --;
> > > +
> > > +        nr_spis += (virtio_irq - 32) + 1;
> > It looks like it is an interrupt per device, which could lead to quite a
> > few of them being allocated.
> 
> Yes.
> 
> 
> > So, if we end up allocating
> > let's say 6 virtio interrupts for a domain, the chance of a clash with a
> > physical interrupt of a passthrough device is real.
> 
> Yes.
> 
> 
> > 
> > I am not entirely sure how to solve it, but these are a few ideas:
> > - choosing virtio interrupts that are less likely to conflict (maybe >
> >    1000)
> > - make the virtio irq (optionally) configurable so that a user could
> >    override the default irq and specify one that doesn't conflict
> > - implementing support for virq != pirq (even the xl interface doesn't
> >    allow to specify the virq number for passthrough devices, see "irqs")
> 
> Good ideas. The first requires minimum effort. Couldn't we choose virtio
> interrupt to allocate after making sure it is absent in guest "irqs"
> (d_config->b_info.irqs[i]), I mean to find some holes?

Yes, that might be possible too.

So far we have tried to stay away from dynamic irq allocation for guests
virtual devices, but we also didn't have to deal with potentially large
amount of them :-)


  reply	other threads:[~2020-08-06  0:37 UTC|newest]

Thread overview: 140+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03 18:21 [RFC PATCH V1 00/12] IOREQ feature (+ virtio-mmio) on Arm Oleksandr Tyshchenko
2020-08-03 18:21 ` [RFC PATCH V1 01/12] hvm/ioreq: Make x86's IOREQ feature common Oleksandr Tyshchenko
2020-08-04  7:45   ` Paul Durrant
2020-08-04 11:10     ` Oleksandr
2020-08-04 11:23       ` Paul Durrant
2020-08-04 11:51         ` Oleksandr
2020-08-04 13:18           ` Paul Durrant
2020-08-04 13:52       ` Julien Grall
2020-08-04 15:41         ` Jan Beulich
2020-08-04 19:11         ` Stefano Stabellini
2020-08-05  7:01           ` Jan Beulich
2020-08-06  0:37             ` Stefano Stabellini
2020-08-06  6:59               ` Jan Beulich
2020-08-06 20:32                 ` Stefano Stabellini
2020-08-07 13:19                   ` Oleksandr
2020-08-07 16:45               ` Oleksandr
2020-08-07 21:50                 ` Stefano Stabellini
2020-08-07 22:19                   ` Oleksandr
2020-08-10 13:41                     ` Oleksandr
2020-08-10 23:34                       ` Stefano Stabellini
2020-08-11  9:19                         ` Julien Grall
2020-08-11 10:10                           ` Oleksandr
2020-08-11 22:47                             ` Stefano Stabellini
2020-08-12 14:35                               ` Oleksandr
2020-08-12 23:08                                 ` Stefano Stabellini
2020-08-13 20:16                                   ` Julien Grall
2020-08-07 23:45                   ` Oleksandr
2020-08-10 23:34                     ` Stefano Stabellini
2020-08-05  8:33           ` Julien Grall
2020-08-06  0:37             ` Stefano Stabellini
2020-08-06  9:45               ` Julien Grall
2020-08-06 23:48                 ` Stefano Stabellini
2020-08-10 19:20                   ` Julien Grall
2020-08-10 23:34                     ` Stefano Stabellini
2020-08-11 11:28                       ` Julien Grall
2020-08-11 22:48                         ` Stefano Stabellini
2020-08-12  8:19                           ` Julien Grall
2020-08-20 19:14                             ` Oleksandr
2020-08-21  0:53                               ` Stefano Stabellini
2020-08-21 18:54                                 ` Julien Grall
2020-08-05 13:30   ` Julien Grall
2020-08-06 11:37     ` Oleksandr
2020-08-10 16:29       ` Julien Grall
2020-08-10 17:28         ` Oleksandr
2020-08-05 16:15   ` Andrew Cooper
2020-08-06  8:20     ` Oleksandr
2020-08-15 17:30   ` Julien Grall
2020-08-16 19:37     ` Oleksandr
2020-08-03 18:21 ` [RFC PATCH V1 02/12] hvm/dm: Make x86's DM " Oleksandr Tyshchenko
2020-08-03 18:21 ` [RFC PATCH V1 03/12] xen/mm: Make x86's XENMEM_resource_ioreq_server handling common Oleksandr Tyshchenko
2020-08-03 18:21 ` [RFC PATCH V1 04/12] xen/arm: Introduce arch specific bits for IOREQ/DM features Oleksandr Tyshchenko
2020-08-04  7:49   ` Paul Durrant
2020-08-04 14:01     ` Julien Grall
2020-08-04 23:22       ` Stefano Stabellini
2020-08-15 17:56       ` Julien Grall
2020-08-17 14:36         ` Oleksandr
2020-08-04 23:22   ` Stefano Stabellini
2020-08-05  7:05     ` Jan Beulich
2020-08-05 16:41       ` Stefano Stabellini
2020-08-05 19:45         ` Oleksandr
2020-08-05  9:32     ` Julien Grall
2020-08-05 15:41       ` Oleksandr
2020-08-06 10:19         ` Julien Grall
2020-08-10 18:09       ` Oleksandr
2020-08-10 18:21         ` Oleksandr
2020-08-10 19:00         ` Julien Grall
2020-08-10 20:29           ` Oleksandr
2020-08-10 22:37             ` Julien Grall
2020-08-11  6:13               ` Oleksandr
2020-08-12 15:08                 ` Oleksandr
2020-08-11 17:09       ` Oleksandr
2020-08-11 17:50         ` Julien Grall
2020-08-13 18:41           ` Oleksandr
2020-08-13 20:36             ` Julien Grall
2020-08-13 21:49               ` Oleksandr
2020-08-13 20:39             ` Oleksandr Tyshchenko
2020-08-13 22:14               ` Julien Grall
2020-08-14 12:08                 ` Oleksandr
2020-08-05 14:12   ` Julien Grall
2020-08-05 14:45     ` Jan Beulich
2020-08-05 19:30     ` Oleksandr
2020-08-06 11:08       ` Julien Grall
2020-08-06 11:29         ` Jan Beulich
2020-08-20 18:30           ` Oleksandr
2020-08-21  6:16             ` Jan Beulich
2020-08-21 11:13               ` Oleksandr
2020-08-06 13:27         ` Oleksandr
2020-08-10 18:25           ` Julien Grall
2020-08-10 19:58             ` Oleksandr
2020-08-05 16:13   ` Jan Beulich
2020-08-05 19:47     ` Oleksandr
2020-08-03 18:21 ` [RFC PATCH V1 05/12] hvm/dm: Introduce xendevicemodel_set_irq_level DM op Oleksandr Tyshchenko
2020-08-04 23:22   ` Stefano Stabellini
2020-08-05  9:39     ` Julien Grall
2020-08-06  0:37       ` Stefano Stabellini
2020-08-06 11:32         ` Julien Grall
2020-08-06 23:49           ` Stefano Stabellini
2020-08-07  8:43             ` Jan Beulich
2020-08-07 21:50               ` Stefano Stabellini
2020-08-08  9:27                 ` Julien Grall
2020-08-08  9:28                   ` Julien Grall
2020-08-10 23:34                   ` Stefano Stabellini
2020-08-11 13:04                     ` Julien Grall
2020-08-11 22:48                       ` Stefano Stabellini
2020-08-18  9:31                         ` Julien Grall
2020-08-21  0:53                           ` Stefano Stabellini
2020-08-17 15:23                 ` Jan Beulich
2020-08-17 22:56                   ` Stefano Stabellini
2020-08-18  8:03                     ` Jan Beulich
2020-08-05 16:15   ` Jan Beulich
2020-08-05 22:12     ` Oleksandr
2020-08-03 18:21 ` [RFC PATCH V1 06/12] libxl: Introduce basic virtio-mmio support on Arm Oleksandr Tyshchenko
2020-08-03 18:21 ` [RFC PATCH V1 07/12] A collection of tweaks to be able to run emulator in driver domain Oleksandr Tyshchenko
2020-08-05 16:19   ` Jan Beulich
2020-08-05 16:40     ` Paul Durrant
2020-08-06  9:22       ` Oleksandr
2020-08-06  9:27         ` Jan Beulich
2020-08-14 16:30           ` Oleksandr
2020-08-16 15:36             ` Julien Grall
2020-08-17 15:07               ` Oleksandr
2020-08-03 18:21 ` [RFC PATCH V1 08/12] xen/arm: Invalidate qemu mapcache on XENMEM_decrease_reservation Oleksandr Tyshchenko
2020-08-05 16:21   ` Jan Beulich
2020-08-06 11:35     ` Julien Grall
2020-08-06 11:50       ` Jan Beulich
2020-08-06 14:28         ` Oleksandr
2020-08-06 16:33           ` Jan Beulich
2020-08-06 16:57             ` Oleksandr
2020-08-03 18:21 ` [RFC PATCH V1 09/12] libxl: Handle virtio-mmio irq in more correct way Oleksandr Tyshchenko
2020-08-04 23:22   ` Stefano Stabellini
2020-08-05 20:51     ` Oleksandr
2020-08-03 18:21 ` [RFC PATCH V1 10/12] libxl: Add support for virtio-disk configuration Oleksandr Tyshchenko
2020-08-04 23:23   ` Stefano Stabellini
2020-08-05 21:12     ` Oleksandr
2020-08-06  0:37       ` Stefano Stabellini [this message]
2020-08-03 18:21 ` [RFC PATCH V1 11/12] libxl: Insert "dma-coherent" property into virtio-mmio device node Oleksandr Tyshchenko
2020-08-04 23:23   ` Stefano Stabellini
2020-08-05 20:35     ` Oleksandr
2020-08-03 18:21 ` [RFC PATCH V1 12/12] libxl: Fix duplicate memory node in DT Oleksandr Tyshchenko
2020-08-15 17:24 ` [RFC PATCH V1 00/12] IOREQ feature (+ virtio-mmio) on Arm Julien Grall
2020-08-16 19:34   ` Oleksandr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.2008051419370.5748@sstabellini-ThinkPad-T480s \
    --to=sstabellini@kernel.org \
    --cc=anthony.perard@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien@xen.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=olekstysh@gmail.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).