libxl: Add "grant_usage" parameter for virtio disk devices

Allow administrators to control whether Xen grant mappings for
the virtio disk devices should be used. By default (when new
parameter is not specified), the existing behavior is retained
(we enable grants if backend-domid != 0).

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
This commit is contained in:
Oleksandr Tyshchenko authored and Jan Beulich committed 2024-02-19 12:46:07 +01:00
1 parent f93629b18b
commit 1eb013ef97
10 files changed
+555 -444

No files matched your search

+24
View File
@@ -406,6 +406,30 @@ 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.
=item B<grant_usage=BOOLEAN>
=over 4
=item Description
Specifies the usage of Xen grants for accessing guest memory. Only applicable
to specification "virtio".
=item Supported values
1, 0
=item Mandatory
No
=item Default value
If this option is missing, then the default grant setting will be used,
i.e. "grant_usage=1" if backend-domid != 0 or "grant_usage=0" otherwise.
=back
=back
=head1 COLO Parameters
+6
View File
@@ -1885,6 +1885,9 @@ x.ActiveDisk = C.GoString(xc.active_disk)
x.HiddenDisk = C.GoString(xc.hidden_disk)
if err := x.Trusted.fromC(&xc.trusted);err != nil {
return fmt.Errorf("converting field Trusted: %v", err)
}
if err := x.GrantUsage.fromC(&xc.grant_usage);err != nil {
return fmt.Errorf("converting field GrantUsage: %v", err)
}
return nil}
@@ -1933,6 +1936,9 @@ if x.HiddenDisk != "" {
xc.hidden_disk = C.CString(x.HiddenDisk)}
if err := x.Trusted.toC(&xc.trusted); err != nil {
return fmt.Errorf("converting field Trusted: %v", err)
}
if err := x.GrantUsage.toC(&xc.grant_usage); err != nil {
return fmt.Errorf("converting field GrantUsage: %v", err)
}
return nil
+1
View File
@@ -741,6 +741,7 @@ ColoExport string
ActiveDisk string
HiddenDisk string
Trusted Defbool
GrantUsage Defbool
}
type DeviceNic struct {
+7
View File
@@ -578,6 +578,13 @@
*/
#define LIBXL_HAVE_DEVICE_DISK_SPECIFICATION 1
/*
* LIBXL_HAVE_DISK_GRANT_USAGE indicates that the libxl_device_disk
* has 'grant_usage' field to specify the usage of Xen grants for
* the specification 'virtio'.
*/
#define LIBXL_HAVE_DISK_GRANT_USAGE 1
/*
* LIBXL_HAVE_CONSOLE_ADD_XENSTORE indicates presence of the function
* libxl_console_add_xenstore() in libxl.
+2 -2
View File
@@ -1372,12 +1372,12 @@ next_resize:
libxl_device_disk *disk = &d_config->disks[i];
if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
if (disk->backend_domid != LIBXL_TOOLSTACK_DOMID)
if (libxl_defbool_val(disk->grant_usage))
iommu_needed = true;
FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq,
disk->backend_domid,
disk->backend_domid != LIBXL_TOOLSTACK_DOMID) );
libxl_defbool_val(disk->grant_usage)) );
}
}
+13
View File
@@ -183,6 +183,9 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid,
return ERROR_INVAL;
}
disk->transport = LIBXL_DISK_TRANSPORT_MMIO;
libxl_defbool_setdefault(&disk->grant_usage,
disk->backend_domid != LIBXL_TOOLSTACK_DOMID);
}
if (hotplug && disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
@@ -468,6 +471,8 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
flexarray_append(back, libxl__device_disk_string_of_transport(disk->transport));
flexarray_append_pair(back, "base", GCSPRINTF("%"PRIu64, disk->base));
flexarray_append_pair(back, "irq", GCSPRINTF("%u", disk->irq));
flexarray_append_pair(back, "grant_usage",
libxl_defbool_val(disk->grant_usage) ? "1" : "0");
}
flexarray_append(front, "backend-id");
@@ -662,6 +667,14 @@ static int libxl__disk_from_xenstore(libxl__gc *gc, const char *libxl_path,
goto cleanup;
}
disk->irq = strtoul(tmp, NULL, 10);
tmp = libxl__xs_read(gc, XBT_NULL,
GCSPRINTF("%s/grant_usage", libxl_path));
if (!tmp)
libxl_defbool_set(&disk->grant_usage,
disk->backend_domid != LIBXL_TOOLSTACK_DOMID);
else
libxl_defbool_set(&disk->grant_usage, strtoul(tmp, NULL, 0));
}
disk->vdev = xs_read(ctx->xsh, XBT_NULL,
+1
View File
@@ -803,6 +803,7 @@ libxl_device_disk = Struct("device_disk", [
("active_disk", string),
("hidden_disk", string),
("trusted", libxl_defbool),
("grant_usage", libxl_defbool),
])
libxl_device_nic = Struct("device_nic", [
File diff suppressed because it is too large. Load diff
+6 -3
View File
@@ -3,9 +3,12 @@
#define xlu__disk_yyIN_HEADER 1
#line 5 "libxlu_disk_l.h"
#line 31 "libxlu_disk_l.l"
#define _GNU_SOURCE
#line 8 "libxlu_disk_l.h"
#line 11 "libxlu_disk_l.h"
#define YY_INT_ALIGNED short int
@@ -694,8 +697,8 @@ extern int yylex (yyscan_t yyscanner);
#undef yyTABLES_NAME
#endif
#line 300 "libxlu_disk_l.l"
#line 306 "libxlu_disk_l.l"
#line 699 "libxlu_disk_l.h"
#line 702 "libxlu_disk_l.h"
#undef xlu__disk_yyIN_HEADER
#endif /* xlu__disk_yyHEADER_H */
+3
View File
@@ -220,6 +220,9 @@ hidden-disk=[^,]*,? { STRIP(','); SAVESTRING("hidden-disk", hidden_disk, FROMEQU
trusted,? { libxl_defbool_set(&DPC->disk->trusted, true); }
untrusted,? { libxl_defbool_set(&DPC->disk->trusted, false); }
grant_usage=1,? { libxl_defbool_set(&DPC->disk->grant_usage, true); }
grant_usage=0,? { libxl_defbool_set(&DPC->disk->grant_usage, false); }
/* the target magic parameter, eats the rest of the string */
target=.* { STRIP(','); SAVESTRING("target", pdev_path, FROMEQUALS); }
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.