-
Notifications
You must be signed in to change notification settings - Fork 1.2k
dragonball: Fix warnings in default build #11618
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
dragonball: Fix warnings in default build #11618
Conversation
e09e8da
to
94925f5
Compare
94925f5
to
16ce9fc
Compare
16ce9fc
to
b6542a4
Compare
@@ -879,7 +879,7 @@ impl DeviceManager { | |||
/// Start all registered devices when booting the associated virtual machine. | |||
pub fn start_devices( | |||
&mut self, | |||
vm_as: &GuestAddressSpaceImpl, | |||
#[allow(unused)] vm_as: &GuestAddressSpaceImpl, |
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.
Why do we need start_devices
here, rather than using _vm_as
?
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 think the difference here between the previous _
qualifying variable to kill unused is those two fields are not read anywhere, but here vm_as
will be used if host-device
is enabled. Actually this kind of writing is not elegant at least, we can work on refactoring it later
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.
Yep, sure.
src/dragonball/dbs_utils/Cargo.toml
Outdated
@@ -10,6 +10,9 @@ repository = "https://github.com/openanolis/dragonball-sandbox" | |||
keywords = ["dragonball", "secure-sandbox", "utils"] | |||
readme = "README.md" | |||
|
|||
[features] | |||
with-serde = [] |
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.
What is this feature used for?
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 think the feature attribute is useless for this test, since impl Serialize for MacAddr
doesn't have the attribute, right?
#[cfg(feature = "with-serde")]
#[test]
fn test_mac_addr_serialization_and_deserialization() {
let mac: MacAddr =
serde_json::from_str("\"12:34:56:78:9a:bc\"").expect("MacAddr deserialization failed.");
let bytes = mac.get_bytes();
assert_eq!(bytes, [0x12u8, 0x34, 0x56, 0x78, 0x9a, 0xbc]);
let s = serde_json::to_string(&mac).expect("MacAddr serialization failed.");
assert_eq!(s, "\"12:34:56:78:9a:bc\"");
}
impl Serialize for MacAddr {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
self.to_string().serialize(serializer)
}
}
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.
We either remove the feature assertion on top of test_mac_addr_serialization_and_deserialization
, or we add this feature to features section, otherwise test_mac_addr_serialization_and_deserialization
will not be triggering 🤔
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 think we should simply remove #[cfg(feature = "with-serde")]
from test_mac_addr_serialization_and_deserialization
.
@@ -1438,7 +1439,7 @@ mod tests { | |||
let guest_addr = GuestAddress(*dbs_boot::layout::GUEST_MEM_END); | |||
|
|||
let cache_len = 1024 * 1024 * 1024; | |||
let mmap_region = MmapRegion::build( | |||
let mmap_region = vm_memory::MmapRegion::build( |
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.
Why do you add the vm_memory
here?
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.
It documented in the commit message, MmapRegion
is only need when virtio-fs
feature is enabled during testing
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.
Perhaps you can use this instead:
use vm_memory::{GuestAddress, GuestUsize};
#[cfg(feature = "virtio-fs")]
use vm_memory::MmapRegion;
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.
Sure, I thought the same way before, and I just saw only one place which referenced MmapRegion
which makes me tend to think it would be a bit overkill. Either way is fine actually, I will amend it
Code inside `test_mac_addr_serialization_and_deserialization` test does not actually require this `with-serde` feature to test, removing the assertion here to enable this test. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
`VcpuManagerError` is only needed when `host-device` feature is enabled, gate the import behind that feature. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Some fields in structures used for testing purpose are never read, rename to send out the message. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Some variables went unused if certain features are not enabled, use `#[allow(unused)]` to suppress those warnings at the time being. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
`MmapRegion` is only used while `virtio-fs` is enabled during testing dragonball, gate the import behind `virtio-fs` feature. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
b6542a4
to
6392733
Compare
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!
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
We always compile dragonball with
make
command, which enablesall-features
by default in our makefile. This leave some warning in defaultcargo build
unnoticed.Signed-off-by: Ruoqing He heruoqing@iscas.ac.cn