libbxl: add support for pvscsi, iteration 3
v3 cover libbxl: add support for pvscsi, iteration 3
Port vscsi=[] and scsi-{attach,detach,list} commands from xend to libxl.
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
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.
Please review. The first two changes could be applied independent from the libxl changes.
Olaf
Olaf Hering (4):
vscsiif.h: fix WWN notation for p-dev property
docs: add vscsi to xenstore-paths.markdown
docs: add pvscsi.txt
libxl: add support for vscsi
docs/misc/pvscsi.txt | 188 ++++++++++++++++++ docs/misc/xenstore-paths.markdown | 10 + tools/libxl/Makefile | 1 + tools/libxl/libxl.c | 172 ++++++++++++++++ tools/libxl/libxl.h | 29 +++ tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_device.c | 2 + tools/libxl/libxl_freebsd.c | 8 + tools/libxl/libxl_internal.h | 12 ++ tools/libxl/libxl_linux.c | 60 ++++++ tools/libxl/libxl_netbsd.c | 8 + tools/libxl/libxl_types.idl | 49 +++++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vscsi.c | 375 +++++++++++++++++++++++++++++++++++ tools/libxl/xl.h | 3 + tools/libxl/xl_cmdimpl.c | 249 ++++++++++++++++++++++- tools/libxl/xl_cmdtable.c | 15 ++ xen/include/public/io/vscsiif.h | 2 +- 18 files changed, 1183 insertions(+), 2 deletions(-) create mode 100644 docs/misc/pvscsi.txt create mode 100644 tools/libxl/libxl_vscsi.c
PATCH v3 1/4 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 v3 2/4 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
@@ -232,6 +232,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)
@@ -302,6 +307,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. Described in [pvscsi.txt](pvscsi.txt) + #### ~/backend/console/$DOMID/$DEVID/* [] A PV console backend. Described in [console.txt](console.txt)
@@ -403,6 +412,7 @@ ifb device used by Remus to buffer network output from the associated vif. [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,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 v3 3/4 docs: add pvscsi.txt
In reply to Olaf Hering--- docs/misc/pvscsi.txt | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+)
docs/misc/pvscsi.txt new file +188 -0
@@ -0,0 +1,188 @@ +. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +PVSCSI + +== Overview == + +PVSCSI allows to assing a "physical" SCSI device from dom0 to a domU. The device +is not limited to be a native SCSI device. Everything visible as SCSI device in +dom0 can be used. Currently PVSCSI is only available in Linux dom0 and domU. + +== TODO === + +How to do live migration? + - pdev will likely be evaluated again on the target host if it came from + domU.cfg. But what about pdev from 'xl scsi-attach pdev vdev'? Its required + to adjust h:c:t:l on the target host. + +How to handle FIXME in libxl_retrieve_domain_configuration? + - "MERGE(vscsi, vscsis, COMPARE_DEVID, {});", when does this code run? + +Implement libvirt integration. + - Is the API used by xl usable for libvirt? + - How does libvirt assign a raw SCSI device? + Jim said: + > vscsi=[ '/dev/sda,0:1:2:3', '4:3:2:1,1:1:1:1,feature-host' ] + In libvirt-speak, this is SCSI host device assignment + http://libvirt.org/formatdomain.html#elementsHostDev + Here's the SCSI example + <devices> + <hostdev mode='subsystem' type='scsi' sgio='filtered' rawio='yes'> + <source> + <adapter name='scsi_host0'/> + <address type='scsi' bus='0' target='0' unit='0'/> + </source> + <readonly/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </hostdev> + ... + </devices> + I suppose 'feature-host' maps to attributes such as 'sgio' and 'rawio'. + The source element describes the SCSI device as seen from the host. + + +== History == + +Support for PVSCSI was added to the classic xenlinux kernel and to xend in +xen-3.3 in 2008. Support for PVSCSI was added to the upstream pvops kernel 3.18 +in 2014. Backends exists just for Linux. A frontend exists for Linux, and maybe +for FreeBSD according to google. + + +== Config Format == + +The domU.cfg syntax is "vscsi=[ 'pdev,vdev[,option]', 'pdev,vdev[,option]' ]". +'pdev' describes the physical device, preferable in a persistant format. +'vdev' is the domU device in vHOST:CHANNEL:TARGET:LUN notation, all integers. +'option' lists additional flags which a backend may recognize. + + +== Configuring xenlinux backend == + +"pdev" is the dom0 device in either /dev/scsidev or pHOST:CHANNEL:TARGET:LUN +notation. Currently only the option value "feature-host" is recognized. SCSI +command emulation in backend driver is bypassed when "feature-host" is +specified. + +Its recommended to use persistant 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. + + +== Configuring pvops backend == + +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 targetcli. The "pdev" in domU.cfg has to +refer to a config item in that framework instead of the raw device. + +The LIO uses a concept of backstore and frontend drivers. LIO backstore drivers +provide access to the actual storage, LIO frontend drivers provide an interface +which is accessed with SCSI commands. Within the LIO the frontend is connected +to a certain backstore. + +For Xen its recommended to use the PSCSI backstore. Other backstores may work as +well, but they are not tested. The xen-scsiback module is the LIO frontend, and +at the same time the backend for the domU. In general the config flow is: +- the LIO backstore refers to physical storage in a persistant way +- the given storage gets a free, unique name within the LIO backstore +- the LIO frontend refers to that free, unique name in the LIO backstore +- the connection to the LIO backstore gets a naa.WWN:LUN in the LIO frontend +- the "pdev" in domU.cfg refers to that naa.WWN:LUN in the LIO frontend + +Example for targetcli and a xen-scsiback aware python-rtslib: + + # modprobe -v xen-scsiback + # DEV=/dev/disk/by-id/ata-TSSTcorp_DVD+_-RW_TS-H653G_R4576GFZ638411 + # NAME="my_dvd" + # NAA=$(printf "naa.%s\n" `od -N 8 -t x8 -A n < /dev/urandom`) + # targetcli "/backstores/pscsi create name=$NAME dev=${DEV}" + # targetcli "/xen-pvscsi create wwn=$NAA" + # targetcli "/xen-pvscsi/$NAA/tpg1/luns create /backstores/pscsi/$NAME" + # echo "vscsi=[ '${NAA}:0,0:0:0:0' ]" + +The last line is the domU.cfg snippet. + + +== Xenstore Format == + +The backend driver uses a single_host:many_devices notation to manage domU +devices. Everything is stored in /local/domain/0/backend/vscsi/. The xenstore +layout looks like this: + + <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/ + + +== Interface in xl == + +xl scsi-attach domid <PhysDevice> <VirtDevice>[,<option>] +xl scsi-detach domid <VirtDevice> +xl scsi-list domid [domid, ...] + + +== Interface in libxl == + +To be defined so that both xl and libvirt pass in the same data. + + +== Interface in libvirt == + +Has yet to be found. + +. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +# vim: tw=80 et ts=4
PATCH v3 4/4 libxl: add support for vscsi
In reply to Olaf HeringPort pvscsi support from xend to libxl. See pvscsi.txt for details.
Outstanding work is listed in the TODO section.
--- tools/libxl/Makefile | 1 + tools/libxl/libxl.c | 172 ++++++++++++++++ tools/libxl/libxl.h | 29 +++ tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_device.c | 2 + tools/libxl/libxl_freebsd.c | 8 + tools/libxl/libxl_internal.h | 12 ++ tools/libxl/libxl_linux.c | 60 ++++++ tools/libxl/libxl_netbsd.c | 8 + tools/libxl/libxl_types.idl | 49 +++++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vscsi.c | 375 +++++++++++++++++++++++++++++++++++ tools/libxl/xl.h | 3 + tools/libxl/xl_cmdimpl.c | 249 ++++++++++++++++++++++- tools/libxl/xl_cmdtable.c | 15 ++ 15 files changed, 984 insertions(+), 1 deletion(-)
tools/libxl/Makefile +1 -0
@@ -91,6 +91,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 \
tools/libxl/libxl.c +172 -0
202 lines not on this page · raw message
tools/libxl/libxl.h +29 -0
@@ -1224,6 +1224,35 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, libxl_device_channel *channel, libxl_channelinfo *channelinfo); +/* Virtual SCSI */ +int libxl_device_vscsi_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vscsi *vscsi, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vscsi_remove(libxl_ctx *ctx, uint32_t domid, + libxl_device_vscsi *vscsi, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vscsi_destroy(libxl_ctx *ctx, uint32_t domid, + libxl_device_vscsi *vscsi, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; + +libxl_device_vscsi *libxl_device_vscsi_list (libxl_ctx *ctx,uint32_t domid,int *num); +int libxl_device_vscsi_getinfo (libxl_ctx *ctx, +uint32_t domid, +libxl_device_vscsi *vscsi_host, +libxl_vscsi_dev *vscsi_dev, +libxl_vscsiinfo *vscsiinfo); +void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev); +int libxl_device_vscsi_get_host (libxl_ctx *ctx, +uint32_t domid, +const char *cfg, +libxl_device_vscsi **vscsi_host); +int libxl_device_vscsi_parse (libxl_ctx *ctx,const char *cfg, +libxl_device_vscsi *vscsi_host, +libxl_vscsi_dev *vscsi_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
@@ -1136,6 +1136,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_vscsis (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_vscsis * 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(vscsi) DEFINE_DEVICES_ADD(vtpm)#undef DEFINE_DEVICES_ADD
tools/libxl/libxl_freebsd.c +8 -0
@@ -131,3 +131,11 @@ libxl_device_model_version libxl__default_device_model(libxl__gc *gc) {return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN ; } + +int libxl_device_vscsi_parse_pdev (libxl__gc *gc,char *pdev,unsigned int *hst, +unsigned int *chn,unsigned int *tgt, +unsigned int *lun) +{ + +return ERROR_NOPARAVIRT ; +}
tools/libxl/libxl_internal.h +12 -0
@@ -1794,6 +1794,10 @@ _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s); _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);/* Return the system-wide default device model */ _hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc); +/* Convert h:c:t:l string to int */ +_hidden int libxl_device_vscsi_parse_hctl(libxl__gc *gc, char *str, libxl_vscsi_hctl *hctl); +/* Convert /dev/scsi to h:c:t:l */ +_hidden int libxl_device_vscsi_parse_pdev(libxl__gc *gc, char *pdev, libxl_vscsi_hctl *hctl);/* Check how executes hotplug script currently */ int libxl__hotplug_settings (libxl__gc *gc,xs_transaction_t t);
@@ -2386,6 +2390,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_vscsi_add(libxl__egc *egc, uint32_t domid, +libxl_device_vscsi *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);
@@ -3005,6 +3013,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_vscsis(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_linux.c +60 -0
63 lines not on this page · raw message
tools/libxl/libxl_netbsd.c +8 -0
@@ -95,3 +95,11 @@ libxl_device_model_version libxl__default_device_model(libxl__gc *gc) {return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL ; } + +int libxl_device_vscsi_parse_pdev (libxl__gc *gc,char *pdev,unsigned int *hst, +unsigned int *chn,unsigned int *tgt, +unsigned int *lun) +{ + +return ERROR_NOPARAVIRT ; +}
tools/libxl/libxl_types.idl +49 -0
67 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 +375 -0
375 lines not on this page · raw message
tools/libxl/xl.h +3 -0
@@ -83,6 +83,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 +248 -1
267 lines not on this page · raw message
tools/libxl/xl_cmdtable.c +15 -0
@@ -365,6 +365,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",
Re: [PATCH v3 3/4] docs: add pvscsi.txt
In reply to Olaf HeringQuoted 25 lines · Olaf Hering
Signed-off-by Olaf Hering <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir Fraser <[email protected]>Cc Tim Deegan <[email protected]>--- docs/misc/pvscsi.txt | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+)docs/misc/pvscsi.txt new file +9
-0@@ -0,0 +1,188 @@ +. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +PVSCSI + +== Overview == + +PVSCSI allows to assing a "physical" SCSI device from dom0 to a domU. The device +is not limited to be a native SCSI device. Everything visible as SCSI device in +dom0 can be used. Currently PVSCSI is only available in Linux dom0 and domU. +
docs/misc/pvscsi.txt line 19
Quoted 10 lines
docs/misc/pvscsi.txt new file +10
-0+== TODO === + +How to do live migration? + - pdev will likely be evaluated again on the target host if it came from + domU.cfg. But what about pdev from 'xl scsi-attach pdev vdev'? Its required + to adjust h:c:t:l on the target host. + +How to handle FIXME in libxl_retrieve_domain_configuration? + - "MERGE(vscsi, vscsis, COMPARE_DEVID, {});", when does this code run? +
I don't think this kind of information that relates to libxl internal belongs here.
Anyway, to answer you question. libxl_retrieve_domain_configuration is called by xl when you do migration / detailed domain configuration listing etc.
I think the comment above MERGE macro states what it does and how to use it. Is there anything that's not clear to you?
Wei.
Re: [PATCH v3 2/4] docs: add vscsi to xenstore-paths.markdown
In reply to Olaf HeringOn Fri, Mar 06, 2015 at 10:45:54AM +0100, Olaf Hering wrote:
[...]
docs/misc/xenstore-paths.markdown ifb device used by Remus to buffer network output from the associated vif. · line 415
Quoted 8 lines
#### ~/backend/console/$DOMID/$DEVID/* []
A PV console backend. Described in [console.txt](console.txt)
docs/misc/xenstore-paths.markdown +1
-0@@ -403,6 +412,7 @@ ifb device used by Remus to buffer network output from the associated vif. [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,vscsiif.h.html
^
public,io,vscsiif.hQuoted 8 lines
docs/misc/xenstore-paths.markdown +0
-0[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
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Olaf HeringThis is a very big patch, I've only skimmed it so far.
I think you need to fix some overly long lines. I won't mention them individually inline.
Regarding all the parsing stuffs, you haven't defined vscsispec so I cannot review it. You might want to look at docs/misc/xl-disk-configuration.txt.
I'm not suggesting you have to write something like that, but considering all the compatibility issues you might have you might actually end up writing up a document like that.
Then after that, do you consider writing a lexer for vscsispec? We have one for diskspec, see libxlu_disk_l.l. That might result in a shorter patch?
Quoted 4 lines · Olaf Hering
Port pvscsi support from xend to libxl. See pvscsi.txt for details.
Outstanding work is listed in the TODO section.
There is no TODO section in this patch. :-)
Quoted 5 lines
Signed-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]>
Quoted 16 lines
--- tools/libxl/Makefile | 1 + tools/libxl/libxl.c | 172 ++++++++++++++++ tools/libxl/libxl.h | 29 +++ tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_device.c | 2 + tools/libxl/libxl_freebsd.c | 8 + tools/libxl/libxl_internal.h | 12 ++ tools/libxl/libxl_linux.c | 60 ++++++ tools/libxl/libxl_netbsd.c | 8 + tools/libxl/libxl_types.idl | 49 +++++ tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/libxl_vscsi.c | 375 +++++++++++++++++++++++++++++++++++ tools/libxl/xl.h | 3 + tools/libxl/xl_cmdimpl.c | 249 ++++++++++++++++++++++- tools/libxl/xl_cmdtable.c | 15 ++
Better split this patch into two. One for libxl and one for xl.
Or you can even split it into three, one for introducing libxl types, one for implementing functionalities in libxl and one for xl.
Quoted 28 lines
15 files changed, 984 insertions(+), 1 deletion(-)tools/libxl/Makefile +1
-0@@ -91,6 +91,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 \tools/libxl/libxl.c +6
-0@@ -1967,6 +1967,166 @@ static int libxl__resolve_domid(libxl__gc *gc, const char *name, }/******************************************************************************/ +static int libxl__device_from_vscsi (libxl__gc *gc,uint32_t domid, +libxl_device_vscsi *vscsi, +libxl__device *device) +{ + device->backend_domid = vscsi->backend_domid; + device->devid = vscsi->devid;
tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 1985
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ device->domid = domid; + device->backend_kind =LIBXL__DEVICE_KIND_VSCSI ; + device->kind =LIBXL__DEVICE_KIND_VSCSI ; + +return 0 ; +} + +void libxl__device_vscsi_add (libxl__egc *egc,uint32_t domid, +libxl_device_vscsi *vscsi, +libxl__ao_device *aodev)
You need to update this domain's JSON configuration. Cf. libxl__device_vtpm_add and friends. Also look at libxl_internal.h L2310.
Quoted 13 lines
tools/libxl/libxl.c +13
-0+{ +STATE_AO_GC (aodev->ao); +libxl_ctx *ctx =libxl__gc_owner (gc); +flexarray_t *front; +flexarray_t *back; +libxl__device *device; +char *be_path; +unsigned int be_dirs =0 , rc, i; + +if (vscsi->devid ==-1 ) { + rc =ERROR_FAIL ; + goto out; + }
tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 2008
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ +/* Prealloc key+value: 4 toplevel + 4 per device */ + i =2 * (4 + (4 * vscsi->num_vscsi_devs)); + back =flexarray_make (gc, i,1 ); + front =flexarray_make (gc,2 *2 ,1 ); + +GCNEW (device); + rc =libxl__device_from_vscsi (gc, domid, vscsi, device); +if ( rc !=0 ) goto out; +
Coding style. No space after ( and before ). You can even just use
if (!rc) goto out;
Quoted 6 lines
tools/libxl/libxl.c +6
-0+/* Check if backend device path is already present */ + be_path =libxl__device_backend_path (gc, device); +if (!libxl__xs_directory (gc,XBT_NULL , be_path, &be_dirs) || !be_dirs) { +/* backend does not exist, create a new one */ +flexarray_append_pair (back,"frontend-id" ,GCSPRINTF ("%d" , domid)); +flexarray_append_pair (back,"online" ,"1" );
tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 2024
Quoted 10 lines
tools/libxl/libxl.c +10
-0+flexarray_append_pair (back,"state" ,"1" ); +flexarray_append_pair (back,"feature-host" ,GCSPRINTF ("%d" , !!vscsi->feature_host)); + +flexarray_append_pair (front,"backend-id" ,GCSPRINTF ("%d" , vscsi->backend_domid)); +flexarray_append_pair (front,"state" ,"1" ); + } + +for (i =0 ; i < vscsi->num_vscsi_devs; i++) { +libxl_vscsi_dev *v = vscsi->vscsi_devs + i; +/* Trigger removal, otherwise create new device */
Why do you want to trigger removal in "add" function?
Quoted 13 lines
tools/libxl/libxl.c +13
-0+if (be_dirs) { +unsigned int nb =0 ; +/* Preserve existing device */ +if (libxl__xs_directory (gc,XBT_NULL ,GCSPRINTF ("%s/vscsi-devs/dev-%u" , be_path, v->vscsi_dev_id), &nb) && nb) { +/* Trigger device removal by forwarding state to XenbusStateClosing */ +if (v->remove) +flexarray_append_pair (back,GCSPRINTF ("vscsi-devs/dev-%u/state" , v->vscsi_dev_id),"5" ); +continue ; + } + } +flexarray_append_pair (back,GCSPRINTF ("vscsi-devs/dev-%u/p-devname" , v->vscsi_dev_id), v->p_devname); +switch (v->pdev_type) { +case LIBXL_VSCSI_PDEV_TYPE_WWN :
[...]
Quoted 30 lines
tools/libxl/libxl.c +30
-0+xs_transaction_t t; +retry_transaction: + t =xs_transaction_start (ctx->xsh); +libxl__xs_writev (gc, t, be_path, +libxl__xs_kvs_of_flexarray (gc, back, back->count)); +xs_write (ctx->xsh, t,GCSPRINTF ("%s/state" , be_path),"7" ,2 ); +if (!xs_transaction_end (ctx->xsh, t,0 )) { +if (errno ==EAGAIN ) + goto retry_transaction; +LOGE (ERROR ,"xs transaction failed" ); + rc =ERROR_FAIL ; + goto out; + } +libxl__wait_for_backend (gc, be_path,"4" ); + +retry_transaction2: + t =xs_transaction_start (ctx->xsh); +for (i =0 ; i < vscsi->num_vscsi_devs; i++) { +libxl_vscsi_dev *v = vscsi->vscsi_devs + i; +if (v->remove) { +char *path, *val; + path =GCSPRINTF ("%s/vscsi-devs/dev-%u/state" , be_path, v->vscsi_dev_id); + val =libxl__xs_read (gc, t, path); +if (val &&strcmp (val,"6" ) ==0 ) { + path =GCSPRINTF ("%s/vscsi-devs/dev-%u/state" , be_path, v->vscsi_dev_id); +xs_rm (ctx->xsh, t, path); + path =GCSPRINTF ("%s/vscsi-devs/dev-%u/p-devname" , be_path, v->vscsi_dev_id); +xs_rm (ctx->xsh, t, path); + path =GCSPRINTF ("%s/vscsi-devs/dev-%u/p-dev" , be_path, v->vscsi_dev_id); +xs_rm (ctx->xsh, t, path);
tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 2112
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ path =GCSPRINTF ("%s/vscsi-devs/dev-%u/v-dev" , be_path, v->vscsi_dev_id); +xs_rm (ctx->xsh, t, path); + path =GCSPRINTF ("%s/vscsi-devs/dev-%u" , be_path, v->vscsi_dev_id); +xs_rm (ctx->xsh, t, path); + }else { +LOGE (ERROR ,"%s: %s has %s, expected 6" , __func__, path, val); + } + } + } +
Please avoid using goto to retry transaction.
Quoted 17 lines
tools/libxl/libxl.c +17
-0+if (!xs_transaction_end (ctx->xsh, t,0 )) { +if (errno ==EAGAIN ) + goto retry_transaction2; +LOGE (ERROR ,"xs transaction failed" ); + rc =ERROR_FAIL ; + goto out; + } +/* As we are not adding new device, skip waiting for it */ +libxl__ao_complete (egc, aodev->ao,0 ); + + rc =0 ; +out: + aodev->rc = rc; +if (rc) aodev->callback (egc, aodev); +return ; +} +
[...]
tools/libxl/libxl.c
Quoted 7 lines
tools/libxl/libxl.c +7
-0+GC_FREE ; +return rc; +} + +void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev) +{
Can this only be an internal function? I.e. use libxl__ namespace.
Same comment applies to similar functions.
Wei.
Re: [PATCH v3 2/4] docs: add vscsi to xenstore-paths.markdown
In reply to Wei LiuQuoted 4 lines · Wei Liu
On Fri, Mar 06, 2015 at 10:45:54AM +0100, Olaf Hering wrote:
[...]Quoted 2 lines
#### ~/backend/console/$DOMID/$DEVID/* []
Quoted 8 lines
docs/misc/xenstore-paths.markdown ifb device used by Remus to buffer network output from the associated vif. · line 415
Quoted 6 lines
A PV console backend. Described in [console.txt](console.txt)
docs/misc/xenstore-paths.markdown +1
-0@@ -403,6 +412,7 @@ ifb device used by Remus to buffer network output from the associated vif. [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,vscsiif.h.html^ public,io,vscsiif.h
Thanks, I will fix that.
Olaf
Re: [PATCH v3 3/4] docs: add pvscsi.txt
In reply to Wei LiuQuoted 14 lines · Wei Liu
docs/misc/pvscsi.txt line 19
Quoted 10 lines · Olaf Hering
+== TODO ===
docs/misc/pvscsi.txt new file +9
-0+ +How to do live migration? + - pdev will likely be evaluated again on the target host if it came from + domU.cfg. But what about pdev from 'xl scsi-attach pdev vdev'? Its required + to adjust h:c:t:l on the target host. + +How to handle FIXME in libxl_retrieve_domain_configuration? + - "MERGE(vscsi, vscsis, COMPARE_DEVID, {});", when does this code run? +I don't think this kind of information that relates to libxl internal belongs here.
Its the overall TODO list, it has to go somewhere. And it will be removed once its empty.
Quoted 3 lines
Anyway, to answer you question.
libxl_retrieve_domain_configurationis called by xl when you do migration / detailed domain configuration listing etc.
How can the values diverge? With commands like 'scsi-attach'?
Quoted 2 lines
I think the comment above MERGE macro states what it does and how to use it. Is there anything that's not clear to you?
I think for vscsi it has to compare the vdev h:c:t:l part, just as disk compares xvda. I will look at this once I'm done with libvirt integration.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Wei LiuQuoted 2 lines · Wei Liu
I think you need to fix some overly long lines. I won't mention them individually inline.
Some are just copy&paste from other places. I will check what can be trimmed.
Quoted 3 lines
Regarding all the parsing stuffs, you haven't defined vscsispec so I cannot review it. You might want to look at
docs/misc/xl-disk-configuration.txt.
Its in pvscsi.txt, not complete yet.
Quoted 3 lines
I'm not suggesting you have to write something like that, but considering all the compatibility issues you might have you might actually end up writing up a document like that.
I will check if its needed.
Quoted 3 lines
Then after that, do you consider writing a lexer for vscsispec? We have one for diskspec, see libxlu_disk_l.l. That might result in a shorter patch?
The bulk is not the parser but using the result of the parsing. Or do you spot something that is better done with flex?
Quoted 4 lines · Olaf Hering
Quoted 2 lines
Port pvscsi support from xend to libxl. See pvscsi.txt for details. Outstanding work is listed in the TODO section.
There is no TODO section in this patch. :-)
See the line above, its in pvscsi.txt.
Quoted 4 lines
Better split this patch into two. One for libxl and one for xl.
Or you can even split it into three, one for introducing libxl types, one for implementing functionalities in libxl and one for xl.
Would that actually improve things? In another thread it was suggested to have it all in a single patch to avoid jumping around between mails.
Quoted 5 lines
tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 1985
Quoted 3 lines
tools/libxl/libxl.c +3
-0+void libxl__device_vscsi_add (libxl__egc *egc,uint32_t domid, +libxl_device_vscsi *vscsi, +libxl__ao_device *aodev)You need to update this domain's JSON configuration. Cf.
libxl__device_vtpm_addand friends. Also look atlibxl_internal.hL2310.
So I need to add my function to the comment near DEFINE_DEVICE_ADD()? Or do you mean something else?
Quoted 24 lines
Quoted 13 lines
tools/libxl/libxl.c +13
-0+{ +STATE_AO_GC (aodev->ao); +libxl_ctx *ctx =libxl__gc_owner (gc); +flexarray_t *front; +flexarray_t *back; +libxl__device *device; +char *be_path; +unsigned int be_dirs =0 , rc, i; + +if (vscsi->devid ==-1 ) { + rc =ERROR_FAIL ; + goto out; + }tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 2008
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ +/* Prealloc key+value: 4 toplevel + 4 per device */ + i =2 * (4 + (4 * vscsi->num_vscsi_devs)); + back =flexarray_make (gc, i,1 ); + front =flexarray_make (gc,2 *2 ,1 ); + +GCNEW (device); + rc =libxl__device_from_vscsi (gc, domid, vscsi, device); +if ( rc !=0 ) goto out; +Coding style. No space after ( and before ). You can even just use
Quoted 1 line
if (!rc) goto out;
Copy&paste from some similar code from staging-4.4:libxl__device_vtpm_add
Quoted 9 lines
Quoted 9 lines
tools/libxl/libxl.c +9
-0+/* Check if backend device path is already present */ + be_path =libxl__device_backend_path (gc, device); +if (!libxl__xs_directory (gc,XBT_NULL , be_path, &be_dirs) || !be_dirs) { +/* backend does not exist, create a new one */ +flexarray_append_pair (back,"frontend-id" ,GCSPRINTF ("%d" , domid)); +flexarray_append_pair (back,"online" ,"1" ); +flexarray_append_pair (back,"state" ,"1" ); +flexarray_append_pair (back,"feature-host" ,GCSPRINTF ("%d" , !!vscsi->feature_host)); +
Quoted 8 lines
tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 2024
Quoted 7 lines
tools/libxl/libxl.c +7
-0+flexarray_append_pair (front,"backend-id" ,GCSPRINTF ("%d" , vscsi->backend_domid)); +flexarray_append_pair (front,"state" ,"1" ); + } + +for (i =0 ; i < vscsi->num_vscsi_devs; i++) { +libxl_vscsi_dev *v = vscsi->vscsi_devs + i; +/* Trigger removal, otherwise create new device */ Why do you want to trigger removal in "add" function?
Because the vscsi is a single_host:many_devices, contrary to single_host:singe_device for other backends.
Quoted 1 line
Please avoid using goto to retry transaction.
Just copy&paste from other code, just grep for "retry_transaction".
Quoted 5 lines
tools/libxl/libxl_vscsi.c line 125
Quoted 3 lines
tools/libxl/libxl_vscsi.c new file +3
-0+void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev) +{Can this only be an internal function? I.e. use
libxl__namespace.
Ok, will add the underscore.
Olaf
Re: [PATCH v3 3/4] docs: add pvscsi.txt
In reply to Olaf HeringQuoted 17 lines · Olaf Hering
Quoted 14 lines · Wei Liu
docs/misc/pvscsi.txt line 19
Quoted 10 lines · Olaf Hering
+== TODO ===
docs/misc/pvscsi.txt new file +9
-0+ +How to do live migration? + - pdev will likely be evaluated again on the target host if it came from + domU.cfg. But what about pdev from 'xl scsi-attach pdev vdev'? Its required + to adjust h:c:t:l on the target host. + +How to handle FIXME in libxl_retrieve_domain_configuration? + - "MERGE(vscsi, vscsis, COMPARE_DEVID, {});", when does this code run? +I don't think this kind of information that relates to libxl internal belongs here.
Quoted 9 lines
Its the overall TODO list, it has to go somewhere. And it will be removed once its empty.
Quoted 3 lines
Anyway, to answer you question.
libxl_retrieve_domain_configurationis called by xl when you do migration / detailed domain configuration listing etc.How can the values diverge? With commands like 'scsi-attach'?
Because there are states that are only available in xenstore. We want to reflect that in the retrieved configuration. I think at the moment only disk needs such handling. If you don't think vscsi values can diverge you can just use {}.
Quoted 6 lines
Quoted 2 lines
I think the comment above MERGE macro states what it does and how to use it. Is there anything that's not clear to you?
I think for vscsi it has to compare the vdev h:c:t:l part, just as disk compares xvda. I will look at this once I'm done with libvirt integration.
The point is to identify a device from guest's PoV. h:c:t:l might be good enough.
Wei.
Quoted 2 lines
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Olaf HeringQuoted 18 lines · Olaf Hering
Quoted 2 lines · Wei Liu
I think you need to fix some overly long lines. I won't mention them individually inline.
Some are just copy&paste from other places. I will check what can be trimmed.
Quoted 3 lines
Regarding all the parsing stuffs, you haven't defined vscsispec so I cannot review it. You might want to look at
docs/misc/xl-disk-configuration.txt.Its in pvscsi.txt, not complete yet.
Quoted 3 lines
I'm not suggesting you have to write something like that, but considering all the compatibility issues you might have you might actually end up writing up a document like that.
Quoted 9 lines
I will check if its needed.
Quoted 3 lines
Then after that, do you consider writing a lexer for vscsispec? We have one for diskspec, see libxlu_disk_l.l. That might result in a shorter patch?
The bulk is not the parser but using the result of the parsing. Or do you spot something that is better done with flex?
I didn't look into details. I had the impression that there were lots of manual string parsing.
Quoted 7 lines
Quoted 4 lines · Olaf Hering
Quoted 2 lines
Port pvscsi support from xend to libxl. See pvscsi.txt for details. Outstanding work is listed in the TODO section.
There is no TODO section in this patch. :-)
See the line above, its in pvscsi.txt.
Quoted 7 lines
Quoted 4 lines
Better split this patch into two. One for libxl and one for xl.
Or you can even split it into three, one for introducing libxl types, one for implementing functionalities in libxl and one for xl.
Would that actually improve things? In another thread it was suggested to have it all in a single patch to avoid jumping around between mails.
I think it would, because 1) it only requires me to focus on one specific aspect, 2) it enables we commit work that is ready.
But I don't have very strong opinion on this, so you can keep using one patch.
Quoted 10 lines
Quoted 6 lines
tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 1985
Quoted 4 lines
tools/libxl/libxl.c +3
-0+void libxl__device_vscsi_add (libxl__egc *egc,uint32_t domid, +libxl_device_vscsi *vscsi, +libxl__ao_device *aodev)You need to update this domain's JSON configuration. Cf.
libxl__device_vtpm_addand friends. Also look atlibxl_internal.hL2310.So I need to add my function to the comment near
DEFINE_DEVICE_ADD()? Or do you mean something else?
No. I mean you need to modify this function to comply with locking scheme and update JSON template.
libxl_internal.h documents how this supposes to work. You can use libxl__device_vtpm_add as an example to see how it is actually implemented.
See
2052 if (aodev->update_json) {
2053 lock = libxl__lock_domain_userdata(gc, domid);
2054 if (!lock) {
2055 rc = ERROR_LOCK_FAIL;
2056 goto out;
2057 }
2058
2059 rc = libxl__get_domain_configuration(gc, domid, &d_config);
2060 if (rc) goto out;
2061
2062 DEVICE_ADD(vtpm, vtpms, domid, &vtpm_saved, COMPARE_DEVID, &d_config);
2063 }
2064
That handles JSON template update when you do device hotplug.
Quoted 26 lines
Quoted 24 lines
Quoted 13 lines
tools/libxl/libxl.c +13
-0+{ +STATE_AO_GC (aodev->ao); +libxl_ctx *ctx =libxl__gc_owner (gc); +flexarray_t *front; +flexarray_t *back; +libxl__device *device; +char *be_path; +unsigned int be_dirs =0 , rc, i; + +if (vscsi->devid ==-1 ) { + rc =ERROR_FAIL ; + goto out; + }tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 2008
Quoted 10 lines
tools/libxl/libxl.c +10
-0+ +/* Prealloc key+value: 4 toplevel + 4 per device */ + i =2 * (4 + (4 * vscsi->num_vscsi_devs)); + back =flexarray_make (gc, i,1 ); + front =flexarray_make (gc,2 *2 ,1 ); + +GCNEW (device); + rc =libxl__device_from_vscsi (gc, domid, vscsi, device); +if ( rc !=0 ) goto out; +Coding style. No space after ( and before ). You can even just use
Quoted 1 line
if (!rc) goto out;
Quoted 3 lines
Copy&paste from some similar code from staging-4.4:
libxl__device_vtpm_add
Sorry about the inconsistency in code.
Let's not introduce more code that violates coding style. :-)
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
tools/libxl/libxl.c +9
-0+/* Check if backend device path is already present */ + be_path =libxl__device_backend_path (gc, device); +if (!libxl__xs_directory (gc,XBT_NULL , be_path, &be_dirs) || !be_dirs) { +/* backend does not exist, create a new one */ +flexarray_append_pair (back,"frontend-id" ,GCSPRINTF ("%d" , domid)); +flexarray_append_pair (back,"online" ,"1" ); +flexarray_append_pair (back,"state" ,"1" ); +flexarray_append_pair (back,"feature-host" ,GCSPRINTF ("%d" , !!vscsi->feature_host)); +Quoted 8 lines
tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 2024
Quoted 7 lines
tools/libxl/libxl.c +7
-0+flexarray_append_pair (front,"backend-id" ,GCSPRINTF ("%d" , vscsi->backend_domid)); +flexarray_append_pair (front,"state" ,"1" ); + } + +for (i =0 ; i < vscsi->num_vscsi_devs; i++) { +libxl_vscsi_dev *v = vscsi->vscsi_devs + i; +/* Trigger removal, otherwise create new device */ Why do you want to trigger removal in "add" function?
Quoted 3 lines
Because the vscsi is a single_host:many_devices, contrary to single_host:singe_device for other backends.
I need to do some more research before commenting on this.
Quoted 4 lines
Quoted 1 line
Please avoid using goto to retry transaction.
Just copy&paste from other code, just grep for "
retry_transaction".
New code should use for or while to do this. We would very much like to fix those goto loop but just haven't got there.
Wei.
Quoted 9 lines
Quoted 5 lines
tools/libxl/libxl_vscsi.c line 125
Quoted 3 lines
tools/libxl/libxl_vscsi.c new file +3
-0+void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev) +{Can this only be an internal function? I.e. use
libxl__namespace.Ok, will add the underscore.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Wei LiuQuoted 5 lines · Wei Liu
tools/libxl/libxl.c static int libxl__resolve_domid(libxl__gc *gc, const char *name, · line 1985
Quoted 3 lines
tools/libxl/libxl.c +3
-0+void libxl__device_vscsi_add (libxl__egc *egc,uint32_t domid, +libxl_device_vscsi *vscsi, +libxl__ao_device *aodev)You need to update this domain's JSON configuration. Cf.
libxl__device_vtpm_addand friends. Also look atlibxl_internal.hL2310.
Its not clear to me why every libxl__device_<type>_add copies the passed in libxl_device_<type> into a local named <type>_saved. Why is it not enough to work directly with the input? Its not obvious what the purpose of that copy is, nothing seems to alter the input.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
Quoted 5 lines · Olaf Hering
Quoted 3 lines · Wei Liu
Quoted 3 lines
tools/libxl/libxl.c +3
-0+void libxl__device_vscsi_add (libxl__egc *egc,uint32_t domid, +libxl_device_vscsi *vscsi, +libxl__ao_device *aodev)
Quoted 8 lines
Quoted 2 lines
You need to update this domain's JSON configuration. Cf.
libxl__device_vtpm_addand friends. Also look atlibxl_internal.hL2310.Its not clear to me why every libxl__device_<type>_add copies the passed in libxl_device_<type> into a local named <type>_saved. Why is it not enough to work directly with the input? Its not obvious what the purpose of that copy is, nothing seems to alter the input.
The input might be altered in the hotplug function, see libxl__device_<type>_setdefault functions.
We want to save the original one. However the save need to happen later, so we need to copy the original input and save that copy if necessary.
Wei.
Quoted 1 line
Olaf
Re: [PATCH v3 3/4] docs: add pvscsi.txt
In reply to Olaf HeringQuoted 17 lines · Olaf Hering
Quoted 14 lines · Wei Liu
docs/misc/pvscsi.txt line 19
Quoted 10 lines · Olaf Hering
+== TODO ===
docs/misc/pvscsi.txt new file +9
-0+ +How to do live migration? + - pdev will likely be evaluated again on the target host if it came from + domU.cfg. But what about pdev from 'xl scsi-attach pdev vdev'? Its required + to adjust h:c:t:l on the target host. + +How to handle FIXME in libxl_retrieve_domain_configuration? + - "MERGE(vscsi, vscsis, COMPARE_DEVID, {});", when does this code run? +I don't think this kind of information that relates to libxl internal belongs here.
Quoted 2 lines
Its the overall TODO list, it has to go somewhere. And it will be removed once its empty.
I'm not convinced it needs to go anywhere other than perhaps the cover letter or your own ledger.
There doesn't seem to be very much in this document which actually belongs, almost everything should be somewhere else IMHO.
"== Config Format ==" certainly belongs in xl.cfg(5) and not here as do "== Configuring FOO backend ==" (or perhaps a relevant "host setup" wiki page).
"== Xenstore Format ==" belongs in either docs/misc/xenstore-paths.markdown or (more likely) in vscsiif.h. So does "== Backend - Frontend Protocol ==".
"== Interface in xl ==" belongs in the xl manpages.
"== Interface in libxl ==" is a waste of time as it stands, but if it contained useful information it should go in libxl.h.
"== Interface in libvirt ==" should go in the libvirt docs.
Ian.
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Wei LiuQuoted 5 lines · Wei Liu
tools/libxl/libxl_vscsi.c line 125
Quoted 3 lines
tools/libxl/libxl_vscsi.c new file +3
-0+void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev) +{Can this only be an internal function? I.e. use
libxl__namespace.
And take a libxl__gc *gc not a libxl_ctx, except in very exception circumstances.
Quoted 4 lines
Same comment applies to similar functions.
Wei.
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Olaf Heringtools/libxl/libxl.h
Quoted 4 lines · Olaf Hering
tools/libxl/libxl.h +0
-0
Needs a LIBXL_HAVE define too.
Quoted 20 lines
tools/libxl/libxl.h +16
-0@@ -1224,6 +1224,35 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, libxl_device_channel *channel, libxl_channelinfo *channelinfo); +/* Virtual SCSI */ +int libxl_device_vscsi_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vscsi *vscsi, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vscsi_remove(libxl_ctx *ctx, uint32_t domid, + libxl_device_vscsi *vscsi, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vscsi_destroy(libxl_ctx *ctx, uint32_t domid, + libxl_device_vscsi *vscsi, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; + +libxl_device_vscsi *libxl_device_vscsi_list (libxl_ctx *ctx,uint32_t domid,int *num); +int libxl_device_vscsi_getinfo(libxl_ctx *ctx, + uint32_t domid,
tools/libxl/libxl.h int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, · line 1252
Quoted 10 lines
tools/libxl/libxl.h +9
-0+ libxl_device_vscsi *vscsi_host, + libxl_vscsi_dev *vscsi_dev, + libxl_vscsiinfo *vscsiinfo); +void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev); +int libxl_device_vscsi_get_host (libxl_ctx *ctx, +uint32_t domid, +const char *cfg, +libxl_device_vscsi **vscsi_host);
What do these two non-standard functions do?
In general the caller would be expected to provide a libxl_device_vscsi, which will be filled in, rather than having the function allocate one.
tools/libxl/libxl.h int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, · line 1254
Quoted 3 lines
tools/libxl/libxl.h +3
-0+int libxl_device_vscsi_parse (libxl_ctx *ctx,const char *cfg, +libxl_device_vscsi *vscsi_host, +libxl_vscsi_dev *vscsi_dev);
Like with disk, this is xend/xl specific but might be of use to other toolstacks, therefore it belongs in libxlu not in libxl proper.
(this might apply to get_host too, depending on what it does)
tools/libxl/libxl.h
Quoted 11 lines
tools/libxl/libxl.h +1
-0+/* 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.h +6
-0+int libxl_device_vscsi_parse_pdev (libxl__gc *gc,char *pdev,unsigned int *hst, +unsigned int *chn,unsigned int *tgt, +unsigned int *lun) +{ + +return ERROR_NOPARAVIRT ;
That's a rather odd error code to use here.
(also, unnecessary blank line)
Quoted 5 lines
tools/libxl/libxl_netbsd.c +0
-0
tools/libxl/libxl_netbsd.c libxl_device_model_version libxl__default_device_model(libxl__gc *gc) · line 104
Quoted 10 lines
tools/libxl/libxl_netbsd.c +7
-0@@ -95,3 +95,11 @@ libxl_device_model_version libxl__default_device_model(libxl__gc *gc) {return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL ; } + +int libxl_device_vscsi_parse_pdev (libxl__gc *gc,char *pdev,unsigned int *hst, +unsigned int *chn,unsigned int *tgt, +unsigned int *lun) +{ + +return ERROR_NOPARAVIRT ;
As before.
Quoted 6 lines
tools/libxl/libxl_netbsd.c +1
-0+}tools/libxl/libxl_types.idl +0
-0
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 550
Quoted 9 lines
tools/libxl/libxl_types.idl +6
-0@@ -542,6 +542,37 @@ libxl_device_channel = Struct("device_channel", [ ])), ]) +libxl_vscsi_pdev_type = Enumeration("vscsi_pdev_type", [ + (0, "INVALID"), + (1, "DEV"), + (2, "WWN"), + (3, "HCTL"), + ], init_val = "LIBXL_VSCSI_PDEV_TYPE_INVALID")
You don't need init_val if it happens to be zero.
Quoted 5 lines
tools/libxl/libxl_types.idl +5
-0+ +libxl_vscsi_hctl = Struct("vscsi_hctl", [ + ("hst", uint32), + ("chn", uint32), + ("tgt", uint32),
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 565
Quoted 10 lines
tools/libxl/libxl_types.idl +10
-0+ ("lun", uint32), + ]) + +libxl_vscsi_dev = Struct("vscsi_dev", [ + ("vscsi_dev_id", libxl_devid), + ("remove", bool), + ("p_devname", string), + ("pdev_type", libxl_vscsi_pdev_type), + ("pdev", libxl_vscsi_hctl), + ("vdev", libxl_vscsi_hctl),
Are these last two valid for LIBXL_VSCSI_PDEV_TYPE != HCTL?
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 573
Quoted 8 lines
tools/libxl/libxl_types.idl +8
-0+ ]) + +libxl_device_vscsi = Struct("device_vscsi", [ + ("backend_domid", libxl_domid), + ("devid", libxl_devid), + ("v_hst", uint32), + ("vscsi_devs", Array(libxl_vscsi_dev, "num_vscsi_devs")), + ("feature_host", bool),
What is this feature thing? What does !host imply?
tools/libxl/libxl_vscsi.c
Quoted 5 lines
tools/libxl/libxl_vscsi.c new file +0
-0
Needs a copyright and a license.
Re: [PATCH v3 4/4] libxl: add support for vscsi
Quoted 12 lines · Ian Campbell
tools/libxl/libxl.h int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, · line 1251
Quoted 6 lines · Olaf Hering
tools/libxl/libxl.h +6
-0+void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev); +int libxl_device_vscsi_get_host (libxl_ctx *ctx, +uint32_t domid, +const char *cfg, +libxl_device_vscsi **vscsi_host);What do these two non-standard functions do?
In general the caller would be expected to provide a
libxl_device_vscsi, which will be filled in, rather than having the function allocate one.
Quoted 7 lines
tools/libxl/libxl.h int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, · line 1254
Quoted 3 lines
tools/libxl/libxl.h +3
-0+int libxl_device_vscsi_parse (libxl_ctx *ctx,const char *cfg, +libxl_device_vscsi *vscsi_host, +libxl_vscsi_dev *vscsi_dev);Like with disk, this is xend/xl specific but might be of use to other toolstacks, therefore it belongs in libxlu not in libxl proper. (this might apply to
get_hosttoo, depending on what it does)
libvirt for example will do the very same what xl currently does. But so far I did not get to libvirt yet. The interface is not finished yet.
Last time I looked at libxl vs. libxlu it introduced a circular dependency. Thats why all the simple string parsing is in libxl itself. But I will double check if the current layout allows a split. Basically I tried to simplify things for the caller and have all the functionality in libxl before libxl_device_vscsi is passed to libxl_device_vscsi_{add,remove).
I will address the other comments as well in the next round.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Ian CampbellQuoted 8 lines · Ian Campbell
tools/libxl/libxl.h int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, · line 1251
Quoted 6 lines · Olaf Hering
tools/libxl/libxl.h +6
-0+void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev); +int libxl_device_vscsi_get_host (libxl_ctx *ctx, +uint32_t domid, +const char *cfg, +libxl_device_vscsi **vscsi_host);What do these two non-standard functions do?
append_dev handles the single_host:many_devices layout, append yet another libxl_vscsi_dev to libxl_device_vscsi.
get_host either finds an existing libxl_device_vscsi or creates a new one, to be passed to libxl_device_vscsi_add.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Olaf HeringQuoted 18 lines · Olaf Hering
Quoted 16 lines · Ian Campbell
tools/libxl/libxl.h int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, · line 1251
Quoted 6 lines · Olaf Hering
tools/libxl/libxl.h +6
-0+void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev); +int libxl_device_vscsi_get_host (libxl_ctx *ctx, +uint32_t domid, +const char *cfg, +libxl_device_vscsi **vscsi_host);What do these two non-standard functions do?
In general the caller would be expected to provide a
libxl_device_vscsi, which will be filled in, rather than having the function allocate one.Quoted 3 lines
tools/libxl/libxl.h +3
-0+int libxl_device_vscsi_parse (libxl_ctx *ctx,const char *cfg, +libxl_device_vscsi *vscsi_host, +libxl_vscsi_dev *vscsi_dev);
Quoted 6 lines
Quoted 3 lines
Like with disk, this is xend/xl specific but might be of use to other toolstacks, therefore it belongs in libxlu not in libxl proper. (this might apply to
get_hosttoo, depending on what it does)libvirt for example will do the very same what xl currently does. But so far I did not get to libvirt yet. The interface is not finished yet.
That sort of "libvirt uses some xm/xl style syntax" is exactly why libxlu exists.
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Ian CampbellQuoted 10 lines · Ian Campbell
tools/libxl/libxl.h int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, · line 1251
Quoted 6 lines · Olaf Hering
tools/libxl/libxl.h +6
-0+void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev); +int libxl_device_vscsi_get_host (libxl_ctx *ctx, +uint32_t domid, +const char *cfg, +libxl_device_vscsi **vscsi_host);What do these two non-standard functions do?
In general the caller would be expected to provide alibxl_device_vscsi, which will be filled in, rather than having the function allocate one.
Is it OK if the caller allocates libxl_device_vscsi, but libxl does further allocations for the number of libxl_vscsi_dev?
Related: I see libxl_device_vscsi_dispose does now a pointer check, so I assume its required to validate input in libxl_device_vscsi_get_host.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Ian CampbellQuoted 10 lines · Ian Campbell
tools/libxl/libxl_freebsd.c libxl_device_model_version libxl__default_device_model(libxl__gc *gc) · line 140
Quoted 6 lines · Olaf Hering
tools/libxl/libxl_freebsd.c +6
-0+int libxl_device_vscsi_parse_pdev (libxl__gc *gc,char *pdev,unsigned int *hst, +unsigned int *chn,unsigned int *tgt, +unsigned int *lun) +{ + +return ERROR_NOPARAVIRT ;That's a rather odd error code to use here.
(also, unnecessary blank line)
What error should be returned?
Looks like this function can be moved to xlu. Should I introduce a libxlu_$(OS).c or just use #ifdef in libxlu_vscsi.c?
Quoted 8 lines
Quoted 8 lines
tools/libxl/libxl_types.idl +8
-0+libxl_vscsi_hctl = Struct("vscsi_hctl", [ + ("hst", uint32), + ("chn", uint32), + ("tgt", uint32), + ("lun", uint32), + ]) + +libxl_vscsi_dev = Struct("vscsi_dev", [
Quoted 8 lines
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 565
Quoted 6 lines
tools/libxl/libxl_types.idl +6
-0+ ("vscsi_dev_id", libxl_devid), + ("remove", bool), + ("p_devname", string), + ("pdev_type", libxl_vscsi_pdev_type), + ("pdev", libxl_vscsi_hctl), + ("vdev", libxl_vscsi_hctl),Are these last two valid for
LIBXL_VSCSI_PDEV_TYPE!= HCTL?
At least for vdev, which is always in HCTL format.
pdev is kind of orphan in case of LIBXL_VSCSI_PDEV_TYPE_WWN. The code records pdev.lun somewhere, just in case. But in the end the LUN is already part of the cfg string so nothing needs to make use of pdev anymore.
Quoted 10 lines
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 573
Quoted 8 lines
tools/libxl/libxl_types.idl +8
-0+ ]) + +libxl_device_vscsi = Struct("device_vscsi", [ + ("backend_domid", libxl_domid), + ("devid", libxl_devid), + ("v_hst", uint32), + ("vscsi_devs", Array(libxl_vscsi_dev, "num_vscsi_devs")), + ("feature_host", bool),What is this feature thing? What does !host imply?
This enables raw SCSI command passthrough in xenlinux. If the flag is off then each command is checked. The check allows many commands to passthrough, one command needs emulation and unhandled commands are rejected. The flag is a noop in pvops because it doesnt look at such flag. I was told its not required, dont know the details.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
Quoted 11 lines · Olaf Hering
Quoted 9 lines · Ian Campbell
tools/libxl/libxl_freebsd.c libxl_device_model_version libxl__default_device_model(libxl__gc *gc) · line 140
Quoted 6 lines · Olaf Hering
tools/libxl/libxl_freebsd.c +6
-0+int libxl_device_vscsi_parse_pdev (libxl__gc *gc,char *pdev,unsigned int *hst, +unsigned int *chn,unsigned int *tgt, +unsigned int *lun) +{ + +return ERROR_NOPARAVIRT ;That's a rather odd error code to use here.
Quoted 3 lines
Quoted 1 line
(also, unnecessary blank line)
What error should be returned?
Take a look at the list and find one that fits, or look at other similar stub functions. If there is no suitable existing error code then feel free to add one.
Quoted 2 lines
Looks like this function can be moved to xlu. Should I introduce a libxlu_$(OS).c or just use #ifdef in
libxlu_vscsi.c?
I think we could live with either.
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
tools/libxl/libxl_types.idl +8
-0+libxl_vscsi_hctl = Struct("vscsi_hctl", [ + ("hst", uint32), + ("chn", uint32), + ("tgt", uint32), + ("lun", uint32), + ]) + +libxl_vscsi_dev = Struct("vscsi_dev", [Quoted 8 lines
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 565
Quoted 6 lines
tools/libxl/libxl_types.idl +6
-0+ ("vscsi_dev_id", libxl_devid), + ("remove", bool), + ("p_devname", string), + ("pdev_type", libxl_vscsi_pdev_type), + ("pdev", libxl_vscsi_hctl), + ("vdev", libxl_vscsi_hctl),Are these last two valid for
LIBXL_VSCSI_PDEV_TYPE!= HCTL?
Quoted 6 lines
At least for vdev, which is always in HCTL format.
pdev is kind of orphan in case of
LIBXL_VSCSI_PDEV_TYPE_WWN. The code records pdev.lun somewhere, just in case. But in the end the LUN is already part of the cfg string so nothing needs to make use of pdev anymore.
Perhaps pdev should be in the !WWN part of a KeyedUnion then?
Quoted 12 lines
Quoted 11 lines
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 573
Quoted 9 lines
tools/libxl/libxl_types.idl +8
-0+ ]) + +libxl_device_vscsi = Struct("device_vscsi", [ + ("backend_domid", libxl_domid), + ("devid", libxl_devid), + ("v_hst", uint32), + ("vscsi_devs", Array(libxl_vscsi_dev, "num_vscsi_devs")), + ("feature_host", bool),What is this feature thing? What does !host imply?
Quoted 5 lines
This enables raw SCSI command passthrough in xenlinux. If the flag is off then each command is checked. The check allows many commands to passthrough, one command needs emulation and unhandled commands are rejected. The flag is a noop in pvops because it doesnt look at such flag. I was told its not required, dont know the details.
Sounds like it at the very least needs a better name.
But if you don't really know what a thing is for or what the details are then it would probably be best just to leave it out until someone who does know comes along with a followup patch.
Ian.
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Olaf HeringQuoted 13 lines · Olaf Hering
Quoted 10 lines · Ian Campbell
tools/libxl/libxl.h int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, · line 1251
Quoted 6 lines · Olaf Hering
tools/libxl/libxl.h +6
-0+void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev); +int libxl_device_vscsi_get_host (libxl_ctx *ctx, +uint32_t domid, +const char *cfg, +libxl_device_vscsi **vscsi_host);What do these two non-standard functions do?
In general the caller would be expected to provide alibxl_device_vscsi, which will be filled in, rather than having the function allocate one.
Quoted 2 lines
Is it OK if the caller allocates
libxl_device_vscsi, but libxl does further allocations for the number oflibxl_vscsi_dev?
Yes, we do that a lot.
See also the comment about memory allocation in libxl.h
Quoted 2 lines
Related: I see
libxl_device_vscsi_disposedoes now a pointer check, so I assume its required to validate input inlibxl_device_vscsi_get_host.
Not sure what you mean, you should call libxl_device_vcsci_init before using the object and then _dispose when you are done.
Ian.
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Ian CampbellQuoted 11 lines · Ian Campbell
Quoted 10 lines · Olaf Hering
Quoted 8 lines · Ian Campbell
tools/libxl/libxl_freebsd.c libxl_device_model_version libxl__default_device_model(libxl__gc *gc) · line 140
Quoted 6 lines · Olaf Hering
tools/libxl/libxl_freebsd.c +6
-0+int libxl_device_vscsi_parse_pdev (libxl__gc *gc,char *pdev,unsigned int *hst, +unsigned int *chn,unsigned int *tgt, +unsigned int *lun) +{ + +return ERROR_NOPARAVIRT ;That's a rather odd error code to use here.
Quoted 4 lines
Quoted 1 line
What error should be returned?
Take a look at the list and find one that fits, or look at other similar stub functions. If there is no suitable existing error code then feel free to add one.
NOPARAVIRT looked like a perfect fit, there are no PV drivers for BSD. I will use something else then.
Quoted 3 lines
Quoted 2 lines
Looks like this function can be moved to xlu. Should I introduce a libxlu_$(OS).c or just use #ifdef in
libxlu_vscsi.c?I think we could live with either.
Ok, will check what looks best, and where to bail out if vscsi= is used on BSD.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 565
Quoted 13 lines
tools/libxl/libxl_types.idl +13
-0+libxl_vscsi_hctl = Struct("vscsi_hctl", [ + ("hst", uint32), + ("chn", uint32), + ("tgt", uint32), + ("lun", uint32), + ]) +libxl_vscsi_dev = Struct("vscsi_dev", [ + ("vscsi_dev_id", libxl_devid), + ("remove", bool), + ("p_devname", string), + ("pdev_type", libxl_vscsi_pdev_type), + ("pdev", libxl_vscsi_hctl), + ("vdev", libxl_vscsi_hctl),Are these last two valid for
LIBXL_VSCSI_PDEV_TYPE!= HCTL?
Quoted 6 lines
Quoted 5 lines
At least for vdev, which is always in HCTL format.
pdev is kind of orphan in case ofLIBXL_VSCSI_PDEV_TYPE_WWN. The code records pdev.lun somewhere, just in case. But in the end the LUN is already part of the cfg string so nothing needs to make use of pdev anymore.Perhaps pdev should be in the !WWN part of a KeyedUnion then?
Its not clear to me how a Union would look like. I will study the other usages. From a quick look the layout may look like:
DEV { pdev, vdev }
WWN { string, vdev }
HCTL { pdev, vdev }
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 573
Quoted 8 lines
tools/libxl/libxl_types.idl +8
-0+ ]) + +libxl_device_vscsi = Struct("device_vscsi", [ + ("backend_domid", libxl_domid), + ("devid", libxl_devid), + ("v_hst", uint32), + ("vscsi_devs", Array(libxl_vscsi_dev, "num_vscsi_devs")), + ("feature_host", bool),What is this feature thing? What does !host imply?
Quoted 6 lines
Quoted 5 lines
This enables raw SCSI command passthrough in xenlinux. If the flag is off then each command is checked. The check allows many commands to passthrough, one command needs emulation and unhandled commands are rejected. The flag is a noop in pvops because it doesnt look at such flag. I was told its not required, dont know the details.
Sounds like it at the very least needs a better name.
Ok, will rename it to feature_noemul or feature_xenlinux_raw_scsicmd or whatever.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Ian CampbellQuoted 5 lines · Ian Campbell
Quoted 2 lines · Olaf Hering
Related: I see
libxl_device_vscsi_disposedoes now a pointer check, so I assume its required to validate input inlibxl_device_vscsi_get_host.Not sure what you mean, you should call
libxl_device_vcsci_initbefore using the object and then_disposewhen you are done.
I mean NULL pointer checks, will do that for at least *vscsi_host.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Ian CampbellQuoted 18 lines · Ian Campbell
Quoted 17 lines · Olaf Hering
Quoted 15 lines · Ian Campbell
tools/libxl/libxl.h int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, · line 1251
Quoted 6 lines · Olaf Hering
tools/libxl/libxl.h +6
-0+void libxl_device_vscsi_append_dev (libxl_ctx *ctx,libxl_device_vscsi *hst, +libxl_vscsi_dev *dev); +int libxl_device_vscsi_get_host (libxl_ctx *ctx, +uint32_t domid, +const char *cfg, +libxl_device_vscsi **vscsi_host);What do these two non-standard functions do?
In general the caller would be expected to provide a
libxl_device_vscsi, which will be filled in, rather than having the function allocate one.Quoted 3 lines
tools/libxl/libxl.h +3
-0+int libxl_device_vscsi_parse (libxl_ctx *ctx,const char *cfg, +libxl_device_vscsi *vscsi_host, +libxl_vscsi_dev *vscsi_dev);
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Like with disk, this is xend/xl specific but might be of use to other toolstacks, therefore it belongs in libxlu not in libxl proper. (this might apply to
get_hosttoo, depending on what it does)libvirt for example will do the very same what xl currently does. But so far I did not get to libvirt yet. The interface is not finished yet.
That sort of "libvirt uses some xm/xl style syntax" is exactly why libxlu exists.
I moved these functions to libxlu now. The only function called by libxl and libxlu was libxl__device_vscsi_parse_hctl. I just duplicated that function and made it static in their source files for the time being.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Olaf HeringQuoted 13 lines · Olaf Hering
Quoted 11 lines · Ian Campbell
Quoted 10 lines · Olaf Hering
Quoted 8 lines · Ian Campbell
tools/libxl/libxl_freebsd.c libxl_device_model_version libxl__default_device_model(libxl__gc *gc) · line 140
Quoted 6 lines · Olaf Hering
tools/libxl/libxl_freebsd.c +6
-0+int libxl_device_vscsi_parse_pdev (libxl__gc *gc,char *pdev,unsigned int *hst, +unsigned int *chn,unsigned int *tgt, +unsigned int *lun) +{ + +return ERROR_NOPARAVIRT ;That's a rather odd error code to use here.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
What error should be returned?
Take a look at the list and find one that fits, or look at other similar stub functions. If there is no suitable existing error code then feel free to add one.
NOPARAVIRT looked like a perfect fit, there are no PV drivers for BSD.
Which has no impact on the ability to parse a pdev or not.
(Also this error code is used when it is not possible to speak the pv control protocol, but you weren't to know that)
Quoted 1 line
I will use something else then.
Thanks.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
tools/libxl/libxl_types.idl +6
-0+libxl_vscsi_hctl = Struct("vscsi_hctl", [ + ("hst", uint32), + ("chn", uint32), + ("tgt", uint32), + ("lun", uint32), + ])Quoted 8 lines
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 565
Quoted 7 lines
tools/libxl/libxl_types.idl +7
-0+libxl_vscsi_dev = Struct("vscsi_dev", [ + ("vscsi_dev_id", libxl_devid), + ("remove", bool), + ("p_devname", string), + ("pdev_type", libxl_vscsi_pdev_type), + ("pdev", libxl_vscsi_hctl), + ("vdev", libxl_vscsi_hctl),Are these last two valid for
LIBXL_VSCSI_PDEV_TYPE!= HCTL?At least for vdev, which is always in HCTL format.
pdev is kind of orphan in case ofLIBXL_VSCSI_PDEV_TYPE_WWN. The code records pdev.lun somewhere, just in case. But in the end the LUN is already part of the cfg string so nothing needs to make use of pdev anymore.
Quoted 8 lines
Quoted 1 line
Perhaps pdev should be in the !WWN part of a KeyedUnion then?
Its not clear to me how a Union would look like. I will study the other usages. From a quick look the layout may look like:
DEV { pdev, vdev }
WWN { string, vdev }
HCTL { pdev, vdev }
I don't think vdev should be in the union.
I don't know what the keys are so I can't comment on what should be in them.
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 10 lines
tools/libxl/libxl_types.idl libxl_device_channel = Struct("device_channel", [ · line 573
Quoted 9 lines
tools/libxl/libxl_types.idl +8
-0+ ]) + +libxl_device_vscsi = Struct("device_vscsi", [ + ("backend_domid", libxl_domid), + ("devid", libxl_devid), + ("v_hst", uint32), + ("vscsi_devs", Array(libxl_vscsi_dev, "num_vscsi_devs")), + ("feature_host", bool),What is this feature thing? What does !host imply?
This enables raw SCSI command passthrough in xenlinux. If the flag is off then each command is checked. The check allows many commands to passthrough, one command needs emulation and unhandled commands are rejected. The flag is a noop in pvops because it doesnt look at such flag. I was told its not required, dont know the details.
Quoted 4 lines
Quoted 1 line
Sounds like it at the very least needs a better name.
Ok, will rename it to
feature_noemulorfeature_xenlinux_raw_scsicmdor whatever.
Neither of those appear to be a good description of what you say quoted above.
It sounds somewhat analogous to the pciback permissive mode, but I don't know that for sure.
Also, should this be a defbool or not?
Ian.
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Olaf HeringQuoted 10 lines · Olaf Hering
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Olaf Hering
Related: I see
libxl_device_vscsi_disposedoes now a pointer check, so I assume its required to validate input inlibxl_device_vscsi_get_host.Not sure what you mean, you should call
libxl_device_vcsci_initbefore using the object and then_disposewhen you are done.I mean NULL pointer checks, will do that for at least
*vscsi_host.
That is only to make _dispose function NULL-tolerant. Why does that affect your implementation?
Wei.
Quoted 1 line
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
Quoted 6 lines · Wei Liu
Quoted 5 lines · Olaf Hering
Quoted 3 lines · Ian Campbell
Quoted 2 lines · Olaf Hering
Related: I see
libxl_device_vscsi_disposedoes now a pointer check, so I assume its required to validate input inlibxl_device_vscsi_get_host.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Not sure what you mean, you should call
libxl_device_vcsci_initbefore using the object and then_disposewhen you are done.I mean NULL pointer checks, will do that for at least
*vscsi_host.That is only to make
_disposefunction NULL-tolerant. Why does that affect your implementation?
I have not checked other code pats in libxl, but does libxl expect valid input? At least glibc for example expects valid input, str*(NULL) crashes.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
Quoted 11 lines · Olaf Hering
Quoted 9 lines · Wei Liu
Quoted 8 lines · Olaf Hering
Quoted 5 lines · Ian Campbell
Quoted 2 lines · Olaf Hering
Related: I see
libxl_device_vscsi_disposedoes now a pointer check, so I assume its required to validate input inlibxl_device_vscsi_get_host.Not sure what you mean, you should call
libxl_device_vcsci_initbefore using the object and then_disposewhen you are done.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
I mean NULL pointer checks, will do that for at least
*vscsi_host.That is only to make
_disposefunction NULL-tolerant. Why does that affect your implementation?I have not checked other code pats in libxl, but does libxl expect valid input? At least glibc for example expects valid input, str*(NULL) crashes.
At the very least that's not the reason _dispose checks for NULL. Dispose function checks for NULL so that you don't need to do the extra check in caller like "if(xx) _dispose(xx);"
Most if not all libxl APIs assume that the input is valid, because following our paradigm, you must call _init function before using a type. At the point you pass a type to libxl functions it should already be initialised (which means it is valid).
Wei.
Quoted 1 line
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
In reply to Ian CampbellQuoted 8 lines · Ian Campbell
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines · Olaf Hering
Quoted 1 line
+ ("
feature_host", bool),What is this feature thing? What does !host imply?
This enables raw SCSI command passthrough in xenlinux. If the flag is off then each command is checked. The check allows many commands to passthrough, one command needs emulation and unhandled commands are rejected. The flag is a noop in pvops because it doesnt look at such flag. I was told its not required, dont know the details.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Sounds like it at the very least needs a better name.
Ok, will rename it to
feature_noemulorfeature_xenlinux_raw_scsicmdor whatever.Neither of those appear to be a good description of what you say quoted above.
Ian, after some thought its not clear to me why the name "feature_host" should be changed. The config option is "feature-host", the backend expects a property named "feature-host". So it seems natural to also name the variable that way. In the end it just passes a boolean from the config to xenstore, nothing else is done with it.
Quoted 1 line
Also, should this be a defbool or not?
This is a good idea. I remmeber xend had code to make sure that all devices within a vhost had the same value for "feature-host". I think the intention was that whole physical hosts are passed to a domU. A defbool makes it easier to preserve the initial value based on the first config item.
Olaf
Re: [PATCH v3 4/4] libxl: add support for vscsi
Quoted 13 lines · Olaf Hering
Quoted 11 lines · Ian Campbell
Quoted 11 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines · Olaf Hering
Quoted 1 line
+ ("
feature_host", bool),What is this feature thing? What does !host imply?
This enables raw SCSI command passthrough in xenlinux. If the flag is off then each command is checked. The check allows many commands to passthrough, one command needs emulation and unhandled commands are rejected. The flag is a noop in pvops because it doesnt look at such flag. I was told its not required, dont know the details.
Sounds like it at the very least needs a better name.
Ok, will rename it to
feature_noemulorfeature_xenlinux_raw_scsicmdor whatever.
Quoted 8 lines
Quoted 2 lines
Neither of those appear to be a good description of what you say quoted above.
Ian, after some thought its not clear to me why the name "
feature_host" should be changed. The config option is "feature-host", the backend expects a property named "feature-host". So it seems natural to also name the variable that way. In the end it just passes a boolean from the config to xenstore, nothing else is done with it.
Regardless of the current internal details feature_host gives me no clue at all what the flag does, and this is a public facing API.
If not a better name then some docs (or a pointer to them) would help.
Quoted 7 lines
Quoted 1 line
Also, should this be a defbool or not?
This is a good idea. I remmeber xend had code to make sure that all devices within a vhost had the same value for "feature-host". I think the intention was that whole physical hosts are passed to a domU. A defbool makes it easier to preserve the initial value based on the first config item.
In which case it sounds to me like this flag should be at a per-vhost level and not at a per device level.
Ian.
Re: [PATCH v3 4/4] libxl: add support for vscsi
Quoted 11 lines · Ian Campbell
Quoted 7 lines · Olaf Hering
Quoted 1 line · Ian Campbell
Also, should this be a defbool or not?
This is a good idea. I remmeber xend had code to make sure that all devices within a vhost had the same value for "feature-host". I think the intention was that whole physical hosts are passed to a domU. A defbool makes it easier to preserve the initial value based on the first config item.
In which case it sounds to me like this flag should be at a per-vhost level and not at a per device level.
Its per vhost already, "libxl_device_vscsi" refers to the virtual scsi host, and "libxl_vscsi_dev" refers to a device connected to that host. Perhaps the latter needs a better name to make the difference more obvious.
Olaf
wating for backend changes (was Re: [PATCH v3 4/4] libxl: add support for vscsi)
In reply to Olaf HeringHow is new code supposed to wait for backend changes?
Right now there are two APIs for that:
- libxl__wait_for_backend loops for a while until it returns an error.
- libxl__ev_devstate_wait registers a watch and a timer.
In case of pvscsi there are three variants:
- new, can use libxl__wait_device_connection
- reconfigure, can use both of the above
- remove, may use DEFINE_DEVICE_REMOVE and its
libxl__initiate_device_remove
The reconfigure case has to wait for various states, depending on the state before the reconfiguration.
The pci code in libxl uses just libxl__wait_for_backend. Looking through the history it seems the function was added just for pci. Is it a deprecated function, should callers get converted to libxl__ev_devstate_wait?
Olaf
Quoted 146 lines · Olaf Hering
tools/libxl/libxl.c +146
-0+void libxl__device_vscsi_add (libxl__egc *egc,uint32_t domid, +libxl_device_vscsi *vscsi, +libxl__ao_device *aodev) +{ +STATE_AO_GC (aodev->ao); +libxl_ctx *ctx =libxl__gc_owner (gc); +flexarray_t *front; +flexarray_t *back; +libxl__device *device; +char *be_path; +unsigned int be_dirs =0 , rc, i; + +if (vscsi->devid ==-1 ) { + rc =ERROR_FAIL ; + goto out; + } + +/* Prealloc key+value: 4 toplevel + 4 per device */ + i =2 * (4 + (4 * vscsi->num_vscsi_devs)); + back =flexarray_make (gc, i,1 ); + front =flexarray_make (gc,2 *2 ,1 ); + +GCNEW (device); + rc =libxl__device_from_vscsi (gc, domid, vscsi, device); +if ( rc !=0 ) goto out; + +/* Check if backend device path is already present */ + be_path =libxl__device_backend_path (gc, device); +if (!libxl__xs_directory (gc,XBT_NULL , be_path, &be_dirs) || !be_dirs) { +/* backend does not exist, create a new one */ +flexarray_append_pair (back,"frontend-id" ,GCSPRINTF ("%d" , domid)); +flexarray_append_pair (back,"online" ,"1" ); +flexarray_append_pair (back,"state" ,"1" ); +flexarray_append_pair (back,"feature-host" ,GCSPRINTF ("%d" , !!vscsi->feature_host)); + +flexarray_append_pair (front,"backend-id" ,GCSPRINTF ("%d" , vscsi->backend_domid)); +flexarray_append_pair (front,"state" ,"1" ); + } + +for (i =0 ; i < vscsi->num_vscsi_devs; i++) { +libxl_vscsi_dev *v = vscsi->vscsi_devs + i; +/* Trigger removal, otherwise create new device */ +if (be_dirs) { +unsigned int nb =0 ; +/* Preserve existing device */ +if (libxl__xs_directory (gc,XBT_NULL ,GCSPRINTF ("%s/vscsi-devs/dev-%u" , be_path, v->vscsi_dev_id), &nb) && nb) { +/* Trigger device removal by forwarding state to XenbusStateClosing */ +if (v->remove) +flexarray_append_pair (back,GCSPRINTF ("vscsi-devs/dev-%u/state" , v->vscsi_dev_id),"5" ); +continue ; + } + } +flexarray_append_pair (back,GCSPRINTF ("vscsi-devs/dev-%u/p-devname" , v->vscsi_dev_id), v->p_devname); +switch (v->pdev_type) { +case LIBXL_VSCSI_PDEV_TYPE_WWN : +flexarray_append_pair (back, +GCSPRINTF ("vscsi-devs/dev-%u/p-dev" , v->vscsi_dev_id), + v->p_devname); +break ; +case LIBXL_VSCSI_PDEV_TYPE_DEV : +case LIBXL_VSCSI_PDEV_TYPE_HCTL : +flexarray_append_pair (back, +GCSPRINTF ("vscsi-devs/dev-%u/p-dev" , v->vscsi_dev_id), +GCSPRINTF ("%u:%u:%u:%u" , v->pdev.hst, v->pdev.chn, v->pdev.tgt, v->pdev.lun)); +break ; +case LIBXL_VSCSI_PDEV_TYPE_INVALID : +default : + rc =ERROR_FAIL ; + goto out; + } +flexarray_append_pair (back,GCSPRINTF ("vscsi-devs/dev-%u/v-dev" , v->vscsi_dev_id), +GCSPRINTF ("%u:%u:%u:%u" , v->vdev.hst, v->vdev.chn, v->vdev.tgt, v->vdev.lun)); +flexarray_append_pair (back,GCSPRINTF ("vscsi-devs/dev-%u/state" , v->vscsi_dev_id),"1" ); + } + + aodev->dev = device; +/* Either create new host or reconfigure existing host */ +if (be_dirs ==0 ) { +libxl__device_generic_add (gc,XBT_NULL , device, +libxl__xs_kvs_of_flexarray (gc, back, back->count), +libxl__xs_kvs_of_flexarray (gc, front, front->count), +NULL ); + aodev->action =LIBXL__DEVICE_ACTION_ADD ; +libxl__wait_device_connection (egc, aodev); + rc =0 ; +/* Done with new host */ + goto out; + } + +/* Only new devices, write them and do vscsi host reconfiguration */ +xs_transaction_t t; +retry_transaction: + t =xs_transaction_start (ctx->xsh); +libxl__xs_writev (gc, t, be_path, +libxl__xs_kvs_of_flexarray (gc, back, back->count)); +xs_write (ctx->xsh, t,GCSPRINTF ("%s/state" , be_path),"7" ,2 ); +if (!xs_transaction_end (ctx->xsh, t,0 )) { +if (errno ==EAGAIN ) + goto retry_transaction; +LOGE (ERROR ,"xs transaction failed" ); + rc =ERROR_FAIL ; + goto out; + } +libxl__wait_for_backend (gc, be_path,"4" ); + +retry_transaction2: + t =xs_transaction_start (ctx->xsh); +for (i =0 ; i < vscsi->num_vscsi_devs; i++) { +libxl_vscsi_dev *v = vscsi->vscsi_devs + i; +if (v->remove) { +char *path, *val; + path =GCSPRINTF ("%s/vscsi-devs/dev-%u/state" , be_path, v->vscsi_dev_id); + val =libxl__xs_read (gc, t, path); +if (val &&strcmp (val,"6" ) ==0 ) { + path =GCSPRINTF ("%s/vscsi-devs/dev-%u/state" , be_path, v->vscsi_dev_id); +xs_rm (ctx->xsh, t, path); + path =GCSPRINTF ("%s/vscsi-devs/dev-%u/p-devname" , be_path, v->vscsi_dev_id); +xs_rm (ctx->xsh, t, path); + path =GCSPRINTF ("%s/vscsi-devs/dev-%u/p-dev" , be_path, v->vscsi_dev_id); +xs_rm (ctx->xsh, t, path); + path =GCSPRINTF ("%s/vscsi-devs/dev-%u/v-dev" , be_path, v->vscsi_dev_id); +xs_rm (ctx->xsh, t, path); + path =GCSPRINTF ("%s/vscsi-devs/dev-%u" , be_path, v->vscsi_dev_id); +xs_rm (ctx->xsh, t, path); + }else { +LOGE (ERROR ,"%s: %s has %s, expected 6" , __func__, path, val); + } + } + } + +if (!xs_transaction_end (ctx->xsh, t,0 )) { +if (errno ==EAGAIN ) + goto retry_transaction2; +LOGE (ERROR ,"xs transaction failed" ); + rc =ERROR_FAIL ; + goto out; + } +/* As we are not adding new device, skip waiting for it */ +libxl__ao_complete (egc, aodev->ao,0 ); + + rc =0 ; +out: + aodev->rc = rc; +if (rc) aodev->callback (egc, aodev); +return ; +}
Re: wating for backend changes (was Re: [PATCH v3 4/4] libxl: add support for vscsi)
Quoted 7 lines · Olaf Hering
How is new code supposed to wait for backend changes?
Right now there are two APIs for that:
-libxl__wait_for_backendloops for a while until it returns an error.
-libxl__ev_devstate_waitregisters a watch and a timer.
Quoted 8 lines
In case of pvscsi there are three variants:
- new, can uselibxl__wait_device_connection
- reconfigure, can use both of the above
- remove, may useDEFINE_DEVICE_REMOVEand its
libxl__initiate_device_removeThe reconfigure case has to wait for various states, depending on the state before the reconfiguration.
For the time being I used also polling via libxl__wait_for_backend. Doing event driven reconfigure can be implemented, but only with quite some effort.
Olaf
wating for backend changes (was Re: [PATCH v3 4/4] libxl: add support for vscsi)
In reply to Olaf HeringOlaf Hering writes ("wating for backend changes (was Re: [PATCH v3 4/4] libxl: add support for vscsi)"):
Quoted 4 lines
How is new code supposed to wait for backend changes?
Right now there are two APIs for that:
-libxl__wait_for_backendloops for a while until it returns an error.
This is deprecated. I seem to remember I wrote a patch to clarify the internal docs but it seems to be languishing in one of my outstanding series.
Quoted 1 line
-
libxl__ev_devstate_waitregisters a watch and a timer.
New code should use this.
Quoted 5 lines
In case of pvscsi there are three variants:
- new, can uselibxl__wait_device_connection
- reconfigure, can use both of the above
- remove, may useDEFINE_DEVICE_REMOVEand its
libxl__initiate_device_remove
...
Quoted 4 lines
The pci code in libxl uses just
libxl__wait_for_backend. Looking through the history it seems the function was added just for pci. Is it a deprecated function, should callers get converted tolibxl__ev_devstate_wait?
Ideally, yes.
Thanks,
Ian.