Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3e04045
Add some stubs for Windows xenstore support
JKDingwall Mar 4, 2014
39473b2
Implement osnmread, osnmwrite, osnmopen, osnmclose for os.name = ["nt"]
JKDingwall Mar 5, 2014
2fdda78
Use the Windows API to find the device path for the xenbus device.
JKDingwall Mar 5, 2014
62e33fe
Some little missing pieces and fixes. Successfully tested a xenstore…
JKDingwall Mar 5, 2014
33ca9ac
Add WindowsDriverError exception and use it when a failure to find th…
JKDingwall Mar 12, 2014
6528785
Merge branch 'windows' of github.com:JKDingwall/pyxs into windows
JKDingwall Mar 12, 2014
41ac098
Don't provide the C code the work is derived from inline, reference b…
JKDingwall Mar 12, 2014
8560106
Remove __del__()
JKDingwall Mar 12, 2014
778599c
ctypes.POINTER() allocates memory which does not get reclaimed by gc …
JKDingwall Jun 24, 2014
2a30b10
Avoid trailing NULL in value on write
JKDingwall Mar 26, 2015
e843c29
Merge remote-tracking branch 'origin/master' into windows
JKDingwall Mar 26, 2015
ab5a2b3
Add WMI support for Windows Server 2012 with Xen Project PV drivers
royjenkins May 11, 2015
1f391fd
Raise PyXSError properly
royjenkins May 11, 2015
c2b9c9f
Don't call connect() uneccesarily
royjenkins May 12, 2015
7a7bf55
Stop session being created as a list
royjenkins May 12, 2015
36c0aa3
Never allow _wmiSession to be null
royjenkins May 13, 2015
7de6314
Retry Win32OperatingSystem WMI request if it fails
royjenkins May 14, 2015
3f48756
Add additional retries with half-second sleeps around WMI requests; t…
royjenkins May 14, 2015
8fb255d
Increase wait period on retry
royjenkins May 22, 2015
d4411af
Many more retries
royjenkins May 26, 2015
819d275
< not >
royjenkins May 27, 2015
0046ff3
except: is bad practice, don't do it
JKDingwall May 29, 2015
17ed891
whitespace cleanup
JKDingwall May 29, 2015
2d96334
Mark the xenbus connection according to the pv driver project not the…
JKDingwall May 29, 2015
bd9f4b7
Try to decide on the windows xenbus connection class by looking for t…
JKDingwall May 29, 2015
b5d311f
remove unused import.
JKDingwall May 29, 2015
d82404e
remove unused pythoncom import
JKDingwall Jun 3, 2015
b8b12c1
workaround for http://lists.xenproject.org/archives/html/win-pv-devel…
JKDingwall Feb 12, 2016
fb83b1a
prefer "/dev/xen/xenbus" to "/proc/xen/xenbus" on Linux
JKDingwall Apr 11, 2016
0446c8b
prefer XenBusConnection over UnixSocketConnection on posix platforms
JKDingwall Apr 11, 2016
b68f046
Rename DEBUG to CONTROL to match xen-4.9. Don't send an empty payloa…
JKDingwall Apr 28, 2018
b1bb2c4
Use noop control packet while waiting
JKDingwall Sep 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions pyxs/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

__all__ = ["Event", "Op", "Packet"]

import os
import struct
from collections import namedtuple

Expand All @@ -21,7 +22,7 @@

#: Operations supported by XenStore.
Operations = Op = namedtuple("Operations", [
"DEBUG",
"CONTROL",
"DIRECTORY",
"READ",
"GET_PERMS",
Expand Down Expand Up @@ -67,12 +68,17 @@ class Packet(namedtuple("_Packet", "op rq_id tx_id size payload")):

def __new__(cls, op, payload, rq_id=None, tx_id=None):
# Checking restrictions:
# a) payload is limited to 4096 bytes.
if len(payload) > 4096:
raise InvalidPayload(payload)
# b) operation requested is present in ``xsd_sockmsg_type``.
# a) operation requested is present in ``xsd_sockmsg_type``.
if op not in Op:
raise InvalidOperation(op)

# This is to code around http://lists.xenproject.org/archives/html/win-pv-devel/2016-02/msg00005.html
if os.name == "nt" and op == Op.READ and payload is None:
payload = ""

# b) payload is limited to 4096 bytes.
if len(payload) > 4096:
raise InvalidPayload(payload)

return super(Packet, cls).__new__(cls,
op, rq_id or 0, tx_id or 0, len(payload), payload)
27 changes: 20 additions & 7 deletions pyxs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
import threading
import time
import posixpath
import os
from collections import deque

from ._internal import Event, Packet, Op
from .connection import UnixSocketConnection, XenBusConnection
from .connection import UnixSocketConnection, XenBusConnection, XenBusConnectionWinWINPV, XenBusConnectionWinGPLPV
from .exceptions import UnexpectedPacket, PyXSError
from .helpers import validate_path, validate_watch_path, validate_perms, \
dict_merge, force_unicode, error
Expand Down Expand Up @@ -85,11 +86,23 @@ def __init__(self, unix_socket_path=None, socket_timeout=None,
xen_bus_path=None, connection=None, transaction=None):
if connection:
self.connection = connection
elif unix_socket_path or not xen_bus_path:
self.connection = UnixSocketConnection(
unix_socket_path, socket_timeout=socket_timeout)
elif os.name in ["posix"]:
if xen_bus_path or not unix_socket_path:
self.connection = XenBusConnection(xen_bus_path)
else:
self.connection = UnixSocketConnection(
unix_socket_path, socket_timeout=socket_timeout)
elif os.name in ["nt"]:
# There are two windows pv driver projects, examine wmi
# classes to try and determine which one we want to use.
import wmi
try:
wmi.WMI(moniker="//./root/wmi", find_classes=False).XenProjectXenStoreBase()
self.connection = XenBusConnectionWinWINPV()
except AttributeError:
self.connection = XenBusConnectionWinGPLPV()
else:
self.connection = XenBusConnection(xen_bus_path)
raise ConnectionError("no connection to xenstore available")

self.tx_id = 0
self.tx_lock = threading.Lock()
Expand Down Expand Up @@ -213,7 +226,7 @@ def ls(self, path):
:param str path: path to list.
"""
payload = self.execute_command(Op.DIRECTORY, path)
return [] if payload is "" else payload.split("\x00")
return [] if payload is "" else map(lambda x : x.split('/')[-1], payload.split("\x00"))

def get_permissions(self, path):
"""Returns a list of permissions for a given `path`, see
Expand Down Expand Up @@ -441,7 +454,7 @@ def wait(self, sleep=None):
# Executing a noop, hopefuly we'll get some events queued
# in the meantime. Note: I know it sucks, but it seems like
# there's no other way ...
self.client.execute_command(Op.DEBUG, "")
self.client.execute_command(Op.CONTROL, "noop")

if sleep is not None:
time.sleep(sleep)
Loading