From owner-svn-soc-all@FreeBSD.ORG Mon Sep 9 14:27:18 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F15A4926 for ; Mon, 9 Sep 2013 14:27:18 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C37DA2A1E for ; Mon, 9 Sep 2013 14:27:18 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r89ERI08045168 for ; Mon, 9 Sep 2013 14:27:18 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r89ERIoU045162 for svn-soc-all@FreeBSD.org; Mon, 9 Sep 2013 14:27:18 GMT (envelope-from zcore@FreeBSD.org) Date: Mon, 9 Sep 2013 14:27:18 GMT Message-Id: <201309091427.r89ERIoU045162@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257161 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Sep 2013 14:27:19 -0000 Author: zcore Date: Mon Sep 9 14:27:18 2013 New Revision: 257161 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257161 Log: add multi backing files support we can support up to 6 backing files. Each backing file per port. Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Mon Sep 9 14:26:35 2013 (r257160) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Mon Sep 9 14:27:18 2013 (r257161) @@ -753,42 +753,47 @@ static int pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { - int i; + int i, ret = 0; struct pci_ahci_softc *sc; - char bident[sizeof("XX:X")]; - struct blockif_ctxt *bctxt; + char *str, *cpy, *fstr; if (opts == NULL) { printf("pci_ahci: backing device required\n"); return (1); } + str = cpy = strdup(opts); dbg = fopen("/tmp/log", "w+"); DPRINTF(("pci_ahci initializing\n")); - /* - * Attempt to open the backing image. Use the PCI slot/func - * for the identifier string since that uniquely identifies - * a storage device. - */ - snprintf(bident, sizeof(bident), "%d:%d", pi->pi_slot, pi->pi_func); - - bctxt = blockif_open(opts, bident); - if (bctxt == NULL) - return (1); - sc = malloc(sizeof(struct pci_ahci_softc)); memset(sc, 0, sizeof(struct pci_ahci_softc)); - pi->pi_arg = sc; sc->asc_pi = pi; - - sc->port[0].bctx = bctxt; - sc->ports = MAX_PORTS; + for (i = 0; i < sc->ports; i++) { - if (!sc->port[i].bctx) - continue; + char bident[sizeof("XX:X:X")]; + struct blockif_ctxt *bctxt; + + fstr = strsep(&str, ","); + if (fstr == NULL) + break; + /* + * Attempt to open the backing image. Use the PCI + * slot/func/ahci_port for the identifier string + * since that uniquely identifies a storage device. + */ + snprintf(bident, sizeof(bident), "%d:%d:%d", + pi->pi_slot, pi->pi_func, i); + + bctxt = blockif_open(fstr, bident); + if (bctxt == NULL) { + ret = 1; + goto open_fail; + } + + sc->port[i].bctx = bctxt; sc->port[i].pr_sc = sc; pthread_cond_init(&sc->port[i].flush_cond, NULL); /* @@ -821,7 +826,15 @@ pci_emul_alloc_bar(pi, 5, PCIBAR_MEM32, AHCI_OFFSET+sc->ports*AHCI_STEP); - return (0); +open_fail: + free(cpy); + if (ret) { + int n; + for (n = i - 1; n >= 0; n--) + blockif_close(sc->port[n].bctx); + free(sc); + } + return ret; } static void