Add shared disk ID as serial number in shared disk XML
authorMartin Schwenke <martin@meltin.net>
Thu, 19 Jun 2014 01:33:32 +0000 (11:33 +1000)
committerMartin Schwenke <martin@meltin.net>
Wed, 25 Jun 2014 10:46:16 +0000 (20:46 +1000)
Hedge bets by continuing to write the ID to the image file.

While touching this code, add the cluster name to the temporary
filename for the shared disk ID map.  Setting $shared_disk_ids needs
to move to shared_disk_setup() so $CLUSTER can be used.  Also need to
update this path in mknsd.sh.

Signed-off-by: Martin Schwenke <martin@meltin.net>
base/all/root/scripts/mknsd.sh
config.d/10shareddisk.defconf

index a44632119c45f71d88e66ca46b76ec3e9a3553b2..01b23f258922454253960611060f093a906e45de 100755 (executable)
@@ -8,7 +8,7 @@ set -e
 echo
 echo "Setting up NSDs"
 nsdfile=/tmp/nsd.$$
-idfile=$(dirname $0)/shared_disk_ids
+idfile=$(dirname $0)/shared_disk_ids.@@CLUSTER@@
 if [ -r "$idfile" ] ; then
     pat=$(tr '\n' '|' <"$idfile"  | sed -e 's@|$@@')
     multipath -dl |
index 0e3119aeb26d49ba8d0e3950ef540bf9482266f8..ed21f9cb9c83b54d17782d9f8e3b06b94cf804f0 100644 (file)
@@ -78,6 +78,7 @@ shared_disk_template ()
     for SHARED_DISK_NUM in $(seq 1 $SHAREDDISK_COUNT) ; do
        local DISK="${VIRTBASE}/${CLUSTER}/shared${SHARED_DISK_NUM}"
        run_hooks hack_disk_hooks "shared"
+       local serial=$(sed -n "${SHARED_DISK_NUM}p" "$shared_disk_ids")
        for p in $(seq 1 $paths) ; do
            local dev="${devices[$n]}"
            [ -n "$dev" ] || die "Too many shared disks!  The function shared_disk_template needs to be hacked to allow more shared disks..."
@@ -86,6 +87,7 @@ shared_disk_template ()
       <driver name='qemu' cache='@@SHARED_DISK_CACHE@@'/>
       <source file='${DISK}'/>
       <target dev='@@SHARED_DISK_PREFIX@@${dev}' bus='@@SHARED_DISK_TYPE@@'/>
+      <serial>${serial}</serial>
       <shareable/>
     </disk>
 EOF
@@ -105,12 +107,11 @@ shared_disk_post_config_hook()
 
 register_hook post_config_hooks shared_disk_post_config_hook
 
-shared_disk_ids="tmp/shared_disk_ids"
-
 register_hook create_cluster_hooks shared_disk_setup
 
 shared_disk_setup ()
 {
+    shared_disk_ids="tmp/shared_disk_ids.${CLUSTER}"
     rm -f "$shared_disk_ids"
 
     if [ -n "$SHAREDDISKSIZE" -a -n "$SHAREDDISK_TEMPLATE" -a \