blob: a29f8a0364f98e1cb94c01fc3942705ed91724e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/bin/bash
#This script is used to start-up a KVM-based virtual machine with a specific
#kernel, specified via command line with -k option
#--------------------------------------------------#
#virt-xml <domain> --edit --boot kernel=args=<args>
VIRTXML_BIN=`which virt-xml 2> /dev/null`
DEFAULT_OPS="ro vconsole.font=latarcyrheb-sun16 LANG=en_CA.UTF-8 console=ttyS0
crashkernel=128M"
# Display usage help function
usage() {
echo
echo "boot_kernel.sh: start a virtual machine with a direct kernel"
echo
echo "Usage: boot_kernel.sh -d <vm_name> -k <kernel> -r <root_dev> -o \"<kernel_opts>\""
echo
echo "-d: Specify the virtual machine name (domain name)"
echo "-k: Kernel executable path to be loaded in the virtual machine"
echo "-o: Kernel Options command line arguments (please use \"\")"
echo "-r: Root device, partition where rootfs is stored inside VM"
echo "-h: Show this help"
}
if [ -z $VIRTXML_BIN ]; then
echo "virt-xml executable not found..."
echo "Please make sure your system has virt-install package installed"
echo
exit
fi
add_kernel_to_xml() {
echo $VIRTXML_BIN --edit --boot kernel=$KERNEL_PATH kernel_args=$KERNEL_OPS
}
while getopts "d:hk:o:r:" ARG; do
case $ARG in
d) #domain name
DOMAIN_NAME=$OPTARG
;;
h)
#help menu
usage
;;
k) #kernel path
KERNEL_PATH=$OPTARG
;;
o)
#kernel_ops
KERNEL_OPS=$OPTARG
;;
r)
#root_device
ROOT_DEV=$OPTARG
;;
*)
usage
exit
;;
esac
done
#Ensure $KERNEL_PATH is valid
if [ -z $KERNEL_PATH ]; then
echo "Kernel image not specified..."
usage
exit 1
fi
if [ ! -f $KERNEL_PATH ]; then
echo "Kernel image not found...exiting"
exit 1
fi
#add_kernel_to_xml
$VIRTXML_BIN $DOMAIN_NAME --edit --boot kernel=$KERNEL_PATH
#Set kernel_args
if [ -z "$KERNEL_OPS" ]; then
$VIRTXML_BIN $DOMAIN_NAME --edit --boot kernel_args="root=$ROOT_DEV $DEFAULT_OPS"
else
$VIRTXML_BIN $DOMAIN_NAME --edit --boot kernel=$KERNEL_PATH --boot kernel_args="root=$ROOT_DEV ro $KERNEL_OPS"
fi
#Starting VM
virsh start $DOMAIN_NAME
|