>From 16297b511b6bec22c7d93c871c82f05b0e1aa5ee Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Fri, 10 Jun 2011 15:36:42 -0400 Subject: [PATCH] Check the network for activity as well as the disk. Signed-off-by: Chris Lalancette --- oz/Guest.py | 34 +++++++++++++++++++++++++++++----- 1 files changed, 29 insertions(+), 5 deletions(-) diff --git a/oz/Guest.py b/oz/Guest.py index a0d1385..d83ada7 100644 --- a/oz/Guest.py +++ b/oz/Guest.py @@ -399,8 +399,15 @@ class Guest(object): diskdev = disktarget[0].prop('dev') if diskdev is None: raise oz.OzException.OzException("Could not find disk target device") + inttarget = doc.xpathEval("/domain/devices/interface/target") + if len(inttarget) < 1: + raise oz.OzException.OzException("Could not find interface target") + intdev = inttarget[0].prop('dev') + if intdev is None: + raise oz.OzException.OzException("Could not find interface target device") last_disk_activity = 0 + last_network_activity = 0 inactivity_countdown = inactivity_timeout origcount = count while count > 0: @@ -408,6 +415,7 @@ class Guest(object): self.log.debug("Waiting for %s to finish installing, %d/%d" % (self.tdl.name, count, origcount)) try: rd_req, rd_bytes, wr_req, wr_bytes, errs = libvirt_dom.blockStats(diskdev) + rx_bytes, rx_packets, rx_errs, rx_drop, tx_bytes, tx_packets, tx_errs, tx_drop = libvirt_dom.interfaceStats(intdev) except libvirt.libvirtError, e: self.log.debug("Libvirt Domain Info Failed:") self.log.debug(" code is %d" % e.get_error_code()) @@ -424,13 +432,28 @@ class Guest(object): else: raise - # if we saw no disk activity in the countdown window, we presume the - # install has hung. Fail here + # if we saw no disk or network activity in the countdown window, + # we presume the install has hung. Fail here if inactivity_countdown == 0: self.capture_screenshot(libvirt_dom.XMLDesc(0)) - raise oz.OzException.OzException("No disk activity in %d seconds, failing" % (inactivity_timeout)) - - if (rd_req + wr_req) == last_disk_activity: + raise oz.OzException.OzException("No disk or network activity in %d seconds, failing" % (inactivity_timeout)) + + # rd_req and wr_req are the *total* number of disk read requests and + # write requests ever made for this domain. Similarly rd_bytes and + # wr_bytes are the total number of network bytes read or written + # for this domain + + # we define activity as having done a read or write request on the + # install disk, or having done at least 4KB of network transfers in + # the last second. The thinking is that if the installer is putting + # bits on disk, there will be disk activity, so we should keep + # waiting. On the other hand, the installer might be downloading + # bits to eventually install on disk, so we look for network + # activity as well. We say that transfers of at least 4KB must be + # made, however, to try to reduce false positives from things like + # ARP requests + + if (rd_req + wr_req) == last_disk_activity and (rd_bytes + wr_bytes) < (last_network_activity + 4096): # if we saw no read or write requests since the last iteration, # decrement our activity timer inactivity_countdown -= 1 @@ -439,6 +462,7 @@ class Guest(object): inactivity_countdown = inactivity_timeout last_disk_activity = rd_req + wr_req + last_network_activity = rd_bytes + wr_bytes count -= 1 time.sleep(1) -- 1.7.4.4