Re: libvirt-python API for "domdisplay"

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

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]