目录

Python使用Libvirt Api

libvirt api文档

libvrit文档:https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetBlockInfo

示例参考:https://github.com/libvirt

示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
[root@localhost ~]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> conn = libvirt.openReadOnly(None)
>>> conn.lookupByName("OTRS")
<libvirt.virDomain instance at 0x7f332aae63b0>
>>> conn.lookupByName("OTRS").info()
[5, 8388608L, 8388608L, 4, 0L]
>>> help(conn)
>>> help(conn.lookupByName("OTRS"))
>>> conn.lookupByName("OTRS").blockInfo("vda",0)
[214748364800L, 6836981760L, 6836981760L]