diff options
-rw-r--r-- | libvirt/utils_domain_def.go | 4 | ||||
-rw-r--r-- | libvirt/utils_domain_def_test.go | 11 |
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) + } +} |