github.com/Cloud-Foundations/Dominator@v0.3.4/hypervisor/manager/vsock.go (about)

     1  package manager
     2  
     3  import (
     4  	"net"
     5  
     6  	"github.com/Cloud-Foundations/Dominator/lib/net/vsock"
     7  )
     8  
     9  func (m *Manager) checkVsockets() error {
    10  	if err := vsock.CheckVsockets(); err != nil {
    11  		m.Logger.Debugf(0, "CheckVsockets(): %v\n", err)
    12  		return nil
    13  	}
    14  	m.vsocketsEnabled = true
    15  	m.Logger.Println("VSOCK enabled")
    16  	return nil
    17  }
    18  
    19  func (m *Manager) getVmCID(ipAddr net.IP) (uint32, error) {
    20  	if !m.vsocketsEnabled {
    21  		return 0, nil
    22  	}
    23  	if ip4 := ipAddr.To4(); ip4 == nil {
    24  		return 0, nil
    25  	} else {
    26  		return uint32(ip4[0])<<24 |
    27  				uint32(ip4[1])<<16 |
    28  				uint32(ip4[2])<<8 |
    29  				uint32(ip4[3]),
    30  			nil
    31  	}
    32  }