-
Notifications
You must be signed in to change notification settings - Fork 37
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 nil pointer dereference on CreateVM #176
Conversation
Codecov Report
@@ Coverage Diff @@
## main #176 +/- ##
==========================================
- Coverage 47.00% 46.85% -0.15%
==========================================
Files 45 45
Lines 1951 1957 +6
==========================================
Hits 917 917
- Misses 930 936 +6
Partials 104 104
Continue to review full report at Codecov.
|
infrastructure/firecracker/config.go
Outdated
|
||
bootArgs := "" | ||
if cfg.BootSource.BootArgs != nil { | ||
bootArgs = *cfg.BootSource.BootArgs |
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.
As an alternative, we could create the fcmodels.BootSource
before the api call and set the values if not nil. This works though.
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 like that more, updated.
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 tried to remember why I did this and I remember. First I just solved the initrd problem and then realized bootargs can face the same issue, so fixed that too and my brain did not say "hey you conditionally set 2 fields from a struct that has 3 fields"
The system does not allow to create a VM with both rootfs and initrd specified, that means we should be able to create a vm without initrd, but the code had some strange assumption about that: 160: _, err = client.PutGuestBootSource(ctx, &fcmodels.BootSource{ 161: KernelImagePath: &cfg.BootSource.KernelImagePage, 162: BootArgs: *cfg.BootSource.BootArgs, => 163: InitrdPath: *cfg.BootSource.InitrdPath, 164: }) At the same time, it can happen with BootArgs too as it's not a required field. Fixes #175
7455a11
to
a126670
Compare
What this PR does / why we need it:
The system does not allow to create a VM with both rootfs and initrd
specified, that means we should be able to create a vm without initrd,
but the code had some strange assumption about that:
At the same time, it can happen with BootArgs too as it's not a required
field.
Which issue(s) this PR fixes:
Fixes #175
Special notes for your reviewer:
Checklist: