libbxl: add support for pvscsi, iteration 7
v7 cover libbxl: add support for pvscsi, iteration 7
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:
- check if "detach <vdev>" can be done with single host/single device instead of the ->remove field
- check if a transaction should be used in libxl__device_vscsi_add
- maybe use events instead of polling for "state" changes in reconfigure (libxl__wait_for_backend vs. libxl__ev_devstate_wait)
- comply with tools/libxl/CODING_STYLE everywhere
- document pvscsi in xen wiki
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
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
libxl: add support for vscsi
vscsiif.h: add some notes about xenstore layout Scripts to create and delete xen-scsiback nodes in Linux target
framework
docs/man/xl.cfg.pod.5 | 55 +++ docs/man/xl.pod.1 | 18 + docs/misc/xenstore-paths.markdown | 10 + tools/libxl/Makefile | 2 + tools/libxl/libxl.c | 578 +++++++++++++++++++++++++ tools/libxl/libxl.h | 35 ++ tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_device.c | 2 + tools/libxl/libxl_internal.h | 14 + tools/libxl/libxl_types.idl | 53 +++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vscsi.c | 344 +++++++++++++++ tools/libxl/libxlu_vscsi.c | 718 +++++++++++++++++++++++++++++++ tools/libxl/libxlutil.h | 18 + tools/libxl/xl.h | 3 + tools/libxl/xl_cmdimpl.c | 208 ++++++++- 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 | 70 ++- 21 files changed, 2323 insertions(+), 2 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
PATCH v7 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
PATCH v7 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
PATCH v7 3/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 | 55 +++ docs/man/xl.pod.1 | 18 + tools/libxl/Makefile | 2 + tools/libxl/libxl.c | 578 ++++++++++++++++++++++++++++ tools/libxl/libxl.h | 35 ++ tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_device.c | 2 + tools/libxl/libxl_internal.h | 14 + tools/libxl/libxl_types.idl | 53 +++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vscsi.c | 344 +++++++++++++++++ tools/libxl/libxlu_vscsi.c | 718 +++++++++++++++++++++++++++++++++++ tools/libxl/libxlutil.h | 18 + tools/libxl/xl.h | 3 + tools/libxl/xl_cmdimpl.c | 208 +++++++++- tools/libxl/xl_cmdtable.c | 15 + 16 files changed, 2064 insertions(+), 1 deletion(-)
docs/man/xl.cfg.pod.5 +55 -0
@@ -517,6 +517,61 @@ 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 "na.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 \
@@ -141,6 +142,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 +578 -0
614 lines not on this page · raw message
tools/libxl/libxl.h +35 -0
@@ -836,6 +836,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);#define LIBXL_HAVE_PCITOPOLOGY 1/* +* LIBXL_HAVE_VSCSI +* +* If this is defined, the PV SCSI feature is supported. +*/ +#define LIBXL_HAVE_VSCSI 1 + +/* * LIBXL_HAVE_SOCKET_BITMAP * * If this is defined, then libxl_socket_bitmap_alloc and
@@ -1539,6 +1546,34 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, libxl_device_channel *channel, libxl_channelinfo *channelinfo); +/* Virtual SCSI */ +int libxl_device_vscsictrl_add(libxl_ctx *ctx, uint32_t domid, + libxl_device_vscsictrl *vscsi, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vscsictrl_remove(libxl_ctx *ctx, uint32_t domid, + libxl_device_vscsictrl *vscsi, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vscsictrl_destroy(libxl_ctx *ctx, uint32_t domid, + libxl_device_vscsictrl *vscsi, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; + +libxl_device_vscsictrl *libxl_device_vscsictrl_list (libxl_ctx *ctx,uint32_t domid,int *num); +int libxl_device_vscsictrl_getinfo (libxl_ctx *ctx,uint32_t domid, +libxl_device_vscsictrl *vscsictrl, +libxl_device_vscsidev *vscsidev, +libxl_vscsiinfo *vscsiinfo); +/* Remove vscsidev connected to vscsictrl */ +int libxl_device_vscsidev_remove(libxl_ctx *ctx, uint32_t domid, + libxl_device_vscsictrl *vscsi, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +void libxl_device_vscsictrl_append_vscsidev (libxl_ctx *ctx, +libxl_device_vscsictrl *ctrl, +libxl_device_vscsidev *dev); +/* Virtual TPMs */ int libxl_device_vtpm_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vtpm *vtpm,const libxl_asyncop_how *ao_how)
tools/libxl/libxl_create.c +1 -0
@@ -1166,6 +1166,7 @@ static void domcreate_rebuild_done(libxl__egc *egc,libxl__multidev_begin (ao, &dcs->multidev); dcs->multidev.callback = domcreate_launch_dm;libxl__add_disks (egc, ao, domid, d_config, &dcs->multidev); +libxl__add_vscsictrls (egc, ao, domid, d_config, &dcs->multidev);libxl__multidev_prepared (egc, &dcs->multidev,0 );return ;
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 */
@@ -562,6 +563,7 @@ void libxl__multidev_prepared(libxl__egc *egc, DEFINE_DEVICES_ADD(disk) DEFINE_DEVICES_ADD(nic) +DEFINE_DEVICES_ADD(vscsictrl) DEFINE_DEVICES_ADD(vtpm)#undef DEFINE_DEVICES_ADD
tools/libxl/libxl_internal.h +14 -0
@@ -2576,6 +2576,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 *vscsi, +libxl__ao_device *aodev); + _hidden void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid,libxl_device_vtpm *vtpm,libxl__ao_device *aodev);
@@ -3294,6 +3298,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);
@@ -3506,6 +3514,11 @@ _hidden void libxl__domain_suspend(libxl__egc *egc,/* used by libxc to suspend the guest during migration */ _hidden void libxl__domain_suspend_callback(void *data); +/* return an array of vscsictrls with num elements */ +_hidden int libxl__vscsi_collect_ctrls(libxl__gc *gc, +uint32_t domid, +libxl_device_vscsictrl **ctrls, +int *num);/* * Convenience macros.
@@ -3963,6 +3976,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 +53 -0
71 lines not on this page · raw message
tools/libxl/libxl_types_internal.idl +1 -0
@@ -22,6 +22,7 @@ libxl__device_kind = Enumeration("device_kind", [ (6, "VKBD"), (7, "CONSOLE"), (8, "VTPM"), + (9, "VSCSI"), ]) libxl__console_backend = Enumeration("console_backend", [
tools/libxl/libxl_vscsi.c new file +344 -0
344 lines not on this page · raw message
tools/libxl/libxlu_vscsi.c new file +718 -0
718 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 vscsictrl with device described in str (pdev,vdev[,options]) */ +int xlu_vscsi_get_ctrl (XLU_Config *config, +libxl_ctx *ctx, +uint32_t domid, +const char *str, +libxl_device_vscsictrl *vscsictrl); +/* 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 +207 -1
226 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
Re: [PATCH v7 3/5] libxl: add support for vscsi
tools/libxl/libxl.c int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, · line 7378
Quoted 5 lines · Olaf Hering
tools/libxl/libxl.c +1
-0@@ -6799,6 +7375,8 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,MERGE (nic, nics,COMPARE_DEVID , {}); +MERGE (vscsictrl, vscsictrls,COMPARE_VSCSI , {});
I think the actual "merge" should be like this, to copy the data gathered from xenstore into the d_config which was built from JSON. {libxl_device_vscsictrl_dispose(dst); libxl_device_vscsictrl_copy(CTX, dst, src);
}
Olaf
Re: [PATCH v7 3/5] libxl: add support for vscsi
In reply to Olaf Heringtools/libxl/libxlu_vscsi.c line 604
Quoted 11 lines · Olaf Hering
tools/libxl/libxlu_vscsi.c new file +10
-0+int xlu_vscsi_detach (XLU_Config *cfg,libxl_ctx *ctx,uint32_t domid,char *str) +{ +if (vc->num_vscsidevs >1 ) { +/* Remove single vscsidev connected to this vscsictrl */ ; + ctrl.devid = vc->devid; + ctrl.vscsidevs[0 ].vscsidev_id = vd->vscsidev_id; +libxl_device_vscsidev_remove (ctx, domid, &ctrl,NULL ); + }else { +/* Wipe entire vscsictrl */ ; +libxl_device_vscsictrl_remove (ctx, domid, vc,NULL );
In this version I have moved the decision to remove vscsictrl into libxlu. I wonder if thats a valid approach. Should there be a libxl_device_vscsidev_remove which takes a *vscsidev, walks the list of vscsictrls in xenstore and then calls either a variant of libxl_device_vscsictrl_remove or libxl__device_vscsidev_rm? Please advice.
Olaf
Re: [PATCH v7 3/5] libxl: add support for vscsi
In reply to Olaf Heringtools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 2425
Quoted 8 lines · Olaf Hering
tools/libxl/libxl.c +7
-0+static int libxl__vscsictrl_next_vscsidev_id (libxl__gc *gc,uint32_t domid, +libxl_device_vscsictrl *vscsi, +libxl_devid *vscsidev_id) +{ + path =GCSPRINTF ("%s/vscsi/%u/next_vscsidev_id" , +libxl__xs_libxl_path (gc, domid), + vscsi->devid);
This creates /libxl/<domid>/vscsi/<devid>/counter. Where is the place to remove /libxl/<domid>/vscsi/<devid> during scsi-detach? As a workaround I'm in the process to move the counter to the backend path.
Olaf
Re: [PATCH v7 3/5] libxl: add support for vscsi
Quoted 1 line · Olaf Hering
I'm in the process to move the counter to the backend path.
... which fails due to libxl__device_exists(). So, back to /libxl
Olaf
PATCH v7 4/5 vscsiif.h: add some notes about xenstore layout
In reply to Olaf Hering--- xen/include/public/io/vscsiif.h | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
xen/include/public/io/vscsiif.h +68 -0
@@ -104,6 +104,74 @@* 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" +* +* +* 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 */ /*
PATCH v7 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