libxl: add support for pvscsi, iteration 10
v10 cover libxl: add support for pvscsi, iteration 10
Port vscsi=[] and scsi-{attach,detach,list} commands from xend to libxl.
libvirt uses its existing SCSI support:
http://lists.xenproject.org/archives/html/xen-devel/2015-04/msg02963.html
targetcli/rtslib has to be aware of xen-scsiback (upstream unresponsive):
http://article.gmane.org/gmane.linux.scsi.target.devel/8146
TODO:
- document pvscsi in xen wiki
Changes between v9 and v10:
- rebase to 'staging' (3b971de..829e03c)
Changes between v8 and v9:
- Mention libxl_ctrl_index in vscsiif.h
- Rename idx to libxl_ctrl_index
- Fix device assignment in vscsidev_remove
- Add vscsictrls to multidev callchain
- Reorder some functions
- Move and rename vscsidev_rm
- Remove libxl prefix from static functions
- Reorder functions in libxl_vscsi.c
- Add comment to libxl_vscsidev_aodev_cb
- Move libxl_device_vscsictrl_remove into libxl_vscsi.c
- Enclose libxl__device instead of aodev in libxl__vscsidev_rm
- Update typedef of libxl__vscsidev_rm
- Assign devid earlier in libxl__device_vscsictrl_add
- Rework xlu_vscsi_get_ctrl and main_vscsiattach
- Add config idx also to libxl_vscsiinfo
- Make libxl__vscsi_collect_ctrls static
- Implement libxl_device_vscsidev_add
- Move vscsictrl add from libxl.c to libxl_vscsi.c
- Export libxl__device_nextid for internal use
- Remove some checks for empty controllers
- Introduce an idx file to present the config index in empty vscsictrls
- Use libxl__ev_devstate_wait in libxl__device_vscsictrl_reconfigure_add
- Rework error handling in libxl__vscsi_fill_ctrl
- Remove state checking from libxl__vscsi_fill_dev
- Wrap long lines in libxl__device_vscsictrl_new_backend
- Use LIBXL_DESTROY_TIMEOUT in libxl__device_vscsidev_rm
- Remove tab from libxl__vscsi_collect_ctrls
- Goto out if libxl__device_vscsidev_backend_set_add fails
- Add fallthrough to libxl__device_vscsidev_backend_set_add
- Fix typo in xl.cfg.pod: naa.
- Wrap long line in xl.cfg.pod.5
- Use memmove in libxl_device_vscsictrl_remove_vscsidev
- Adjust code in main_vscsilist to fit in 80 chars
- Align switch and case to gain 4 columns
- Wrap long line in libxl__device_vscsi_reconfigure_rm
- Wrap long line in libxl__device_vscsidev_rm_be
- Adjust flexarray size in libxl__device_vscsi_reconfigure_rm
- Rework libxl_device_vscsidev_remove
- Introduce libxl_device_vscsictrl_remove_vscsidev
- Use stack variables in xlu_vscsi_get_ctrl
- Rename function names to refer to vscsictrl
- Rename local variables to refer to vscsictrl
- Use generic vscsictrl->devid
http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg03196.html
Changes between v7 and v8:
- Make be_path const in libxl__device_vscsictrl_add
- Adjust years in Copyright
- Whitespace in libxl_device_vscsictrl idl
- Implement libxl_device_vscsictrl_destroy
- Set backend_devid
- Reorder assignments in libxl__device_vscsictrl_add
- Whitespace changes for libxl__device_vscsi_reconfigure_add
- Register watch unconditionally in libxl__device_vscsidev_rm
- Wait for StateClosing for unconnected frontends in detach
- Adjust logic in libxl__vscsi_fill_dev
- Rework scsi-detach
- Increase swap partition from 12 to 96 blocks for mkswap
- Update MERGE macro for vscsictrls
http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg01662.html
Changes between v6 and v7:
- rebase to 'staging' (3b971de)
- Introduce libxl_device_vscsictrl_append_vscsidev
- Add libxl__vscsi_collect_ctrls and used it in libxl_device_vscsictrl_list
- Convert type of lun from u32 to u64 per SCSI spec
- Use vscsi_saved in libxl__device_vscsictrl_add
- Assign unique vscsidev_id per vscsictrl
- Rename vscsi_dev to vscsidev in function names
- Rename variables in libxl_vscsiinfo
- Rename locals to refer to ctrl/dev
- Rename various strings from host to ctrl
- Rename local variables vscsi_ctrl to vscsictrl
- Rename libxl_device_vscsictrl->vscsi_devs to vscsidevs
- Remove libxl_device_vscsidev->remove, rework detach
- Rename libxl_device_vscsidev->vscsi_dev_id to vscsidev_id
- Rename local variables vscsi_host to vscsi_ctrl
- Rename local variables v_hst to v_ctrl
- Remove libxl_device_vscsictrl->v_hst
- Rename libxl_vscsi_dev to libxl_device_vscsidev
- Rename libxl_device_vscsi to libxl_device_vscsictrl
http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg00884.html
Changes between v5 and v6:
- rebase to 'staging' (a7b39c8 and b7e7ad8)
- Fix off-by-one in xlu__vscsi_compare_udev
- xl.cfg: use options instead of option
- xl.cfg: fix grammar for pdev/options
- xl.cfg: fix Usually typo
- Remove next_vscsi_dev_id from libxl_device_vscsi
- Use XLU_WWN_LEN also in libxl_vscsi.c
http://lists.xenproject.org/archives/html/xen-devel/2015-11/msg01446.html
Changes between v4 and v5:
- vscsiif.h: refer to backend_domid
- Set update_json in libxl_device_vscsi_remove
- Remove comment from libxl__device_vscsi_add
- Remove debug LOG from libxl__device_vscsi_reconfigure
- Move local nb variable in libxl__device_vscsi_reconfigure
- Make be_path const in libxl__device_vscsi_reconfigure
- Adjust libxl__device_vscsi_dev_backend_set to avoid long lines
- Adjust libxl__device_vscsi_dev_backend_rm to avoid long lines
- Use CTX in libxl__device_vscsi_dev_backend_rm
- Make be_path const in libxl__device_vscsi_dev_backend_rm
- xl.cfg: Its typo
- xl.cfg: Use persistent instead of persistant
- Rename feature_host to scsi_raw_cmds
- target-create-xen-scsiback.sh: detect pvops and xenlinux
- Wrap long lines in main_vscsilist
- Call libxl_vscsiinfo_dispose unconditional
- Let scsi-list print p-dev instead of p-devname
- Handle broken vscsi device entry in xenstore
- Split libxl__vscsi_fill_host from libxl_device_vscsi_list
- Make xlu_vscsi_append_dev static
- Remove reference to pvscsi.txt from xenstore-paths.markdown
- xl.cfg: update Linux and xenlinux
- xl.cfg: refer to backend domain instead of dom0
- xl.cfg: be more verbose what persistant format is
- return if libxl__device_vscsi_dev_backend_set fails in libxl__device_vscsi_new_backend
- target-create-xen-scsiback.sh: set also alias for libvirt
http://lists.xenproject.org/archives/html/xen-devel/2015-05/msg00523.html
Changes between v3 and v4:
- Use libxl__device_nextid in libxl__device_vscsi_add
- Remove check for duplicate pdev assignment from libxl_device_vscsi_get_host
- Caller provides libxl_device_vscsi to libxl_device_vscsi_get_host
- Define LIBXL_HAVE_VSCSI
- Remove init_val from libxl_vscsi_pdev_type
- Move some functions from libxl to libxlu
- Introduce libxl_device_vscsi->next_vscsi_dev_id to handle holes
- Use Struct in KeyedUnion for ocaml idl
- docs: Mention pvscsi in xl and xl.cfg
- Turn feature_host into a defbool and add checking
- Support pvops and /dev/ nodes in config
- Wrap entire libxlu_vscsi.c with ifdef linux
- Set remove flag in libxl_device_vscsi_list
- Fix vscsiif path in xenstore-paths.markdown
- vscsiif.h: add some notes about xenstore layout
- Add copyright to libxlu_vscsi.c and libxl_vscsi.c
- Scripts to create and delete xen-scsiback nodes in Linux target framework
- Remove pvscsi.txt
http://lists.xenproject.org/archives/html/xen-devel/2015-04/msg01949.html
Changes between v2 and v3:
- Adjust change for vscsiif.h
- Support "naa.wwn:lun" notation in pvops kernel
- Add example for pvops kernel using targetcli
patch required for python-rtslib:
http://article.gmane.org/gmane.linux.scsi.target.devel/8146
- Use vdev variable in libxl_device_vscsi_parse
http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg00734.html
Changes between v1 and v2:
- ported to current staging
http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg00030.html
Initial attempt was sent a year ago:
http://lists.xenproject.org/archives/html/xen-devel/2014-04/msg03958.html
Most comments are addressed.
This version has been tested with SLES as backend and frontend. This version has been tested with pvops as backend and SLES as frontend.
Olaf Hering (5):
vscsiif.h: fix WWN notation for p-dev property
docs: add vscsi to xenstore-paths.markdown
vscsiif.h: add some notes about xenstore layout
libxl: add support for vscsi
Scripts to create and delete xen-scsiback nodes in Linux target
framework
docs/man/xl.cfg.pod.5 | 56 ++ docs/man/xl.pod.1 | 18 + docs/misc/xenstore-paths.markdown | 10 + tools/libxl/Makefile | 2 + tools/libxl/libxl.c | 9 + tools/libxl/libxl.h | 42 ++ tools/libxl/libxl_create.c | 41 +- tools/libxl/libxl_device.c | 2 + tools/libxl/libxl_internal.h | 9 + tools/libxl/libxl_types.idl | 55 ++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vscsi.c | 1184 ++++++++++++++++++++++++++++++ tools/libxl/libxlu_vscsi.c | 684 +++++++++++++++++ tools/libxl/libxlutil.h | 18 + tools/libxl/xl.h | 3 + tools/libxl/xl_cmdimpl.c | 225 +++++- tools/libxl/xl_cmdtable.c | 15 + tools/misc/Makefile | 4 + tools/misc/target-create-xen-scsiback.sh | 135 ++++ tools/misc/target-delete-xen-scsiback.sh | 41 ++ xen/include/public/io/vscsiif.h | 71 +- 21 files changed, 2620 insertions(+), 5 deletions(-) create mode 100644 tools/libxl/libxl_vscsi.c create mode 100644 tools/libxl/libxlu_vscsi.c create mode 100755 tools/misc/target-create-xen-scsiback.sh create mode 100755 tools/misc/target-delete-xen-scsiback.sh
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 1/5 vscsiif.h: fix WWN notation for p-dev property
The pvops kernel expects either "naa.WWN:LUN" or "h:c:t:l" in the p-dev property. Add the missing :LUN part to the comment.
--- xen/include/public/io/vscsiif.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/public/io/vscsiif.h +1 -1
@@ -60,7 +60,7 @@* * A string specifying the backend device: either a 4-tuple "h:c:t:l" * (host, controller, target, lun, all integers), or a WWN (e.g. -* "naa.60014054ac780582"). +* "naa.60014054ac780582:0"). * * v-dev * Values: string
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 2/5 docs: add vscsi to xenstore-paths.markdown
In reply to Olaf Hering--- docs/misc/xenstore-paths.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+)
docs/misc/xenstore-paths.markdown +10 -0
@@ -265,6 +265,11 @@ A virtual keyboard device frontend. Described by A virtual network device frontend. Described by [xen/include/public/io/netif.h][NETIF] +#### ~/device/vscsi/$DEVID/* [] + +A virtual scsi device frontend. Described by +[xen/include/public/io/vscsiif.h][SCSIIF] + #### ~/console/* [] The primary PV console device. Described in [console.txt](console.txt)
@@ -335,6 +340,10 @@ A virtual keyboard device backend. Described by A virtual network device backend. Described by [xen/include/public/io/netif.h][NETIF] +#### ~/backend/vscsi/$DOMID/$DEVID/* [] + +A PV SCSI backend. + #### ~/backend/console/$DOMID/$DEVID/* [] A PV console backend. Described in [console.txt](console.txt)
@@ -525,6 +534,7 @@ domain instead of a daemon in dom0. [KBDIF]: http://xenbits.xen.org/docs/unstable/hypercall/include,public,io,kbdif.h.html [LIBXLMEM]: http://xenbits.xen.org/docs/unstable/misc/libxl_memory.txt [NETIF]: http://xenbits.xen.org/docs/unstable/hypercall/include,public,io,netif.h.html +[SCSIIF]: http://xenbits.xen.org/docs/unstable/hypercall/include,public,io,vscsiif.h.html [SI]: http://xenbits.xen.org/docs/unstable/hypercall/include,public,xen.h.html#Struct_start_info [VCPU]: http://xenbits.xen.org/docs/unstable/hypercall/include,public,vcpu.h.html [XSWIRE]: http://xenbits.xen.org/docs/unstable/hypercall/include,public,io,xs_wire.h.html
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 3/5 vscsiif.h: add some notes about xenstore layout
In reply to Olaf Hering--- xen/include/public/io/vscsiif.h | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
xen/include/public/io/vscsiif.h +69 -0
@@ -104,6 +104,75 @@* response structures. */ +/* +* Xenstore format in practice +* =========================== +* +* The backend driver uses a single_host:many_devices notation to manage domU +* devices. Everything is stored in /local/domain/<backend_domid>/backend/vscsi/. +* The xenstore layout looks like this (dom0 is assumed to be the backend_domid): +* +* <domid>/<vhost>/feature-host = "0" +* <domid>/<vhost>/frontend = "/local/domain/<domid>/device/vscsi/0" +* <domid>/<vhost>/frontend-id = "<domid>" +* <domid>/<vhost>/online = "1" +* <domid>/<vhost>/state = "4" +* <domid>/<vhost>/vscsi-devs/dev-0/p-dev = "8:0:2:1" or "naa.wwn:lun" +* <domid>/<vhost>/vscsi-devs/dev-0/state = "4" +* <domid>/<vhost>/vscsi-devs/dev-0/v-dev = "0:0:0:0" +* <domid>/<vhost>/vscsi-devs/dev-1/p-dev = "8:0:2:2" +* <domid>/<vhost>/vscsi-devs/dev-1/state = "4" +* <domid>/<vhost>/vscsi-devs/dev-1/v-dev = "0:0:1:0" +* +* The frontend driver maintains its state in +* /local/domain/<domid>/device/vscsi/. +* +* <vhost>/backend = "/local/domain/0/backend/vscsi/<domid>/<vhost>" +* <vhost>/backend-id = "0" +* <vhost>/event-channel = "20" +* <vhost>/ring-ref = "43" +* <vhost>/state = "4" +* <vhost>/vscsi-devs/dev-0/state = "4" +* <vhost>/vscsi-devs/dev-1/state = "4" +* +* In addition to the entries for backend and frontend these flags are stored +* for the toolstack: +* +* <domid>/<vhost>/vscsi-devs/dev-1/p-devname = "/dev/$device" +* <domid>/<vhost>/libxl_ctrl_index = "0" +* +* +* Backend/frontend protocol +* ========================= +* +* To create a vhost along with a device: +* <domid>/<vhost>/feature-host = "0" +* <domid>/<vhost>/frontend = "/local/domain/<domid>/device/vscsi/0" +* <domid>/<vhost>/frontend-id = "<domid>" +* <domid>/<vhost>/online = "1" +* <domid>/<vhost>/state = "1" +* <domid>/<vhost>/vscsi-devs/dev-0/p-dev = "8:0:2:1" +* <domid>/<vhost>/vscsi-devs/dev-0/state = "1" +* <domid>/<vhost>/vscsi-devs/dev-0/v-dev = "0:0:0:0" +* Wait for <domid>/<vhost>/state + <domid>/<vhost>/vscsi-devs/dev-0/state become 4 +* +* To add another device to a vhost: +* <domid>/<vhost>/state = "7" +* <domid>/<vhost>/vscsi-devs/dev-1/p-dev = "8:0:2:2" +* <domid>/<vhost>/vscsi-devs/dev-1/state = "1" +* <domid>/<vhost>/vscsi-devs/dev-1/v-dev = "0:0:1:0" +* Wait for <domid>/<vhost>/state + <domid>/<vhost>/vscsi-devs/dev-1/state become 4 +* +* To remove a device from a vhost: +* <domid>/<vhost>/state = "7" +* <domid>/<vhost>/vscsi-devs/dev-1/state = "5" +* Wait for <domid>/<vhost>/state to become 4 +* Wait for <domid>/<vhost>/vscsi-devs/dev-1/state become 6 +* Remove <domid>/<vhost>/vscsi-devs/dev-1/{state,p-dev,v-dev,p-devname} +* Remove <domid>/<vhost>/vscsi-devs/dev-1/ +* +*/ +/* Requests from the frontend to the backend */ /*
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 4/5 libxl: add support for vscsi
In reply to Olaf HeringPort pvscsi support from xend to libxl:
vscsi=['pdev,vdev{,options}']
xl scsi-attach
xl scsi-detach
xl scsi-list
--- docs/man/xl.cfg.pod.5 | 56 ++ docs/man/xl.pod.1 | 18 + tools/libxl/Makefile | 2 + tools/libxl/libxl.c | 9 + tools/libxl/libxl.h | 42 ++ tools/libxl/libxl_create.c | 41 +- tools/libxl/libxl_device.c | 2 + tools/libxl/libxl_internal.h | 9 + tools/libxl/libxl_types.idl | 55 ++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vscsi.c | 1184 ++++++++++++++++++++++++++++++++++ tools/libxl/libxlu_vscsi.c | 684 ++++++++++++++++++++ tools/libxl/libxlutil.h | 18 + tools/libxl/xl.h | 3 + tools/libxl/xl_cmdimpl.c | 225 ++++++- tools/libxl/xl_cmdtable.c | 15 + 16 files changed, 2360 insertions(+), 4 deletions(-)
docs/man/xl.cfg.pod.5 +56 -0
@@ -517,6 +517,62 @@ value is optional if this is a guest domain. =back +=item B<vscsi=[ "VSCSI_SPEC_STRING", "VSCSI_SPEC_STRING", ...]> + +Specifies the PVSCSI devices to be provided to the guest. PVSCSI passes +SCSI devices from the backend domain to the guest. + +Each VSCSI_SPEC_STRING consists of "pdev,vdev[,options]". +'pdev' describes the physical device, preferable in a persistent format +such as /dev/disk/by-*/*. +'vdev' is the domU device in vHOST:CHANNEL:TARGET:LUN notation, all integers. +'options' lists additional flags which a backend may recognize. + +The supported values for "pdev" and "options" depends on the backend driver used: + +=over 4 + +=item B<Linux> + +=over 4 + +=item C<pdev> + +The backend driver in the pvops kernel is part of the Linux-IO Target framework +(LIO). As such the SCSI devices have to be configured first with the tools +provided by this framework, such as a xen-scsiback aware targetcli. The "pdev" +in domU.cfg has to refer to a config item in that framework instead of the raw +device. Usually this is a WWN in the form of "naa.WWN:LUN". + +=item C<options> + +No options recognized. + +=back + +=item B<Linux based on classic Xen kernel> + +=over 4 + +=item C<pdev> + +The dom0 device in either /dev/scsidev or pHOST:CHANNEL:TARGET:LUN notation. + +It's recommended to use persistent names "/dev/disk/by-*/*" to refer to a "pdev". +The toolstack will translate this internally to "h:c:t:l" notation, which is how +the backend driver will access the device. Using the "h:c:t:l" notation for +"pdev" in domU.cfg is discouraged because this value will change across reboots, +depending on the detection order in the OS. + +=item C<options> + +Currently only the option value "feature-host" is recognized. SCSI command +emulation in backend driver is bypassed when "feature-host" is specified. + +=back + +=back + =item B<vfb=[ "VFB_SPEC_STRING", "VFB_SPEC_STRING", ...]> Specifies the paravirtual framebuffer devices which should be supplied
docs/man/xl.pod.1 +18 -0
@@ -1293,6 +1293,24 @@ List virtual trusted platform modules for a domain. =back +=head2 PVSCSI DEVICES + +=over 4 + +=item B<scsi-attach> I<domain-id> I<pdev> I<vdev>,I<[feature-host]> + +Creates a new vscsi device in the domain specified by I<domain-id>. + +=item B<scsi-detach> I<domain-id> I<vdev> + +Removes the vscsi device from domain specified by I<domain-id>. + +=item B<scsi-list> I<domain-id> I<[domain-id] ...> + +List vscsi devices for the domain specified by I<domain-id>. + +=back + =head1 PCI PASS-THROUGH =over 4
tools/libxl/Makefile +2 -0
@@ -99,6 +99,7 @@ endif LIBXL_LIBS += -lyajl LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \ + libxl_vscsi.o \ libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o \ libxl_internal.o libxl_utils.o libxl_uuid.o \ libxl_json.o libxl_aoutils.o libxl_numa.o libxl_vnuma.o \
@@ -142,6 +143,7 @@ AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h _libxl_list.h _paths.h \ AUTOSRCS= libxlu_cfg_y.c libxlu_cfg_l.c AUTOSRCS += _libxl_save_msgs_callout.c _libxl_save_msgs_helper.c LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_l.o libxlu_cfg.o \ + libxlu_vscsi.o \ libxlu_disk_l.o libxlu_disk.o libxlu_vif.o libxlu_pci.o $(LIBXLU_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
tools/libxl/libxl.c +9 -0
@@ -4179,6 +4179,7 @@ DEFINE_DEVICE_REMOVE_CUSTOM(usbctrl, destroy, 1)/* The following functions are defined: * libxl_device_disk_add * libxl_device_nic_add +* libxl_device_vscsictrl_add * libxl_device_vtpm_add * libxl_device_usbctrl_add * libxl_device_usbdev_add
@@ -4210,6 +4211,9 @@ DEFINE_DEVICE_ADD(disk)/* nic */ DEFINE_DEVICE_ADD(nic) +/* vscsi */ +DEFINE_DEVICE_ADD(vscsictrl) + /* vtpm */ DEFINE_DEVICE_ADD(vtpm)
@@ -6760,6 +6764,11 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,MERGE (nic, nics,COMPARE_DEVID , {}); +MERGE (vscsictrl, vscsictrls,COMPARE_VSCSI , { +libxl_device_vscsictrl_dispose (dst); +libxl_device_vscsictrl_copy (CTX , dst, src); + }); +MERGE (vtpm, vtpms,COMPARE_DEVID , {});MERGE (pci, pcidevs,COMPARE_PCI , {});
tools/libxl/libxl.h +42 -0
54 lines not on this page · raw message
tools/libxl/libxl_create.c +38 -3
70 lines not on this page · raw message
tools/libxl/libxl_device.c +2 -0
@@ -543,6 +543,7 @@ void libxl__multidev_prepared(libxl__egc *egc,* The following functions are defined: * libxl__add_disks * libxl__add_nics +* libxl__add_vscsictrls * libxl__add_vtpms * libxl__add_usbctrls * libxl__add_usbs
@@ -564,6 +565,7 @@ void libxl__multidev_prepared(libxl__egc *egc, DEFINE_DEVICES_ADD(disk) DEFINE_DEVICES_ADD(nic) +DEFINE_DEVICES_ADD(vscsictrl) DEFINE_DEVICES_ADD(vtpm) DEFINE_DEVICES_ADD(usbctrl) DEFINE_DEVICES_ADD(usbdev)
tools/libxl/libxl_internal.h +9 -0
@@ -2581,6 +2581,10 @@ _hidden void libxl__device_nic_add(libxl__egc *egc, uint32_t domid, libxl_device_nic *nic, libxl__ao_device *aodev); +_hidden void libxl__device_vscsictrl_add(libxl__egc *egc, uint32_t domid, +libxl_device_vscsictrl *vscsictrl, +libxl__ao_device *aodev); + _hidden void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid,libxl_device_vtpm *vtpm,libxl__ao_device *aodev);
@@ -3346,6 +3350,10 @@ _hidden void libxl__add_nics(libxl__egc *egc, libxl__ao *ao, uint32_t domid, libxl_domain_config *d_config, libxl__multidev *multidev); +_hidden void libxl__add_vscsictrls(libxl__egc *egc, libxl__ao *ao, uint32_t domid, +libxl_domain_config *d_config, +libxl__multidev *multidev); + _hidden void libxl__add_vtpms(libxl__egc *egc, libxl__ao *ao, uint32_t domid,libxl_domain_config *d_config,libxl__multidev *multidev);
@@ -4032,6 +4040,7 @@ static inline void libxl__update_config_vtpm(libxl__gc *gc,* devices have same identifier. */ #define COMPARE_DEVID (a, b) ((a)->devid == (b)->devid)#define COMPARE_DISK (a, b) (!strcmp((a)->vdev, (b)->vdev)) +#define COMPARE_VSCSI (a, b) ((a)->devid == (b)->devid)#define COMPARE_PCI (a, b) ((a)->func == (b)->func && \ (a)->bus == (b)->bus && \ (a)->dev == (b)->dev)
tools/libxl/libxl_types.idl +55 -0
73 lines not on this page · raw message
tools/libxl/libxl_types_internal.idl +1 -0
@@ -23,6 +23,7 @@ libxl__device_kind = Enumeration("device_kind", [ (7, "CONSOLE"), (8, "VTPM"), (9, "VUSB"), + (10, "VSCSI"), ]) libxl__console_backend = Enumeration("console_backend", [
tools/libxl/libxl_vscsi.c new file +1184 -0
1,184 lines not on this page · raw message
tools/libxl/libxlu_vscsi.c new file +684 -0
684 lines not on this page · raw message
tools/libxl/libxlutil.h +18 -0
@@ -118,6 +118,24 @@ int xlu_rdm_parse(XLU_Config *cfg, libxl_rdm_reserve *rdm, const char *str);int xlu_vif_parse_rate (XLU_Config *cfg,const char *rate,libxl_device_nic *nic); +/* Fill ctrl/dev with device described in str (pdev,vdev[,options]) */ +int xlu_vscsi_get_ctrl (XLU_Config *cfg,libxl_ctx *ctx,uint32_t domid, +const char *str, +libxl_device_vscsictrl *ctrl, +libxl_device_vscsidev *dev, +libxl_device_vscsictrl **existing); +/* Parse config string and fill provided vscsi ctrl and vscsi device */ +int xlu_vscsi_parse (XLU_Config *cfg,libxl_ctx *ctx,const char *str, +libxl_device_vscsictrl *new_ctrl, +libxl_device_vscsidev *new_dev); +/* Detach vscsi device described in config string (pdev,vdev[,options]) */ +int xlu_vscsi_detach (XLU_Config *cfg,libxl_ctx *ctx,uint32_t domid,char *str); +/* Add vscsi device described in config string (pdev,vdev[,options]) to d_config */ +int xlu_vscsi_config_add (XLU_Config *cfg, +libxl_ctx *ctx, +const char *str, +int *num_vscsis, +libxl_device_vscsictrl **vscsis);#endif /* LIBXLUTIL_H */ /*
tools/libxl/xl.h +3 -0
@@ -89,6 +89,9 @@ int main_channellist(int argc, char **argv);int main_blockattach (int argc,char **argv);int main_blocklist (int argc,char **argv);int main_blockdetach (int argc,char **argv); +int main_vscsiattach (int argc,char **argv); +int main_vscsilist (int argc,char **argv); +int main_vscsidetach (int argc,char **argv);int main_vtpmattach (int argc,char **argv);int main_vtpmlist (int argc,char **argv);int main_vtpmdetach (int argc,char **argv);
tools/libxl/xl_cmdimpl.c +224 -1
243 lines not on this page · raw message
tools/libxl/xl_cmdtable.c +15 -0
@@ -351,6 +351,21 @@ struct cmd_spec cmd_table[] = {"Destroy a domain's virtual block device" ,"<Domain> <DevId>" , }, + { "scsi-attach", + &main_vscsiattach,1 ,1 , +"Attach a dom0 SCSI device to a domain." , +"<Domain> <PhysDevice> <VirtDevice>" , + }, + { "scsi-list", + &main_vscsilist,0 ,0 , +"List all dom0 SCSI devices currently attached to a domain." , +"<Domain(s)>" , + }, + { "scsi-detach", + &main_vscsidetach,0 ,1 , +"Detach a specified SCSI device from a domain." , +"<Domain> <VirtDevice>" , + }, { "vtpm-attach", &main_vtpmattach,1 ,1 , "Create a new virtual TPM device",
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 5/5 Scripts to create and delete xen-scsiback nodes in Linux target framework
In reply to Olaf HeringJust to make them public, not meant for merging:
The scripts used during development to create a bunch of SCSI devices in dom0 using the Linux target framework. targetcli3 and rtslib3 is used.
A patch is required for python-rtslib:
http://article.gmane.org/gmane.linux.scsi.target.devel/8146
--- tools/misc/Makefile | 4 + tools/misc/target-create-xen-scsiback.sh | 135 +++++++++++++++++++++++++++++++ tools/misc/target-delete-xen-scsiback.sh | 41 ++++++++++ 3 files changed, 180 insertions(+)
tools/misc/Makefile +4 -0
@@ -35,6 +35,8 @@ INSTALL_SBIN += $(INSTALL_SBIN-y) # Everything to be installed in a private bin/ INSTALL_PRIVBIN += xenpvnetboot +INSTALL_PRIVBIN += target-create-xen-scsiback.sh +INSTALL_PRIVBIN += target-delete-xen-scsiback.sh # Everything to be installed TARGETS_ALL := $(INSTALL_BIN) $(INSTALL_SBIN) $(INSTALL_PRIVBIN)
@@ -45,6 +47,8 @@ TARGETS_COPY += xen-ringwatch TARGETS_COPY += xencons TARGETS_COPY += xencov_split TARGETS_COPY += xenpvnetboot +TARGETS_COPY += target-create-xen-scsiback.sh +TARGETS_COPY += target-delete-xen-scsiback.sh # Everything which needs to be built TARGETS_BUILD := $(filter-out $(TARGETS_COPY),$(TARGETS_ALL))
tools/misc/target-create-xen-scsiback.sh new file +135 -0
135 lines not on this page · raw message
tools/misc/target-delete-xen-scsiback.sh new file +41 -0
41 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 4/5] libxl: add support for vscsi
In reply to Olaf HeringQuoted 22 lines · Olaf Hering
Port pvscsi support from xend to libxl:
vscsi=['pdev,vdev{,options}']
xl scsi-attach
xl scsi-detach
xl scsi-listSigned-off-by Olaf Hering <[email protected]>Cc Ian Jackson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>--- docs/man/xl.cfg.pod.5 | 56 ++ docs/man/xl.pod.1 | 18 + tools/libxl/Makefile | 2 + tools/libxl/libxl.c | 9 + tools/libxl/libxl.h | 42 ++ tools/libxl/libxl_create.c | 41 +- tools/libxl/libxl_device.c | 2 + tools/libxl/libxl_internal.h | 9 + tools/libxl/libxl_types.idl | 55 ++
Quoted 9 lines
tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vscsi.c | 1184 ++++++++++++++++++++++++++++++++++ tools/libxl/libxlu_vscsi.c | 684 ++++++++++++++++++++ tools/libxl/libxlutil.h | 18 + tools/libxl/xl.h | 3 + tools/libxl/xl_cmdimpl.c | 225 ++++++- tools/libxl/xl_cmdtable.c | 15 + 16 files changed, 2360 insertions(+), 4 deletions(-)
Some minor comments. With those addressed:
And also:
...
Quoted 47 lines
tools/libxl/libxl_device.c +2
-0@@ -543,6 +543,7 @@ void libxl__multidev_prepared(libxl__egc *egc,* The following functions are defined: * libxl__add_disks * libxl__add_nics +* libxl__add_vscsictrls * libxl__add_vtpms * libxl__add_usbctrls * libxl__add_usbs @@ -564,6 +565,7 @@ void libxl__multidev_prepared(libxl__egc *egc, DEFINE_DEVICES_ADD(disk) DEFINE_DEVICES_ADD(nic) +DEFINE_DEVICES_ADD(vscsictrl) DEFINE_DEVICES_ADD(vtpm) DEFINE_DEVICES_ADD(usbctrl) DEFINE_DEVICES_ADD(usbdev)tools/libxl/libxl_internal.h +8
-0@@ -2581,6 +2581,10 @@ _hidden void libxl__device_nic_add(libxl__egc *egc, uint32_t domid, libxl_device_nic *nic, libxl__ao_device *aodev); +_hidden void libxl__device_vscsictrl_add(libxl__egc *egc, uint32_t domid, +libxl_device_vscsictrl *vscsictrl, +libxl__ao_device *aodev); + _hidden void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid,libxl_device_vtpm *vtpm,libxl__ao_device *aodev);@@ -3346,6 +3350,10 @@ _hidden void libxl__add_nics(libxl__egc *egc, libxl__ao *ao, uint32_t domid, libxl_domain_config *d_config, libxl__multidev *multidev); +_hidden void libxl__add_vscsictrls(libxl__egc *egc, libxl__ao *ao, uint32_t domid, +libxl_domain_config *d_config, +libxl__multidev *multidev); + _hidden void libxl__add_vtpms(libxl__egc *egc, libxl__ao *ao, uint32_t domid,libxl_domain_config *d_config,libxl__multidev *multidev);
tools/libxl/libxl_internal.h static inline void libxl__update_config_vtpm(libxl__gc *gc, · line 4043
Quoted 4 lines
tools/libxl/libxl_internal.h +1
-0@@ -4032,6 +4040,7 @@ static inline void libxl__update_config_vtpm(libxl__gc *gc,* devices have same identifier. */ #define COMPARE_DEVID (a, b) ((a)->devid == (b)->devid)#define COMPARE_DISK (a, b) (!strcmp((a)->vdev, (b)->vdev)) +#define COMPARE_VSCSI (a, b) ((a)->devid == (b)->devid)
Is this really needed? I'd prefer using COMPARE_DEVID() instead.
Quoted 3 lines
tools/libxl/libxl_internal.h +0
-0#define COMPARE_PCI (a, b) ((a)->func == (b)->func && \ (a)->bus == (b)->bus && \ (a)->dev == (b)->dev)
...
Quoted 54 lines
tools/libxl/libxl_vscsi.c new file +48
-0@@ -0,0 +1,1184 @@ +/* +* Copyright (C) 2016 SUSE Linux GmbH +* Author Olaf Hering <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program 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. +*/ +#include "libxl_osdeps.h" /* must come before any other headers */ +#include "libxl_internal.h" + +typedef struct vscsidev_rm { +libxl_device_vscsictrl *ctrl; +char *be_path; +int dev_wait; +libxl__device dev; +}vscsidev_rm_t ; + +typedef void (*vscsictrl_add )(libxl__egc *egc, +libxl__ao_device *aodev, +libxl_device_vscsictrl *vscsictrl, +libxl_domain_config *d_config); + +#define XLU_WWN_LEN 16 + +static int vscsi_parse_hctl (char *str,libxl_vscsi_hctl *hctl) +{ +unsigned int hst, chn, tgt; +unsigned long long lun; + +if (sscanf (str,"%u:%u:%u:%llu" , &hst, &chn, &tgt, &lun) !=4 ) +return ERROR_INVAL ; + + hctl->hst = hst; + hctl->chn = chn; + hctl->tgt = tgt; + hctl->lun = lun; +return 0 ; +} + +static bool vscsi_wwn_valid (const char *p) +{
tools/libxl/libxl_vscsi.c line 58
Quoted 10 lines
tools/libxl/libxl_vscsi.c new file +10
-0+bool ret = true; +int i =0 ; + +for (i =0 ; i <XLU_WWN_LEN ; i++, p++) { +if (*p >='0' && *p <='9' ) +continue ; +if (*p >='a' && *p <='f' ) +continue ; +if (*p >='A' && *p <='F' ) +continue ;
What about using isxdigit() here?
Or even: omit the whole function and use "%16[0-9a-fA-F]" as format of sscanf().
Quoted 41 lines
tools/libxl/libxl_vscsi.c new file +41
-0+ ret = false; +break ; + } +return ret; +} + +/* Translate p-dev back into pdev.type */ +static bool vscsi_parse_pdev (libxl__gc *gc,libxl_device_vscsidev *dev, +char *c,char *p,char *v) +{ +libxl_vscsi_hctl hctl; +unsigned long long lun; +char wwn[XLU_WWN_LEN +1 ]; +bool parsed_ok = false; + +libxl_vscsi_hctl_init (&hctl); + + dev->pdev.p_devname =libxl__strdup (NOGC , c); + +if (strncmp (p,"naa." ,4 ) ==0 ) { +/* WWN as understood by pvops */ +memset (wwn,0 ,sizeof (wwn)); +if (sscanf (p,"naa.%16c:%llu" , wwn, &lun) ==2 &&vscsi_wwn_valid (wwn)) { +libxl_vscsi_pdev_init_type (&dev->pdev,LIBXL_VSCSI_PDEV_TYPE_WWN ); + dev->pdev.u.wwn.m =libxl__strdup (NOGC , p); + parsed_ok = true; + } + }else if (vscsi_parse_hctl (p, &hctl) ==0 ) { +/* Either xenlinux, or pvops with properly configured alias in sysfs */ +libxl_vscsi_pdev_init_type (&dev->pdev,LIBXL_VSCSI_PDEV_TYPE_HCTL ); +libxl_vscsi_hctl_copy (CTX , &dev->pdev.u.hctl.m, &hctl); + parsed_ok = true; + } + +if (parsed_ok &&vscsi_parse_hctl (v, &dev->vdev) !=0 ) + parsed_ok = false; + +libxl_vscsi_hctl_dispose (&hctl); + +return parsed_ok; +}
...
Quoted 30 lines
tools/libxl/libxlu_vscsi.c new file +24
-0@@ -0,0 +1,684 @@ +/* +* libxlu_vscsi.c - xl configuration file parsing: setup and helper functions +* +* Copyright (C) 2016 SUSE Linux GmbH +* Author Olaf Hering <[email protected]> +* Author Ondřej Holeček <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program 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. +*/ +#include "libxl_osdeps.h" /* must come before any other headers */ +#include <unistd.h> +#include <ctype.h> +#include <dirent.h> +#include <sys/stat.h> +#include <fcntl.h> +#include "libxlu_internal.h"
...
tools/libxl/libxlu_vscsi.c line 146
Quoted 12 lines
tools/libxl/libxlu_vscsi.c new file +12
-0+static bool xlu__vscsi_wwn_valid (const char *p) +{ +bool ret = true; +int i =0 ; + +for (i =0 ; i <XLU_WWN_LEN ; i++, p++) { +if (*p >='0' && *p <='9' ) +continue ; +if (*p >='a' && *p <='f' ) +continue ; +if (*p >='A' && *p <='F' ) +continue ;
Same as above: isxdigit() or completely omit the function.
tools/libxl/libxlu_vscsi.c
Quoted 5 lines
tools/libxl/libxlu_vscsi.c new file +5
-0+ ret = false; +break ; + } +return ret; +}
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 4/5] libxl: add support for vscsi
Quoted 4 lines · Juergen Gross
Quoted 1 line · Olaf Hering
+#define
COMPARE_VSCSI(a, b)((a)->devid == (b)->devid)Is this really needed? I'd prefer using
COMPARE_DEVID()instead.
COMPARE_VSCSI used to do something else in an earlier variant. Now COMPARE_DEVID can be used.
Quoted 3 lines
Quoted 1 line
+ if (
sscanf(p, "naa.%16c:%llu", wwn, &lun)== 2 &&vscsi_wwn_valid(wwn)) {Or even: omit the whole function and use "%16[0-9a-fA-F]" as format of
sscanf().
Yes, thanks for the feedback. I will change it.
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 4/5] libxl: add support for vscsi
In reply to Olaf HeringOlaf Hering writes ("[PATCH v10 4/5] libxl: add support for vscsi"):
Quoted 6 lines
Port pvscsi support from xend to libxl:
vscsi=['pdev,vdev{,options}']
xl scsi-attach
xl scsi-detach
xl scsi-list
Thanks for this contribution. I have tried to review it, although I don't fully understand the underlying vscsi subsystem. The public API looks reasonably good.
Quoted 3 lines
tools/libxl/libxl_types.idl +0
-1--- a/tools/libxl/libxl_types.idl
...
Quoted 5 lines
tools/libxl/libxl_types.idl +5
-0+libxl_vscsiinfo = Struct("vscsiinfo", [ + ("backend", string), + ("backend_id", uint32), + ("frontend", string), + ("frontend_id", uint32),
tools/libxl/libxl_types.idl libxl_nicinfo = Struct("nicinfo", [ · line 769
Quoted 10 lines
tools/libxl/libxl_types.idl +10
-0+ ("devid", libxl_devid), + ("pdev", libxl_vscsi_pdev), + ("vdev", libxl_vscsi_hctl), + ("idx", libxl_devid), + ("vscsidev_id", libxl_devid), + ("scsi_raw_cmds", bool), + ("vscsictrl_state", integer), + ("vscsidev_state", integer), + ("evtch", integer), + ("rref", integer),
I don't think the event channel and ring ref belong here. (That they are present in some other devices is a mistake.)
Quoted 8 lines
tools/libxl/libxl_types.idl +8
-0+static int xlu__vscsi_parse_dev(XLU_Config *cfg, char *pdev, libxl_vscsi_hctl *hctl) +{ + struct stat dentry; + char *sysfs = NULL; + const char *type; + int rc, found = 0; + DIR *dirp; + struct dirent *de;
...
tools/libxl/libxl_types.idl
Quoted 7 lines
tools/libxl/libxl_types.idl +7
-0+ /* /sys/dev/type/major:minor symlink added in 2.6.27 */ + if (asprintf(&sysfs, "/sys/dev/%s/%u:%u/device/scsi_device", type, + major(dentry.st_rdev), minor(dentry.st_rdev)) < 0) { + sysfs = NULL; + rc = ERROR_NOMEM; + goto out; + }
I'm not sure that this sysfs parsing ought to be in xl rather than libxl. Also, this is Linux-specific code. So it needs to be made conditional somehow.
It seems to me that the contents of xlu__vscsi_target should be much closer to vscsi_pdev_type (unless I have misunderstood).
Perhaps the libxl_types.idl API needs to change. In general, the libxl API ought to be close enough in semantics to the xl config API that the correspondence is obvious. I don't think that's the case here.
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 4/5] libxl: add support for vscsi
Quoted 3 lines · Ian Jackson
I'm not sure that this sysfs parsing ought to be in xl rather than libxl. Also, this is Linux-specific code. So it needs to be made conditional somehow.
The whole libxlu file is inside #ifdef __linux__? I will address the other comments in another mail.
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 4/5] libxl: add support for vscsi
Olaf Hering writes ("Re: [PATCH v10 4/5] libxl: add support for vscsi"):
Quoted 6 lines · Ian Jackson
Quoted 3 lines
I'm not sure that this sysfs parsing ought to be in xl rather than libxl. Also, this is Linux-specific code. So it needs to be made conditional somehow.
The whole libxlu file is inside #ifdef
__linux__?
Oh, so it is. Sorry for not spotting that. TBH I think it might be better to do this the way that other kernel-specific things are done, eg libxl_linux.c etc.
But I think changing this ought to wait until we settle whether this code ought to be in xl or libxl.
Quoted 1 line
I will address the other comments in another mail.
Thanks
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 4/5] libxl: add support for vscsi
In reply to Ian JacksonQuoted 17 lines · Ian Jackson
Quoted 8 lines
tools/libxl/libxlu_vscsi.c new file +8
-0+static int xlu__vscsi_parse_dev (XLU_Config *cfg,char *pdev,libxl_vscsi_hctl *hctl) +{ +struct stat dentry; +char *sysfs =NULL ; +const char *type; +int rc, found =0 ; +DIR *dirp; +struct dirent *de;...
tools/libxl/libxlu_vscsi.c line 102
Quoted 7 lines
tools/libxl/libxlu_vscsi.c new file +7
-0+/* /sys/dev/type/major:minor symlink added in 2.6.27 */ +if (asprintf (&sysfs,"/sys/dev/%s/%u:%u/device/scsi_device" , type, +major (dentry.st_rdev),minor (dentry.st_rdev)) <0 ) { + sysfs =NULL ; + rc =ERROR_NOMEM ; + goto out; + }
Quoted 3 lines
I'm not sure that this sysfs parsing ought to be in xl rather than libxl. Also, this is Linux-specific code. So it needs to be made conditional somehow.
I think this depends on how libvirt is supposed to interact with libxl here. Right now libvirt is rather dumb, it supports just the host:channel:target:lun notation for a backend. My patch for it (which I have to rebase now) creates a string "pdev,vdev" and calls xlu_vscsi_get_host. I will rebase the libvirt patch and resend it as well.
Quoted 2 lines
It seems to me that the contents of
xlu__vscsi_targetshould be much closer tovscsi_pdev_type(unless I have misunderstood).
Well, if its important where that struct is supposed to be in the file, I can move it down.
Quoted 4 lines
Perhaps the libxl_types.idl API needs to change. In general, the libxl API ought to be close enough in semantics to the xl config API that the correspondence is obvious. I don't think that's the case here.
I'm not sure what this paragraph means.
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel