aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libvirt/utils_domain_def.go5
-rw-r--r--libvirt/utils_domain_def_test.go21
2 files changed, 9 insertions, 17 deletions
diff --git a/libvirt/utils_domain_def.go b/libvirt/utils_domain_def.go
index 90175de1..95c6c0d6 100644
--- a/libvirt/utils_domain_def.go
+++ b/libvirt/utils_domain_def.go
@@ -70,10 +70,7 @@ func splitKernelCmdLine(cmdLine string) ([]map[string]string, error) {
continue
}
- kv := strings.Split(argVal, "=")
- if len(kv) != 2 {
- return nil, fmt.Errorf("Can't parse kernel command line: '%s'", cmdLine)
- }
+ kv := strings.SplitN(argVal, "=", 2)
k, v := kv[0], kv[1]
// if the key is duplicate, start a new map
if _, ok := currCmdLine[k]; ok {
diff --git a/libvirt/utils_domain_def_test.go b/libvirt/utils_domain_def_test.go
index 746c095b..3b3061c5 100644
--- a/libvirt/utils_domain_def_test.go
+++ b/libvirt/utils_domain_def_test.go
@@ -12,8 +12,14 @@ func init() {
}
func TestSplitKernelCmdLine(t *testing.T) {
- e := []map[string]string{{"foo": "bar"}, {"foo": "bar", "key": "val"}, {"_": "nosplash rw"}}
- r, err := splitKernelCmdLine("foo=bar foo=bar key=val nosplash rw")
+ e := []map[string]string{
+ {"foo": "bar"},
+ {
+ "foo": "bar",
+ "key": "val",
+ "root": "UUID=aa52d618-a2c4-4aad-aeb7-68d9e3a2c91d"},
+ {"_": "nosplash rw"}}
+ r, err := splitKernelCmdLine("foo=bar foo=bar key=val root=UUID=aa52d618-a2c4-4aad-aeb7-68d9e3a2c91d nosplash rw")
if !reflect.DeepEqual(r, e) {
t.Fatalf("got='%s' expected='%s'", spew.Sdump(r), spew.Sdump(e))
}
@@ -22,17 +28,6 @@ func TestSplitKernelCmdLine(t *testing.T) {
}
}
-func TestSplitKernelInvalidCmdLine(t *testing.T) {
- v := "foo=barfoo=bar"
- r, err := splitKernelCmdLine(v)
- if r != nil {
- t.Fatalf("got='%s' expected='%s'", spew.Sdump(r), err)
- }
- if err == nil {
- t.Errorf("Expected error for parsing '%s'", v)
- }
-}
-
func TestSplitKernelEmptyCmdLine(t *testing.T) {
var e []map[string]string
r, err := splitKernelCmdLine("")