Commit ff18f526 authored by Guido Trotter's avatar Guido Trotter
Browse files

Merge remote branch 'origin/devel-2.1'

* origin/devel-2.1:
  Explicitely return None from IgnoreSignals
  AsyncUDPSocket: fix IgnoreSignals usage and test
  Add KVM chroot feature
  Fix and Improve TryToRoman unittest

	  - trivial
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarMichael Hanselmann <>
parents a01b500b 2fd7f564
......@@ -112,10 +112,12 @@ class AsyncUDPSocket(GanetiBaseAsyncoreDispatcher):
# this method is overriding an asyncore.dispatcher method
def handle_read(self):
payload, address = utils.IgnoreSignals(self.recvfrom,
ip, port = address
self.handle_datagram(payload, ip, port)
recv_result = utils.IgnoreSignals(self.recvfrom,
if recv_result is not None:
payload, address = recv_result
ip, port = address
self.handle_datagram(payload, ip, port)
def handle_datagram(self, payload, ip, port):
"""Handle an already read udp datagram
......@@ -3104,12 +3104,16 @@ def IgnoreSignals(fn, *args, **kwargs):
return fn(*args, **kwargs)
except EnvironmentError, err:
if err.errno != errno.EINTR:
if err.errno == errno.EINTR:
return None
except (select.error, socket.error), err:
# In python 2.6 and above select.error is an IOError, so it's handled
# above, in 2.5 and below it's not, and it's handled here.
if not (err.args and err.args[0] == errno.EINTR):
if err.args and err.args[0] == errno.EINTR:
return None
......@@ -690,7 +690,24 @@
<simpara>This option is only effective with kvm versions >= 87
and qemu-kvm versions >= 0.11.0.
<simpara>Valid for the KVM hypervisor.</simpara>
<simpara>This boolean option determines wether to run the KVM
instance in a chroot directory.
<para>If it is set to <quote>true</quote>, an empty directory
is created before starting the instance and its path is passed via
the -chroot flag to kvm.
The directory is removed when the instance is stopped.
<simpara>It is set to <quote>false</quote> by default.</simpara>
......@@ -61,11 +61,31 @@ class TestPartial(testutils.GanetiTestCase):
class TestTryToRoman(testutils.GanetiTestCase):
"""test the compat.TryToRoman function"""
def setUp(self):
# Save the compat.roman module so we can alter it with a fake...
self.compat_roman_module = compat.roman
def tearDown(self):
# ...and restore it at the end of the test
compat.roman = self.compat_roman_module
def testAFewIntegers(self):
# This test only works is the roman module is installed
if compat.roman is not None:
self.assertEquals(compat.TryToRoman(0), 0)
self.assertEquals(compat.TryToRoman(1), "I")
self.assertEquals(compat.TryToRoman(4), "IV")
self.assertEquals(compat.TryToRoman(5), "V")
def testWithNoRoman(self):
# compat.roman is saved/restored in setUp/tearDown
compat.roman = None
self.assertEquals(compat.TryToRoman(0), 0)
self.assertEquals(compat.TryToRoman(1), "I")
self.assertEquals(compat.TryToRoman(4), "IV")
self.assertEquals(compat.TryToRoman(5), "V")
self.assertEquals(compat.TryToRoman(1), 1)
self.assertEquals(compat.TryToRoman(4), 4)
self.assertEquals(compat.TryToRoman(5), 5)
def testStrings(self):
self.assertEquals(compat.TryToRoman("astring"), "astring")
......@@ -29,6 +29,7 @@ import time
from ganeti import daemon
from ganeti import errors
from ganeti import utils
import testutils
......@@ -172,10 +173,14 @@ class TestAsyncUDPSocket(testutils.GanetiTestCase):
self.client = _MyAsyncUDPSocket()
self.server.bind(("", 0))
self.port = self.server.getsockname()[1]
# Save utils.IgnoreSignals so we can do evil things to it...
self.saved_utils_ignoresignals = utils.IgnoreSignals
def tearDown(self):
# ...and restore it as well
utils.IgnoreSignals = self.saved_utils_ignoresignals
def testNoDoubleBind(self):
......@@ -229,6 +234,17 @@ class TestAsyncUDPSocket(testutils.GanetiTestCase):
["p1", "p2", "error", "p3", "error", "terminate"])
self.assertEquals(self.server.error_count, 2)
def testSignaledWhileReceiving(self):
utils.IgnoreSignals = lambda fn, *args, **kwargs: None
self.client.enqueue_send("", self.port, "p1")
self.client.enqueue_send("", self.port, "p2")
self.assertEquals(self.server.received, [])
self.client.enqueue_send("", self.port, "terminate")
utils.IgnoreSignals = self.saved_utils_ignoresignals
self.assertEquals(self.server.received, ["p1", "p2", "terminate"])
if __name__ == "__main__":
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment