// ListVMs list all known VMs managed by libvirt
ListVMs list all known VMs managed by libvirt
// ListVMs list all known VMs managed by libvirt
func (vt *VMTool) ListVMs() (map[string]*VMInfo, error) {
	domains, err := vt.conn.ListDomains()
	if err != nil {
		return nil, fmt.Errorf("failed to list all domains: %v", err)
	}
	vms := make(map[string]*VMInfo, len(domains))
	for _, domain := range domains {
		uuid, err := domain.GetUUIDString()
		if err != nil {
			return nil, fmt.Errorf("failed to get domain's uuid: %v", err)
		}
		state, err := domain.GetState()
		if err != nil {
			return nil, fmt.Errorf("failed to get domain(%q) state: %v", uuid, err)
		}
		vms[uuid] = &VMInfo{
			UUID:  uuid,
			State: state,
		}
	}
	return vms, nil
}
func ( vt * VMTool ) ListVMs ( ) ( map [ string ] * VMInfo , error ) { domains , err := vt . conn . ListDomains ( ) if err != nil { return nil , fmt . Errorf ( " " , err ) } vms := make ( map [ string ] * VMInfo , len ( domains ) ) for _ , domain := range domains { uuid , err := domain . GetUUIDString ( ) if err != nil { return nil , fmt . Errorf ( " " , err ) } state , err := domain . GetState ( ) if err != nil { return nil , fmt . Errorf ( " " , uuid , err ) } vms [ uuid ] = & VMInfo { UUID : uuid , State : state , } } return vms , nil }
ListVMs list all known VMs managed by libvirt
ListVMs list all known VMs managed by libvirt