[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] xenstore/wmi behaviour


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: James Dingwall <james@xxxxxxxxxxxxxx>
  • Date: Fri, 6 Nov 2015 15:26:10 +0000
  • Delivery-date: Fri, 06 Nov 2015 16:48:31 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Hi,

I am accessing xenstore using python via wmi and I appear to have inconsistent 
behaviour compared to Linux with xenstore-read.  My 
xenstore key is:

/a/path/to/a/key = ""

In xs.c in the xen source:

            char *val = xs_read(xsh, xth, argv[optind], &len);
            if (val == NULL) {
                warnx("couldn't read path %s", argv[optind]);
                return 1;
            }

So a NULL return value is used to indicate that the key does not exist.  
Testing this:

# xenstore-read /a/path/to/a/key ; echo $?

0
# # no output or error

However reading the same key on Windows through wmi instead results in python 
getting a None type object where I believe it should 
get an empty string "".

Setting up a connection in Python through wmi to xenstore then:

>>> print session.GetValue("/a/path/to/a/key")
(None,)

In powershell:
PS C:\>$base = gwmi -n root\wmi -cl XenProjectXenStoreBase
PS C:\>$sid = $base.AddSession("MyNewSession")
PS C:\>$session = gwmi -n root\wmi -q "select * from XenProjectXenStoreSession 
where SessionId=$($sid.SessionId)"
PS C:\>$v = $session.GetValue("/a/path/to/a/key").value
PS C:\>echo $v.getType();
You cannot call a method on a null-valued expression.
At line:1 char:1
+ echo $v.getType()
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
PS C:\>echo "".getType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object

So the behaviour outside of python seems to be the same.

I have tried to follow the xen source code and I didn't find any special NULL 
-> "" conversion in the read path but it is quite 
possible I have missed something.  Therefore I believe that 
SessionExecuteGetValue() of wmi.c should be doing something special so 
there is compatibility in its behaviour between operating systems.

Thanks,
James


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.