/usr/lib/python3/dist-packages/novaagent/xenbus.py is in python3-novaagent 2.1.13-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | from pyxs.exceptions import UnexpectedPacket
from pyxs.client import Router
from pyxs._internal import Event
from pyxs._internal import NUL
from pyxs._internal import Op
import select
class XenGuestRouter(Router):
def __call__(self):
try:
while True:
rlist, _wlist, _xlist = select.select(
[self.connection, self.r_terminator], [], [])
if not rlist:
continue
elif self.r_terminator in rlist:
break
packet = self.connection.recv()
if packet.op == Op.WATCH_EVENT:
event = Event(*packet.payload.split(NUL)[:-1])
for monitor in self.monitors[event.token]:
monitor.events.put(event)
else:
"""
The try/except is the reason for the subclass from the
pyxs package. Since this is on the guest only the below
gets the packet payload and returns it without the
validation piece failing.
"""
rvar = None
try:
self.rvars[packet.rq_id]
rvar = self.rvars.pop(packet.rq_id, None)
except Exception:
temp_rq_id = list(self.rvars.keys())[0]
rvar = self.rvars.pop(temp_rq_id, None)
if rvar is None:
raise UnexpectedPacket(packet)
else:
rvar.set(packet)
finally:
self.connection.close()
self.r_terminator.close()
self.w_terminator.close()
|