[libvirt] VMware driver: SessionIsActive API / Sessions.ValidateSession permission

Matthias Bolte matthias.bolte at googlemail.com
Mon Feb 15 22:22:27 UTC 2016

2016-02-11 12:59 GMT+01:00 Richard W.M. Jones <rjones at redhat.com>:
> Is calling SessionIsActive necessary?  From my (very limited)
> understanding, it seems as if we might use 'SessionManager.
> currentSession' property instead, which doesn't require admin
> permissions.  Actually the code [see link above] already does this
> when ctx->hasSessionIsActive is false, but that doesn't apply to
> modern vCenter.

SessionIsActive Is not necessary here, but it seemed to be the better
solution compared to this more hacky way of checking session object. I
wasn't aware that is would require admin level privileges.

> Also, why is it even necessary to check if the session is active here?
> Shouldn't we just log in unconditionally?

This was done a long time ago, I don't remember all the details, but
the gist of it goes like this:

The login session will expire after some idle time. I'm not sure if an
expired session could be detected from the server responses at all or
if it was just too difficult to integrated it that way. Anyway, I
ended up checking if the login session was still good and re-login if
it wasn't at the start of every libvirt driver function.

The driver could probably login at the start of each libvirt driver
function and logout at the end, completely avoiding the issue of
idling login session. On the other hand that would be a major chance
in the way the driver works. So I'm not tempted to chance stuff like
this now and am going to play it save.

As said before, SessionIsActive was used because it seemed to be the
right thing to do and I wasn't aware of the consequences at the time.

Here's a patch that basically reverts the offending commit. The patch
is only compile tested, as I don't have a vCenter at hand to test
this. Do you have the option to test this in an actual setup?

Matthias Bolte
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-esx-Avoid-using-vSphere-SessionIsActive-function.patch
Type: text/x-patch
Size: 6014 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160215/d94cdff9/attachment-0001.bin>

More information about the libvir-list mailing list