aboutsummaryrefslogtreecommitdiff
path: root/libvirt
diff options
context:
space:
mode:
authorDuncan Mac-Vicar P <dmacvicar@suse.de>2017-11-23 14:50:27 +0100
committerDuncan Mac-Vicar P <dmacvicar@suse.de>2017-11-24 17:56:44 +0100
commita05679a1e2d4ae29e496131a88ba1a129d7f331e (patch)
tree36606e7f85b15a4dd639c698f9c7a1f973781be7 /libvirt
parent1cbfe466f0fb8c2320c54cec9e54fbdb1d5bd4ac (diff)
downloadterraform-provider-libvirt-a05679a1e2d4ae29e496131a88ba1a129d7f331e.tar
terraform-provider-libvirt-a05679a1e2d4ae29e496131a88ba1a129d7f331e.tar.gz
Do not choke on empty kernel cmdline
Diffstat (limited to 'libvirt')
-rw-r--r--libvirt/utils_domain_def.go4
-rw-r--r--libvirt/utils_domain_def_test.go11
2 files changed, 15 insertions, 0 deletions
diff --git a/libvirt/utils_domain_def.go b/libvirt/utils_domain_def.go
index 4e46cb62..670d8b02 100644
--- a/libvirt/utils_domain_def.go
+++ b/libvirt/utils_domain_def.go
@@ -54,6 +54,10 @@ func getOriginalMachineName(caps libvirtxml.Caps, arch string, virttype string,
// key
func splitKernelCmdLine(cmdLine string) ([]map[string]string, error) {
var cmdLines []map[string]string
+ if len(cmdLine) == 0 {
+ return cmdLines, nil
+ }
+
currCmdLine := make(map[string]string)
argVals := strings.Split(cmdLine, " ")
for _, argVal := range argVals {
diff --git a/libvirt/utils_domain_def_test.go b/libvirt/utils_domain_def_test.go
index 4880804e..7ff57203 100644
--- a/libvirt/utils_domain_def_test.go
+++ b/libvirt/utils_domain_def_test.go
@@ -32,3 +32,14 @@ func TestSplitKernelInvalidCmdLine(t *testing.T) {
t.Errorf("Expected error for parsing '%s'", v)
}
}
+
+func TestSplitKernelEmptyCmdLine(t *testing.T) {
+ var e []map[string]string
+ r, err := splitKernelCmdLine("")
+ if !reflect.DeepEqual(r, e) {
+ t.Fatalf("got='%s' expected='%s'", spew.Sdump(r), spew.Sdump(e))
+ }
+ if err != nil {
+ t.Error(err)
+ }
+}