Esempio n. 1
0
func (d *VirDomain) DetachDeviceFlags(xml string, flags uint) error {
	cXml := C.CString(xml)
	defer C.free(unsafe.Pointer(cXml))
	result := C.virDomainDetachDeviceFlags(d.ptr, cXml, C.uint(flags))
	if result == -1 {
		return GetLastError()
	}
	return nil
}
Esempio n. 2
0
// DetachDevice detaches a virtual device from a domain, using the flags
// parameter to control how the device is detached. DomDeviceModifyCurrent
// specifies that the device allocation is removed based on current domain
// state. DomDeviceModifyLive specifies that the device shall be deallocated
// from the active domain instance only and is not from the persisted domain
// configuration. DomDeviceModifyConfig specifies that the device shall be
// deallocated from the persisted domain configuration only. Note that the
// target hypervisor must return an error if unable to satisfy flags. E.g. the
// hypervisor driver will return failure if DomDeviceModifyLive is specified
// but it only supports removing the persisted device allocation.
func (dom Domain) DetachDevice(deviceXML string, flags DomainDeviceModifyFlag) error {
	cXML := C.CString(deviceXML)
	defer C.free(unsafe.Pointer(cXML))

	dom.log.Printf("detaching a virtual device from domain (flags = %v)...\n", flags)
	cRet := C.virDomainDetachDeviceFlags(dom.virDomain, cXML, C.uint(flags))
	ret := int32(cRet)

	if ret == -1 {
		err := LastError()
		dom.log.Printf("an error occurred: %v\n", err)
		return err
	}

	dom.log.Println("device detached")

	return nil
}