查看运行的KVM的虚机

时间:2021-07-14 10:21:10
[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