Skip to content
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

Merged
merged 1 commit into from
Nov 21, 2016

Conversation

praveenkumar
Copy link
Collaborator

@praveenkumar praveenkumar commented Nov 15, 2016

@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.

(ubuntu) DBG | Extracting Kernel Options
Error creating machine: Error in driver during machine creation: Not abled to parse isolinux.cfg, Please use --xhyve-boot-cmd option

@zchee
Copy link
Member

zchee commented Nov 15, 2016

@praveenkumar Thanks! I'll review it :)

@zchee
Copy link
Member

zchee commented Nov 16, 2016

sorry for the delays.
I'll review at today.

Copy link
Member

@zchee zchee left a 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 {
Copy link
Member

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?

Copy link
Collaborator Author

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?

Copy link
Member

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 {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, I was misunderstanding...?

Copy link
Collaborator Author

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 {
Copy link
Member

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
}


Copy link
Member

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.

Copy link
Collaborator Author

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 {
Copy link
Member

@zchee zchee Nov 17, 2016

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.

Copy link
Collaborator Author

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`)
Copy link
Member

@zchee zchee Nov 17, 2016

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.

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

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.

@zchee
Copy link
Member

zchee commented Nov 17, 2016

@praveenkumar Ah, forgot @ mention.
This comment just for mentioned.

}
}
if d.BootCmd == "" {
err = errors.New("Not abled to parse isolinux.cfg, Please use --xhyve-boot-cmd option")
Copy link
Member

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.

Copy link
Collaborator Author

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.

@zchee
Copy link
Member

zchee commented Nov 17, 2016

@praveenkumar And, nit: comment is not negative. Just wondering(?)
No offense to you.

@praveenkumar
Copy link
Collaborator Author

@zchee Thanks for detailed review, I will incorporate those suggestion and update the PR soon.

@zchee
Copy link
Member

zchee commented Nov 17, 2016

@praveenkumar Thanks :)

@praveenkumar praveenkumar force-pushed the fix_150 branch 2 times, most recently from 67736cb to e1f45c8 Compare November 18, 2016 07:47
@zchee
Copy link
Member

zchee commented Nov 19, 2016

@praveenkumar thanks for update :) ready?

@praveenkumar
Copy link
Collaborator Author

@zchee yes, let's merge it :)

@zchee
Copy link
Member

zchee commented Nov 20, 2016

@praveenkumar I see :)
I'll merge it after the final check, Thanks!!

@praveenkumar
Copy link
Collaborator Author

I'll merge it after the final check.

Sure, take your time 👍

@zchee
Copy link
Member

zchee commented Nov 21, 2016

@praveenkumar Thanks :) I tested it, works successfully!
LGTM, merge.

@zchee zchee merged commit 261fa05 into machine-drivers:master Nov 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants