From: Ian Campbell Subject: Re: [PATCH] libbxl: add support for pvscsi, iteration 1 Date: Fri, 2 May 2014 16:11:45 +0100 Message-ID: <1399043505.18944.3.camel@kazak.uk.xensource.com> References: <1398855802-29618-1-git-send-email-olaf@aepfle.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1398855802-29618-1-git-send-email-olaf@aepfle.de> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Olaf Hering Cc: Ondrej Holecek , Ian Jackson , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Wed, 2014-04-30 at 13:03 +0200, Olaf Hering wrote: > Add support for vscsi= in domU.cfg, add new xl commands scsi-attach, > scsi-list, scsi-detach. The syntax follows what xend understood. > > pvscsi provides a dom0 SCSI device as-is to a domU. The backend and > frontend drivers can be found in xen-linux, or its forward-ported > variants. This patch was tested with an openSUSE dom0 and a SLES12 > guest. Any openSUSE/SLE11/SLE12 dom0/domU combination will work. > > The domU.cfg syntax is "vscsi=[ 'pdev,vdev[,option]' ]". pdev is the > dom0 device in either /dev/$device or HOST:CHANNEL:TARGET:LUN notation. > vdev is the domU device in HOST:CHANNEL:TARGET:LUN notation. > > xl scsi-attach will attach a SCSI device at runtime. > xl scsi-detach will remove a SCSI drivce at runtime. Is a drivce a device or a drive ;-) > xl scsi-list lists SCSI devices for a list of domains. > > The backend driver uses a single_host:many_devices notation to manage > domU devices. The xenstore layout looks like this: Please can you add ~/device/vscsi/$DEVID/* and ~/backend/vif/$DOMID/$DEVID/* to docs/misc/xenstore-paths.markdown. If you were inclined to improve xen/include/public/io/vscsiif.h by using some of the content from here then that would be awesome too. > > /local/domain/0/backend/vscsi///feature-host = "0" > /local/domain/0/backend/vscsi///frontend = "/local/domain//device/vscsi/0" > /local/domain/0/backend/vscsi///frontend-id = "" > /local/domain/0/backend/vscsi///online = "1" > /local/domain/0/backend/vscsi///state = "4" > /local/domain/0/backend/vscsi///vscsi-devs/dev-0/p-dev = "8:0:2:1" > /local/domain/0/backend/vscsi///vscsi-devs/dev-0/state = "4" > /local/domain/0/backend/vscsi///vscsi-devs/dev-0/v-dev = "0:0:0:0" > /local/domain/0/backend/vscsi///vscsi-devs/dev-1/p-dev = "8:0:2:2" > /local/domain/0/backend/vscsi///vscsi-devs/dev-1/state = "4" > /local/domain/0/backend/vscsi///vscsi-devs/dev-1/v-dev = "0:0:1:0" > > /local/domain//device/vscsi//backend = "/local/domain/0/backend/vscsi//" > /local/domain//device/vscsi//backend-id = "0" > /local/domain//device/vscsi//event-channel = "20" > /local/domain//device/vscsi//ring-ref = "43" > /local/domain//device/vscsi//state = "4" > /local/domain//device/vscsi//vscsi-devs/dev-0/state = "4" > /local/domain//device/vscsi//vscsi-devs/dev-1/state = "4" > > This is a challenge for libxl because libxl currently handles only > single_host:single_device in its device helper functions. This is a bit like pci I suppose? > Due to this > limitation in libxl, scsi-detach will remove the whole virtual scsi host > with all its virtual devices, instead of just the requested single > virtual device. That's rather unfortunate! Are multiple allowed/supported? e.g. could I (or better, libxl by default) setup a device-per-host situation to alleviate this? For pcifront/back we support bus reconfiguration (via XenbusStateReconfigur{ing,ed}) which is how this works there. Does vscsi not support anything like that? > scsi-attach can cope with this limitation because it > could write the required files directly into xenstore to attach yet > another virtual scsi device to an existing virtual scsi host. However, > this functionality is currently not implemented. > > To support the pdev notation '/dev/$device' it is required to parse > sysfs to translate the path to HST:CHN:TGT:LUN notation. In its current > variant /sys/dev/ is used, which is available since at least Linux 3.0. > Support for dom0 kernels which lack this interface will be added later. Are there any such kernels which anyone cares about any more? > This is a draft patch to get it out of the door, to get help with > solving the libxl limitation above, and of course for public code review. > In this first iteration: > - the domU.cfg parser for vscsi=[] is functional. > - xl scsi-list will print output similar to its xm counter part. > - xl scsi-detach will remove entire scsi hosts, unlike its xm counter part. What did xm do instead? Fail? > - xl scsi-attach is not yet implemented. > - coding style may be way off in some parts of the new code. I shall keep that in mind and not comment on it on the expectation that you want a chance to go through it before I get all pernickety. > Signed-off-by: Olaf Hering > Cc: Ian Campbell > Cc: Ian Jackson > Cc: Ondrej Holecek > --- > docs/man/xl.cfg.pod.5 | 30 +++ > docs/man/xl.pod.1 | 20 ++ > tools/libxl/libxl.c | 201 +++++++++++++++++++ > tools/libxl/libxl.h | 20 ++ > tools/libxl/libxl_create.c | 1 + > tools/libxl/libxl_device.c | 1 + > tools/libxl/libxl_internal.h | 9 + > tools/libxl/libxl_types.idl | 42 ++++ > tools/libxl/libxl_types_internal.idl | 1 + > tools/libxl/xl.h | 3 + > tools/libxl/xl_cmdimpl.c | 360 ++++++++++++++++++++++++++++++++++- > tools/libxl/xl_cmdtable.c | 15 ++ > 12 files changed, 702 insertions(+), 1 deletion(-) > > diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 > index c8ce6c1..413e4be 100644 > --- a/docs/man/xl.cfg.pod.5 > +++ b/docs/man/xl.cfg.pod.5 > @@ -388,6 +388,36 @@ value is optional if this is a guest domain. > > =back > > +=item B > + > +Specifies the PVSCSI devices to be provided to the guest. PVSCSI passes > +dom0 SCSI devices as-is to the guest. > + > +Each B is a mapping from dom0 SCSI devices to guest visible > +SCSI devices, like 'pvdev,vdev[,option]'. Example: '/dev/sdm,3:0:4:5,feature-host' > + > +=over 4 > + > +=item C > + > +Specifies the dom0 visible SCSI device. The string can be either a device path > +like to a block device like /dev/disk/by-id/scsi-XYZ. Or it can be a device path "like to a ... like" I think you can drop the first "like". Actually, I think the either is misplaced. "Can be a device path either to a block device like ... or to a char device like ... > +to a char device like /dev/sg5. Or it can be specified in the SCSI notation > +HOST:CHANNEL:TARGET:LUN. Hrm, that's now the third or in this either, which is making the wording a bit unwieldy (i.e. my suggestion above no long really applies). Perhaps a bulletted list is the way to go? > Note that the latter format is unreliable because > +the HOST value can change across dom0 reboots. /dev/sgN would be unreliable too I think? As might block devices not using the /dev/disk/by-* links you give in the example. You might be best saying that only /dev/disk/by-* block device references are reliable because all of the others might change over a reboot. > + > +=item C > + > +Specifies how the SCSI device is mapped into the guest. The notation is in > +SCSI notation HOST:CHANNEL:TARGET:LUN. HOST in this case means a virthal Typo "virtual" > +SCSI host within the guest. All of HOST:CHANNEL:TARGET:LUN are numbers I think, are they hex/dec/oct? Are there limits? > + > +=item C