Skip to content

Conversation

@JKDingwall
Copy link
Contributor

Hi,

This branch allows PyXS to work on Windows in combination with the GPLPV drivers. The tested environment is:
Windows 2008R2
GPLPV 0.11.0.3
Python 2.7.6
pywin32-218.win-amd64-py2.7

The modified code was successfully tested on Windows and Linux with:

import os
import pyxs

if os.name in ["nt"]:
    xs = pyxs.Client(None)
elif os.name in ["posix"]:
    xs = pyxs.Client(xen_bus_path="/proc/xen/xenbus")

print xs.ls("/tools/data/vminfo")
print xs.read("vm")

@JKDingwall
Copy link
Contributor Author

I probably should have mentioned that failure cases are not well tested yet:)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think importing ctypes.wintypes qualified might improve readability:

from ctypes import wintypes

foo(wintypes.BOOL)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A copy of the code from the serial example, as with the other piece below it could be changed if preferred.

@superbobry
Copy link
Collaborator

Overall, the Windows-specific code seems really complicated. Maybe we can simplify it somehow?

@JKDingwall
Copy link
Contributor Author

@superbobry - Thank you for the quick review:) I will take some time to incorporate your suggestions on to my branch as soon as possible along with anything else that reveals itself once I've run through tests for my application.

I was unable to find an native implementation of these API calls in pywin32 so a lot of the code is about importing the API directly from the relevant DLL and creating structures suitable for use with that. Since this is the first time I've ever done this sort of thing it was a bit of a brute force cut & paste hack job based on the serial example and it might need someone with more experience to comment on the possibility of simplifying this.

@superbobry
Copy link
Collaborator

Hi, sorry for taking so long to get to this.

Is there a spec. for accessing XenStore on Windows? I do hope there's a more consistent (with Linux) way of approaching the issue.

@JKDingwall
Copy link
Contributor Author

The fork on my account now has support for both the GPLPV and the WinPV driver projects. The original support for GPLPV uses the Windows API to open a connection to the xenbus which is then used exactly the same as under Linux. It is quite complicated because of how the xenbus device is identified and opened but essentially the same code as done in the block driver. The WinPV project exposes xenstore through WMI so we have created a bridge to that in PyXS. There are currently some issues in how the WinPV driver handles empty strings in xenstore as it returns them as None rather than "". This has been raised on the WinPV mailing list.

@superbobry
Copy link
Collaborator

This sounds very exciting. However, I'm not sure I could maintain this code as part of pyxs, since I'm not at all familiar with the Windows side of things.

Here's what I propose instead:

  • Convert a fork into a separate library, e.g. winpyxs.
  • The library will extend pyxs with two connection classes: XenBusConnectionWinWINPV and XenBusConnectionWinGPLPV and provide Windows-specific wrappers for pyxs.monitor and pyxs.Client.

What do you think?

P.S. As of 0.4.0 you need a pyxs.Router to plug a custom connection class into pyxs.Client:

router = Router(CustomConnectionClass())
with pyxs.Client(router=router) as c:
    # ...

@superbobry
Copy link
Collaborator

I did a quick googling and failed to locate any developer documentation for GPLPV and WinPV drivers. How did you work out how to use these?

JKDingwall and others added 4 commits April 11, 2016 16:34
The check operation essentially does an fsck of the xenstore tdb database which is expensive.  A small xenstore patch can be used to introduce a noop control function and it is preferable to use that.  No operation should be necessary here but the implementation of the wait() is wrong in this branch.  The upstream release handles this correctly but the change would be quite intrusive.
@joelnb
Copy link

joelnb commented Nov 21, 2019

I had a go at implementing this as suggested in a separate module (entirely based on the work here) and was able to get a version which works with the current version of pyxs. There are some rough edges still and it's possible that some features are not working correctly but reading keys/listing directories is definitely fully functional. There's no documentation or tests currently but I plan to sort that out, hopefully over the coming week!

The repo is located here: https://github.com/joelnb/win-pyxs
And I pushed it to PyPI for easier installation (in case anyone wants to test): https://pypi.org/project/win-pyxs/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants