Skip to content

Commit a4b95a0

Browse files
authored
Merge pull request #639 from cyril-s/fix_vol_backing_storage_format_nil_569
check if volume backing store format is present before creating #569
2 parents 50a5506 + be29b79 commit a4b95a0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libvirt/volume_def.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ func newDefBackingStoreFromLibvirt(baseVolume *libvirt.StorageVol) (libvirtxml.S
6060
if err != nil {
6161
return libvirtxml.StorageVolumeBackingStore{}, fmt.Errorf("could not get base image path: %s", err)
6262
}
63-
backingStoreDef := libvirtxml.StorageVolumeBackingStore{
64-
Path: baseVolPath,
65-
Format: &libvirtxml.StorageVolumeTargetFormat{
63+
var backingStoreVolFormat *libvirtxml.StorageVolumeTargetFormat
64+
if baseVolumeDef.Target.Format != nil {
65+
backingStoreVolFormat = &libvirtxml.StorageVolumeTargetFormat{
6666
Type: baseVolumeDef.Target.Format.Type,
67-
},
67+
}
68+
}
69+
backingStoreDef := libvirtxml.StorageVolumeBackingStore{
70+
Path: baseVolPath,
71+
Format: backingStoreVolFormat,
6872
}
6973
return backingStoreDef, nil
7074
}

0 commit comments

Comments
 (0)