func (p *VirStoragePool) StorageVolCreateXMLFrom(xmlConfig string, clonevol VirStorageVol, flags uint32) (VirStorageVol, error) { cXml := C.CString(string(xmlConfig)) defer C.free(unsafe.Pointer(cXml)) ptr := C.virStorageVolCreateXMLFrom(p.ptr, cXml, clonevol.ptr, C.uint(flags)) if ptr == nil { return VirStorageVol{}, GetLastError() } return VirStorageVol{ptr: ptr}, nil }
// CreateStorageVolumeFrom creates a storage volume in the parent pool, using // the "cloneVol" volume as input. Information for the new volume (name, perms) // are passed via a typical volume XML description. // Since 1.0.1 VolCreatePreallocMetadata in "flags" can be used to get higher // performance with qcow2 image files which don't support full preallocation, by // creating a sparse image file with metadata. // "Free" should be used to free the resources after the storage volume object // is no longer needed. func (pool StoragePool) CreateStorageVolumeFrom(xml string, cloneVol StorageVolume, flags StorageVolumeCreateFlag) (StorageVolume, error) { cXML := C.CString(xml) defer C.free(unsafe.Pointer(cXML)) pool.log.Printf("creating storage volume from another volume (flags = %v)...\n", flags) cVol := C.virStorageVolCreateXMLFrom(pool.virStoragePool, cXML, cloneVol.virStorageVol, C.uint(flags)) if cVol == nil { err := LastError() pool.log.Printf("an error occurred: %v\n", err) return StorageVolume{}, err } pool.log.Println("volume created") storageVolume := StorageVolume{ log: pool.log, virStorageVol: cVol, } return storageVolume, nil }