Specifies the transport mechanism for the Virtio device, only "mmio" is
supported for now.
+=item B<grant_usage=BOOLEAN>
+
+If this option is B<true>, the Xen grants are always enabled.
+If this option is B<false>, the Xen grants are always disabled.
+
+If this option is missing, then the default grant setting will be used,
+i.e. enable grants if backend-domid != 0.
+
=back
=item B<tee="STRING">
x.BackendDomname = C.GoString(xc.backend_domname)
x.Type = C.GoString(xc._type)
x.Transport = VirtioTransport(xc.transport)
+if err := x.GrantUsage.fromC(&xc.grant_usage);err != nil {
+return fmt.Errorf("converting field GrantUsage: %v", err)
+}
x.Devid = Devid(xc.devid)
x.Irq = uint32(xc.irq)
x.Base = uint64(xc.base)
if x.Type != "" {
xc._type = C.CString(x.Type)}
xc.transport = C.libxl_virtio_transport(x.Transport)
+if err := x.GrantUsage.toC(&xc.grant_usage); err != nil {
+return fmt.Errorf("converting field GrantUsage: %v", err)
+}
xc.devid = C.libxl_devid(x.Devid)
xc.irq = C.uint32_t(x.Irq)
xc.base = C.uint64_t(x.Base)
BackendDomname string
Type string
Transport VirtioTransport
+GrantUsage Defbool
Devid Devid
Irq uint32
Base uint64
/* The caller is responsible to complete / close the fdt node */
static int make_virtio_mmio_node_common(libxl__gc *gc, void *fdt, uint64_t base,
- uint32_t irq, uint32_t backend_domid)
+ uint32_t irq, uint32_t backend_domid,
+ bool grant_usage)
{
int res;
gic_interrupt intr;
res = fdt_property(fdt, "dma-coherent", NULL, 0);
if (res) return res;
- if (backend_domid != LIBXL_TOOLSTACK_DOMID) {
+ if (grant_usage) {
uint32_t iommus_prop[2];
iommus_prop[0] = cpu_to_fdt32(GUEST_PHANDLE_IOMMU);
}
static int make_virtio_mmio_node(libxl__gc *gc, void *fdt, uint64_t base,
- uint32_t irq, uint32_t backend_domid)
+ uint32_t irq, uint32_t backend_domid,
+ bool grant_usage)
{
int res;
- res = make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid);
+ res = make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid, grant_usage);
if (res) return res;
return fdt_end_node(fdt);
static int make_virtio_mmio_node_device(libxl__gc *gc, void *fdt, uint64_t base,
uint32_t irq, const char *type,
- uint32_t backend_domid)
+ uint32_t backend_domid, bool grant_usage)
{
int res;
- res = make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid);
+ res = make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid, grant_usage);
if (res) return res;
/* Add device specific nodes */
iommu_needed = true;
FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq,
- disk->backend_domid) );
+ disk->backend_domid,
+ disk->backend_domid != LIBXL_TOOLSTACK_DOMID) );
}
}
if (virtio->transport != LIBXL_VIRTIO_TRANSPORT_MMIO)
continue;
- if (virtio->backend_domid != LIBXL_TOOLSTACK_DOMID)
+ if (libxl_defbool_val(virtio->grant_usage))
iommu_needed = true;
FDT( make_virtio_mmio_node_device(gc, fdt, virtio->base,
virtio->irq, virtio->type,
- virtio->backend_domid) );
+ virtio->backend_domid,
+ libxl_defbool_val(virtio->grant_usage)) );
}
/*
("backend_domname", string),
("type", string),
("transport", libxl_virtio_transport),
+ ("grant_usage", libxl_defbool),
("devid", libxl_devid),
# Note that virtio-mmio parameters (irq and base) are for internal
# use by libxl and can't be modified.
libxl_device_virtio *virtio,
bool hotplug)
{
- return libxl__resolve_domid(gc, virtio->backend_domname,
- &virtio->backend_domid);
+ int rc;
+
+ rc = libxl__resolve_domid(gc, virtio->backend_domname,
+ &virtio->backend_domid);
+ if (rc < 0) return rc;
+
+ libxl_defbool_setdefault(&virtio->grant_usage,
+ virtio->backend_domid != LIBXL_TOOLSTACK_DOMID);
+
+ return 0;
}
static int libxl__device_from_virtio(libxl__gc *gc, uint32_t domid,
flexarray_append_pair(back, "base", GCSPRINTF("%#"PRIx64, virtio->base));
flexarray_append_pair(back, "type", GCSPRINTF("%s", virtio->type));
flexarray_append_pair(back, "transport", GCSPRINTF("%s", transport));
+ flexarray_append_pair(back, "grant_usage",
+ libxl_defbool_val(virtio->grant_usage) ? "1" : "0");
return 0;
}
}
}
+ tmp = NULL;
+ rc = libxl__xs_read_checked(gc, XBT_NULL,
+ GCSPRINTF("%s/grant_usage", be_path), &tmp);
+ if (rc) goto out;
+
+ if (tmp) {
+ libxl_defbool_set(&virtio->grant_usage, strtoul(tmp, NULL, 0));
+ }
+
tmp = NULL;
rc = libxl__xs_read_checked(gc, XBT_NULL,
GCSPRINTF("%s/type", be_path), &tmp);
} else if (MATCH_OPTION("transport", token, oparg)) {
rc = libxl_virtio_transport_from_string(oparg, &virtio->transport);
if (rc) return rc;
+ } else if (MATCH_OPTION("grant_usage", token, oparg)) {
+ libxl_defbool_set(&virtio->grant_usage, strtoul(oparg, NULL, 0));
} else {
fprintf(stderr, "Unknown string \"%s\" in virtio spec\n", token);
return -1;