From: Ian Campbell Subject: Re: [PATCH V2] libxl: support custom block hotplug scripts Date: Wed, 1 Aug 2012 11:05:18 +0100 Message-ID: <1343815518.27221.49.camel@zakaz.uk.xensource.com> References: <84f0686ebcbfb0fa3a43.1343815057@cosworth.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <84f0686ebcbfb0fa3a43.1343815057@cosworth.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "xen-devel@lists.xen.org" Cc: Ian Jackson , Roger Pau Monne List-Id: xen-devel@lists.xenproject.org On Wed, 2012-08-01 at 10:57 +0100, Ian Campbell wrote: > I have tested with a custom block script which uses "lvchange -a" to > dynamically add remove the referenced device (simulates iSCSI login/logout > without requiring me to faff around setting up an iSCSI target). Script below for reference. Configured with: 'access=w,vdev=xvde,script=block-lvm,target=VG=VG LV=trash' Once you've done the initial "lvchange -a n /dev/VG/trash" then you should find that /dv/VG/trash exists only when the domain exists. I deliberately chose a target with = in it to valid the "target= eats to end of line" use case. As expected it works, the params node ends up as "VG=VG LV=trash". This also exercised the behaviour of not stat()ing the device in libxl. 8<------------------------------------------- #!/bin/bash dir=$(dirname "$0") . "$dir/block-common.sh" p=$(xenstore_read "$XENBUS_PATH/params") evalVariables $p exec 1>>/tmp/block-lvm.log DEV=/dev/$VG/$LV echo block-lvm $command on `date` echo VG=$VG LV=$LV DEV=$DEV case "$command" in add) if [ -e $DEV ] ; then fatal "$DEV already active, disable with \`lvchange -a n $DEV\'" fi lvchange -a y $DEV write_dev $DEV exit 0 ;; remove) lvchange -a n $DEV exit 0 ;; esac