From: Steven Haigh Subject: Re: block-iscsi with Xen 4.5 / 4.6 Date: Wed, 4 May 2016 20:18:18 +1000 Message-ID: <5729CC6A.7040506@crc.id.au> References: <20160415074557.5jc6ra5cfh7lddni@mac> <20160415080354.3iw3g6f4qcbpmvoi@mac> <1aa4407c83225184e49138e4500246de@crc.id.au> <20160415090104.7flxu2jptoj6p4z2@mac> <5729834F.9050306@crc.id.au> <20160504073432.fpcporcbk4nwkzpa@mac> <5729B5B6.5030908@crc.id.au> <20160504093723.jtdxg25hmglyd4m6@mac> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6317501920010666485==" Return-path: Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axtt3-0006XD-JG for xen-devel@lists.xenproject.org; Wed, 04 May 2016 10:18:33 +0000 In-Reply-To: <20160504093723.jtdxg25hmglyd4m6@mac> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============6317501920010666485== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TePQ97UNjrSq2bWgsSfRUGWveboA3EKuA" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --TePQ97UNjrSq2bWgsSfRUGWveboA3EKuA Content-Type: multipart/mixed; boundary="MLoExiaBEnhFCAKoOlfuU2iqJhQVno21n" From: Steven Haigh To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Cc: xen-devel@lists.xenproject.org Message-ID: <5729CC6A.7040506@crc.id.au> Subject: Re: block-iscsi with Xen 4.5 / 4.6 References: <20160415074557.5jc6ra5cfh7lddni@mac> <20160415080354.3iw3g6f4qcbpmvoi@mac> <1aa4407c83225184e49138e4500246de@crc.id.au> <20160415090104.7flxu2jptoj6p4z2@mac> <5729834F.9050306@crc.id.au> <20160504073432.fpcporcbk4nwkzpa@mac> <5729B5B6.5030908@crc.id.au> <20160504093723.jtdxg25hmglyd4m6@mac> In-Reply-To: <20160504093723.jtdxg25hmglyd4m6@mac> --MLoExiaBEnhFCAKoOlfuU2iqJhQVno21n Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 4/05/2016 7:37 PM, Roger Pau Monn=C3=A9 wrote: > On Wed, May 04, 2016 at 06:41:26PM +1000, Steven Haigh wrote: >> On 4/05/2016 5:34 PM, Roger Pau Monn=C3=A9 wrote: >>> On Wed, May 04, 2016 at 03:06:23PM +1000, Steven Haigh wrote: >>> It is important for us to use the '-e' in order to make sure all the = failure=20 >>> points are correctly handled, without the '-e' some command might fai= l and=20 >>> the script wouldn't realize. >> >> I honestly think this is pretty nasty. While it may not be true of all= >> scripts, the block-iscsi script can only really fail in a couple of >> places - yet we have this set of procedures called: >> >> parse_target -> check_tools -> prepare -> add -> attach -> find_device= >> -> write_dev. >> >> At least check_tools, prepare, add, attach, find_device could all be >> rolled into a single function - as the majority of the rest is 1-4 lin= es >> of code. >=20 > No, check_tools is used by both the attach and the detach path, so it c= annot=20 > be rolled into a single function together with the other ones, and the = same=20 > applies to mostly all other functions (find_device is also shared betwe= en=20 > the add and remove functions). >=20 > IMHO, I think the current code is fine because each function has a smal= l=20 > logical task to accomplish, so it's easy to make sure each function doe= s=20 > what it's supposed to do, nothing more and nothing less. Batching every= thing=20 > into one big function would make this harder. >=20 > That doesn't mean that I'm not open to improving it, so if you think it= =20 > would be better/easier using some other logical organization patches ar= e=20 > welcome :). Right now, my changes are here: http://paste.fedoraproject.org/362462/62356799/ It works perfectly well if you're the ONLY device connecting to the specified iSCSI target, but falls apart when something else has the lock and doesn't clean up after itself. =46rom using set -x in there, I can see this when it runs: ++ dirname /etc/xen/scripts/block-iscsi-lock + dir=3D/etc/xen/scripts + . /etc/xen/scripts/block-common.sh +++ dirname /etc/xen/scripts/block-iscsi-lock ++ dir=3D/etc/xen/scripts ++ . /etc/xen/scripts/xen-hotplug-common.sh ++++ dirname /etc/xen/scripts/block-iscsi-lock +++ dir=3D/etc/xen/scripts +++ . /etc/xen/scripts/hotplugpath.sh ++++ sbindir=3D/usr/sbin ++++ bindir=3D/usr/bin ++++ LIBEXEC=3D/usr/lib/xen ++++ LIBEXEC_BIN=3D/usr/lib/xen/bin ++++ libdir=3D/usr/lib64 ++++ SHAREDIR=3D/usr/share ++++ XENFIRMWAREDIR=3D/usr/lib/xen/boot ++++ XEN_CONFIG_DIR=3D/etc/xen ++++ XEN_SCRIPT_DIR=3D/etc/xen/scripts ++++ XEN_LOCK_DIR=3D/var/lock ++++ XEN_RUN_DIR=3D/var/run/xen ++++ XEN_PAGING_DIR=3D/var/lib/xen/xenpaging ++++ XEN_DUMP_DIR=3D/var/lib/xen/dump +++ . /etc/xen/scripts/logging.sh +++ . /etc/xen/scripts/xen-script-common.sh ++++ set -e +++ . /etc/xen/scripts/locking.sh ++++ LOCK_BASEDIR=3D/var/run/xen-hotplug +++ exec Entered lock_device SUN COMSTAR 1.0 Peripheral device type: disk libxl: error: libxl_exec.c:118:libxl_report_child_exitstatus: /etc/xen/scripts/block-iscsi-lock add [22016] exited with error status 99= libxl: error: libxl.c:3127:local_device_attach_cb: unable to add vbd with id 268446976: No such file or directory libxl: error: libxl_bootloader.c:408:bootloader_disk_attached_cb: failed to attach local disk for bootloader execution libxl: error: libxl_bootloader.c:279:bootloader_local_detached_cb: unable to detach locally attached disk libxl: error: libxl_create.c:1142:domcreate_rebuild_done: cannot (re-)build domain: -3 libxl: error: libxl.c:1591:libxl__destroy_domid: non-existant domain 57 libxl: error: libxl.c:1549:domain_destroy_callback: unable to destroy guest with domid 57 libxl: error: libxl.c:1476:domain_destroy_cb: destruction of domain 57 failed On a side note, it looks like the -e is not very uniformly used: block:#!/bin/bash block-enbd:#!/bin/bash block-iscsi:#!/bin/bash -e block-iscsi-lock:#!/bin/bash -x block-nbd:#!/bin/bash block-tap:#!/bin/bash -e external-device-migrate:#!/bin/bash vif2:#!/bin/bash vif-bridge:#!/bin/bash vif-nat:#!/bin/bash vif-openvswitch:#!/bin/bash vif-route:#!/bin/bash vif-setup:#!/bin/bash but probably gets set everywhere via xen-script-common.sh - hence things dying easily. --=20 Steven Haigh Email: netwiz@crc.id.au Web: https://www.crc.id.au Phone: (03) 9001 6090 - 0412 935 897 --MLoExiaBEnhFCAKoOlfuU2iqJhQVno21n-- --TePQ97UNjrSq2bWgsSfRUGWveboA3EKuA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXKcxqAAoJEEGvNdV6fTHcDtIP/iwd2fC1pOKQjGC6cmCro1Oj ERwHUzQa35Mul5EYNkdJZEHi63Lp37jlAPu8VANzgPsoHa96wq2lfTm1HvQRqps1 1hINMaTy8gP0q2bhfAuieW6iN1dW4UUuz0AZE2K/T78pi2TG6+OeresuOFyqWeT2 mdfuSepWYpspccBWM3C8tcvfIWTOeCMnKSn34mIjxlCaX41ZKpa5XCarUAeFswST YeAd4H3dzuRx2/rynxQ7a+nSrzfujPUsqVKo9XlyAG5ECKlz5wqbtufTXTlV0dnq b7zSu8LA9jm2YJjih77vd0VgVZIY5l3lcwyeZcitvjobMJFjhI7RVaaomUBJ6Tot S7Tu32Tky7zYFVzc3zI5OmoMFwiQrkvZox+N54r0eJg+gMw4a0Ve8DPAcwJAtPG3 WVUMjggLCFEMqfcLvZlApq1I+wlRJ+Vosr5OJiInlUjv52z8HJl+zncpHWrbC0WW jDHNlmskH5q6GaiVIQzg3OG9BWbJLqVw2pdV8KwKWSzNOuxfrEba3CZuwqAVE6wN H1QKvO3rtzTSZ6qaQFA+b8BSpge1CXg4pOqpzxVR29rqMRRd23CBe4n5a9bp3LZ9 Oi2PxtXaDoz0g//yilZ3gxHJ/1PObXuNWbdp84gqZ+GsxDU8zAGRzpDSVyA1OgkI AOTUKxn8cWIaPRtad+89 =tt0H -----END PGP SIGNATURE----- --TePQ97UNjrSq2bWgsSfRUGWveboA3EKuA-- --===============6317501920010666485== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --===============6317501920010666485==--