diff options
author | neel <neel@FreeBSD.org> | 2013-02-01 01:16:26 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2013-02-01 01:16:26 +0000 |
commit | c9a45ab898c8adbadbd15cf73d00a9dbf1d4ba52 (patch) | |
tree | c09fa09551b6d13bd2246f729f6ab7a749826895 /sys/amd64 | |
parent | 2163564eabb1b46f1a6d5412efcec28e5315fad2 (diff) | |
download | FreeBSD-src-c9a45ab898c8adbadbd15cf73d00a9dbf1d4ba52.zip FreeBSD-src-c9a45ab898c8adbadbd15cf73d00a9dbf1d4ba52.tar.gz |
Increase the number of passthru devices supported by bhyve.
The maximum length of an environment variable puts a limitation on the
number of passthru devices that can be specified via a single variable.
The workaround is to allow user to specify passthru devices via multiple
environment variables instead of a single one.
Obtained from: NetApp
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/vmm/io/ppt.c | 2 | ||||
-rw-r--r-- | sys/amd64/vmm/vmm.c | 44 |
2 files changed, 29 insertions, 17 deletions
diff --git a/sys/amd64/vmm/io/ppt.c b/sys/amd64/vmm/io/ppt.c index fdf136b..d3ec8d1 100644 --- a/sys/amd64/vmm/io/ppt.c +++ b/sys/amd64/vmm/io/ppt.c @@ -89,7 +89,7 @@ static struct pptdev { void **cookie; struct pptintr_arg *arg; } msix; -} pptdevs[32]; +} pptdevs[64]; static int num_pptdevs; diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index d0e6427..82d4baa 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -862,30 +862,42 @@ vm_lapic(struct vm *vm, int cpu) boolean_t vmm_is_pptdev(int bus, int slot, int func) { - int found, b, s, f, n; + int found, i, n; + int b, s, f; char *val, *cp, *cp2; /* - * setenv pptdevs "1/2/3 4/5/6 7/8/9 10/11/12" + * XXX + * The length of an environment variable is limited to 128 bytes which + * puts an upper limit on the number of passthru devices that may be + * specified using a single environment variable. + * + * Work around this by scanning multiple environment variable + * names instead of a single one - yuck! */ + const char *names[] = { "pptdevs", "pptdevs2", "pptdevs3", NULL }; + + /* set pptdevs="1/2/3 4/5/6 7/8/9 10/11/12" */ found = 0; - cp = val = getenv("pptdevs"); - while (cp != NULL && *cp != '\0') { - if ((cp2 = strchr(cp, ' ')) != NULL) - *cp2 = '\0'; - - n = sscanf(cp, "%d/%d/%d", &b, &s, &f); - if (n == 3 && bus == b && slot == s && func == f) { - found = 1; - break; - } + for (i = 0; names[i] != NULL && !found; i++) { + cp = val = getenv(names[i]); + while (cp != NULL && *cp != '\0') { + if ((cp2 = strchr(cp, ' ')) != NULL) + *cp2 = '\0'; + + n = sscanf(cp, "%d/%d/%d", &b, &s, &f); + if (n == 3 && bus == b && slot == s && func == f) { + found = 1; + break; + } - if (cp2 != NULL) - *cp2++ = ' '; + if (cp2 != NULL) + *cp2++ = ' '; - cp = cp2; + cp = cp2; + } + freeenv(val); } - freeenv(val); return (found); } |