查看运行的KVM的虚机

[root@ok Desktop]# cat demo.py 
#!/usr/bin/python
import libvirt
conn = libvirt.open("qemu:///system")

for id in conn.listDomainsID():
	dom = conn.lookupByID(id)
	infos = dom.info()
	print ""
	print "ID = %d" % id
	print "Name = %s" %dom.name()
	print "State = %d" % infos[0]
	print ""

 

[root@ok Desktop]# ./demo.py 

ID = 1
Name = win7
State = 1


ID = 2
Name = centos02
State = 1


ID = 4
Name = 12c
State = 1

 

posted @ 2016-07-05 22:10  bass  阅读(490)  评论(0编辑  收藏  举报