示例#1
0
func (d *VirDomain) UpdateDeviceFlags(xml string, flags uint) error {
	cXml := C.CString(xml)
	defer C.free(unsafe.Pointer(cXml))
	result := C.virDomainUpdateDeviceFlags(d.ptr, cXml, C.uint(flags))
	if result == -1 {
		return GetLastError()
	}
	return nil
}
示例#2
0
// UpdateDevice changes a virtual device on a domain, using the flags parameter
// to control how the device is changed. DomDeviceModifyCurrent specifies that
// the device change is made based on current domain state. DomDeviceModifyLive
// specifies that the device shall be changed on the active domain instance
// only and is not added to the persisted domain configuration.
// DomDeviceModifyConfig specifies that the device shall be changed on 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
// modifying the persisted device allocation.
func (dom Domain) UpdateDevice(deviceXML string, flags DomainDeviceModifyFlag) error {
	cXML := C.CString(deviceXML)
	defer C.free(unsafe.Pointer(cXML))

	dom.log.Printf("updating a virtual device on domain (flags = %v)...\n", flags)
	cRet := C.virDomainUpdateDeviceFlags(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 updated")

	return nil
}