From: Olaf Hering Subject: [PATCH] libbxl: add support for pvscsi, iteration 1 Date: Wed, 30 Apr 2014 13:03:22 +0200 Message-ID: <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: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Ondrej Holecek , Olaf Hering , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org 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. 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: /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. 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. 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. 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. - xl scsi-attach is not yet implemented. - coding style may be way off in some parts of the new code. 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 +to a char device like /dev/sg5. Or it can be specified in the SCSI notation +HOST:CHANNEL:TARGET:LUN. Note that the latter format is unreliable because +the HOST value can change across dom0 reboots. + +=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 +SCSI host within the guest. + +=item C