当前位置: 首页>>代码示例>>Golang>>正文


Golang C.GoVboxFAILED函数代码示例

本文整理汇总了Golang中C.GoVboxFAILED函数的典型用法代码示例。如果您正苦于以下问题:Golang GoVboxFAILED函数的具体用法?Golang GoVboxFAILED怎么用?Golang GoVboxFAILED使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GoVboxFAILED函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Init

// Init initializes the VirtualBox global data structures.
//
// Due to VirtualBox oddness, Init should ideally be called in the
// application's main thread. The odds of this happening are maximized by
// calling Init() from the application's main goroutine.
//
// It returns any error encountered.
func Init() error {
	// For convenience, Init() is idempotent.

	if glueInitialized == false {
		result := C.GoVboxCGlueInit()
		if C.GoVboxFAILED(result) != 0 {
			cmessage := C.GoString(&C.g_szVBoxErrMsg[0])
			return errors.New(fmt.Sprintf("VBoxCGlueInit failed: %s", cmessage))
		}

		glueInitialized = true
		AppVersion = uint(C.GoVboxGetAppVersion())
		ApiVersion = uint(C.GoVboxGetApiVersion())
	}

	if client == nil {
		result := C.GoVboxClientInitialize(&client)
		if C.GoVboxFAILED(result) != 0 || client == nil {
			client = nil
			return errors.New(fmt.Sprintf("pfnClientInitialize failed: %x", result))
		}
	}

	if cbox == nil {
		result := C.GoVboxGetVirtualBox(client, &cbox)
		if C.GoVboxFAILED(result) != 0 || cbox == nil {
			cbox = nil
			return errors.New(fmt.Sprintf("Failed to get IVirtualBox: %x", result))
		}
	}

	return nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:40,代码来源:vbox.go

示例2: GetMediumFormats

// GetMediumFormats returns the guest OS formats supported by VirtualBox.
// It returns a slice of MediumFormat instances and any error encountered.
func (props *SystemProperties) GetMediumFormats() ([]MediumFormat, error) {
	var cformatsPtr **C.IMediumFormat
	var formatCount C.ULONG

	result := C.GoVboxGetMediumFormats(props.cprops, &cformatsPtr, &formatCount)
	if C.GoVboxFAILED(result) != 0 || (cformatsPtr == nil && formatCount > 0) {
		return nil, errors.New(
			fmt.Sprintf("Failed to get IMediumFormat array: %x", result))
	}

	sliceHeader := reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(cformatsPtr)),
		Len:  int(formatCount),
		Cap:  int(formatCount),
	}
	cformatsSlice := *(*[]*C.IMediumFormat)(unsafe.Pointer(&sliceHeader))

	var formats = make([]MediumFormat, formatCount)
	for i := range cformatsSlice {
		formats[i] = MediumFormat{cformatsSlice[i]}
	}

	C.GoVboxArrayOutFree(unsafe.Pointer(cformatsPtr))
	return formats, nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:27,代码来源:medium_format.go

示例3: Unregister

// Unregister removes this from VirtualBox's list of registered machines.
// The returned slice of Medium instances is intended to be passed to
// DeleteConfig to get all the VM's files cleaned.
// It returns an array of detached Medium instances and any error encountered.
func (machine *Machine) Unregister(cleanupMode CleanupMode) ([]Medium, error) {
	var cmediaPtr **C.IMedium
	var mediaCount C.ULONG

	result := C.GoVboxMachineUnregister(machine.cmachine,
		C.PRUint32(cleanupMode), &cmediaPtr, &mediaCount)
	if C.GoVboxFAILED(result) != 0 || (cmediaPtr == nil && mediaCount != 0) {
		return nil, errors.New(
			fmt.Sprintf("Failed to unregister IMachine: %x", result))
	}

	sliceHeader := reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(cmediaPtr)),
		Len:  int(mediaCount),
		Cap:  int(mediaCount),
	}
	cmediaSlice := *(*[]*C.IMedium)(unsafe.Pointer(&sliceHeader))

	var media = make([]Medium, mediaCount)
	for i := range cmediaSlice {
		media[i] = Medium{cmediaSlice[i]}
	}

	C.GoVboxArrayOutFree(unsafe.Pointer(cmediaPtr))
	return media, nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:30,代码来源:machine.go

示例4: GetMachines

// GetMachines returns the machines known to VirtualBox.
// It returns a slice of Machine instances and any error encountered.
func GetMachines() ([]Machine, error) {
	if err := Init(); err != nil {
		return nil, err
	}

	var cmachinesPtr **C.IMachine
	var machineCount C.ULONG

	result := C.GoVboxGetMachines(cbox, &cmachinesPtr, &machineCount)
	if C.GoVboxFAILED(result) != 0 ||
		(cmachinesPtr == nil && machineCount != 0) {
		return nil, errors.New(
			fmt.Sprintf("Failed to get IMachine array: %x", result))
	}

	sliceHeader := reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(cmachinesPtr)),
		Len:  int(machineCount),
		Cap:  int(machineCount),
	}
	cmachinesSlice := *(*[]*C.IMachine)(unsafe.Pointer(&sliceHeader))

	var machines = make([]Machine, machineCount)
	for i := range cmachinesSlice {
		machines[i] = Machine{cmachinesSlice[i]}
	}

	C.GoVboxArrayOutFree(unsafe.Pointer(cmachinesPtr))
	return machines, nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:32,代码来源:machine.go

示例5: ComposeMachineFilename

// ComposeMachineFilename returns a default VM config file path.
// If baseFolder is empty, VirtualBox's default machine folder will be used.
// It returns a string and any error encountered.
func ComposeMachineFilename(
	name string, flags string, baseFolder string) (string, error) {
	if err := Init(); err != nil {
		return "", err
	}

	var cpath *C.char
	cname := C.CString(name)
	cflags := C.CString(flags)
	cbaseFolder := C.CString(baseFolder)
	result := C.GoVboxComposeMachineFilename(cbox, cname, cflags, cbaseFolder,
		&cpath)
	C.free(unsafe.Pointer(cname))
	C.free(unsafe.Pointer(cflags))
	C.free(unsafe.Pointer(cbaseFolder))

	if C.GoVboxFAILED(result) != 0 || cpath == nil {
		return "", errors.New(
			fmt.Sprintf("IVirtualBox failed to compose machine name: %x", result))
	}

	path := C.GoString(cpath)
	C.GoVboxUtf8Free(cpath)
	return path, nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:28,代码来源:vbox.go

示例6: GetGuestOsTypes

// GetGuestOsTypes returns the guest OS types supported by VirtualBox.
// It returns a slice of GuestOsType instances and any error encountered.
func GetGuestOsTypes() ([]GuestOsType, error) {
  if err := Init(); err != nil {
    return nil, err
  }

  var ctypesPtr **C.IGuestOSType
  var typeCount C.ULONG

  result := C.GoVboxGetGuestOSTypes(cbox, &ctypesPtr, &typeCount)
  if C.GoVboxFAILED(result) != 0 || (ctypesPtr == nil && typeCount != 0) {
    return nil, errors.New(
        fmt.Sprintf("Failed to get IGuestOSType array: %x", result))
  }

  sliceHeader := reflect.SliceHeader{
    Data: uintptr(unsafe.Pointer(ctypesPtr)),
    Len:  int(typeCount),
    Cap:  int(typeCount),
  }
  ctypesSlice := *(*[]*C.IGuestOSType)(unsafe.Pointer(&sliceHeader))

  var types = make([]GuestOsType, typeCount)
  for i := range ctypesSlice {
    types[i] = GuestOsType{ctypesSlice[i]}
  }

  C.GoVboxArrayOutFree(unsafe.Pointer(ctypesPtr))
  return types, nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:31,代码来源:os_type.go

示例7: Close

// Close removes the bond between the Medium object and the image backing it.
// After this call, the Medium instance should be released, as any calls
// involving it will error out. The image file is not deleted, so it can be
// bound to a new Medium by calling OpenMedium.
// It returns any error encountered.
func (medium *Medium) Close() error {
	result := C.GoVboxMediumClose(medium.cmedium)
	if C.GoVboxFAILED(result) != 0 {
		return errors.New(fmt.Sprintf("Failed to close IMedium: %x", result))
	}
	return nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:12,代码来源:medium.go

示例8: WaitForCompletion

// WaitForCompletion waits for all the operations tracked by this to complete.
// The timeout argument is in milliseconds. -1 is used to wait indefinitely.
// It returns any error encountered.
func (progress *Progress) WaitForCompletion(timeout int) error {
	result := C.GoVboxProgressWaitForCompletion(progress.cprogress,
		C.int(timeout))
	if C.GoVboxFAILED(result) != 0 {
		return errors.New(fmt.Sprintf("Failed to wait on IProgress: %x", result))
	}
	return nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:11,代码来源:progress.go

示例9: LockMachine

// LockMachine obtains a lock on a VM, so it can be modified or started.
// It returns any error encountered.
func (session *Session) LockMachine(machine Machine, lockType LockType) error {
	result := C.GoVboxLockMachine(machine.cmachine, session.csession,
		C.PRUint32(lockType))
	if C.GoVboxFAILED(result) != 0 {
		return errors.New(fmt.Sprintf("Failed to lock IMachine: %x", result))
	}
	return nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:10,代码来源:session.go

示例10: SetVramSize

// SetVramSize changes the machine's emulated mouse type.
// It returns a number and any error encountered.
func (machine *Machine) SetVramSize(vram uint) error {
	result := C.GoVboxSetMachineVRAMSize(machine.cmachine, C.PRUint32(vram))
	if C.GoVboxFAILED(result) != 0 {
		return errors.New(
			fmt.Sprintf("Failed to set IMachine VRAM size: %x", result))
	}
	return nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:10,代码来源:machine.go

示例11: UnlockMachine

// UnlockMachine releases the VM locked by this session.
// It returns any error encountered.
func (session *Session) UnlockMachine() error {
	result := C.GoVboxUnlockMachine(session.csession)
	if C.GoVboxFAILED(result) != 0 {
		return errors.New(
			fmt.Sprintf("Failed to unlock ISession machine: %x", result))
	}
	return nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:10,代码来源:session.go

示例12: SaveSettings

// SaveSettings saves a machine's modified settings.
// A new machine must have its settings saved before it can be registered.
// It returns a boolean and any error encountered.
func (machine *Machine) SaveSettings() error {
	result := C.GoVboxMachineSaveSettings(machine.cmachine)
	if C.GoVboxFAILED(result) != 0 {
		return errors.New(
			fmt.Sprintf("Failed to save IMachine settings: %x", result))
	}
	return nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:11,代码来源:machine.go

示例13: GetDisplay

// GetDisplay obtains the display of the VM controlled by this.
// It returns a new Display instance and any error encountered.
func (console *Console) GetDisplay() (Display, error) {
	var display Display
	result := C.GoVboxGetConsoleDisplay(console.cconsole, &display.cdisplay)
	if C.GoVboxFAILED(result) != 0 || display.cdisplay == nil {
		return display, errors.New(
			fmt.Sprintf("Failed to get IConsole display: %x", result))
	}
	return display, nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:11,代码来源:console.go

示例14: GetMachine

// GetMachine obtains the VM associated with this set of VM controls.
// It returns a new Machine instance and any error encountered.
func (console *Console) GetMachine() (Machine, error) {
	var machine Machine
	result := C.GoVboxGetConsoleMachine(console.cconsole, &machine.cmachine)
	if C.GoVboxFAILED(result) != 0 || machine.cmachine == nil {
		return machine, errors.New(
			fmt.Sprintf("Failed to get IConsole machine: %x", result))
	}
	return machine, nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:11,代码来源:console.go

示例15: GetSize

// GetSize returns the actual size of the image backing the medium.
// The returned size can be smaller than the logical size for dynamically grown
// images.
// It returns a byte quantity and any error encountered.
func (medium *Medium) GetSize() (int64, error) {
	var csize C.PRInt64

	result := C.GoVboxGetMediumSize(medium.cmedium, &csize)
	if C.GoVboxFAILED(result) != 0 {
		return 0, errors.New(fmt.Sprintf("Failed to get IMedium size: %x", result))
	}
	return int64(csize), nil
}
开发者ID:jvaemape,项目名称:vbox,代码行数:13,代码来源:medium.go


注:本文中的C.GoVboxFAILED函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。