-
Notifications
You must be signed in to change notification settings - Fork 113
mount: Virtio-blk container rootfs mount for ACRN hypervisor #574
Conversation
Related to: kata-containers/runtime#1779 |
@vijaydhanraj Seeing this error:
Can you gofmt the |
Sure will do. Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #574 +/- ##
==========================================
+ Coverage 50.39% 50.62% +0.22%
==========================================
Files 17 17
Lines 2385 2392 +7
==========================================
+ Hits 1202 1211 +9
Misses 1026 1026
+ Partials 157 155 -2 |
/test |
mount.go
Outdated
|
||
// If hot-plugged, get the device node path based on the PCI address else | ||
// use the virt path provided in Storage Source | ||
if strings.Contains(storage.Source, "/dev") { |
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.
Please can you add some unit tests for this code? This is a very weak match (not anchored) so would match things like /home/developer/foo.txt
. Can you add anchoring reliably to guarantee you only match on actual devices?
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.
Using HasPrefix() now instead of Contains. Added a few negative test cases to check the flow.
mount.go
Outdated
// use the virt path provided in Storage Source | ||
if strings.Contains(storage.Source, "/dev") { | ||
// Make sure the virt path is valid | ||
_, err := os.Stat(storage.Source) |
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 you are matching devices, can you use os.Stat.Mode()
and os.ModeDevice
to check you really got one?
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.
done
For block devices added by acrn, virtpath is directly udpated in storage.source and so no scanning of PCIAddr is required. This is because, the virtio-blk device is not hot-plugged but added during VM launch and updated later with container rootfs using block rescan feature. v2->v3: 1. Addressed weak match for checking storage block device. 2. Added device check for storage block device. 3. Added negative unit tests for the new code. v1->v2: gofmt'd the mount file. Fixes: kata-containers#573 Signed-off-by: Vijay Dhanraj <[email protected]>
/test |
For block devices added by acrn, virtpath is directly udpated
in storage.source and so no scanning of PCIAddr is required.
This is because, the virtio-blk device is not hot-plugged but
added during VM launch and updated later with container rootfs
using block rescan feature.
Fixes: #573
Signed-off-by: Vijay Dhanraj [email protected]