Hi,
This patchset intends to make grant mapping usage configurable for virtio
devices. Currently they are forced enabled for backends running on non-Dom0
domains. This patchset adds a new `grant_usage` parameter for the virtio
devices, which can be used to enable or disable grant mappings irrespective of
the backend domain, while still preserving the default behavior in absence of a
parameter.
V2->V3:
- Patch 2/3 is new and fixes ordering issues with default values.
- Reuse `libxl_defbool` instead of defining a new type, it can take values 0 and
1.
- Improved commit logs and comments.
V1->V2:
- Instead of just 0 or 1, the argument can take multiple values now and control
the functionality in a better way.
- Update .gen.go files as well.
- Don't add nodes under frontend path.
Viresh Kumar (3):
libxl: virtio: Remove unused frontend nodes
libxl: Call libxl__virtio_devtype.set_default() early enough
libxl: arm: Add grant_usage parameter for virtio devices
docs/man/xl.cfg.5.pod.in | 8 +++++++
tools/golang/xenlight/helpers.gen.go | 6 +++++
tools/golang/xenlight/types.gen.go | 1 +
tools/libs/light/libxl_arm.c | 22 +++++++++++--------
tools/libs/light/libxl_create.c | 11 +++++++++-
tools/libs/light/libxl_types.idl | 1 +
tools/libs/light/libxl_virtio.c | 33 ++++++++++++++++++++++------
tools/xl/xl_parse.c | 2 ++
8 files changed, 67 insertions(+), 17 deletions(-)
--
2.31.1.272.g89b43f80a514
The libxl_virtio file works for only PV devices and the nodes under the
frontend path are not used by anyone. Remove them.
While at it, also add a comment to the file describing what devices this
file is used for.
Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
---
V2: New patch.
tools/libs/light/libxl_virtio.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/tools/libs/light/libxl_virtio.c b/tools/libs/light/libxl_virtio.c
index faada49e184e..eadcb7124c3f 100644
--- a/tools/libs/light/libxl_virtio.c
+++ b/tools/libs/light/libxl_virtio.c
@@ -10,6 +10,9 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
+ *
+ * This is used for PV (paravirtualized) devices only and the frontend isn't
+ * aware of the xenstore.
*/
#include "libxl_internal.h"
@@ -49,11 +52,6 @@ static int libxl__set_xenstore_virtio(libxl__gc *gc, uint32_t domid,
flexarray_append_pair(back, "type", GCSPRINTF("%s", virtio->type));
flexarray_append_pair(back, "transport", GCSPRINTF("%s", transport));
- flexarray_append_pair(front, "irq", GCSPRINTF("%u", virtio->irq));
- flexarray_append_pair(front, "base", GCSPRINTF("%#"PRIx64, virtio->base));
- flexarray_append_pair(front, "type", GCSPRINTF("%s", virtio->type));
- flexarray_append_pair(front, "transport", GCSPRINTF("%s", transport));
-
return 0;
}
--
2.31.1.272.g89b43f80a514
For generic virtio devices, where we don't need to add compatible or
other special DT properties, the type field is set to "virtio,device".
But this misses the case where the user sets the type with a valid
virtio device id as well, like "virtio,device1a" for file system device.
The complete list of virtio device ids is mentioned here:
https://docs.oasis-open.org/virtio/virtio/v1.2/cs01/virtio-v1.2-cs01.html#x…
Update documentation to support that as well.
Fixes: dd54ea500be8 ("docs: add documentation for generic virtio devices")
Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko(a)epam.com>
---
V2->V3:
- Updated commit log and clarified / fixed doc.
- Tag from Oleksandr.
docs/man/xl.cfg.5.pod.in | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index 10f37990be57..24ac92718288 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -1608,8 +1608,11 @@ example, "type=virtio,device22" for the I2C device, whose device-tree binding is
L<https://www.kernel.org/doc/Documentation/devicetree/bindings/i2c/i2c-virtio…>
-For generic virtio devices, where we don't need to set special or compatible
-properties in the Device Tree, the type field must be set to "virtio,device".
+For other generic virtio devices, where we don't need to set special or
+compatible properties in the Device Tree, the type field must be set to
+"virtio,device" or "virtio,device<N>", where "N" is the virtio device id in
+hexadecimal format, without the "0x" prefix and all in lower case, like
+"virtio,device1a" for the file system device.
=item B<transport=STRING>
--
2.31.1.272.g89b43f80a514
Since the driver doesn't support interrupts, we must return early when
index is set to VIRTIO_CONFIG_IRQ_IDX.
Fixes: 544f0278afca ("virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX")
Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
---
V2: Simplify and fix comments.
hw/virtio/vhost-user-i2c.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c
index 60eaf0d95be0..4eef3f063376 100644
--- a/hw/virtio/vhost-user-i2c.c
+++ b/hw/virtio/vhost-user-i2c.c
@@ -128,6 +128,14 @@ static void vu_i2c_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
{
VHostUserI2C *i2c = VHOST_USER_I2C(vdev);
+ /*
+ * We don't support interrupts, return early if index is set to
+ * VIRTIO_CONFIG_IRQ_IDX.
+ */
+ if (idx == VIRTIO_CONFIG_IRQ_IDX) {
+ return;
+ }
+
vhost_virtqueue_mask(&i2c->vhost_dev, vdev, idx, mask);
}
@@ -135,6 +143,14 @@ static bool vu_i2c_guest_notifier_pending(VirtIODevice *vdev, int idx)
{
VHostUserI2C *i2c = VHOST_USER_I2C(vdev);
+ /*
+ * We don't support interrupts, return early if index is set to
+ * VIRTIO_CONFIG_IRQ_IDX.
+ */
+ if (idx == VIRTIO_CONFIG_IRQ_IDX) {
+ return false;
+ }
+
return vhost_virtqueue_pending(&i2c->vhost_dev, idx);
}
--
2.31.1.272.g89b43f80a514
Philippe Mathieu-Daudé <philmd(a)linaro.org> writes:
> On 17/4/23 08:02, Viresh Kumar wrote:
>> Since the driver doesn't support interrupts, we must return early when
>> index is set to VIRTIO_CONFIG_IRQ_IDX.
>> Fixes: 544f0278afca ("virtio: introduce macro
>> VIRTIO_CONFIG_IRQ_IDX")
>> Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
>> ---
>> hw/virtio/vhost-user-i2c.c | 20 ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
>> diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c
>> index 60eaf0d95be0..45100a24953c 100644
>> --- a/hw/virtio/vhost-user-i2c.c
>> +++ b/hw/virtio/vhost-user-i2c.c
>> @@ -128,6 +128,16 @@ static void vu_i2c_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
>> {
>> VHostUserI2C *i2c = VHOST_USER_I2C(vdev);
>> + /*
>> + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
>> + * as the Marco of configure interrupt's IDX, If this driver does not
>
> Copy/paste of pre-existing comment, still I wonder who is "the Marco
> of configure" :P
>
>> + * support, the function will return
>> + */
First patch of my last VirtIO series fixes these all up.
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
On 17-04-23, 09:36, Philippe Mathieu-Daudé wrote:
> On 17/4/23 08:02, Viresh Kumar wrote:
> > Since the driver doesn't support interrupts, we must return early when
> > index is set to VIRTIO_CONFIG_IRQ_IDX.
> >
> > Fixes: 544f0278afca ("virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX")
> > Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
> > ---
> > hw/virtio/vhost-user-i2c.c | 20 ++++++++++++++++++++
> > 1 file changed, 20 insertions(+)
> >
> > diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c
> > index 60eaf0d95be0..45100a24953c 100644
> > --- a/hw/virtio/vhost-user-i2c.c
> > +++ b/hw/virtio/vhost-user-i2c.c
> > @@ -128,6 +128,16 @@ static void vu_i2c_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
> > {
> > VHostUserI2C *i2c = VHOST_USER_I2C(vdev);
> > + /*
> > + * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1
> > + * as the Marco of configure interrupt's IDX, If this driver does not
>
> Copy/paste of pre-existing comment, still I wonder who is "the Marco of
> configure" :P
>
> > + * support, the function will return
> > + */
Yeah the comment could be improved, I didn't touch it as it was
written this way for many drivers :)
Maybe a simple comment like is all we need:
/*
* We don't support interrupts, return early if index is set to
* VIRTIO_CONFIG_IRQ_IDX.
*/
--
viresh