2
# vim: tabstop=4 shiftwidth=4 softtabstop=4
4
# Copyright 2010 United States Government as represented by the
5
# Administrator of the National Aeronautics and Space Administration.
8
# Licensed under the Apache License, Version 2.0 (the "License"); you may
9
# not use this file except in compliance with the License. You may obtain
10
# a copy of the License at
12
# http://www.apache.org/licenses/LICENSE-2.0
14
# Unless required by applicable law or agreed to in writing, software
15
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17
# License for the specific language governing permissions and limitations
20
INSTANCES_PATH=${INSTANCES_PATH:-/var/lib/nova/instances}
21
if [ -z "$1" ]; then echo "specify an instance id to debug"; exit; fi
23
if [ -n "$3" ]; then DEVICE=$3; fi
26
if [ -n "$2" ]; then CMD=$2; fi
30
if [ $CMD != "umount" ] && [ $CMD != "launch" ]; then
31
# destroy the instance
34
# mount the filesystem
36
DEVICE=`losetup --show -f disk`
39
mount /dev/mapper/${DEVICE:4}p1 t
42
if [ $CMD != "mount" ] && [ $CMD != "umount" ]; then
44
# make serial console listen on ttyS0
45
cat >t/etc/init/ttyS0.conf <<TTY_EOF
48
# This service maintains a getty on ttyS0 from the point the system is
49
# started until it is shut down again.
51
start on stopped rc RUNLEVEL=[2345]
52
stop on runlevel [!2345]
55
exec /sbin/getty -L 115200 ttyS0 xterm
59
# set debug root password
60
chroot t passwd -u root
61
# TODO(vish): automate this with expect
64
tr -d '\n' < libvirt.xml > debug.xml
65
sed -i "s/<serial type=\"file\">.*<\/serial>/<serial type=\"pty\"><source path=\"\/dev\/pts\/1\"\/><target port=\"0\"\/><\/serial>/g" debug.xml
69
virsh create debug.xml
73
mount /dev/mapper/${DEVICE:4}p1 t
75
# clear debug root password
76
chroot t passwd -l root
78
# remove the serial console conf
79
rm -f t/etc/init/ttyS0.conf
82
if [ $CMD != "mount" ] && [ $CMD != "launch" ]; then
84
# unmount the filesystem
90
# recreate the instance
91
virsh create libvirt.xml