Daniel P. Berrange wrote:
On Fri, Apr 09, 2010 at 03:31:37PM +0100, Antoine Martin wrote:
> [snip]
>>> * not everything is exposed via libvirt:
>>> virsh can retrieve vncdisplay
>>> but libvirt (or at least the python bindings) does not. How come?
>>> This happens to be one thing I need for writing a libvirt backend for my
>>> virtual desktop software.
>> The 'virsh vncdisplay' command is simply fetching the XML doc for the
>> guest and then extracting the VNC port using a xpath expression
>>
>> /domain/devices/graphics[@type='vnc']/@port
>>
>> So for python you'd want to just get an XML handling module and do similar.
> Yes, I saw that in the virsh code.
> Shouldn't this be part of the libvirt api proper??
> Isn't it supposed to shield us from dealing with files and XML?
It isn't scalable to add APIs for extracting each possible piece of info
from the XML. All languages have APIs for extracting data from XML using
XPath (or DOM). Thus it is better to leave that flexibility to the apps
rather than hardcoding APIs for it in libvirt. The XML schemas/docs are
a formal part of the libvit API, so we're not trying to sheild that from
apps.
I was thinking of something like:
domain.get_attribute("vncdisplay")
Because it's a shame to have to use virsh as a wrapper (or XML file
parsing) and re-do all the work that was done to get to the domain
object when all your really want is just an attribute..
Cheers
Antoine
Regards,
Daniel