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

Re: [libvirt] libvirt-python API for "domdisplay"



On 17.06.2013 17:19, mzawdx wrote:
> Hi all:
>     Work with virsh CLI, I can easy use the CLI " virsh -c
> qemu+tcp://127.0.0.1/system domdisplay instance-00000001" successfully:
>  
> [root webmintest ~]#  virsh -c qemu+tcp://127.0.0.1/system domdisplay
> instance-00000001
> Please enter your authentication name: fred
> Please enter your password:
> vnc://127.0.0.1:0
>  
> However, I can find any libvit-python API related to this CLI, does it
> exist ?

No. The domdisplay command is pure virsh with a XPATH magic. The
algorithm is as follows:

1) dump the XML of desired domain
2) for i in "vnc", "spice", "rdp"; do
2a)   xpath = string(/domain/devices/graphics[ type='%s']/@port), %i
2b)   port = xpath_query($domxml, $xpath)
2c)   if !port continue
2d)   xpath = string(/domain/devices/graphics[ type='%s']/@listen), %i
2e)   listen = xpath_query($domxml, $xpath)
2f)   if ($i == "vnc) port -= 5900;
3) print %s://%s:%d, %i %listen %port

The whole source is here:

http://libvirt.org/git/?p=libvirt.git;a=blob;f=tools/virsh-domain.c;h=955e882151827dc69f9aeb374a870134a9777910;hb=HEAD#l8756

Michal


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