From owner-svn-src-head@freebsd.org Tue Dec 11 20:47:01 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC8611313DA9; Tue, 11 Dec 2018 20:47:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 741136C962; Tue, 11 Dec 2018 20:47:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 568B353BC; Tue, 11 Dec 2018 20:47:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBBKl1ih007489; Tue, 11 Dec 2018 20:47:01 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBBKl1aB007487; Tue, 11 Dec 2018 20:47:01 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201812112047.wBBKl1aB007487@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Dec 2018 20:47:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341829 - head/usr.sbin/bhyve X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/usr.sbin/bhyve X-SVN-Commit-Revision: 341829 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 741136C962 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-0.75 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.75)[-0.747,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Dec 2018 20:47:02 -0000 Author: mav Date: Tue Dec 11 20:47:00 2018 New Revision: 341829 URL: https://svnweb.freebsd.org/changeset/base/341829 Log: Allow CTL device specification in bhyve virtio-scsi. There was a large refactoring done in CTL to allow multiple ioctl frontend ports (and respective devices) to be created, particularly for bhyve. Unfortunately, respective part of bhyve functionality got lost somehow from the original virtio-scsi commit. This change allows wanted device path to be specified in either of two ways: -s 6,virtio-scsi,/dev/cam/ctl1.1 -s 6,virtio-scsi,dev=/dev/cam/ctl2.3 If neither is specified, the default /dev/cam/ctl device is used. While there, remove per-queue CTL device opening, which makes no sense at this point. Reported by: wg Reviewed by: araujo MFC after: 3 days Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D18504 Modified: head/usr.sbin/bhyve/bhyve.8 head/usr.sbin/bhyve/pci_virtio_scsi.c Modified: head/usr.sbin/bhyve/bhyve.8 ============================================================================== --- head/usr.sbin/bhyve/bhyve.8 Tue Dec 11 19:34:25 2018 (r341828) +++ head/usr.sbin/bhyve/bhyve.8 Tue Dec 11 20:47:00 2018 (r341829) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 24, 2018 +.Dd December 11, 2018 .Dt BHYVE 8 .Os .Sh NAME @@ -298,7 +298,16 @@ if not explicitly specified. .Pp SCSI devices: .Bl -tag -width 10n -.It Pa /dev/cam/ Ns Oo , Ns Ar port and initiator_id Oc +.It Pa /dev/cam/ctl Ns Oo Ar pp . Ns Ar vp Oc Ns Oo , Ns Ar scsi-device-options Oc +.El +.Pp +The +.Ar scsi-device-options +are: +.Bl -tag -width 10n +.It Li iid= Ns Ar IID +Initiator ID to use when sending requests to specified CTL port. +The default value is 0. .El .Pp TTY devices: Modified: head/usr.sbin/bhyve/pci_virtio_scsi.c ============================================================================== --- head/usr.sbin/bhyve/pci_virtio_scsi.c Tue Dec 11 19:34:25 2018 (r341828) +++ head/usr.sbin/bhyve/pci_virtio_scsi.c Tue Dec 11 20:47:00 2018 (r341829) @@ -105,7 +105,6 @@ struct pci_vtscsi_config { struct pci_vtscsi_queue { struct pci_vtscsi_softc * vsq_sc; struct vqueue_info * vsq_vq; - int vsq_ctl_fd; pthread_mutex_t vsq_mtx; pthread_mutex_t vsq_qmtx; pthread_cond_t vsq_cv; @@ -529,7 +528,7 @@ pci_vtscsi_request_handle(struct pci_vtscsi_queue *q, sbuf_delete(sb); } - err = ioctl(q->vsq_ctl_fd, CTL_IO, io); + err = ioctl(sc->vss_ctl_fd, CTL_IO, io); if (err != 0) { WPRINTF(("CTL_IO: err=%d (%s)\n", errno, strerror(errno))); cmd_wr->response = VIRTIO_SCSI_S_FAILURE; @@ -639,14 +638,8 @@ pci_vtscsi_init_queue(struct pci_vtscsi_softc *sc, int i; queue->vsq_sc = sc; - queue->vsq_ctl_fd = open("/dev/cam/ctl", O_RDWR); queue->vsq_vq = &sc->vss_vq[num + 2]; - if (queue->vsq_ctl_fd < 0) { - WPRINTF(("cannot open /dev/cam/ctl: %s\n", strerror(errno))); - return (-1); - } - pthread_mutex_init(&queue->vsq_mtx, NULL); pthread_mutex_init(&queue->vsq_qmtx, NULL); pthread_cond_init(&queue->vsq_cv, NULL); @@ -672,24 +665,34 @@ static int pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { struct pci_vtscsi_softc *sc; - char *optname = NULL; - char *opt; - int i; + char *opt, *optname; + const char *devname; + int i, optidx = 0; sc = calloc(1, sizeof(struct pci_vtscsi_softc)); - sc->vss_ctl_fd = open("/dev/cam/ctl", O_RDWR); + devname = "/dev/cam/ctl"; + while ((opt = strsep(&opts, ",")) != NULL) { + optname = strsep(&opt, "="); + if (opt == NULL && optidx == 0) { + if (optname[0] != 0) + devname = optname; + } else if (strcmp(optname, "dev") == 0 && opt != NULL) { + devname = opt; + } else if (strcmp(optname, "iid") == 0 && opt != NULL) { + sc->vss_iid = strtoul(opt, NULL, 10); + } else { + fprintf(stderr, "Invalid option %s\n", optname); + free(sc); + return (1); + } + optidx++; + } + sc->vss_ctl_fd = open(devname, O_RDWR); if (sc->vss_ctl_fd < 0) { - WPRINTF(("cannot open /dev/cam/ctl: %s\n", strerror(errno))); + WPRINTF(("cannot open %s: %s\n", devname, strerror(errno))); + free(sc); return (1); - } - - while ((opt = strsep(&opts, ",")) != NULL) { - if ((optname = strsep(&opt, "=")) != NULL) { - if (strcmp(optname, "iid") == 0) { - sc->vss_iid = strtoul(opt, NULL, 10); - } - } } vi_softc_linkup(&sc->vss_vs, &vtscsi_vi_consts, sc, pi, sc->vss_vq);