summaryrefslogtreecommitdiffstats
path: root/distribution/virt/import/runtest.sh
blob: 5cb60ac0d14f2b205819585f81d57f6ce4a9ebe6 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
#!/bin/bash

# Source the common test script helpers
. /usr/bin/rhts_environment.sh
. /usr/local/bin/rhts_virt_funcs.sh

result=PASS
value=0
kvm_num=0
home_basedir=0
# control where to log debug messages to:
# devnull = 1 : log to /dev/null
# devnull = 0 : log to file specified in ${DEBUGLOG}
devnull=0
mkdir -p /home/virtimages/VirtualMachines

# Create debug log
DEBUGLOG=`mktemp -p /mnt/testarea -t virtinstall.XXXXXX`

# locking to avoid races
lck=$OUTPUTDIR/$(basename $0).lck

function TurnOnLibvirtdLogging() 
{
    if alias | grep cp=; then
       unalias cp
    fi
    cp -f /etc/libvirt/libvirtd.conf /etc/libvirt/libvirtd.conf.orig
    echo 'log_filters="1:libvirt 1:util 1:qemu"' >> /etc/libvirt/libvirtd.conf
    echo 'log_outputs="1:file:/tmp/libvirtd_debug.log"' >> /etc/libvirt/libvirtd.conf

    if ! service libvirtd restart; then 
	echo "There was a problem restarting libvirtd!!!" 
    fi
}


function TurnOffLibvirtdLogging() 
{

    perl -pi.bak -e 's/^log_.*$//g' /etc/libvirt/libvirtd.conf
  
    if ! service libvirtd restart; then 
	echo "There was a problem restarting libvirtd!!!" 
    fi
}



# Log a message to the ${DEBUGLOG} or to /dev/null
function DeBug ()
{
    local msg="$1"
    local timestamp=$(date +%Y%m%d-%H%M%S)
    if [ "$devnull" = "0" ]; then
	    echo -n "${timestamp}: " >>$DEBUGLOG 2>&1
	    echo "${msg}" >>$DEBUGLOG 2>&1
    else
	echo "${msg}" >/dev/null 2>&1
    fi
}

function ChangeBootArgs ()
{
    DeBug "Enter ChangeBootArgs"
    IMAGE=$1
    GUESTRECIPEID=$2

    # FIXME: check for first loop device is free

    if [ ! -e "/mnt/boot" ]; then
        mkdir /mnt/boot
    fi
    losetup /dev/loop0 $IMAGE
    kpartx -a /dev/loop0
    BOOT=$(blkid -o device -t LABEL="/boot" | grep loop0)
    BOOTEFI=$(blkid -o device -t LABEL="/boot/efi" | grep loop0)
    if [ -n "$BOOT" ]; then
        mount $BOOT /mnt/boot
        # Change recipeid
        if [ -e "/mnt/boot/grub/grub.conf" ]; then
            sed -i "s/^\(\skernel .*\)\$/\1 BEAKER_RECIPE_ID=$GUESTRECIPEID/" /mnt/boot/grub/grub.conf
            sed -i "s|^\(\skernel .*\)\$|\1 BEAKER_LAB_CONTROLLER_URL=$BEAKER_LAB_CONTROLLER_URL|" /mnt/boot/grub/grub.conf
        fi
        umount /mnt/boot
    elif [ -n "$BOOTEFI" ]; then
        mount $BOOTEFI /mnt/boot
        # Change recipeid
        if [ -e "/mnt/boot/efi/redhat/elilo.conf" ]; then
            sed -i "s/^\(\sappend=\".*\)\"\$/\1 BEAKER_RECIPE_ID=$GUESTRECIPEID\"/" /mnt/boot/efi/redhat/elilo.conf
            sed -i "s|^\(\sappend=\".*\)\"\$|\1 BEAKER_LAB_CONTROLLER_URL=$BEAKER_LAB_CONTROLLER_URL\"|" /mnt/boot/efi/redhat/elilo.conf
        fi
        umount /mnt/boot
    else
        echo "No Boot Partition found"
    fi
    kpartx -d /dev/loop0
    losetup -d /dev/loop0
}

function SelectKernel ()
{
    DeBug "Enter SelectKernel"
    VR=$1
    EXTRA=$2
    DeBug "VR=$VR EXTRA=$EXTRA"

    # If not version or Extra selected then choose the latest installed version
    if [ -z "$EXTRA" -a -z "$VR" ]; then
	DeBug "ERROR: missing args"
	return 1
    fi

    # Workaround for broken RT kernel spec file, part 1
    if [ "$EXTRA" = "rt" ]; then
	DeBug "EXTRA=$EXTRA"
	EXTRA=""
    fi

    # Workaround for broken RT kernel spec file, part 2
    if [ "$EXTRA" = "rt-vanilla" ]; then
	DeBug "EXTRA=$EXTRA"
	EXTRA="vanilla"
    fi

    # Workaround for broken RT kernel spec file, part 1
    if [ "$EXTRA" = "up" ]; then
	DeBug "EXTRA=$EXTRA"
	EXTRA=""
    fi

    echo "***** Attempting to switch boot kernel to ($VR$EXTRA) *****"
    DeBug "Attempting to switch boot kernel to ($VR$EXTRA)"

    grub_file=/boot/grub/grub.conf

    if [ -f $grub_file ]; then
	DeBug "Using: $grub_file"
	COUNT=0
	DEFAULT=undefined
	for i in $(grep '^title' $grub_file | sed 's/.*(\(.*\)).*/\1/'); do
	    DeBug "COUNT=$COUNT VR=$VR EXTRA=$EXTRA i=$i"
	    if echo $i | egrep -e "${VR}.*${EXTRA}" ; then
		DEFAULT=$COUNT;
	    fi
	    COUNT=$(expr $COUNT + 1)
	done
	if [[ x"${DEFAULT}" != x"undefined" ]]; then
	    DeBug "DEFAULT=$DEFAULT"
	    /bin/ed -s $grub_file <<EOF
/default/
d
i
default=$DEFAULT
.
w
q
EOF
	fi
	DeBug "$grub_file"
	cat $grub_file | tee -a $DEBUGLOG
    fi

    elilo_file=/boot/efi/efi/redhat/elilo.conf

    if [ -f $elilo_file ]; then
	DeBug "Using: $elilo_file"
	DEFAULT=$(grep -A 2 "image=vmlinuz-$VR$EXTRA$" $elilo_file | awk -F= '/label=/ {print $2}')
	DeBug "DEFAULT=$DEFAULT"
	if [ -n "$DEFAULT" ]; then
	    DeBug "DEFAULT=$DEFAULT"
	    /bin/ed -s $elilo_file <<EOF
/default/
d
i
default=$DEFAULT
.
w
q
EOF
	fi
	DeBug "$elilo_file"
	cat $elilo_file | tee -a $DEBUGLOG
    fi

    yaboot_file=/boot/etc/yaboot.conf
 
    if [ -f $yaboot_file ] ; then
	DeBug "Using: $yaboot_file"
	grep vmlinuz $yaboot_file
	if [ $? -eq 0 ] ; then
	    VM=z
	else
	    VM=x
	fi
	DEFAULT=$(grep -A 1 "image=/vmlinu$VM-$VR$EXTRA" $yaboot_file | awk -F= '/label=/ {print $2}')
	DeBug "DEFAULT=$DEFAULT"
	if [ -n "$DEFAULT" ] ; then
	    sed -i 's/label=linux/label=orig-linux/g' $yaboot_file
	    sed -i 's/label='$DEFAULT'/label=linux/g' $yaboot_file
	    DeBug "DEFAULT=$DEFAULT"
	    grep -q label=linux $yaboot_file
	    if [ $? -ne 0 ] ; then
		sed -i 's/label=orig-linux/label=linux/g' $yaboot_file
		DeBug "Reverted back to original kernel"
	    fi
	fi
	DeBug "$yaboot_file"
	cat $yaboot_file | tee -a $DEBUGLOG
    fi

    zipl_file=/etc/zipl.conf

    if [ -f $zipl_file ] ; then
	DeBug "Using: $zipl_file"
	DEFAULT=$(grep "image=/boot/vmlinuz-$VR$EXTRA" $zipl_file | awk -Fvmlinuz- '/vmlinuz/ {printf "%.15s\n",$2}')
	DeBug "DEFAULT=$DEFAULT"
	if [ -n "$DEFAULT" ] ; then
	    DeBug "$VR$EXTRA"
	    tag=$(grep "\[$DEFAULT\]" $zipl_file)
	    DeBug "tag=$tag"
	    if [ -z "$tag" ] ; then
		DeBug "Setting it back to default"
		DEFAULT=linux
	    fi
	    /bin/ed -s $zipl_file <<EOF
/default=/
d
i
default=$DEFAULT
.
w
q
EOF
	    zipl
	fi
	DeBug "$zipl_file"
	cat $zipl_file | tee -a $DEBUGLOG
    fi
    
    sync
    sleep 5
    DeBug "Exit SelectKernel"
    return 0
}




function SubmitLog ()
{
    LOG=$1
    rhts_submit_log -l $LOG
}

function SubmitVirtLogs () 
{
    # submit the relevant logfiles
    if [[ ${kvm_num} > 0 ]]; then 
       for kvmlog in $(find /var/log/libvirt/qemu/ -type f)
       do
           rhts_submit_log -l ${kvmlog}
       done
    else 
       for xenlog in $(find /var/log/xen/ -type f)
       do
         rhts_submit_log -l ${xenlog}
       done
       for dumps in $(find /var/lib/xen/dump -type f)
       do
         rhts_submit_log -l ${dumps}
       done
    fi
    
    rhts_submit_log -l ${DEBUGLOG}
    
    #submit dmesg
    dmesg > ./dmesg.txt
    rhts_submit_log -l ./dmesg.txt
    # Always submit the audit.log
    rhts_submit_log -l /var/log/audit/audit.log
    #submit virt-install log file
    if [ -e ${HOME}/.virtinst/virt-install.log ]; then
        rhts_submit_log -l ${HOME}/.virtinst/virt-install.log
    fi
    #submit libvirtd debug log...
    if [ -e /tmp/libvirtd_debug.log ]; then 
        rhts_submit_log -l /tmp/libvirtd_debug.log
        # clean the log for the next test
        echo "" > /tmp/libvirtd_debug.log
    fi
    
}

function setuprhel5consoles()
{
    local RESULT="PASS"
    local FAIL=0

    if ! cp zrhel5_write_consolelogs.initd /etc/init.d/zrhel5_write_consolelogs; then
       echo "Problem copying zrhel5_write_consolelogs.initd to initd dir"
       RESULT="FAIL"
       let "FAIL=${FAIL}+1"        
    fi

    if ! cp zrhel5_write_consolelogs.py /usr/local/bin/zrhel5_write_consolelogs; then 
       echo "Problem copying zrhel5_write_consolelogs.py to /usr/local/bin"
       RESULT="FAIL"
       let "FAIL=${FAIL}+1"        
    fi
    if ! chmod 755 /usr/local/bin/zrhel5_write_consolelogs; then 
       echo "Problem with chmoding zrhel5_write_consolelogs"
       RESULT="FAIL"
       let "FAIL=${FAIL}+1"        
    fi

    if ! chkconfig --add zrhel5_write_consolelogs; then 
       echo "problem with chkconfig --add zrhel5_write_consolelogs"
       RESULT="FAIL"
       let "FAIL=${FAIL}+1"
    fi

    if ! chkconfig zrhel5_write_consolelogs on; then 
       echo "problem with chkconfig zrhel5_write_consolelogs on"
       RESULT="FAIL"
       let "FAIL=${FAIL}+1"
    fi

    iptables -I INPUT -p tcp --dport 8000 -j ACCEPT
    iptables -I INPUT -p udp --dport 8000 -j ACCEPT
    sleep 1
    if ! service iptables save; then
       echo "Problem with service iptables save"
       RESULT="FAIL"
       let "FAIL=${FAIL}+1"        
    fi
      
    if ! cp -f iptables_after_libvirtd.initd /etc/init.d/iptables_after_libvirtd; then
       echo "Problem with copying iptables_after_libvirtd.initd"
       RESULT="FAIL"
       let "FAIL=${FAIL}+1"        
    fi

    if ! chkconfig --add iptables_after_libvirtd; then 
       echo "problem with adding iptables_after_libvirtd"
       RESULT="FAIL"
       let "FAIL=${FAIL}+1"        
    fi

    if ! chkconfig iptables_after_libvirtd on; then 
       echo "problem with chkconfig iptables_after_libvirtd on"
       RESULT="FAIL"
       let "FAIL=${FAIL}+1"
    fi

    if ! service iptables_after_libvirtd start; then 
       echo "problem with service iptables_after_libvirtd start"
       RESULT="FAIL"
       let "FAIL=${FAIL}+1"
    fi
      
    echo "Status of iptables: "
    service iptables status
    service zrhel5_write_consolelogs start
    sleep 2
    echo "Status of rhel5_write_consoles:"
    service zrhel5_write_consolelogs status
    echo "Initial log output:"
    cat /nohup.out
    if [[ ${FAIL} > 0 ]]; then 
       report_result ${TEST}_zrhel5_write_consolelogs WARN $FAIL
       return -1
    else
       report_result ${TEST}_zrhel5_write_consolelogs PASS 0
       return 0
    fi

}

function setupconsolelogs()
{
	local RESULT="PASS"
	local FAIL=0
	if ! gcc -g -Wall logguestconsoles.c -o logguestconsoles -lssl -lcrypto -lcurl $(xmlrpc-c-config client --libs) $(pkg-config libvirt --libs) $(xml2-config --cflags) $(xml2-config --libs); then 
		echo "Problem with compiling logguestconsoles.c file"
		echo "Guest console logs won't be available"
		RESULT="FAIL"
		let "FAIL=${FAIL}+1"
	fi

	if ! cp logguestconsoles /usr/local/bin; then 
		echo "Problem with copying logguestconsoles to /usr/local/bin"
		echo "Guest console logs won't be available"
		RESULT="FAIL"
		let "FAIL=${FAIL}+1"
	fi

	if ! cp logguestconsoles.initd /etc/init.d/logguestconsoles; then 
		echo "problem with copying init script"
		RESULT="FAIL"
		let "FAIL=${FAIL}+1"
	fi

	if ! chkconfig --add logguestconsoles; then 
		echo "problem with chkconfig --add logguestconsoles"
		RESULT="FAIL"
		let "FAIL=${FAIL}+1"
	fi

	if [[ ${FAIL} > 0 ]]; then 
		report_result ${TEST}_consolelogsetup WARN $FAIL
        	return 1
	else
		report_result ${TEST}_consolelogsetup PASS 0
        	return 0
	fi
}

function setuprhel5_xmlrpcc() 
{
        local SRCRPM="xmlrpc-c.el5.src.rpm"
        local FAIL=0
        local OUTPUTLOG="./setuprhel5_xmlrpcc.log"

        if ! rpm -ivh ${LOOKASIDE}/${SRCRPM}; then
                echo "problem with rpm -ivh ${LOOKASIDE}/${SRCRPM}"
                FAIL=$(expr ${FAIL} + 1)
        fi

        exec 5>&1 6>&2
        exec >> ${OUTPUTLOG} 2>&1

        if ! rpmbuild -ba /usr/src/redhat/SPECS/xmlrpc-c.spec; then
                echo "problem with rpmbuild -ba /usr/src/redhat/SPECS/xmlrpc-c.spec"
                FAIL=$(expr ${FAIL} + 1)
        fi

        if ! rpm -Uvh /usr/src/redhat/RPMS/$(arch)/xmlrpc-c*.rpm; then
                echo "problem with rpm -Uvh /usr/src/redhat/RPMS/$(arch)/xmlrpc-c*.rpm"
                FAIL=$(expr ${FAIL} + 1)
        fi

        exec 1>&5 5>&-
        exec 2>&6 6>&-

        if [[ ${FAIL} > 0 ]]; then
                report_result ${TESTNAME}_setuprhel5_xmlrpcc FAIL 1
        else
                report_result ${TESTNAME}_setuprhel5_xmlrpcc PASS 0
        fi
        rhts_submit_log ${OUTPUTLOG}
}



function rename_current_ifcfg_config()
{
    local cfg_file=/etc/sysconfig/network-scripts/ifcfg-$netdev
    local ret=0
    if [ -e "$cfg_file" ]; then
        echo "Found $cfg_file, trying to rename"
        mv -vf $cfg_file /etc/sysconfig/network-scripts/Xifcfg-${netdev}.orig
        ret=$?
    else
        # Bug 845225 - interface name does not match ifcfg- config file name
        echo "Could not find $cfg_file, searching for one based on MAC"
        local ifcfg_files=`grep -l "${mac}" /etc/sysconfig/network-scripts/ifcfg-*`
        echo "Matching config files: $ifcfg_files"
        for cfg_file in $ifcfg_files; do
            bn=`basename $cfg_file`
            mv -vf $cfg_file /etc/sysconfig/network-scripts/X$bn.orig
            if [ $? -ne 0 ]; then
                ret=1
            fi
        done
    fi
    return $ret
}

# Bug 901542 - qemu doesn't depend on seabios-bin, resulting in error: "qemu: PC system firmware (pflash) must be a multiple of 0x1000"
function workaround_bug901542()
{
    yum list installed seabios-bin
    local ret2=$?
    if [ $ret2 -ne 0 ]; then
        echo "Bug 901542, seabios/seabios-bin is not installed, trying to install.."
        yum -y install seabios seabios-bin
        report_result bug901542 FAIL 1
    fi
}

# Bug 958860 - Could not access KVM kernel module: Permission denied
function workaround_bug958860()
{
    local rights=`stat --format=%a /dev/kvm | tail -c 4`
    if [ "${rights:0:1}" -lt "6" -o "${rights:1:1}" -lt "6" -o "${rights:2:1}" -lt "6" ]; then
        echo "Bug 958860 - Could not access KVM kernel module, chmod-ing to 0666"
        chmod 666 /dev/kvm
        report_result bug958860 FAIL 1
    fi
}

# Bug 957897 - service network start won't start network
function workaround_bug957897()
{
    if [ ! -e /etc/sysconfig/network ]; then
        echo "Bug 957897 - service network start won't start network, touching /etc/sysconfig/network"
        touch /etc/sysconfig/network
        restorecon /etc/sysconfig/network
        report_result bug957897 FAIL 1
    fi
}

function ConfirmDefaultNetDevice ()
{
    # RHEL5 brings up all the network devices and sets
    # the last network device to come up as the default.
    # ConfirmDefaultNetDevice: 
    # Confirms the network installation device 
    # is set as the default network device.
    # This is required for proper network bridging on guests.

    # Run for RHEL5 only
    local rhel5_ver="2.6.18"
    local kernel_ver=`rpm -q --queryformat '%{version}\n' -qf /boot/config-$(uname -r)`

    if [ "$rhel5_ver" == "$kernel_ver" ]; then
        echo ""
        echo "***** RHEL5: Verifying the the network installation device is set as the default network device  *****"

        if [ ! -e /root/anaconda-ks.cfg ]; then
            echo ""
            echo "***** WARN: /root/anaconda-ks.cfg file is missing *****"
            echo "***** WARN: Unable to confirm system network installation device *****"
            echo ""
            report_result ${TEST}_ConfirmDefaultNetDevice WARN
        else
            echo ""
            echo "***** Confirming system network installation device *****"
            echo "***** Checking /root/anaconda-ks.cfg *****"

            grep "network --device" /root/anaconda-ks.cfg
            if [ "$?" -ne "0" ]; then
                echo "***** WARN: Unable to confirm system network installation device *****"
                report_result ${TEST}_ConfirmDefaultNetDevice WARN
            else
                # Get system network installation device
                local installdev=$(grep -oP "(?<=--device )[^ ]+" /root/anaconda-ks.cfg)
                if [ "$?" -eq "0" ]; then
                    echo "***** System network installation device = $installdev *****"
                    echo ""
                    echo "***** Confirming system default network device *****"
                    echo "***** Checking route *****"
                    # Get systems current default network device
                    local defaultdev=$(route | grep default | awk '{print $NF}')
                    if [ "$?" -eq "0" ]; then
                        echo "***** Default network device = $defaultdev *****"
                        # Confirm install and default network device are the same device
                        if [ "$installdev" != "$defaultdev" ]; then
                            echo "***** The install and default network devices are not the same device *****"
                            echo "*****   As RHEL5 sets the last device that comes up to the default,   *****"
                            echo "***** its likely this system has multiple nics up on the same subnet  *****"
                            echo ""
                            echo "***** Setting $installdev to default network device *****"

                            # This trick will make the $installdev the last network device to come up
                            # Thus, resetting the RHEL5 default network device
                            ifdown "$installdev"
                            sleep 3
                            ifup "$installdev"

                            # One last check
                            if [ "$installdev" -ne "$defaultdev" ]; then
                                echo "***** WARN: Unable to set $installdev to default network device *****"
                                report_result ${TEST}_ConfirmDefaultNetDevice WARN
                            else
                                echo "***** $installdev successfully set to default network device *****"
                                echo ""
                            fi
                        else
                            echo "***** System installation and default default network device = $defaultdev *****"
                            echo ""
                        fi
                    else
                        echo "***** WARN: Unable to confirm default network device *****"
                        report_result ${TEST}_ConfirmDefaultNetDevice WARN
                    fi
                fi
            fi
        fi
    fi
}

#
# ---------- Start Test -------------
#

# workaround RHEL7 issues
rpm -qa initscripts | grep "\.el7"
if [ $? -eq 0 ]; then
    workaround_bug901542
    workaround_bug958860
    workaround_bug957897
fi

chmod 755 *.initd

# turn on libvirtd debugging log.
TurnOnLibvirtdLogging

## normally this test will run in selinux enforcing mode but sometimes we may
# want to run it in permissive mode to de bug selinux issues:
if [[ -n "${PERMISSIVE_MODE}" ]]; then 
	setenforce Permissive
	if [[ $? != 0 ]] ; then 
		echo "Problem with setting enforcing to permissive"
		report_result ${TEST}/selinux_permissive FAIL 1
		exit 0
	fi
	perl -pi.bak -e 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
fi

# Add in a variable to workaround virt-install and selinux brokeness
#  See BZ [Bug 475786] [RHEL5.3] SELinux AVC Denied: while trying to write to
#  /.virtinst/virt-install.log
if [ -z $HOME ] ; then
    export HOME=/root
fi

# starting with rhel 5.4 we'll have both xen and kvm hypervisors shipped with the tree. 
# This test will be used to install guests under both hypervisors hence it needs to
# identify what it is doing. @virtualization group pulls in packages/kernels for both
# hypervisors and by default kernel-xen is selected which means any guests installed will
# be xen guests. To allow testers to install kvm guestsi, --kvm argument in guest_args 
# will be used. It will NOT be allowed to specify both xen or kvm guests. All guests must
# be of one hypervisor. The flow will be:
#
#    Check if this is rhel6 installation or not. If it is, then just assume all kvm guests 
#      with or without --kvm indicators.
#   
#    If this is rhel5 then, figure what type of guests there are
#     - Make sure that ALL guests are of the same type
#     - if kvm:
#          check the running kernel
#            if baremetal, move on
#            if xen, switch to baremetal kernel and rhts-reboot
#     - if xen:
#          check the running kernel
#            if not kernel-xen error out (it should be the default)
#            if xen, make changes to xend files and rhts-reboot
#     - install guests.
if ver=$(rpm -q --qf '%{version}\n' --whatprovides redhat-release); then
	if [[ ${ver} == 6 || ${ver} > 6 ]]; then
		kvm_num=1
	else
		# ensure that they all are either xen or kvm
        if ! kvm_num=$(./get_guest_info.py --kvm-num) ; then
			echo "can't mix up kvm and non-kvm guests. They all have to be kvm or nonkvm"
			report_result ${TEST}_wrongguestsetup FAIL 1
			submitvirtlogs
			exit 1
		fi
	fi
fi

# if this will be kvm guests' install make sure that correct kernel is running.
if [[ ${kvm_num} > 0 ]]; then
   if uname -r  | grep xen ; then
      xenkern=$(uname -r)
      basekern=${xenkern%"xen"}
      # if for whatever reason base kernel isn't installed, install it..
      if ! rpm -q kernel-${basekern}; then 
         yum -y install kernel-${basekern} kvm 
      fi
      # make sure that yum installed it..
      if ! rpm -q kvm; then 
         echo "Can't find/install kvm"
         report_result ${TEST}_nokvm FAIL 1
         exit 1
      fi 
      echo "this test seems to be for kvm guests, booting into vanilla kernel"
      SelectKernel ${basekern}
      echo "Rebooting into base kernel since this is kvm guest"
      report_result rhts-reboot PASS $REBOOTCOUNT
      rhts-reboot
   fi

   if [[ ${ver} == 6 || ${ver} > 6 ]]; then
      # for rhel6 & above we need to set up bridging and get network manager out
      # of the way...
      if [[ ${REBOOTCOUNT} == 0 ]]; then  

         ## we need to configure/add bridge to establish bridged networking for 
         ## kvm guests
         def_line=$(ip route list | grep ^default)
         defnum=$(perl -e 'for ($i=0; $i<$#ARGV; $i++ ) { if ($ARGV[$i] eq "dev" ) { $_ = $ARGV[ $i + 1 ]; if ( /^(\w*)(\d+)/ ) { print "$_ $2"; } } }' ${def_line} )
         actnum=$(echo ${defnum} | awk '{print $2}')
         netdev=$(echo ${defnum} | awk '{print $1}')
         vifnum=${vifnum:-$actnum}
         if [ -z ${vifnum} ]; then 
            echo "Can't get the interface number "
            report_result ${TEST}_networksetup FAIL 1
            exit 1
         fi 
         brdev="br${vifnum}"
         pdev="p${netdev}"
         mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
         if [ -z ${mac} ]; then 
            echo "Can't find the mac address"
            report_result ${TEST}_networksetupnomac FAIL 1
            exit 1
         fi
         echo "brdev: ${brdev} netdev: ${netdev} pdev: ${pdev} mac: ${mac} "  
    
         rename_current_ifcfg_config
         if [[ $? != 0 ]]; then
            echo "Problem copying network config scripts"
            report_result ${TEST}_networksetup FAIL 1
            exit 1
         fi
         cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$netdev
DEVICE=$netdev
ONBOOT=yes
BRIDGE=$brdev
HWADDR=$mac
EOF
      
         cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$brdev
DEVICE=$brdev
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Bridge
DELAY=0
EOF
      
         service NetworkManager stop
         chkconfig NetworkManager off
         chkconfig network on
         service network restart
         if [[ $? != 0 ]]; then 
             echo "problem restarting network"

             rpm -qa initscripts | grep "\.el7"
             if [ $? -eq 0 ]; then
                 echo "This is known RHEL7 issue, proceeding anyway.."
                 echo "Bug 886090 - ifcfg- config contains ONBOOT=yes for interface with no link"
                 report_result ${TEST}_networksetup FAIL 1
             else
                 report_result ${TEST}_networksetup FAIL 1
                 exit 1
             fi
         else
             echo "configured a bridge: $netdev "
         fi

         echo "Rebooting after configuring the bridge"
         report_result rhts-reboot PASS $REBOOTCOUNT
         rhts-reboot

      # when it's already set up and rebooted, then get the bridge to use to 
      # pass it on to virt-install 
      else 
         def_line=$(ip route list | grep ^default)
         defnum=$(perl -e 'for ($i=0; $i<$#ARGV; $i++ ) { if ($ARGV[$i] eq "dev" ) { $_ = $ARGV[ $i + 1 ]; if ( /^(\w*)(\d+)/ ) { print "$_ $2"; } } }' ${def_line} )
         actnum=$(echo ${defnum} | awk '{print $2}')
         netdev=$(echo ${defnum} | awk '{print $1}')
         vifnum=${vifnum:-$actnum}
         if [ -z ${vifnum} ]; then 
            echo "Can't get the interface number "
            report_result ${TEST}_networksetup FAIL 1
            exit 1
         fi 
         brdev="br${vifnum}"
      fi

    else

         ## we need to configure/add bridge to establish bridged networking for 
         ## kvm guests

         # For RHEL5 before we establish a network bridge device
         # Lets confirm the default network device is correct
         ConfirmDefaultNetDevice

         def_line=$(ip route list | grep ^default)
         defnum=$(perl -e 'for ($i=0; $i<$#ARGV; $i++ ) { if ($ARGV[$i] eq "dev" ) { $_ = $ARGV[ $i + 1 ]; if ( /^(\w*)(\d+)/ ) { print "$_ $2"; } } }' ${def_line} )
         actnum=$(echo ${defnum} | awk '{print $2}')
         netdev=$(echo ${defnum} | awk '{print $1}')
         vifnum=${vifnum:-$actnum}
         if [ -z ${vifnum} ]; then 
            echo "Can't get the interface number "
            report_result ${TEST}_networksetup FAIL 1
            exit 1
         fi 
         brdev="br${vifnum}"
         pdev="p${netdev}"
         mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
         if [ -z ${mac} ]; then 
            echo "Can't find the mac address"
            report_result ${TEST}_networksetupnomac FAIL 1
            exit 1
         fi
         echo "brdev: ${brdev} netdev: ${netdev} pdev: ${pdev} mac: ${mac} "  

         rename_current_ifcfg_config
         if [[ $? != 0 ]]; then
            echo "Problem copying network config scripts"
            report_result ${TEST}_networksetup FAIL 1
            exit 1
         fi
         cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$netdev
DEVICE=$netdev
ONBOOT=yes
BRIDGE=$brdev
HWADDR=$mac
EOF
      
         cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$brdev
DEVICE=$brdev
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Bridge
DELAY=0
EOF
      

         service NetworkManager stop
         chkconfig NetworkManager off
         chkconfig network on
         service network restart
         if [[ $? != 0 ]]; then 
            echo "problem restarting network"
            report_result ${TEST}_networksetup FAIL 1
            exit 1
         else
           echo "configured a bridge: $netdev "
         fi

   fi

   # see BZ# 749611
   if rpm -q kernel-xen; then 
       yum -y erase kernel-xen
   fi

else # this is a xen install
   
   # turn on various logs in xend and restart xend
   if [[ $REBOOTCOUNT == 0 ]]; then 
      if uname -r  | grep -v xen ; then
         basekern=$(uname -r)
         xenkern=${basekern}"xen"
         SelectKernel ${xenkern}
      fi
      perl -pi.bak -e 's/#*\(enable-dump\s+no\)/(enable-dump yes)/g' /etc/xen/xend-config.sxp 
      perl -pi.bak -e 's/^#*XENCONSOLED_LOG_HYPERVISOR=no/XENCONSOLED_LOG_HYPERVISOR=yes/g;s/^#*XENCONSOLED_LOG_GUESTS=no/XENCONSOLED_LOG_GUESTS=yes/g;s/^#*XENCONSOLED_LOG_DIR=.*$/XENCONSOLED_LOG_DIR=\/var\/log\/xen\/console/g' /etc/sysconfig/xend
      echo "Reboot needed to enable xen logging"
      report_result rhts-reboot PASS $REBOOTCOUNT
      rhts-reboot
   else
      echo "Reboot was successful"

       # For RHEL5 before we establish a network bridge device
       # Lets confirm the default network device is correct
       ConfirmDefaultNetDevice
   fi
  
   # are we running on a Xen kernel in domain 0 ?
   # (only report if RHTS tried running us on an unsuitable host)
   #
   if [ -d /proc -a ! -f /proc/xen/privcmd ] ; then
       DeBug "Don't think we are on a Dom0"
       echo "Don't think we are on a Dom0"
       report_result ${TEST} WARN 10
       exit 0
   fi
fi

## we need libvirt-devel, that might not be installed during installation time
if ! rpm -q libvirt-devel; then 
    yum -y install libvirt-devel
    if ! rpm -q libvirt-devel; then 
        echo "can't install libvirt-devel" 
        echo "guest console logs might not work"
        report_result NO_libvirt-devel WARN 10
    fi
fi

echo "***********************"
echo "* SELinux Status      *"
echo "***********************"
/usr/sbin/sestatus
virtinst="virt-install"

if [[ $REBOOTCOUNT > 1 ]]; then 
   echo "Looks like dom0 rebooted during a guest install. Check console logs"
   report_result ${TEST}_dom0rebooted FAIL 99
   submitvirtlogs
   exit 0
fi

i=0
fail=0
./get_guest_info.py > ./tmp.guests
echo "Guests info:"
cat ./tmp.guests

# go thru the guests and set up console sniff/upload 
while read -r guest_recipeid guest_name guest_mac guest_args ; do
   if ! mkdir -p $(pwd)/guests/${guest_name}/logs; then
      report_result ${TEST}_cant_create_dirs FAIL 10
   fi
   guest_con_logfile="$(pwd)/guests/${guest_name}/logs/${guest_name}_console.log"
   echo "$guest_con_logfile $guest_recipeid" >> /usr/local/etc/logguestconsoles.conf
   if [ ! -e $guest_con_logfile ]  ; then 
      touch $guest_con_logfile 
   fi
   chmod a+rw $guest_con_logfile
done < ./tmp.guests

# setup consolelogging
# logguestconsoles create files itself, so if qemu has issues with
# that in future (permissions/selinux), this needs to be started
# only after qemu creates those files
#
# on some rhel5 releases xmlrpc-c package doesn't exist, install it here
if [ ${ver:0:1} -lt 6 ]; then
    minor_ver=$(sed 's/.* release 5\.\([0-9]*\) .*/\1/' /etc/redhat-release) 
    if [[ ${minor_ver} < 6 && ${minor_ver} > 3 ]]; then 
        setuprhel5_xmlrpcc
    fi
fi

if setupconsolelogs; then
   service logguestconsoles start
   sleep 2
   echo "Status of logguestconsoles:"
   service logguestconsoles status
   echo "Initial log output:"
   cat /var/log/logguestconsoles.*
fi

while read -r guest_recipeid guest_name guest_mac guest_args ; do
   DeBug "guest is :
        guest_recipeid=$guest_recipeid
        guest_name=$guest_name
        guest_mac=$guest_mac
        guest_args=$guest_args"
   if [ -z "$guest_name" ] ; then
      echo "get_guest_info.py did not return a guest name"
      report_result ${TEST}_no_guestname FAIL 10
      exit 1
   fi
   if ! mkdir -p $(pwd)/guests/${guest_name}/logs || ! mkdir -p $(pwd)/guests/${guest_name}/iso; then
      echo "Problem creating $(pwd)/guests/${guest_name}/{logs,iso} dirs"
      report_result ${TEST}_cant_create_dirs FAIL 10
      exit 1
   fi
   if ! chmod -R 777 $(pwd)/guests/${guest_name}; then 
      echo "problem with chmod -R 777 $(pwd)/guests/${guest_name}"
      report_result ${TEST}_chmod_issue FAIL  10
      exit 1
   fi

   if [ -n "$*" ]; then
      guest_args=$*
   fi

   # decide where to put the guest's image based on availability
   home_basedir=0
   var_lib_df=$(df /var/lib)
   var_lib_free=$(echo ${var_lib_df} | awk '{print $11}')
   home_df=$(df /home)
   home_free=$(echo ${home_df} | awk '{print $11}')
   if [[ ${home_free} -gt ${var_lib_free} ]]; then 
      mkdir -p /home/virtimages/VirtualMachines
      home_basedir=1
   fi

   if [[ ${kvm_num} > 0 ]]; then
     if [[ ${home_basedir} == 0 ]]; then
         basedir="/var/lib/libvirt/images"
     else
         basedir="/home/virtimages/VirtualMachines"
     fi
   else
     if [[ ${home_basedir} == 0 ]]; then
         basedir="/var/lib/xen/images"
     else
         basedir="/home/virtimages/VirtualMachines"
     fi
   fi

   # Retrieve guest image from Lookaside
   if ! wget -O - $LOOKASIDE/virt_images/${guest_name}.img.bz2 | bzip2 -cd > $basedir/${guest_name}.img; then
      echo "Unable to download/uncompress $LOOKASIDE/virt_images/${guest_name}.img.bz2"
      report_result ${TEST}/NoImage FAIL 100
      exit 1
   fi

   ChangeBootArgs $basedir/${guest_name}.img ${guest_recipeid}

   #bridge=$(ip route list | awk '/^default / { print $NF }' | sed 's/^[^0-9]*//')
   #CMDLINE="-b xenbr${bridge} -n ${guestname} -f ${IMAGE} $args"
   CMDLINE="--name ${guest_name} --mac ${guest_mac} $guest_args --debug --nographics --noreboot --import"
   if [[ ${kvm_num} > 0 ]]; then
      CMDLINE="${CMDLINE}"
   else   
      ## the first 2 conditions are for fedora releases since they too can support xen guests.
      if grep -q -i fedora /etc/fedora-release; then
         CMDLINE="$CMDLINE --serial file,path=$(pwd)/guests/${guest_name}/logs/${guest_name}_console.log --extra-args \"ks=$guest_ks serial console=tty0 console=ttyS0,115200\"" 
      fi
   fi

   CMDLINE="${CMDLINE} --disk path=$basedir/${guest_name}.img,xvda,w"

   # FIXME: Update image to use guest recipe id

   # kvm guest should have --accelerate and --os-variant=virtio26 by default.
   # --kvm switch shouldn't be passed on to virtinstall.exp
   if [[ ${kvm_num} > 0 ]]; then 
      #get rid of --kvm
      CMDLINE=$( echo ${CMDLINE} | awk '{ for (i=1;i<=NF;i++) { if ( $i != "--kvm" ) printf "%s ", $i } }' )
      #add  --accelerate or --os-variant=virtio26 or both
      echo ${CMDLINE} | awk '{rc=0; for(i=1;i<=NF;i++) { if ( $i ~ /--accelerate*/ ) rc+=1; else if ( $i ~ /--os-variant=*/ )  rc += 2;  } exit rc }'
      rc=$?
      if [[ $rc == 0 ]]; then 
         CMDLINE="${CMDLINE} --accelerate --os-variant=virtio26 "
      elif [[ $rc == 1 ]]; then 
         CMDLINE="${CMDLINE} --accelerate "
      elif [[ $rc == 3 ]]; then 
         CMDLINE="${CMDLINE} --os-variant=virtio26 "
     fi
     # make an exception for given --network arg..
     # see BZ#821984
     GIVENNW=$(echo $CMDLINE | awk '{ for (i=1;i<=NF;i++) { if ( $i == "--network" ) { i+=1; printf "%s ", $i } else { continue; } } }')
     if [[ -z "${GIVENNW}" ]]; then 
        CMDLINE="${CMDLINE} --ver6 --network bridge:${brdev} "
     else 
        CMDLINE=$(echo $CMDLINE | awk '{ for (i=1;i<=NF;i++) { if ( $i == "--network" ) { i+=1; continue; } else printf "%s ", $i } }')
        NWARG=""
        for opts in ${GIVENNW}
        do
            NWARG="${NWARG} --network bridge:${brdev},${opts}"
        done
        CMDLINE="${CMDLINE} --ver6 ${NWARG}"
        
     fi

     # beginning with rhel6 virt-install can take -serial option. automatically
     # append serial console args unless one is given already or unless --virttest is given
     if [[ ${ver} == 6 || ${ver} > 6 ]]; then
        echo ${CMDLINE} | awk '{rc=0; for(i=1;i<=NF;i++) { if ( $i == "--virttest" || $i  ~ /--serial*/) exit 1 } exit 0 }'
        rc=$?
        if [[ ${rc} == 0 ]]; then
            CMDLINE="$CMDLINE --serial file,path=$(pwd)/guests/${guest_name}/logs/${guest_name}_console.log"
            # workaround for BZ: 731115
            l_guest_name=$(echo ${guest_name} | tr [:upper:] [:lower:])
            if [[ x"$guest_name" != x"$l_guest_name" ]]; then 
               ln -sf $(pwd)/guests/${guest_name} $(pwd)/guests/${l_guest_name}
               if [[ $? != 0 ]]; then 
                  echo "error with workaround for bz731115"
                  report_result ${TEST}_logdir_link FAIL 100
               fi
            fi
            # end of workaround for BZ 731115
            #
        fi 
     fi
   fi

   DeBug "CMDLINE == $CMDLINE"
   echo "CMDLINE == $CMDLINE"
   DeBug "***** Start $virtinst ${CMDLINE} *****"
   echo  "***** Start $virtinst ${CMDLINE} *****"
   starttime=$(date +%s)
   echo "Start time: $starttime"
   if selinuxenabled; then
      eval /usr/bin/runcon -t unconfined_t -- $virtinst $CMDLINE 2>&1
   else
      eval $virtinst $CMDLINE 2>&1
   fi
   value=$?
   endtime=$(date +%s)
   echo "End time: $endtime"
   if [[ $value == 1 ]]; then
      echo "WARNING: install may or may not have failed. Check the guest"
      let "fail=${fail}+1"
      result=FAIL
      report_result ${TEST}/install_${guest_name} $result $value
   elif [[ $value == 14 ]]; then
      echo "Err No 14 workaround"
      let "fail=${fail}+1"
      result=WARN
      report_result ${TEST}/install_${guest_name} $result $value
   elif [[ $value == 33 ]]; then
      echo "libvirt error"
      let "fail=${fail}+1"
      result=FAIL
      report_result ${TEST}/install_${guest_name}_libvirterror $result $value
   elif [[ $value == 37 ]]; then
      echo "guest crashed"
      let "fail=${fail}+1"
      result=FAIL
      report_result ${TEST}/install_${guest_name}_guestcrash $result $value
   elif [[ $value == 38 ]]; then
      echo "no HVM support on the machine"
      let "fail=${fail}+1"
      result=FAIL
      report_result ${TEST}/install_${guest_name}_noHVMsupport $result $value
   elif [[ $value != 0 ]]; then
      echo "$virtinst FAILED"
      let "fail=${fail}+1"
      result=FAIL
      report_result ${TEST}/install_${guest_name} $result $value
   else
      result=PASS
      elapsed=$(expr $endtime - $starttime)
      echo "***** Finished $virtinst ${guest_name} in $elapsed seconds *****"
      report_result ${TEST}/import_${guest_name} $result $elapsed
   fi
   # and for rhel6 and above we should have a console log.
   if [ -e `pwd`/guests/${guest_name}/logs/${guest_name}_console.log ]; then 
	rhts_submit_log -l `pwd`/guests/${guest_name}/logs/${guest_name}_console.log
   fi
   # upload the guest's config file too.
   if [[ ${kvm_num} < 1 ]]; then 
      rhts_submit_log -l /etc/xen/${guest_name}
   elif virsh dumpxml ${guest_name}; then 
      virsh dumpxml ${guest_name} > ./guests/${guest_name}/logs/${guest_name}.xml
      rhts_submit_log -l ./guests/${guest_name}/logs/${guest_name}.xml
   fi
   let i="$i+1"
done < ./tmp.guests
if [[ $i == 0 ]]; then 
   report_result ${TEST}/noguestinstall PASS 0 
elif [[ ${fail} == 0 ]]; then 
   report_result ${TEST} PASS 0
else 
   report_result ${TEST} FAIL 1
fi

# turn on service for rhel5 console writing.
# This is after the guests are installed so that it won't try to steal console
# from the installation
if [ ${ver:0:1} -lt 6 -a ${minor_ver} -gt 3 -a -z "${NORHEL5CONSOLELOGS}" ]; then
        setuprhel5consoles 
fi

# submit the relevant logfiles
submitvirtlogs
if [ -e /nohup.out ]; then 
    rhts_submit_log -l /nohup.out
fi  

exit 0