xen: added grub.d conf file, added python-2.7 support patch.

This commit is contained in:
Juan RP 2011-01-10 14:35:11 +01:00
parent 402bf160d7
commit e3397f4f32
3 changed files with 181 additions and 0 deletions

View file

@ -0,0 +1,134 @@
#! /bin/sh -e
if [ -f /usr/lib/grub/grub-mkconfig_lib ]; then
. /usr/lib/grub/grub-mkconfig_lib
else
# no grub file, so we notify and exit gracefully
echo "Cannot find grub config file, exiting." >&2
exit 0
fi
XEN_HYPERVISOR_CMDLINE="dom0_mem=512M"
XEN_LINUX_CMDLINE="console=tty0"
if [ -f /etc/default/grub ]; then
. /etc/default/grub
fi
CLASS="--class gnu-linux --class gnu --class os"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
else
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but
# the initrds that Linux uses don't like that.
case ${GRUB_DEVICE} in
/dev/loop/*|/dev/loop[0-9])
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
;;
esac
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
|| [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
xen_entry ()
{
os="$1"
xen_version="$2"
version="$3"
xen_args="$4"
args="$5"
recovery="$6"
printf "menuentry '%s Xen %s, with Linux %s%s' --class xen ${CLASS} {\n" \
"${os}" "${xen_version}" "${version}" "${recovery}"
save_default_entry | sed -e "s/^/\t/"
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
echo '$(printf "Loading Xen hypervisor %s ..." ${xen_version})'
multiboot ${rel_dirname}/${xen_basename} ${xen_args}
echo $(printf "$(gettext "Loading Linux %s kernel ...")" ${version})
module ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
cat << EOF
echo "Loading initial ramdisk ..."
module ${rel_dirname}/${initrd}
EOF
fi
cat << EOF
}
EOF
}
xen_list=`for i in /boot/xen-*.gz; do
if grub_file_is_not_garbage "$i" && ! test -h "$i"; then echo -n "$i "; fi
done`
prepare_boot_cache=
while [ "x$xen_list" != "x" ] ; do
xen=`version_find_latest $xen_list`
echo "Found Xen hypervisor image: $xen" >&2
xen_basename=`basename $xen`
xen_dirname=`dirname $xen`
rel_xen_dirname=`make_system_path_relative_to_its_root $xen_dirname`
xen_version=`echo $xen_basename | sed -e "s,^[^0-9]*-,,g" | sed -e "s,.gz,,g"`
alt_xen_version=`echo $xen_version | sed -e "s,\.old$,,g"`
xen_configfiles=`grep -l 'CONFIG_XEN_PRIVILEGED_GUEST=y' /boot/config-*`
for i in $xen_configfiles ; do
i=`echo $i | sed -e "s,/boot/config-,/boot/vmlinuz-,g"`;
if grub_file_is_not_garbage "$i"; then
list="$list $i";
fi
done
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
echo "Found linux image: $linux" >&2
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
initrd=
for i in "initrd.img-${version}"; do
if test -e "${dirname}/${i}" ; then
initrd="$i"
break
fi
done
if test -n "${initrd}" ; then
echo "Found initrd image: ${dirname}/${initrd}" >&2
else
# "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here.
linux_root_device_thisversion=${GRUB_DEVICE}
fi
xen_entry "${OS}" "${xen_version}" "${version}" \
"${XEN_HYPERVISOR_CMDLINE}" "${GRUB_CMDLINE_LINUX_DEFAULT}"
if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
xen_entry "${OS}" "${xen_version}" "${version}" \
"${XEN_HYPERVISOR_CMDLINE}" "single ${GRUB_CMDLINE_LINUX_DEFAULT}" \
" (recovery mode)"
fi
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
done
xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $xen | tr '\n' ' '`
done

View file

@ -0,0 +1,38 @@
Fixes python-2.7, from http://www.gossamer-threads.com/lists/xen/devel/182210
--- tools/python/xen/util/xmlrpcclient.py.orig 2010-02-02 20:43:01.000000000 +0000
+++ tools/python/xen/util/xmlrpcclient.py 2010-08-18 21:36:05.000000000 +0100
@@ -22,6 +22,7 @@
import string
import xmlrpclib
from types import StringTypes
+from sys import hexversion
try:
@@ -54,7 +55,12 @@
return xmlrpclib.Transport.request(self, host, '/RPC2',
request_body, verbose)
def make_connection(self, host):
- return HTTPUnix(self.__handler)
+ if hexversion < 0x02070000:
+ # python 2.6 or earlier
+ return HTTPUnix(self.__handler)
+ else:
+ # xmlrpclib.Transport changed in python 2.7
+ return HTTPUnixConnection(self.__handler)
# We need our own transport for HTTPS, because xmlrpclib.SafeTransport is
--- tools/python/xen/util/xmlrpclib2.py.orig 2010-02-02 20:43:01.000000000 +0000
+++ tools/python/xen/util/xmlrpclib2.py 2010-08-18 21:35:40.000000000 +0100
@@ -58,6 +58,9 @@
# some bugs in Keep-Alive handling and also enabled it by default
class XMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
protocol_version = "HTTP/1.1"
+ # xend crashes in python 2.7 unless disable_nagle_algorithm = False
+ # it isn't used in earlier versions so it is harmless to set it generally
+ disable_nagle_algorithm = False
def __init__(self, hosts_allowed, request, client_address, server):
self.hosts_allowed = hosts_allowed

View file

@ -63,6 +63,10 @@ do_build()
{
install -d ${DESTDIR}
cd ${DESTDIR} && ln -sf . install
if [ "${xbps_machine}" = "x86_64" ]; then
install -d ${DESTDIR}/usr/lib
cd ${DESTDIR}/usr && ln -s lib lib64 && cd ${wrksrc}
fi
cd ${wrksrc} && make ${makejobs} DISTDIR=${DESTDIR} xen tools
}
@ -78,6 +82,11 @@ do_install()
# Remove upstream xend and use our own.
rm -f ${DESTDIR}/etc/init.d/xend
install -m755 ${FILESDIR}/xend.rc ${DESTDIR}/etc/init.d/xend
# Remove unneeded stuff.
rm -f ${DESTDIR}/install ${DESTDIR}/usr/lib64
# Install grub2 Xen detection.
install -D -m755 ${FILESDIR}/grub.d_09_xen \
${DESTDIR}/etc/grub.d/09_xen
}