summaryrefslogtreecommitdiff
path: root/libvirt/resource_libvirt_volume.go
diff options
context:
space:
mode:
Diffstat (limited to 'libvirt/resource_libvirt_volume.go')
-rw-r--r--libvirt/resource_libvirt_volume.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/libvirt/resource_libvirt_volume.go b/libvirt/resource_libvirt_volume.go
index 5e20c079..a25d157d 100644
--- a/libvirt/resource_libvirt_volume.go
+++ b/libvirt/resource_libvirt_volume.go
@@ -35,6 +35,11 @@ func volumeCommonSchema() map[string]*schema.Schema {
Computed: true,
ForceNew: true,
},
+ "format": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ ForceNew: true,
+ },
"base_volume_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
@@ -50,6 +55,11 @@ func volumeCommonSchema() map[string]*schema.Schema {
Optional: true,
ForceNew: true,
},
+ "base_volume_format": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ ForceNew: true,
+ },
}
}
@@ -106,6 +116,12 @@ func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error
volumeDef.Name = name.(string)
}
+ volumeFormat := "qcow2"
+ if _, ok := d.GetOk("format"); ok {
+ volumeFormat = d.Get("format").(string)
+ }
+ volumeDef.Target.Format.Type = volumeFormat
+
var (
img image
volume *libvirt.StorageVol = nil
@@ -171,7 +187,12 @@ func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error
volume = nil
volumeDef.BackingStore = new(defBackingStore)
- volumeDef.BackingStore.Format.Type = "qcow2"
+
+ baseVolumeFormat := "qcow2"
+ if _, ok := d.GetOk("base_volume_format"); ok {
+ baseVolumeFormat = d.Get("base_volume_format").(string)
+ }
+ volumeDef.BackingStore.Format.Type = baseVolumeFormat
baseVolume, err := virConn.LookupStorageVolByKey(baseVolumeId.(string))
if err != nil {
return fmt.Errorf("Can't retrieve volume %s", baseVolumeId.(string))