Skip to content

Commit be29b79

Browse files
committed
check if volume backing store format is present before creating #569
cover case when backing volume xml doesn't contain format element
1 parent fc4f303 commit be29b79

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)