Skip to content

Instantly share code, notes, and snippets.

@papertigers
Created July 25, 2019 16:29
Show Gist options
  • Save papertigers/2b8a9430d52368368dffb2dc453bd816 to your computer and use it in GitHub Desktop.
Save papertigers/2b8a9430d52368368dffb2dc453bd816 to your computer and use it in GitHub Desktop.
Patch that allows setting the viona feature mask
diff --git a/usr/src/lib/brand/bhyve/zone/boot.c b/usr/src/lib/brand/bhyve/zone/boot.c
index 6e6f3dc640..e1c063d87e 100644
--- a/usr/src/lib/brand/bhyve/zone/boot.c
+++ b/usr/src/lib/brand/bhyve/zone/boot.c
@@ -82,6 +82,23 @@ get_zcfg_var(const char *rsrc, const char *inst, const char *prop)
return (ret);
}
+static long
+viona_feature_mask(const char *inst)
+{
+ char *val;
+ long num;
+
+ if ((val = get_zcfg_var("net", inst, "feature_mask")) == NULL)
+ return 0;
+
+ errno = 0;
+ num = strtol(val, NULL, 0);
+ if (errno != 0 || num < 0)
+ return 0;
+
+ return num;
+}
+
static boolean_t
is_env_true(const char *rsrc, const char *inst, const char *prop)
{
@@ -381,6 +398,7 @@ add_nets(int *argc, char **argv)
int nextpcifn = 1; /* 0 reserved for primary */
char slotconf[MAXNAMELEN];
char *primary = NULL;
+ long fmask;
if ((nets = get_zcfg_var("net", "resources", NULL)) == NULL) {
return (0);
@@ -410,9 +428,11 @@ add_nets(int *argc, char **argv)
nextpcifn++;
}
+ fmask = viona_feature_mask(net);
+
if (snprintf(slotconf, sizeof (slotconf),
- "%d:%d,virtio-net-viona,%s", PCI_SLOT_NICS, pcifn, net) >=
- sizeof (slotconf)) {
+ "%d:%d,virtio-net-viona,%s,feature_mask=%lu", PCI_SLOT_NICS,
+ pcifn, net, fmask) >= sizeof (slotconf)) {
(void) printf("Error: net '%s' too long\n", net);
return (-1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment