Date: Mon, 9 Sep 2013 14:27:18 GMT From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257161 - soc2013/zcore/head/usr.sbin/bhyve Message-ID: <201309091427.r89ERIoU045162@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309091427.r89ERIoU045162>