summaryrefslogtreecommitdiff
path: root/libvirt/utils_domain_def.go
diff options
context:
space:
mode:
authorFlavio Castelli <fcastelli@suse.com>2018-02-20 09:37:39 +0100
committerFlavio Castelli <fcastelli@suse.com>2018-02-20 13:58:57 +0100
commit79e8a4ee25dfec9ecbeb0b65f0caed38e15da67c (patch)
treed0bad561c27b5a48a5b5fe3867652c70055e3135 /libvirt/utils_domain_def.go
parente456355639d72af6ff2da2acd30ec3e914bdd996 (diff)
downloadterraform-provider-libvirt-79e8a4ee25dfec9ecbeb0b65f0caed38e15da67c.tar
terraform-provider-libvirt-79e8a4ee25dfec9ecbeb0b65f0caed38e15da67c.tar.gz
Handle keyword-less kernel params
Allow kernel params that don't have a key/value structure to be handled. Also allow params with nested equal signs, like `root=UUID=aa52d618-a2c4-4aad-aeb7-68d9e3a2c91d` Signed-off-by: Flavio Castelli <fcastelli@suse.com>
Diffstat (limited to 'libvirt/utils_domain_def.go')
-rw-r--r--libvirt/utils_domain_def.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/libvirt/utils_domain_def.go b/libvirt/utils_domain_def.go
index 40d31a09..95c6c0d6 100644
--- a/libvirt/utils_domain_def.go
+++ b/libvirt/utils_domain_def.go
@@ -60,12 +60,17 @@ func splitKernelCmdLine(cmdLine string) ([]map[string]string, error) {
}
currCmdLine := make(map[string]string)
+ keylessCmdLineArgs := []string{}
+
argVals := strings.Split(cmdLine, " ")
for _, argVal := range argVals {
- kv := strings.Split(argVal, "=")
- if len(kv) != 2 {
- return nil, fmt.Errorf("Can't parse kernel command line: '%s'", cmdLine)
+ if !strings.Contains(argVal, "=") {
+ // keyless cmd line (eg: nosplash)
+ keylessCmdLineArgs = append(keylessCmdLineArgs, argVal)
+ continue
}
+
+ 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 {
@@ -77,5 +82,10 @@ func splitKernelCmdLine(cmdLine string) ([]map[string]string, error) {
if len(currCmdLine) > 0 {
cmdLines = append(cmdLines, currCmdLine)
}
+ if len(keylessCmdLineArgs) > 0 {
+ cl := make(map[string]string)
+ cl["_"] = strings.Join(keylessCmdLineArgs, " ")
+ cmdLines = append(cmdLines, cl)
+ }
return cmdLines, nil
}