# HG changeset patch
# User fujita.tomonori@xxxxxxxxxxxxx
# Node ID 6d90075b4fefbe3f12b241f39a1b3959cc3bbeab
# Parent 3749a0e2580a668bfb029fb0348e9f89660becd6
User-space scripts for SCSI frontend and backend drivers
This includes the Python, udev scripts, etc.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
diff -r 3749a0e2580a -r 6d90075b4fef tools/examples/Makefile
--- a/tools/examples/Makefile Wed Aug 02 15:03:05 2006 +0900
+++ b/tools/examples/Makefile Wed Aug 02 15:08:23 2006 +0900
@@ -25,6 +25,7 @@ XEN_SCRIPTS += network-route vif-route
XEN_SCRIPTS += network-route vif-route
XEN_SCRIPTS += network-nat vif-nat
XEN_SCRIPTS += block
+XEN_SCRIPTS += scsi
XEN_SCRIPTS += block-enbd block-nbd
XEN_SCRIPTS += vtpm vtpm-delete
XEN_SCRIPTS += xen-hotplug-cleanup
diff -r 3749a0e2580a -r 6d90075b4fef tools/examples/xen-backend.agent
--- a/tools/examples/xen-backend.agent Wed Aug 02 15:03:05 2006 +0900
+++ b/tools/examples/xen-backend.agent Wed Aug 02 15:08:23 2006 +0900
@@ -7,6 +7,9 @@ claim_lock xenbus_hotplug_global
claim_lock xenbus_hotplug_global
case "$XENBUS_TYPE" in
+ scsi)
+ /etc/xen/scripts/scsi "$ACTION"
+ ;;
vbd)
/etc/xen/scripts/block "$ACTION"
;;
diff -r 3749a0e2580a -r 6d90075b4fef tools/examples/xen-backend.rules
--- a/tools/examples/xen-backend.rules Wed Aug 02 15:03:05 2006 +0900
+++ b/tools/examples/xen-backend.rules Wed Aug 02 15:08:23 2006 +0900
@@ -1,3 +1,4 @@ SUBSYSTEM=="xen-backend", KERNEL=="vbd*"
+SUBSYSTEM=="xen-backend", KERNEL=="scsi*", RUN+="/etc/xen/scripts/scsi
$env{ACTION}"
SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block
$env{ACTION}"
SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm
$env{ACTION}"
SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script}
online"
diff -r 3749a0e2580a -r 6d90075b4fef tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Wed Aug 02 15:03:05 2006 +0900
+++ b/tools/python/xen/xend/XendDomainInfo.py Wed Aug 02 15:08:23 2006 +0900
@@ -1693,8 +1693,9 @@ def addControllerClass(device_class, cls
controllerClasses[device_class] = cls
-from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, usbif
+from xen.xend.server import blkif, scsiif, netif, tpmif, pciif, iopif, irqif,
usbif
addControllerClass('vbd', blkif.BlkifController)
+addControllerClass('scsi', scsiif.SCSIifController)
addControllerClass('vif', netif.NetifController)
addControllerClass('vtpm', tpmif.TPMifController)
addControllerClass('pci', pciif.PciController)
diff -r 3749a0e2580a -r 6d90075b4fef tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py Wed Aug 02 15:03:05 2006 +0900
+++ b/tools/python/xen/xm/create.py Wed Aug 02 15:08:23 2006 +0900
@@ -246,6 +246,11 @@ gopts.var('disk', val='phy:DEV,VDEV,MODE
backend driver domain to use for the disk.
The option may be repeated to add more than one disk.""")
+gopts.var('scsi', val='TYPE:DEV,MODE',
+ fn=append_value, default=[],
+ use="""Add a hba and disk device to a domain. The physical device is
DEV,
+ which is exported.""")
+
gopts.var('pci', val='BUS:DEV.FUNC',
fn=append_value, default=[],
use="""Add a PCI device to a domain, using given params (in hex).
@@ -488,6 +493,15 @@ def configure_disks(config_devs, vals):
if backend:
config_vbd.append(['backend', backend])
config_devs.append(['device', config_vbd])
+
+def configure_scsi(config_devs, vals):
+ """Create the config for a SCSI HBA.
+ """
+ for (dev, mode) in vals.scsi:
+ config_scsi = ['scsi',
+ ['dev', dev ],
+ ['mode', mode ] ]
+ config_devs.append(['device', config_scsi])
def configure_pci(config_devs, vals):
"""Create the config for pci devices.
@@ -683,6 +697,7 @@ def make_config(vals):
config_devs = []
configure_disks(config_devs, vals)
+ configure_scsi(config_devs, vals)
configure_pci(config_devs, vals)
configure_ioports(config_devs, vals)
configure_irq(config_devs, vals)
@@ -708,6 +723,19 @@ def preprocess_disk(vals):
err('Invalid disk specifier: ' + v)
disk.append(d)
vals.disk = disk
+
+def preprocess_scsi(vals):
+ if not vals.scsi: return
+ scsi = []
+ for v in vals.scsi:
+ d = v.split(',')
+ n = len(d)
+ if n == 2:
+ pass
+ else:
+ err('Invalid scsi specifier: ' + v)
+ scsi.append(d)
+ vals.scsi = scsi
def preprocess_pci(vals):
if not vals.pci: return
@@ -864,6 +892,7 @@ def preprocess(vals):
if not vals.kernel and not vals.bootloader:
err("No kernel specified")
preprocess_disk(vals)
+ preprocess_scsi(vals)
preprocess_pci(vals)
preprocess_ioports(vals)
preprocess_ip(vals)
diff -r 3749a0e2580a -r 6d90075b4fef tools/examples/scsi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/examples/scsi Wed Aug 02 15:08:23 2006 +0900
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+dir=$(dirname "$0")
+. "$dir/block-common.sh"
+
+log debug "udev event."
+
+case "$command" in
+ add)
+ done=$(xenstore_read_default "$XENBUS_PATH/scsi" 'MISSING')
+ if [ "$done" != 'MISSING' ]
+ then
+ exit 0
+ fi
+
+ xenstore_write "$XENBUS_PATH/scsi" "info"
+ success
+ ;;
+ remove)
+ # TODO
+ ;;
+esac
+
+exit 0
diff -r 3749a0e2580a -r 6d90075b4fef tools/python/xen/xend/server/scsiif.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/xen/xend/server/scsiif.py Wed Aug 02 15:08:23 2006 +0900
@@ -0,0 +1,56 @@
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#============================================================================
+# Copyright (C) 2004 Mike Wray <mike.wray@xxxxxx>
+# Copyright (C) 2004 Intel Research Cambridge
+# Copyright (C) 2004 Mark Williamson <mark.williamson@xxxxxxxxxxxx>
+# Copyright (C) 2005 XenSource Ltd
+#============================================================================
+
+
+"""Support for SCSI HBAs.
+"""
+
+import re
+import string
+
+from xen.xend import sxp
+from xen.xend.XendError import VmError
+
+from xen.xend.server.DevController import DevController
+
+class SCSIifController(DevController):
+ """SCSI HBAs.
+ """
+
+ def __init__(self, vm):
+ """Create a SCSI HBA.
+ """
+ DevController.__init__(self, vm)
+
+
+ def getDeviceDetails(self, config):
+ """@see DevController.getDeviceDetails"""
+
+ mode = sxp.child_value(config, 'mode')
+ (typ, dev) = string.split(sxp.child_value(config, 'dev'), ':', 1)
+ back = { 'type' : typ,
+ 'dev' : dev,
+ 'mode' : mode,
+ }
+
+ devid = self.allocateDeviceID()
+ front = { 'scsi' : "%i" % devid }
+
+ return (devid, back, front)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|