From owner-svn-src-all@FreeBSD.ORG Fri Feb 1 01:16:27 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BB907839; Fri, 1 Feb 2013 01:16:27 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7F2F7FB2; Fri, 1 Feb 2013 01:16:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r111GRHU003352; Fri, 1 Feb 2013 01:16:27 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r111GRAG003350; Fri, 1 Feb 2013 01:16:27 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201302010116.r111GRAG003350@svn.freebsd.org> From: Neel Natu Date: Fri, 1 Feb 2013 01:16:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r246188 - in head/sys/amd64/vmm: . io X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2013 01:16:27 -0000 Author: neel Date: Fri Feb 1 01:16:26 2013 New Revision: 246188 URL: http://svnweb.freebsd.org/changeset/base/246188 Log: 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 Modified: head/sys/amd64/vmm/io/ppt.c head/sys/amd64/vmm/vmm.c Modified: head/sys/amd64/vmm/io/ppt.c ============================================================================== --- head/sys/amd64/vmm/io/ppt.c Fri Feb 1 00:32:01 2013 (r246187) +++ head/sys/amd64/vmm/io/ppt.c Fri Feb 1 01:16:26 2013 (r246188) @@ -89,7 +89,7 @@ static struct pptdev { void **cookie; struct pptintr_arg *arg; } msix; -} pptdevs[32]; +} pptdevs[64]; static int num_pptdevs; Modified: head/sys/amd64/vmm/vmm.c ============================================================================== --- head/sys/amd64/vmm/vmm.c Fri Feb 1 00:32:01 2013 (r246187) +++ head/sys/amd64/vmm/vmm.c Fri Feb 1 01:16:26 2013 (r246188) @@ -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); }