Re: svn commit: r334940 - head/usr.sbin/bhyve

2018-06-11 Thread Marcelo Araujo
2018-06-11 22:46 GMT+08:00 Pedro Giffuni :

>
>
> On 06/10/18 21:41, Marcelo Araujo wrote:
>
>
>
> 2018-06-11 10:25 GMT+08:00 Pedro Giffuni :
>
>>
>>
>> On 10/06/2018 21:09, Marcelo Araujo wrote:
>>
>>> Author: araujo
>>> Date: Mon Jun 11 02:09:20 2018
>>> New Revision: 334940
>>> URL: https://svnweb.freebsd.org/changeset/base/334940
>>>
>>> Log:
>>>- Add bhyve virtio-scsi storage backend support.
>>>   Example of configuration:
>>>ctl.conf:
>>>portal-group pg0 {
>>>discovery-auth-group no-authentication
>>>listen 0.0.0.0
>>>listen [::]
>>>}
>>>   target iqn.2012-06.com.example:target0 {
>>>auth-group no-authentication
>>>portal-group pg0
>>>port ioctl/5/3
>>>   lun 0 {
>>>path /z/test.img
>>>size 8G
>>>}
>>>lun 1 {
>>>path /z/test1.img
>>>size 8G
>>>}
>>>}
>>>   bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 
>>>   From inside guest:
>>>root@:~ # zpool status test
>>>  pool: test
>>> state: ONLINE
>>>  scan: none requested
>>>config:
>>>   NAMESTATE READ WRITE CKSUM
>>>testONLINE   0 0 0
>>>  da0   ONLINE   0 0 0
>>>  da1   ONLINE   0 0 0
>>>   dmesg:
>>>da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
>>>da0:  Fixed Direct Access SPC-5 SCSI device
>>>da0: Serial Number MYSERIAL
>>>da0: 300.000MB/s transfers
>>>da0: Command Queueing enabled
>>>da0: 8192MB (16777216 512 byte sectors)
>>>da1 at vtscsi0 bus 0 scbus0 target 0 lun 1
>>>da1:  Fixed Direct Access SPC-5 SCSI device
>>>da1: Serial Number MYSERIAL0001
>>>da1: 300.000MB/s transfers
>>>da1: Command Queueing enabled
>>>da1: 8192MB (16777216 512 byte sectors)
>>>   Discussed with:   grehan
>>>Reviewed by: mav
>>>Obtained from:   TrueOS
>>>Relnotes:Yes
>>>Sponsored by:iXsystems Inc.
>>>Tested with: FreeBSD HEAD, Fedora 28 (Workstation) and
>>> Ubuntu 18.04.
>>>Differential Revision:  https://reviews.freebsd.org/D15276
>>>
>>> Added:
>>>head/usr.sbin/bhyve/iov.c   (contents, props changed)
>>>head/usr.sbin/bhyve/iov.h   (contents, props changed)
>>>head/usr.sbin/bhyve/pci_virtio_scsi.c   (contents, props changed)
>>> Modified:
>>>head/usr.sbin/bhyve/Makefile
>>>head/usr.sbin/bhyve/bhyve.8
>>>head/usr.sbin/bhyve/virtio.h
>>>
>>> ...
>>>
>>
>> Added: head/usr.sbin/bhyve/pci_virtio_scsi.c
>>> 
>>> ==
>>> --- /dev/null   00:00:00 1970   (empty, because file is newly added)
>>> +++ head/usr.sbin/bhyve/pci_virtio_scsi.c   Mon Jun 11 02:09:20
>>> 2018(r334940)
>>> @@ -0,0 +1,718 @@
>>> +/*-
>>> + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
>>> + *
>>> + * Copyright (c) 2016 Jakub Klama 
>>> .
>>> + * Copyright (c) 2018 Marcelo Araujo 
>>> .
>>> + * All rights reserved.
>>> + *
>>> + * Redistribution and use in source and binary forms, with or without
>>> + * modification, are permitted provided that the following conditions
>>> + * are met:
>>> + * 1. Redistributions of source code must retain the above copyright
>>> + *notice, this list of conditions and the following disclaimer
>>> + *in this position and unchanged.
>>> + * 2. Redistributions in binary form must reproduce the above copyright
>>> + *notice, this list of conditions and the following disclaimer in
>>> the
>>> + *documentation and/or other materials provided with the
>>> distribution.
>>> + *
>>> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
>>> AND
>>> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
>>> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
>>> PURPOSE
>>> + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
>>> LIABLE
>>> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>>> CONSEQUENTIAL
>>> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
>>> GOODS
>>> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
>>> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
>>> STRICT
>>> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
>>> ANY WAY
>>> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
>>> OF
>>> + * SUCH DAMAGE.
>>> + */
>>> +
>>> +#include 
>>> +__FBSDID("$FreeBSD$");
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 

Re: svn commit: r334940 - head/usr.sbin/bhyve

2018-06-11 Thread Pedro Giffuni



On 06/10/18 21:41, Marcelo Araujo wrote:



2018-06-11 10:25 GMT+08:00 Pedro Giffuni >:




On 10/06/2018 21:09, Marcelo Araujo wrote:

Author: araujo
Date: Mon Jun 11 02:09:20 2018
New Revision: 334940
URL: https://svnweb.freebsd.org/changeset/base/334940


Log:
   - Add bhyve virtio-scsi storage backend support.
      Example of configuration:
   ctl.conf:
   portal-group pg0 {
           discovery-auth-group no-authentication
           listen 0.0.0.0
           listen [::]
   }
      target iqn.2012-06.com.example:target0 {
           auth-group no-authentication
           portal-group pg0
           port ioctl/5/3
              lun 0 {
                   path /z/test.img
                   size 8G
           }
           lun 1 {
                   path /z/test1.img
                   size 8G
           }
   }
      bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 
      From inside guest:
   root@:~ # zpool status test
     pool: test
    state: ONLINE
     scan: none requested
   config:
              NAME        STATE     READ WRITE CKSUM
           test        ONLINE       0     0     0
             da0       ONLINE       0     0     0
             da1       ONLINE       0     0     0
      dmesg:
   da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
   da0:  Fixed Direct Access SPC-5 SCSI
device
   da0: Serial Number MYSERIAL
   da0: 300.000MB/s transfers
   da0: Command Queueing enabled
   da0: 8192MB (16777216 512 byte sectors)
   da1 at vtscsi0 bus 0 scbus0 target 0 lun 1
   da1:  Fixed Direct Access SPC-5 SCSI
device
   da1: Serial Number MYSERIAL0001
   da1: 300.000MB/s transfers
   da1: Command Queueing enabled
   da1: 8192MB (16777216 512 byte sectors)
      Discussed with:           grehan
   Reviewed by:         mav
   Obtained from:               TrueOS
   Relnotes:            Yes
   Sponsored by:                iXsystems Inc.
   Tested with:         FreeBSD HEAD, Fedora 28 (Workstation) and
                        Ubuntu 18.04.
   Differential Revision: https://reviews.freebsd.org/D15276


Added:
   head/usr.sbin/bhyve/iov.c   (contents, props changed)
   head/usr.sbin/bhyve/iov.h   (contents, props changed)
   head/usr.sbin/bhyve/pci_virtio_scsi.c  (contents, props
changed)
Modified:
   head/usr.sbin/bhyve/Makefile
   head/usr.sbin/bhyve/bhyve.8
   head/usr.sbin/bhyve/virtio.h

...


Added: head/usr.sbin/bhyve/pci_virtio_scsi.c

==
--- /dev/null   00:00:00 1970   (empty, because file is newly
added)
+++ head/usr.sbin/bhyve/pci_virtio_scsi.c  Mon Jun 11 02:09:20
2018        (r334940)
@@ -0,0 +1,718 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2016 Jakub Klama .
+ * Copyright (c) 2018 Marcelo Araujo .
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
without
+ * modification, are permitted provided that the following
conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above
copyright
+ *    notice, this list of conditions and the following
disclaimer
+ *    in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above
copyright
+ *    notice, this list of conditions and the following
disclaimer in the
+ *    documentation and/or other materials provided with the
distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY 

Re: svn commit: r334940 - head/usr.sbin/bhyve

2018-06-10 Thread Pedro Giffuni



On 10/06/2018 21:41, Marcelo Araujo wrote:



2018-06-11 10:25 GMT+08:00 Pedro Giffuni >:




On 10/06/2018 21:09, Marcelo Araujo wrote:

Author: araujo
Date: Mon Jun 11 02:09:20 2018
New Revision: 334940
URL: https://svnweb.freebsd.org/changeset/base/334940


Log:
   - Add bhyve virtio-scsi storage backend support.
      Example of configuration:
   ctl.conf:
   portal-group pg0 {
           discovery-auth-group no-authentication
           listen 0.0.0.0
           listen [::]
   }
      target iqn.2012-06.com.example:target0 {
           auth-group no-authentication
           portal-group pg0
           port ioctl/5/3
              lun 0 {
                   path /z/test.img
                   size 8G
           }
           lun 1 {
                   path /z/test1.img
                   size 8G
           }
   }
      bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 
      From inside guest:
   root@:~ # zpool status test
     pool: test
    state: ONLINE
     scan: none requested
   config:
              NAME        STATE     READ WRITE CKSUM
           test        ONLINE       0     0     0
             da0       ONLINE       0     0     0
             da1       ONLINE       0     0     0
      dmesg:
   da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
   da0:  Fixed Direct Access SPC-5 SCSI
device
   da0: Serial Number MYSERIAL
   da0: 300.000MB/s transfers
   da0: Command Queueing enabled
   da0: 8192MB (16777216 512 byte sectors)
   da1 at vtscsi0 bus 0 scbus0 target 0 lun 1
   da1:  Fixed Direct Access SPC-5 SCSI
device
   da1: Serial Number MYSERIAL0001
   da1: 300.000MB/s transfers
   da1: Command Queueing enabled
   da1: 8192MB (16777216 512 byte sectors)
      Discussed with:           grehan
   Reviewed by:         mav
   Obtained from:               TrueOS
   Relnotes:            Yes
   Sponsored by:                iXsystems Inc.
   Tested with:         FreeBSD HEAD, Fedora 28 (Workstation) and
                        Ubuntu 18.04.
   Differential Revision: https://reviews.freebsd.org/D15276


Added:
   head/usr.sbin/bhyve/iov.c   (contents, props changed)
   head/usr.sbin/bhyve/iov.h   (contents, props changed)
   head/usr.sbin/bhyve/pci_virtio_scsi.c  (contents, props
changed)
Modified:
   head/usr.sbin/bhyve/Makefile
   head/usr.sbin/bhyve/bhyve.8
   head/usr.sbin/bhyve/virtio.h

...


Added: head/usr.sbin/bhyve/pci_virtio_scsi.c

==
--- /dev/null   00:00:00 1970   (empty, because file is newly
added)
+++ head/usr.sbin/bhyve/pci_virtio_scsi.c  Mon Jun 11 02:09:20
2018        (r334940)
@@ -0,0 +1,718 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2016 Jakub Klama .
+ * Copyright (c) 2018 Marcelo Araujo .
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
without
+ * modification, are permitted provided that the following
conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above
copyright
+ *    notice, this list of conditions and the following
disclaimer
+ *    in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above
copyright
+ *    notice, this list of conditions and the following
disclaimer in the
+ *    documentation and/or other materials provided with the
distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY 

Re: svn commit: r334940 - head/usr.sbin/bhyve

2018-06-10 Thread Marcelo Araujo
2018-06-11 10:25 GMT+08:00 Pedro Giffuni :

>
>
> On 10/06/2018 21:09, Marcelo Araujo wrote:
>
>> Author: araujo
>> Date: Mon Jun 11 02:09:20 2018
>> New Revision: 334940
>> URL: https://svnweb.freebsd.org/changeset/base/334940
>>
>> Log:
>>- Add bhyve virtio-scsi storage backend support.
>>   Example of configuration:
>>ctl.conf:
>>portal-group pg0 {
>>discovery-auth-group no-authentication
>>listen 0.0.0.0
>>listen [::]
>>}
>>   target iqn.2012-06.com.example:target0 {
>>auth-group no-authentication
>>portal-group pg0
>>port ioctl/5/3
>>   lun 0 {
>>path /z/test.img
>>size 8G
>>}
>>lun 1 {
>>path /z/test1.img
>>size 8G
>>}
>>}
>>   bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 
>>   From inside guest:
>>root@:~ # zpool status test
>>  pool: test
>> state: ONLINE
>>  scan: none requested
>>config:
>>   NAMESTATE READ WRITE CKSUM
>>testONLINE   0 0 0
>>  da0   ONLINE   0 0 0
>>  da1   ONLINE   0 0 0
>>   dmesg:
>>da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
>>da0:  Fixed Direct Access SPC-5 SCSI device
>>da0: Serial Number MYSERIAL
>>da0: 300.000MB/s transfers
>>da0: Command Queueing enabled
>>da0: 8192MB (16777216 512 byte sectors)
>>da1 at vtscsi0 bus 0 scbus0 target 0 lun 1
>>da1:  Fixed Direct Access SPC-5 SCSI device
>>da1: Serial Number MYSERIAL0001
>>da1: 300.000MB/s transfers
>>da1: Command Queueing enabled
>>da1: 8192MB (16777216 512 byte sectors)
>>   Discussed with:   grehan
>>Reviewed by: mav
>>Obtained from:   TrueOS
>>Relnotes:Yes
>>Sponsored by:iXsystems Inc.
>>Tested with: FreeBSD HEAD, Fedora 28 (Workstation) and
>> Ubuntu 18.04.
>>Differential Revision:  https://reviews.freebsd.org/D15276
>>
>> Added:
>>head/usr.sbin/bhyve/iov.c   (contents, props changed)
>>head/usr.sbin/bhyve/iov.h   (contents, props changed)
>>head/usr.sbin/bhyve/pci_virtio_scsi.c   (contents, props changed)
>> Modified:
>>head/usr.sbin/bhyve/Makefile
>>head/usr.sbin/bhyve/bhyve.8
>>head/usr.sbin/bhyve/virtio.h
>>
>> ...
>>
>
> Added: head/usr.sbin/bhyve/pci_virtio_scsi.c
>> 
>> ==
>> --- /dev/null   00:00:00 1970   (empty, because file is newly added)
>> +++ head/usr.sbin/bhyve/pci_virtio_scsi.c   Mon Jun 11 02:09:20
>> 2018(r334940)
>> @@ -0,0 +1,718 @@
>> +/*-
>> + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
>> + *
>> + * Copyright (c) 2016 Jakub Klama .
>> + * Copyright (c) 2018 Marcelo Araujo .
>> + * All rights reserved.
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + * 1. Redistributions of source code must retain the above copyright
>> + *notice, this list of conditions and the following disclaimer
>> + *in this position and unchanged.
>> + * 2. Redistributions in binary form must reproduce the above copyright
>> + *notice, this list of conditions and the following disclaimer in the
>> + *documentation and/or other materials provided with the
>> distribution.
>> + *
>> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
>> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
>> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
>> PURPOSE
>> + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
>> LIABLE
>> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>> CONSEQUENTIAL
>> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
>> GOODS
>> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
>> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
>> STRICT
>> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
>> WAY
>> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>> + * SUCH DAMAGE.
>> + */
>> +
>> +#include 
>> +__FBSDID("$FreeBSD$");
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "bhyverun.h"
>> +#include "pci_emul.h"
>> +#include "virtio.h"
>> +#include "iov.h"
>> +
>> 

Re: svn commit: r334940 - head/usr.sbin/bhyve

2018-06-10 Thread Pedro Giffuni




On 10/06/2018 21:09, Marcelo Araujo wrote:

Author: araujo
Date: Mon Jun 11 02:09:20 2018
New Revision: 334940
URL: https://svnweb.freebsd.org/changeset/base/334940

Log:
   - Add bhyve virtio-scsi storage backend support.
   
   Example of configuration:

   ctl.conf:
   portal-group pg0 {
   discovery-auth-group no-authentication
   listen 0.0.0.0
   listen [::]
   }
   
   target iqn.2012-06.com.example:target0 {

   auth-group no-authentication
   portal-group pg0
   port ioctl/5/3
   
   lun 0 {

   path /z/test.img
   size 8G
   }
   lun 1 {
   path /z/test1.img
   size 8G
   }
   }
   
   bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 
   
   From inside guest:

   root@:~ # zpool status test
 pool: test
state: ONLINE
 scan: none requested
   config:
   
   NAMESTATE READ WRITE CKSUM

   testONLINE   0 0 0
 da0   ONLINE   0 0 0
 da1   ONLINE   0 0 0
   
   dmesg:

   da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
   da0:  Fixed Direct Access SPC-5 SCSI device
   da0: Serial Number MYSERIAL
   da0: 300.000MB/s transfers
   da0: Command Queueing enabled
   da0: 8192MB (16777216 512 byte sectors)
   da1 at vtscsi0 bus 0 scbus0 target 0 lun 1
   da1:  Fixed Direct Access SPC-5 SCSI device
   da1: Serial Number MYSERIAL0001
   da1: 300.000MB/s transfers
   da1: Command Queueing enabled
   da1: 8192MB (16777216 512 byte sectors)
   
   Discussed with:		grehan

   Reviewed by: mav
   Obtained from:   TrueOS
   Relnotes:Yes
   Sponsored by:iXsystems Inc.
   Tested with: FreeBSD HEAD, Fedora 28 (Workstation) and
Ubuntu 18.04.
   Differential Revision:  https://reviews.freebsd.org/D15276

Added:
   head/usr.sbin/bhyve/iov.c   (contents, props changed)
   head/usr.sbin/bhyve/iov.h   (contents, props changed)
   head/usr.sbin/bhyve/pci_virtio_scsi.c   (contents, props changed)
Modified:
   head/usr.sbin/bhyve/Makefile
   head/usr.sbin/bhyve/bhyve.8
   head/usr.sbin/bhyve/virtio.h

...



Added: head/usr.sbin/bhyve/pci_virtio_scsi.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/bhyve/pci_virtio_scsi.c   Mon Jun 11 02:09:20 2018
(r334940)
@@ -0,0 +1,718 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2016 Jakub Klama .
+ * Copyright (c) 2018 Marcelo Araujo .
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer
+ *in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "bhyverun.h"
+#include "pci_emul.h"
+#include "virtio.h"
+#include "iov.h"
+
+#define VTSCSI_RINGSZ  64
+#defineVTSCSI_REQUESTQ 1
+#defineVTSCSI_THR_PER_Q16
+#defineVTSCSI_MAXQ (VTSCSI_REQUESTQ + 2)
+#defineVTSCSI_MAXSEG   64
+
+#defineVTSCSI_IN_HEADER_LEN(_sc)   \
+   (sizeof(struct pci_vtscsi_req_cmd_rd) + _sc->vss_config.cdb_size)
+
+#defineVTSCSI_OUT_HEADER_LEN(_sc)  \
+   (sizeof(struct pci_vtscsi_req_cmd_wr) + _sc->vss_config.sense_size)
+
+#define 

svn commit: r334940 - head/usr.sbin/bhyve

2018-06-10 Thread Marcelo Araujo
Author: araujo
Date: Mon Jun 11 02:09:20 2018
New Revision: 334940
URL: https://svnweb.freebsd.org/changeset/base/334940

Log:
  - Add bhyve virtio-scsi storage backend support.
  
  Example of configuration:
  ctl.conf:
  portal-group pg0 {
  discovery-auth-group no-authentication
  listen 0.0.0.0
  listen [::]
  }
  
  target iqn.2012-06.com.example:target0 {
  auth-group no-authentication
  portal-group pg0
  port ioctl/5/3
  
  lun 0 {
  path /z/test.img
  size 8G
  }
  lun 1 {
  path /z/test1.img
  size 8G
  }
  }
  
  bhyve <...> -s 4,virtio-scsi,/dev/cam/ctl5.3,iid=3 
  
  From inside guest:
  root@:~ # zpool status test
pool: test
   state: ONLINE
scan: none requested
  config:
  
  NAMESTATE READ WRITE CKSUM
  testONLINE   0 0 0
da0   ONLINE   0 0 0
da1   ONLINE   0 0 0
  
  dmesg:
  da0 at vtscsi0 bus 0 scbus0 target 0 lun 0
  da0:  Fixed Direct Access SPC-5 SCSI device
  da0: Serial Number MYSERIAL
  da0: 300.000MB/s transfers
  da0: Command Queueing enabled
  da0: 8192MB (16777216 512 byte sectors)
  da1 at vtscsi0 bus 0 scbus0 target 0 lun 1
  da1:  Fixed Direct Access SPC-5 SCSI device
  da1: Serial Number MYSERIAL0001
  da1: 300.000MB/s transfers
  da1: Command Queueing enabled
  da1: 8192MB (16777216 512 byte sectors)
  
  Discussed with:   grehan
  Reviewed by:  mav
  Obtained from:TrueOS
  Relnotes: Yes
  Sponsored by: iXsystems Inc.
  Tested with:  FreeBSD HEAD, Fedora 28 (Workstation) and
Ubuntu 18.04.
  Differential Revision:  https://reviews.freebsd.org/D15276

Added:
  head/usr.sbin/bhyve/iov.c   (contents, props changed)
  head/usr.sbin/bhyve/iov.h   (contents, props changed)
  head/usr.sbin/bhyve/pci_virtio_scsi.c   (contents, props changed)
Modified:
  head/usr.sbin/bhyve/Makefile
  head/usr.sbin/bhyve/bhyve.8
  head/usr.sbin/bhyve/virtio.h

Modified: head/usr.sbin/bhyve/Makefile
==
--- head/usr.sbin/bhyve/MakefileMon Jun 11 01:32:18 2018
(r334939)
+++ head/usr.sbin/bhyve/MakefileMon Jun 11 02:09:20 2018
(r334940)
@@ -3,6 +3,8 @@
 #
 
 .include 
+CFLAGS+=-I${SRCTOP}/sys
+.PATH:  ${SRCTOP}/sys/cam/ctl
 
 PROG=  bhyve
 PACKAGE=   bhyve
@@ -22,6 +24,8 @@ SRCS= \
bootrom.c   \
console.c   \
consport.c  \
+   ctl_util.c  \
+   ctl_scsi_all.c  \
dbgport.c   \
fwctl.c \
gdb.c   \
@@ -42,6 +46,7 @@ SRCS= \
pci_virtio_console.c\
pci_virtio_net.c\
pci_virtio_rnd.c\
+   pci_virtio_scsi.c   \
pci_uart.c  \
pci_xhci.c  \
pm.c\
@@ -59,12 +64,13 @@ SRCS=   \
virtio.c\
vga.c   \
xmsr.c  \
-   spinup_ap.c
+   spinup_ap.c \
+   iov.c
 
 .PATH:  ${BHYVE_SYSDIR}/sys/amd64/vmm
 SRCS+= vmm_instruction_emul.c
 
-LIBADD=vmmapi md pthread z
+LIBADD=vmmapi md pthread z util sbuf cam
 
 .if ${MK_OPENSSL} == "no"
 CFLAGS+=-DNO_OPENSSL

Modified: head/usr.sbin/bhyve/bhyve.8
==
--- head/usr.sbin/bhyve/bhyve.8 Mon Jun 11 01:32:18 2018(r334939)
+++ head/usr.sbin/bhyve/bhyve.8 Mon Jun 11 02:09:20 2018(r334940)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 1, 2018
+.Dd Jun 11, 2018
 .Dt BHYVE 8
 .Os
 .Sh NAME
@@ -216,6 +216,8 @@ PCI pass-through device.
 Virtio network interface.
 .It Li virtio-blk
 Virtio block storage interface.
+.It Li virtio-scsi
+Virtio SCSI interface.
 .It Li virtio-rnd
 Virtio RNG interface.
 .It Li virtio-console
@@ -285,6 +287,11 @@ Force the file to be opened read-only.
 Specify the logical and physical sector sizes of the emulated disk.
 The physical sector size is optional and is equal to the logical sector size
 if not explicitly specified.
+.El
+.Pp
+SCSI devices:
+.Bl -tag -width 10n
+.It Pa /dev/cam/ Ns Oo , Ns Ar port and initiator_id Oc
 .El
 .Pp
 TTY devices:

Added: head/usr.sbin/bhyve/iov.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/bhyve/iov.c   Mon Jun 11 02:09:20 2018(r334940)
@@ -0,0 +1,141 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2016 Jakub Klama .
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are