OpenWrt – Diff between revs 2 and 3

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 2 Rev 3
Line 86... Line 86...
86 Usage: $SELF [-h|--help] 86 Usage: $SELF [-h|--help]
87 $SELF <target> 87 $SELF <target>
88 [<subtarget> [<extra-qemu-options>]] 88 [<subtarget> [<extra-qemu-options>]]
89 [--kernel <kernel>] 89 [--kernel <kernel>]
90 [--rootfs <rootfs>] 90 [--rootfs <rootfs>]
91 [--machine <machine>] -  
Line 92... Line 91...
92   91  
93 <subtarget> will default to "generic" and must be specified if 92 <subtarget> will default to "generic" and must be specified if
Line 94... Line 93...
94 <extra-qemu-options> are present 93 <extra-qemu-options> are present
Line 99... Line 98...
99 the actual <target> in use. They will default to files under bin/targets/ 98 the actual <target> in use. They will default to files under bin/targets/
Line 100... Line 99...
100   99  
Line 101... Line 100...
101 Examples 100 Examples
102   101  
103 $SELF x86 64 102 $SELF x86 64
104 $SELF x86 64 --machine q35,accel=kvm -device virtio-balloon-pci 103 $SELF x86 64 -enable-kvm -device virtio-balloon-pci
105 $SELF x86 64 -incoming tcp:0:4444 104 $SELF x86 64 -incoming tcp:0:4444
106 $SELF x86 64-glibc 105 $SELF x86 64-glibc
107 $SELF malta be -m 64 106 $SELF malta be -m 64
108 $SELF malta le64 107 $SELF malta le64
109 $SELF malta be-glibc -  
110 $SELF armvirt 32 \\ 108 $SELF malta be-glibc
111 --machine virt,highmem=off \\ 109 $SELF armvirt 32 \\
112 --kernel bin/targets/armvirt/32/openwrt-armvirt-32-zImage \\ 110 --kernel bin/targets/armvirt/32/openwrt-armvirt-32-zImage \\
113 --rootfs bin/targets/armvirt/32/openwrt-armvirt-32-root.ext4 111 --rootfs bin/targets/armvirt/32/openwrt-armvirt-32-root.ext4
Line 114... Line 112...
114 EOF 112 EOF
115 } 113 }
116   114  
Line 117... Line 115...
117 rand_mac() { 115 rand_mac() {
118 hexdump -n 3 -e '"52:54:00" 3/1 ":%02x"' /dev/urandom 116 hexdump -n 3 -e '"52:54:00:" 2/1 "%02x:" 1/1 "%02x"' /dev/urandom
119 } 117 }
120   118  
121 parse_args() { 119 parse_args() {
122 o_qemu_extra=() 120 o_qemu_extra=()
123 while [ "$#" -gt 0 ]; do -  
124 case "$1" in 121 while [ "$#" -gt 0 ]; do
125 --kernel) o_kernel="$2"; shift 2 ;; 122 case "$1" in
126 --rootfs) o_rootfs="$2"; shift 2 ;; 123 --kernel) o_kernel="$2"; shift 2 ;;
127 --machine|-machine|-M) o_mach="$2"; shift 2 ;; 124 --rootfs) o_rootfs="$2"; shift 2 ;;
128 --help|-h) 125 --help|-h)
Line 153... Line 150...
153 } 150 }
Line 154... Line 151...
154   151  
155 start_qemu_armvirt() { 152 start_qemu_armvirt() {
156 local kernel="$o_kernel" 153 local kernel="$o_kernel"
157 local rootfs="$o_rootfs" -  
158 local mach="${o_mach:-virt}" 154 local rootfs="$o_rootfs"
159 local cpu 155 local cpu
Line 160... Line 156...
160 local qemu_exe 156 local qemu_exe
161   157  
Line 183... Line 179...
183 "-drive" "file=$rootfs,format=raw,if=virtio" \ 179 "-drive" "file=$rootfs,format=raw,if=virtio" \
184 "-append" "root=/dev/vda rootwait" \ 180 "-append" "root=/dev/vda rootwait" \
185 ) 181 )
186 } 182 }
Line 187... Line 183...
187   183  
188 "$qemu_exe" -machine "$mach" -cpu "$cpu" -nographic \ 184 "$qemu_exe" -machine virt -cpu "$cpu" -nographic \
189 -netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device virtio-net-pci,id=devlan,netdev=lan,mac="$MAC_LAN" \ 185 -netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device virtio-net-pci,id=devlan,netdev=lan,mac="$MAC_LAN" \
190 -netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device virtio-net-pci,id=devwan,netdev=wan,mac="$MAC_WAN" \ 186 -netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device virtio-net-pci,id=devwan,netdev=wan,mac="$MAC_WAN" \
191 -kernel "$kernel" \ 187 -kernel "$kernel" \
192 "${o_qemu_extra[@]}" 188 "${o_qemu_extra[@]}"
Line 195... Line 191...
195 start_qemu_malta() { 191 start_qemu_malta() {
196 local is64 192 local is64
197 local isel 193 local isel
198 local qemu_exe 194 local qemu_exe
199 local kernel="$o_kernel" 195 local kernel="$o_kernel"
200 local mach="${o_mach:-malta}" -  
Line 201... Line 196...
201   196  
202 # o_subtarget can be le, be, le64, be64, le-glibc, le64-glibc, etc.. 197 # o_subtarget can be le, be, le64, be64, le-glibc, le64-glibc, etc..
203 is64="$(echo $o_subtarget | grep -o 64)" 198 is64="$(echo $o_subtarget | grep -o 64)"
204 [ "$(echo "$o_subtarget" | grep -o '^..')" = "le" ] && isel="el" 199 [ "$(echo "$o_subtarget" | grep -o '^..')" = "le" ] && isel="el"
Line 207... Line 202...
207 [ -n "$kernel" ] || kernel="$o_bindir/openwrt-malta-${o_subtarget%-*}-vmlinux-initramfs.elf" 202 [ -n "$kernel" ] || kernel="$o_bindir/openwrt-malta-${o_subtarget%-*}-vmlinux-initramfs.elf"
Line 208... Line 203...
208   203  
209 # NOTE: order of wan, lan -device arguments matters as it will affect which 204 # NOTE: order of wan, lan -device arguments matters as it will affect which
210 # one will be actually used as the wan, lan network interface inside the 205 # one will be actually used as the wan, lan network interface inside the
211 # guest machine 206 # guest machine
212 "$qemu_exe" -machine "$mach" -nographic \ 207 "$qemu_exe" -machine malta -nographic \
213 -netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device pcnet,netdev=wan,mac="$MAC_WAN" \ 208 -netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device pcnet,netdev=wan,mac="$MAC_WAN" \
214 -netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device pcnet,netdev=lan,mac="$MAC_LAN" \ 209 -netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device pcnet,netdev=lan,mac="$MAC_LAN" \
215 -kernel "$kernel" \ 210 -kernel "$kernel" \
216 "${o_qemu_extra[@]}" 211 "${o_qemu_extra[@]}"
Line 217... Line 212...
217 } 212 }
218   213  
219 start_qemu_x86() { -  
220 local rootfs="$o_rootfs" 214 start_qemu_x86() {
Line 221... Line 215...
221 local mach="${o_mach:-pc}" 215 local rootfs="$o_rootfs"
222 local qemu_exe 216 local qemu_exe
223   217  
Line 231... Line 225...
231 # generic: 32-bit, pentium4 (CONFIG_MPENTIUM4), kvm guest, virtio 225 # generic: 32-bit, pentium4 (CONFIG_MPENTIUM4), kvm guest, virtio
232 # legacy: 32-bit, i486 (CONFIG_M486) 226 # legacy: 32-bit, i486 (CONFIG_M486)
233 # 64: 64-bit, kvm guest, virtio 227 # 64: 64-bit, kvm guest, virtio
234 # 228 #
235 case "${o_subtarget%-*}" in 229 case "${o_subtarget%-*}" in
236 legacy) qemu_exe="qemu-system-i386" ;; 230 legacy) qemu_exe="qemu-system-i386" ;;
237 generic|64) qemu_exe="qemu-system-x86_64" ;; 231 generic|64) qemu_exe="qemu-system-x86_64" ;;
238 *) 232 *)
239 __errmsg "target $o_target: unknown subtarget $o_subtarget" 233 __errmsg "target $o_target: unknown subtarget $o_subtarget"
240 return 1 234 return 1
241 ;; 235 ;;
Line 251... Line 245...
251 # -device ich9-ahci,id=ahci \ 245 # -device ich9-ahci,id=ahci \
252 # -device ide-drive,drive=drv0,bus=ahci.0 \ 246 # -device ide-drive,drive=drv0,bus=ahci.0 \
253 # -drive "file=$rootfs,format=raw,id=drv0,if=none" \ 247 # -drive "file=$rootfs,format=raw,id=drv0,if=none" \
254 # 248 #
255 # [1] https://dev.openwrt.org/ticket/17947 249 # [1] https://dev.openwrt.org/ticket/17947
256 "$qemu_exe" -machine "$mach" -nographic \ 250 "$qemu_exe" -nographic \
257 -netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device e1000,id=devlan,netdev=lan,mac="$MAC_LAN" \ 251 -netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device e1000,id=devlan,netdev=lan,mac="$MAC_LAN" \
258 -netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device e1000,id=devwan,netdev=wan,mac="$MAC_WAN" \ 252 -netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device e1000,id=devwan,netdev=wan,mac="$MAC_WAN" \
259 -device ide-drive,drive=drv0 \ 253 -device ide-drive,drive=drv0 \
260 -drive "file=$rootfs,format=raw,id=drv0,if=none" \ 254 -drive "file=$rootfs,format=raw,id=drv0,if=none" \
261 "${o_qemu_extra[@]}" 255 "${o_qemu_extra[@]}"
262 ;; 256 ;;
263 generic|64) 257 generic|64)
264 "$qemu_exe" -machine "$mach" -nographic \ 258 "$qemu_exe" -nographic \
265 -netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device virtio-net-pci,id=devlan,netdev=lan,mac="$MAC_LAN" \ 259 -netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device virtio-net-pci,id=devlan,netdev=lan,mac="$MAC_LAN" \
266 -netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device virtio-net-pci,id=devwan,netdev=wan,mac="$MAC_WAN" \ 260 -netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device virtio-net-pci,id=devwan,netdev=wan,mac="$MAC_WAN" \
267 -drive "file=$rootfs,format=raw,if=virtio" \ 261 -drive "file=$rootfs,format=raw,if=virtio" \
268 "${o_qemu_extra[@]}" 262 "${o_qemu_extra[@]}"
269 ;; 263 ;;