-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #150 Extract kernel options from the syslinux.conf file if exist #152
Conversation
@praveenkumar Thanks! I'll review it :) |
sorry for the delays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finished review. Sorry for the delay.
return lines | ||
} | ||
|
||
func extractKernelOptions(d *Driver) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you including this func to Driver
method? That's no need d *Driver
arg.
like:
func (d *Driver) extractKernelOptions() error {
Or, Is there any reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you including this func to Driver method?
No, I needed it volumeRootDir := d.ResolveStorePath(isoMountPath)
for this, otherwise I have to again need to mount and get those details. Or there any other better I can get this value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, no, no.
Go language can call d.
methods if the own function has a d.
pointer receiver.
Yes, call d.ResolveStorePath(isoMountPath)
need d
, but if change to below, also can call all of d.
methods.
func (d *Driver) extractKernelOptions() error {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or, I was misunderstanding...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zchee I will check that.
@@ -619,6 +665,10 @@ func (d *Driver) extractKernelImages() error { | |||
return err | |||
} | |||
|
|||
if err := extractKernelOptions(d); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as d *Driver
@@ -397,6 +399,7 @@ func (d *Driver) Create() error { | |||
return err | |||
} | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't like a double newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zchee Agree I will remove that.
if err != nil { | ||
return err | ||
} | ||
for _, line := range readIsoLinuxCfg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know which is better, but that's logic can including readLine
function with adding (d *Driver)
to readLine
.
If you(we) want to find only one append
option, Can avoid scan all line on isolinux.cfg
with regexp.MatchString
and break
.
But, It becomes a little complicated and it processing different from the meaning of the readLine
function name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zchee yes, I will add this logic to readLine
function and then return only matched line.
@@ -84,6 +85,7 @@ var ( | |||
ErrMachineNotExist = errors.New("machine does not exist") | |||
diskRegexp = regexp.MustCompile("^/dev/disk([0-9]+)") | |||
kernelRegexp = regexp.MustCompile(`(vmlinu[xz]|bzImage)[\d]*`) | |||
kernelOptionRegexp = regexp.MustCompile(`\s*append`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: If there is append
text in the menu
(or etc) on isolinux.cfg
, It might be matched that line.
If append
section is always indented, use \s{2}append
is better.
But note that \s{2}append
regexp pattern still not perfect :(
If there is a possibility that append
is not indented, no need to change this pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a possibility that append is not indented, no need to change this pattern.
I can't bet of how other distro have it but for Centos/fedora/boot2docker/minikube it's indented I am in favor to keep it as it is in case some distro not follow intended way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems intended.
However, maybe there is append
to menu
is an edge case.
I leave this to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zchee I will update it to \s{2}
in PR.
@praveenkumar Ah, forgot |
} | ||
} | ||
if d.BootCmd == "" { | ||
err = errors.New("Not abled to parse isolinux.cfg, Please use --xhyve-boot-cmd option") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'm not at good English. but "abled" is google translate suggest Did you mean: Not able to parse isolinux.cfg
https://translate.google.com/?source=gtx_m#en/ja/Not%20abled%20to%20parse%20isolinux.cfg
I leave this to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zchee You are right, need update.
@praveenkumar And, |
@zchee Thanks for detailed review, I will incorporate those suggestion and update the PR soon. |
@praveenkumar Thanks :) |
67736cb
to
e1f45c8
Compare
… file if exist
e1f45c8
to
e51c8fc
Compare
@praveenkumar thanks for update :) ready? |
@zchee yes, let's merge it :) |
@praveenkumar I see :) |
Sure, take your time 👍 |
@praveenkumar Thanks :) I tested it, works successfully! |
@zchee please do a review. I tested with boot2docker, minikube and centos all works as expected. I am still a golang newbie so code might be not so appealing but happy to improve as per suggestion.
Also tested with ubuntu and get error message as expected.