Beispiel #1
0
func (ld *LibvirtDriver) checkConnection() error {
	if alive, _ := ld.conn.IsAlive(); !alive {
		glog.V(1).Info("libvirt disconnected, reconnect")
		conn, err := libvirtgo.NewVirConnection(LibvirtdAddress)
		if err != nil {
			return err
		}
		ld.conn.CloseConnection()
		ld.conn = conn
		return nil
	}
	return fmt.Errorf("connection is alive")
}
Beispiel #2
0
func InitDriver() *LibvirtDriver {
	/* Libvirt adds memballoon device by default */
	hypervisor.PciAddrFrom = 0x06
	conn, err := libvirtgo.NewVirConnection(LibvirtdAddress)
	if err != nil {
		glog.Error("fail to connect to libvirtd ", LibvirtdAddress, err)
		return nil
	}

	return &LibvirtDriver{
		conn: conn,
	}
}