summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libvirt/resource_libvirt_volume.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/libvirt/resource_libvirt_volume.go b/libvirt/resource_libvirt_volume.go
index 7e7173ed..b37a2867 100644
--- a/libvirt/resource_libvirt_volume.go
+++ b/libvirt/resource_libvirt_volume.go
@@ -101,6 +101,20 @@ func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error
volumeDef.Capacity.Amount = d.Get("size").(int)
}
+ if baseVolumeId, ok := d.GetOk("base_volume"); ok {
+ volumeDef.BackingStore = new(defBackingStore)
+ volumeDef.BackingStore.Format.Type = "qcow2"
+ baseVolume, err := virConn.LookupStorageVolByKey(baseVolumeId.(string))
+ if err != nil {
+ return fmt.Errorf("Can't retrieve volume %s", baseVolumeId.(string))
+ }
+ baseVolPath, err := baseVolume.GetPath()
+ if err != nil {
+ return fmt.Errorf("can't get name for base image '%s'", baseVolumeId)
+ }
+ volumeDef.BackingStore.Path = baseVolPath
+ }
+
volumeDefXml, err := xml.Marshal(volumeDef)
if err != nil {
return fmt.Errorf("Error serializing libvirt volume: %s", err)