Thanks to visit codestin.com
Credit goes to github.com

Skip to content

block: Using feature bits to check the read-only flag - #7294

Merged
rbradford merged 1 commit into
cloud-hypervisor:mainfrom
lisongqian:read-only
Aug 26, 2025
Merged

rbradford merged 1 commit into
cloud-hypervisor:mainfrom
lisongqian:read-only

Conversation

@lisongqian

Copy link
Copy Markdown
Contributor

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]

Comment thread virtio-devices/src/block.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code above uses has_feature() but this does it manually - any reason for that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nothing. I just feel a little bit strange to include a function declaration in this file of these structs' definitions.

Comment thread virtio-devices/src/block.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Extract this to a common piece of code and and then use this for read_only ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@lisongqian
lisongqian force-pushed the read-only branch 2 times, most recently from f284a34 to d7d97ff Compare August 25, 2025 13:38

@rbradford rbradford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice PR - thanks!

@rbradford
rbradford enabled auto-merge August 25, 2025 16:04
Comment thread block/src/lib.rs Outdated

@phip1611 phip1611 Aug 26, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

to align style with other error messages:

Suggested change
#[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")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well spotted - thanks @phip1611

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

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]>
auto-merge was automatically disabled August 26, 2025 08:56

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
(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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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!

@rbradford
rbradford added this pull request to the merge queue Aug 26, 2025
Merged via the queue into cloud-hypervisor:main with commit 92370e8 Aug 26, 2025
39 of 40 checks passed
@lisongqian
lisongqian deleted the read-only branch August 27, 2025 02:27
cbrewster added a commit to cbrewster/cloud-hypervisor that referenced this pull request Dec 8, 2025
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]>
github-merge-queue Bot pushed a commit that referenced this pull request Dec 9, 2025
#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]>
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.

3 participants