From owner-freebsd-hackers@freebsd.org Wed Jan 10 15:41:26 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 831DDE62CB7 for ; Wed, 10 Jan 2018 15:41:26 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (mithlond.kdm.org [96.89.93.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "A1-33714", Issuer "A1-33714" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 47C627A86B for ; Wed, 10 Jan 2018 15:41:25 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (localhost [127.0.0.1]) by mithlond.kdm.org (8.15.2/8.14.9) with ESMTPS id w0AFfImF013949 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 10 Jan 2018 10:41:18 -0500 (EST) (envelope-from ken@mithlond.kdm.org) Received: (from ken@localhost) by mithlond.kdm.org (8.15.2/8.14.9/Submit) id w0AFfIMd013948; Wed, 10 Jan 2018 10:41:18 -0500 (EST) (envelope-from ken) Date: Wed, 10 Jan 2018 10:41:18 -0500 From: "Kenneth D. Merry" To: Florian Florensa Cc: freebsd-hackers@freebsd.org Subject: Re: Virtual SCSI Device Message-ID: <20180110154118.GA13659@mithlond.kdm.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (mithlond.kdm.org [127.0.0.1]); Wed, 10 Jan 2018 10:41:18 -0500 (EST) X-Spam-Status: No, score=-2.6 required=5.0 tests=ALL_TRUSTED,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mithlond.kdm.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jan 2018 15:41:26 -0000 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