-
Notifications
You must be signed in to change notification settings - Fork 565
vmm: config: Add DiskConfig check for device serial length #7124
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
Conversation
virtio-devices/src/block.rs
Outdated
| let mut s = Vec::from(s); | ||
| if s.len() > VIRTIO_BLK_ID_BYTES as usize { | ||
| s.truncate(VIRTIO_BLK_ID_BYTES as usize); | ||
| warn!("Serial truncated to {} bytes", VIRTIO_BLK_ID_BYTES); |
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 clarify that it's the block device serial - warn!("Block device serial truncated to {} bytes", VIRTIO_BLK_ID_BYTES)
rbradford
left a comment
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.
lgtm! Thanks.
80c03ff to
48139a0
Compare
virtio-devices/src/block.rs
Outdated
| let serial = serial | ||
| .map(Vec::from) | ||
| .unwrap_or_else(|| build_serial(&disk_path)); | ||
| let serial = if let Some(s) = serial { |
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.
Looking at this PR again - I think the commit message is a bit confusing. Something like:
virtio-devices: block: Truncate device serial to maximum supported length
Truncate the device serial to the maximum supported length to ensure that it is correctly matched during guest boot disk discovery.
|
The other option would be to refuse to create the block device if the serial is too long? |
48139a0 to
e1d3a5b
Compare
If we decide to refuse to create the block device if the serial is too long, would it be better to do the check in DiskConfig? |
Yes - do you want to give it a go? |
virtio-devices/src/block.rs
Outdated
| .unwrap_or_else(|| build_serial(&disk_path)); | ||
| let serial = if let Some(s) = serial { | ||
| let mut s = Vec::from(s); | ||
| if s.len() > VIRTIO_BLK_ID_BYTES as usize { |
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.
May be we should not let user create the device, we are modifying the content provided by the user, Who knows user might use this value to track something?
Yes, I would love to and will update this PR. |
e1d3a5b to
c635c01
Compare
Signed-off-by: Jinrong Liang <[email protected]>
Signed-off-by: Jinrong Liang <[email protected]>
c635c01 to
7f49963
Compare
rbradford
left a comment
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.
Very happy with this version.
f151fdb
When starting a VM with a disk serial specified, for example:
The VM fails to boot and the following log is observed:
This patch adds support for checking and truncating disk custom serial to avoid VM startup failures.