Skip to content

Conversation

RuoqingHe
Copy link
Member

We always compile dragonball with make command, which enables all-features by default in our makefile. This leave some warning in default cargo build unnoticed.

Signed-off-by: Ruoqing He heruoqing@iscas.ac.cn

@RuoqingHe RuoqingHe force-pushed the fix-dragonball-default-build branch from e09e8da to 94925f5 Compare July 24, 2025 05:11
@RuoqingHe RuoqingHe force-pushed the fix-dragonball-default-build branch from 94925f5 to 16ce9fc Compare July 24, 2025 05:12
@RuoqingHe RuoqingHe force-pushed the fix-dragonball-default-build branch from 16ce9fc to b6542a4 Compare July 24, 2025 06:47
@@ -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,
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

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

Yep, sure.

@@ -10,6 +10,9 @@ repository = "https://github.com/openanolis/dragonball-sandbox"
keywords = ["dragonball", "secure-sandbox", "utils"]
readme = "README.md"

[features]
with-serde = []
Copy link
Member

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?

Copy link
Member

@justxuewei justxuewei Jul 25, 2025

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)
    }
}

Copy link
Member Author

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 🤔

Copy link
Member

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(
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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;

Copy link
Member Author

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>
@RuoqingHe RuoqingHe force-pushed the fix-dragonball-default-build branch from b6542a4 to 6392733 Compare July 25, 2025 09:10
Copy link
Member

@justxuewei justxuewei left a comment

Choose a reason for hiding this comment

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

Lgtm, thanks!

Copy link
Contributor

@Apokleos Apokleos left a comment

Choose a reason for hiding this comment

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

LGTM

@RuoqingHe RuoqingHe merged commit 3f46347 into kata-containers:main Jul 28, 2025
691 of 719 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants