Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jan 2018 10:41:18 -0500
From:      "Kenneth D. Merry" <ken@FreeBSD.ORG>
To:        Florian Florensa <florian.florensa@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Virtual SCSI Device
Message-ID:  <20180110154118.GA13659@mithlond.kdm.org>
In-Reply-To: <CACkk1ySq3%2BwriDZZ6QczFey=PwBdfXs=mVTJqB7NuUob2ASe-A@mail.gmail.com>
References:  <CACkk1ySq3%2BwriDZZ6QczFey=PwBdfXs=mVTJqB7NuUob2ASe-A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jan 08, 2018 at 17:13:04 +0100, Florian Florensa wrote:
> Hello,
> 
> I've been trying to hack together a virtual SCSI device, and i've been
> struggling withthe device creation.
> 
> Here is the relevant code on pastebin : https://pastebin.com/e50bYHiQ
> 
> the device never gets created, and xpt_action_default spits error
> regarding unsupported codes :  0xE and 0x708 (XPT_DEV_ADVINFO and
> XPT_SCAN_BUS).
> 
> If anyone can give me some advice, i would appreciate,

In your function online_device():

    done_ccb = xpt_alloc_ccb_nowait();
    xpt_setup_ccb(&done_ccb->ccb_h, vhba_softc->path, CAM_PRIORITY_NORMAL);
    done_ccb->ccb_h.func_code = XPT_GDEV_TYPE;
    xpt_action(done_ccb);
    xpt_async(AC_FOUND_DEVICE, done_ccb->ccb_h.path, done_ccb);

AC_FOUND_DEVICE tells listeners that the device is ready to go.  It is
normally issued by the probe peripheral driver when it has completed
probing a device.

You really want to use xpt_rescan() instead.  That will tell the probe code
to start probing the device.

If you want an example of a working virtual SCSI device, you can just use
CTL.

This will create a "fake" ramdisk (only backed by a small amount of real
memory) and enable it:

ctladm create -b ramdisk -s 104857600000
ctladm port -o on

You can also use the block backend if you want to use a file or block
device as the backing store.

If you don't have real SCSI target capable hardware in your system, you'll
still have the CAM SIM frontend for CTL which will allow you to access your
device.  See:

sys/cam/ctl/ctl_frontend_cam_sim.c

Ken
-- 
Kenneth Merry
ken@FreeBSD.ORG



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180110154118.GA13659>