block: Using feature bits to check the read-only flag - #7294
Conversation
There was a problem hiding this comment.
The code above uses has_feature() but this does it manually - any reason for that?
There was a problem hiding this comment.
Nothing. I just feel a little bit strange to include a function declaration in this file of these structs' definitions.
There was a problem hiding this comment.
Extract this to a common piece of code and and then use this for read_only ?
f284a34 to
d7d97ff
Compare
There was a problem hiding this comment.
to align style with other error messages:
| #[error("Can't execute an operation other than `read` on a read-only device.")] | |
| #[error("Can't execute an operation other than `read` on a read-only device")] |
This patch changes the read-only check using acked features bit, which will help to check more features. Signed-off-by: Songqian Li <[email protected]>
Head branch was pushed to by a user without write access
| } | ||
|
|
||
| fn has_feature(features: u64, feature_flag: u64) -> bool { | ||
| (features & (1u64 << feature_flag)) != 0 |
There was a problem hiding this comment.
nit:
| (features & (1u64 << feature_flag)) != 0 | |
| (features & (1 << feature_flag)) != 0 |
You can leave it as it, but this makes things harder to read than necessary
There was a problem hiding this comment.
Thank you for your review. Align style with others, so remains unchanged.
BTW, you can make multiple comments at once instead of making one at a time, which will save a lot of time. :)
There was a problem hiding this comment.
BTW, you can make multiple comments at once instead of making one at a time, which will save a lot of time. :)
Thanks! I'm used to the one-comment-at-a-time approach. I will try to put more focus on the review feature to submit all my comments in a batch in the future!
92370e8
cloud-hypervisor#7294 adjusted the checks for read-only requests made to virtio-blk devices and started rejecting VIRTIO_BLK_T_GET_ID requests. These requests do not perform any writes and are needed in order to access device serials from within the guest. Signed-off-by: Connor Brewster <[email protected]>
#7294 adjusted the checks for read-only requests made to virtio-blk devices and started rejecting VIRTIO_BLK_T_GET_ID requests. These requests do not perform any writes and are needed in order to access device serials from within the guest. Signed-off-by: Connor Brewster <[email protected]>
block: Using feature bits to check the read-only flag
This patch changes the read-only check using acked features bit, which will help to check more features.
Signed-off-by: Songqian Li [email protected]