This patch fixes the creation of VM images. Previously, FC12 images were created but the files necessary for FC12 image creation are no longer available in the public repositories. This patch now switches it to create FC14 images. To get such a new image one may want to remove all content in /var/cache/libvirt-tck. I takes a long time for the image to install, though. The new FC14 image takes a lot longer to boot. Rather than waiting a fixed timeout during which the VM presumably has booted it is now waiting for the VM to become pingable and then starts the actual tests. Also, the name of the DHCP lease file used by dnsmasq has changed. Rather than hardcoding its name, try to pick it up from the running dnsmasq process's parameters. Fall back to the old name if the name of the leasefile could be determined via 'ps aux'. Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx> --- conf/default.cfg | 12 ++-- conf/ks.cfg | 3 - lib/Sys/Virt/TCK/NetworkHelpers.pm | 84 +++++++++++++++++++++++++++--- scripts/nwfilter/090-install-image.t | 11 ++- scripts/nwfilter/100-ping-still-working.t | 5 - scripts/nwfilter/210-no-mac-spoofing.t | 5 - scripts/nwfilter/220-no-ip-spoofing.t | 5 - scripts/nwfilter/230-no-mac-broadcast.t | 5 - scripts/nwfilter/240-no-arp-spoofing.t | 5 - scripts/nwfilter/300-vsitype.t | 3 - 10 files changed, 104 insertions(+), 34 deletions(-) Index: libvirt-tck/lib/Sys/Virt/TCK/NetworkHelpers.pm =================================================================== --- libvirt-tck.orig/lib/Sys/Virt/TCK/NetworkHelpers.pm +++ libvirt-tck/lib/Sys/Virt/TCK/NetworkHelpers.pm @@ -11,12 +11,76 @@ sub get_first_macaddress { sub get_ip_from_leases{ my $mac = shift; - my $tmp = `grep $mac /var/lib/dnsmasq/dnsmasq.leases`; + my $leasefile = `ps x | sed -n "s/.*dnsmasq.*default.*dhcp-leasefile=\\([/.[:alnum:]]*\\).*/\\1/p"`; + if ( $leasefile eq "" ) { + $leasefile = "/var/lib/dnsmasq/dnsmasq.leases"; + } + diag "leasefile is ${leasefile}"; + my $tmp = `grep $mac $leasefile`; my @fields = split(/ /, $tmp); my $ip = $fields[2]; return $ip; } +sub wait_for_vm_if_up { + my $mac = shift; + my $timeout = shift; + my $ipaddr = ""; + my $tmp = ""; + + while ( $timeout > 0 ) { + $ipaddr = get_ip_from_leases($mac); + if ( $ipaddr != "" ) { + last; + } + sleep(1); + $timeout -= 1; + diag "... waiting for the VM's DHCP lease to show up..." + } + + if ( $ipaddr != "" ) { + while ( $timeout > 0 ) { + $tmp = `ping $ipaddr -c 1 -W 2`; + if ( $tmp =~ "100% packet loss" ) { + $timeout -= 2; + } else { + sleep(5); + return $ipaddr; + } + diag "... waiting for the VM to become pingable..." + } + } + return 0; +} + +sub wait_for_vm_if_down { + my $mac = shift; + my $timeout = shift; + my $ipaddr = ""; + my $tmp = ""; + + $ipaddr = get_ip_from_leases($mac); + if ( $ipaddr == "" ) { + diag "Could not get the IP address of the VM."; + return 0; + } + + while ( $timeout > 0 ) { + $tmp = `ping $ipaddr -c 1 -W 2`; + if ( $tmp =~ "100% packet loss" ) { + diag "VM is off the network now."; + sleep(5); + return 1; + } + $timeout -= 2; + sleep(2); + diag "... waiting for the VM to be off the network ($timeout) ... " + } + return 0; +} + + + sub build_cdrom_ks_image { my $tck = shift; @@ -139,11 +203,19 @@ sub prepare_test_disk_and_vm{ my $dom = $conn->define_domain($guest->as_xml); diag "Starting installation domain"; $dom->create; - diag "wait for installation to finish .. "; - while($dom->is_active()) { - sleep(10); - diag ".. to view progress connect to virtual machine ${domain_name} .. "; - } + # Wait for the interface to come up; this may take a good while + my $guestip = wait_for_vm_if_up(get_first_macaddress($dom), 600); + if ( $guestip eq "" ) { + diag "Installation domain did not show an IP address. Destroying VM."; + $dom->destroy(); + } else { + diag "IP address of installating VM is $guestip"; + # wait until the installation is done -- may take a long time + if (!wait_for_vm_if_down(get_first_macaddress($dom), 7200)) { + diag "Installation did not complete in time. Destroying VM."; + $dom->destroy(); + } + } # cleanup install domain $dom->undefine; $dom = undef; Index: libvirt-tck/conf/default.cfg =================================================================== --- libvirt-tck.orig/conf/default.cfg +++ libvirt-tck/conf/default.cfg @@ -52,25 +52,25 @@ ks = /etc/libvirt-tck/ks.cfg # empty sparse root FS will be created # kernels = ( - # Fedora 11 i686 PAE has pv_ops, so one kernel can do both Xen and KVM guests here + # Fedora 14 i686 PAE has pv_ops, so one kernel can do both Xen and KVM guests here { arch = i686 ostype = ( hvm xen ) - kernel = http://download.fedora.redhat.com/pub/fedora/linux/releases/11/Fedora/i386/os/images/pxeboot/vmlinuz-PAE - initrd = http://download.fedora.redhat.com/pub/fedora/linux/releases/11/Fedora/i386/os/images/pxeboot/initrd-PAE.img + kernel = http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/i386/os/images/pxeboot/vmlinuz-PAE + initrd = http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/i386/os/images/pxeboot/initrd-PAE.img } - # Fedora 11 x86_64 has pv_ops, so one kernel can do both Xen and KVM guests here + # Fedora 14 x86_64 has pv_ops, so one kernel can do both Xen and KVM guests here { arch = x86_64 ostype = ( hvm xen ) - kernel = http://download.fedora.redhat.com/pub/fedora/linux/releases/11/Fedora/x86_64/os/images/pxeboot/vmlinuz - initrd = http://download.fedora.redhat.com/pub/fedora/linux/releases/11/Fedora/x86_64/os/images/pxeboot/initrd.img + kernel = http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/x86_64/os/images/pxeboot/vmlinuz + initrd = http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/x86_64/os/images/pxeboot/initrd.img } # User mode linux i686 needs custom kernel + root filesystem { Index: libvirt-tck/conf/ks.cfg =================================================================== --- libvirt-tck.orig/conf/ks.cfg +++ libvirt-tck/conf/ks.cfg @@ -1,6 +1,6 @@ install text -url --url=http://ftp-stud.hs-esslingen.de/Mirrors/fedora.redhat.com/linux/releases/12/Fedora/i386/os/ +url --url=http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/i386/os/ lang en_US.UTF-8 keyboard de-latin1-nodeadkeys network --device eth0 --bootproto dhcp @@ -27,3 +27,4 @@ poweroff @base @core @hardware-support +%end Index: libvirt-tck/scripts/nwfilter/100-ping-still-working.t =================================================================== --- libvirt-tck.orig/scripts/nwfilter/100-ping-still-working.t +++ libvirt-tck/scripts/nwfilter/100-ping-still-working.t @@ -46,7 +46,7 @@ END { # create first domain and start it diag "Trying domain lookup by name"; my $dom1; -my $dom_name ="tckf12nwtest"; +my $dom_name ="tck-fedora-nwtest"; $dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name); $dom1->create(); @@ -63,8 +63,7 @@ ok($dom1->get_id() > 0, "running domain my $mac1 = get_first_macaddress($dom1); diag "mac is $mac1"; -sleep(30); -my $guestip1 = get_ip_from_leases($mac1); +my $guestip1 = wait_for_vm_if_up($mac1, 60); diag "ip is $guestip1"; # check ebtables entry Index: libvirt-tck/scripts/nwfilter/210-no-mac-spoofing.t =================================================================== --- libvirt-tck.orig/scripts/nwfilter/210-no-mac-spoofing.t +++ libvirt-tck/scripts/nwfilter/210-no-mac-spoofing.t @@ -44,7 +44,7 @@ END { # create first domain and start it -my $dom_name ="tckf12nwtest"; +my $dom_name ="tck-fedora-nwtest"; my $dom1; $dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name); @@ -58,8 +58,7 @@ diag $xml; my $mac1 = get_first_macaddress($dom1); diag "mac is $mac1"; -sleep(30); -my $guestip1 = get_ip_from_leases($mac1); +my $guestip1 = wait_for_vm_if_up($mac1, 60); diag "ip is $guestip1"; # check ebtables entry Index: libvirt-tck/scripts/nwfilter/220-no-ip-spoofing.t =================================================================== --- libvirt-tck.orig/scripts/nwfilter/220-no-ip-spoofing.t +++ libvirt-tck/scripts/nwfilter/220-no-ip-spoofing.t @@ -44,7 +44,7 @@ END { # looking up domain my $dom1; -my $dom_name ="tckf12nwtest"; +my $dom_name ="tck-fedora-nwtest"; $dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name); $dom1->create(); @@ -55,8 +55,7 @@ diag $xml; my $mac1 = get_first_macaddress($dom1); diag "mac is $mac1"; -sleep(30); -my $guestip1 = get_ip_from_leases($mac1); +my $guestip1 = wait_for_vm_if_up($mac1, 60); diag "ip is $guestip1"; # check ebtables entry Index: libvirt-tck/scripts/nwfilter/230-no-mac-broadcast.t =================================================================== --- libvirt-tck.orig/scripts/nwfilter/230-no-mac-broadcast.t +++ libvirt-tck/scripts/nwfilter/230-no-mac-broadcast.t @@ -43,7 +43,7 @@ END { # create first domain and start it my $dom1; -my $dom_name ="tckf12nwtest"; +my $dom_name ="tck-fedora-nwtest"; $dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name); $dom1->create(); @@ -54,8 +54,7 @@ diag $xml; my $mac1 = get_first_macaddress($dom1); diag "mac is $mac1"; -sleep(30); -my $guestip1 = get_ip_from_leases($mac1); +my $guestip1 = wait_for_vm_if_up($mac1, 60); diag "ip is $guestip1"; # check ebtables entry Index: libvirt-tck/scripts/nwfilter/240-no-arp-spoofing.t =================================================================== --- libvirt-tck.orig/scripts/nwfilter/240-no-arp-spoofing.t +++ libvirt-tck/scripts/nwfilter/240-no-arp-spoofing.t @@ -45,7 +45,7 @@ END { # creating domain my $dom1; -my $dom_name ="tckf12nwtest"; +my $dom_name ="tck-fedora-nwtest"; $dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name); $dom1->create(); @@ -56,8 +56,7 @@ diag $xml; my $mac1 = get_first_macaddress($dom1); diag "mac is $mac1"; -sleep(30); -my $guestip1 = get_ip_from_leases($mac1); +my $guestip1 = wait_for_vm_if_up($mac1, 60); diag "ip is $guestip1"; # check ebtables entry Index: libvirt-tck/scripts/nwfilter/090-install-image.t =================================================================== --- libvirt-tck.orig/scripts/nwfilter/090-install-image.t +++ libvirt-tck/scripts/nwfilter/090-install-image.t @@ -19,7 +19,7 @@ network/000-install-image.t - install ne =head1 DESCRIPTION -The test case creates and install a 2GB fedora virtual +The test case creates and install a 2GB fedora virtual disk via kickstart file from the network. =cut @@ -41,15 +41,16 @@ END { $tck->cleanup if $tck; } use File::Spec::Functions qw(catfile catdir rootdir); # variables which may need to be adapted -my $dom_name ="tckf12nwtest"; +my $dom_name ="tck-fedora-nwtest"; my $testdom = prepare_test_disk_and_vm($tck, $conn, $dom_name); $testdom->create(); ok($testdom->get_id() > 0, "running domain has an ID > 0"); -sleep(20); + +my $mac1 = get_first_macaddress($testdom); +diag "mac is $mac1"; +my $guestip1 = wait_for_vm_if_up($mac1, 60); shutdown_vm_gracefully($testdom); exit 0; - - Index: libvirt-tck/scripts/nwfilter/300-vsitype.t =================================================================== --- libvirt-tck.orig/scripts/nwfilter/300-vsitype.t +++ libvirt-tck/scripts/nwfilter/300-vsitype.t @@ -43,6 +43,7 @@ END { SKIP: { skip "lldptool not present", 3 unless -e "/usr/sbin/lldptool"; + skip "eth2 not available", 3 unless `ifconfig eth2` =~ "Link encap:"; # creating domain my $dom1; @@ -58,7 +59,7 @@ SKIP: { my $mac1 = get_first_macaddress($dom1); diag "mac is $mac1"; - sleep(30); + wait_for_vm_if_up($mac1, 60); # check vsi information diag "Verifying VSI information using lldptool"; -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list