xenapi: /boot/guest should point to local SR
Fixes bug 1037516
This patch creates a directory os-guest-kernels inside the local SR, and
sets up /boot/guest to be a symlink to that directory. This way
OpenStack won't pollute Dom0's filesystem.
Change-Id: If8dfe24355bd782a401fed0f2c4b423efd9c11ba
diff --git a/tools/xen/functions b/tools/xen/functions
index 5b4a661..a7d7798 100644
--- a/tools/xen/functions
+++ b/tools/xen/functions
@@ -1,10 +1,8 @@
#!/bin/bash
function xapi_plugin_location {
- for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/"
- do
- if [ -d $PLUGIN_DIR ]
- then
+ for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/"; do
+ if [ -d $PLUGIN_DIR ]; then
echo $PLUGIN_DIR
return 0
fi
@@ -17,7 +15,13 @@
}
function create_directory_for_kernels {
- mkdir -p "/boot/guest"
+ if [ -d "/boot/guest" ]; then
+ echo "INFO: /boot/guest directory already exists, using that" >&2
+ else
+ local LOCALPATH="$(get_local_sr_path)/os-guest-kernels"
+ mkdir -p $LOCALPATH
+ ln -s $LOCALPATH /boot/guest
+ fi
}
function extract_remote_zipball {
@@ -53,3 +57,11 @@
rm -rf $EXTRACTED_FILES
chmod a+x ${XAPI_PLUGIN_DIR}*
}
+
+function get_local_sr {
+ xe sr-list name-label="Local storage" --minimal
+}
+
+function get_local_sr_path {
+ echo "/var/run/sr-mount/$(get_local_sr)"
+}