firecracker icon indicating copy to clipboard operation
firecracker copied to clipboard

Fix bindgen.sh and solve TODO

Open zulinx86 opened this issue 1 year ago • 2 comments

Changes

  • Fix bindgen.sh
  • Generates Rust code from prctl.h and solve TODO

Reason

bindgen.sh is broken for the following reasons:

  • --size_t-is-usize was removed since it became default behavior.
  • *_gen crates were moved under vmm crate and patching iff.rs no longer works.

Additional Info

ABI is compatbile.

# python3 tools/test_bindings.py firecracker_old firecracker_new
INFO:__main__:struct 'b'<serde::de::impls::ArrayVisitor<[kvm_bindings::x86_64::bindings::kvm_xcr; 16]> as serde::de::Expected>::'' matches
INFO:__main__:struct 'b'<&kvm_bindings::x86_64::bindings::kvm_cpuid2 as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&kvm_bindings::x86_64::bindings::kvm_pit_channel_state as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&kvm_bindings::x86_64::bindings::kvm_msrs as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&kvm_bindings::x86_64::bindings::kvm_msr_list as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&kvm_bindings::x86_64::bindings::kvm_xcr as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&kvm_bindings::x86_64::bindings::kvm_debug_exit_arch as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&kvm_bindings::x86_64::bindings::__IncompleteArrayField<kvm_bindings::x86_64::bindings::kvm_msr_entry> as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<[kvm_bindings::x86_64::bindings::kvm_xcr; 16] as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_segment as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_dtable as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&kvm_bindings::x86_64::bindings::__IncompleteArrayField<u32> as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&kvm_bindings::x86_64::bindings::__IncompleteArrayField<kvm_bindings::x86_64::bindings::kvm_cpuid_entry2> as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&alloc::vec::Vec<kvm_bindings::x86_64::bindings::kvm_msr_list, alloc::alloc::Global> as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&alloc::vec::Vec<kvm_bindings::x86_64::bindings::kvm_cpuid2, alloc::alloc::Global> as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<[kvm_bindings::x86_64::bindings::kvm_pit_channel_state; 3] as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_vcpu_events__bindgen_ty_1 as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_vcpu_events__bindgen_ty_2 as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_vcpu_events__bindgen_ty_3 as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_vcpu_events__bindgen_ty_4 as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_vcpu_events__bindgen_ty_5 as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<serde::de::impls::ArrayVisitor<[kvm_bindings::x86_64::bindings::kvm_pit_channel_state; 3]> as serde::de::Expected>::'' matches
INFO:__main__:struct 'b'<vmm_sys_util::fam::FamStructWrapper<kvm_bindings::x86_64::bindings::kvm_cpuid2> as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<alloc::vec::Vec<kvm_bindings::x86_64::bindings::kvm_msrs, alloc::alloc::Global> as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_debugregs as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_lapic_state as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_mp_state as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_regs as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_sregs as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_vcpu_events as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_xcrs as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_xsave as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_pit_state2 as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<kvm_bindings::x86_64::bindings::kvm_clock_data as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'<&vmm_sys_util::fam::FamStructWrapper<kvm_bindings::x86_64::bindings::kvm_msr_list> as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'*mut [kvm_bindings::x86_64::bindings::kvm_msrs] '' matches
INFO:__main__:struct 'b'&mut [kvm_bindings::x86_64::bindings::kvm_cpuid_entry2] '' matches
INFO:__main__:struct 'b'&mut [kvm_bindings::x86_64::bindings::kvm_msr_entry] '' matches
INFO:__main__:struct 'b'&[kvm_bindings::x86_64::bindings::kvm_cpuid_entry2] '' matches
INFO:__main__:struct 'b'&[kvm_bindings::x86_64::bindings::kvm_msr_entry] '' matches
INFO:__main__:struct 'b'&[vmm::io_uring::bindings::io_uring_probe_op] '' matches
INFO:__main__:struct 'b'&[kvm_bindings::x86_64::bindings::kvm_pit_channel_state] '' matches
INFO:__main__:struct 'b'&[kvm_bindings::x86_64::bindings::kvm_xcr] '' matches
INFO:__main__:struct 'b'&[kvm_bindings::x86_64::bindings::kvm_msr_list] '' matches
INFO:__main__:struct 'b'&[kvm_bindings::x86_64::bindings::kvm_msrs] '' matches
INFO:__main__:struct 'b'&[kvm_bindings::x86_64::bindings::kvm_cpuid2] '' matches
INFO:__main__:struct 'b'&[vmm_sys_util::fam::FamStructWrapper<kvm_bindings::x86_64::bindings::kvm_msrs>] '' matches
INFO:__main__:struct 'b'&mut [kvm_bindings::x86_64::bindings::kvm_msrs] '' matches
INFO:__main__:struct 'b'*const [vmm::io_uring::bindings::io_uring_probe_op] '' matches
INFO:__main__:struct 'b'*mut [vmm::io_uring::bindings::io_uring_probe_op] '' matches
INFO:__main__:struct 'b'*const [kvm_bindings::x86_64::bindings::kvm_msrs] '' matches
INFO:__main__:struct 'b'&mut [vmm::io_uring::bindings::io_uring_restriction] '' matches
INFO:__main__:struct 'b'*mut [vmm::io_uring::bindings::io_uring_restriction] '' matches
INFO:__main__:struct 'b'*const [kvm_bindings::x86_64::bindings::kvm_cpuid_entry2] '' matches
INFO:__main__:struct 'b'*const [kvm_bindings::x86_64::bindings::kvm_msr_entry] '' matches
INFO:__main__:struct 'b'*mut [kvm_bindings::x86_64::bindings::kvm_msr_entry] '' matches
INFO:__main__:struct 'b'(*mut [kvm_bindings::x86_64::bindings::kvm_msr_entry], alloc::alloc::Global) '' matches
INFO:__main__:struct 'b'alloc::boxed::Box<[kvm_bindings::x86_64::bindings::kvm_msr_entry], alloc::alloc::Global> '' matches
INFO:__main__:struct 'b'(core::ptr::unique::Unique<[kvm_bindings::x86_64::bindings::kvm_msr_entry]>, alloc::alloc::Global) '' matches
INFO:__main__:struct 'b'*const [kvm_bindings::x86_64::bindings::kvm_cpuid2] '' matches
INFO:__main__:struct 'b'*const [kvm_bindings::x86_64::bindings::kvm_msr_list] '' matches
INFO:__main__:struct 'b'*mut [kvm_bindings::x86_64::bindings::kvm_cpuid_entry2] '' matches
INFO:__main__:struct 'b'*mut [vmm_sys_util::fam::FamStructWrapper<kvm_bindings::x86_64::bindings::kvm_msrs>] '' matches
INFO:__main__:struct 'b'*mut [vmm::io_uring::bindings::io_uring_probe] '' matches
INFO:__main__:struct 'b'*const [vmm_sys_util::fam::FamStructWrapper<kvm_bindings::x86_64::bindings::kvm_msrs>] '' matches
INFO:__main__:struct 'b'&[vmm::io_uring::bindings::io_uring_probe] '' matches
INFO:__main__:struct 'b'*const [vmm::io_uring::bindings::io_uring_probe] '' matches
INFO:__main__:struct 'b'&mut [vmm::io_uring::bindings::io_uring_probe] '' matches
INFO:__main__:struct 'b'&mut [vmm::io_uring::bindings::io_uring_probe_op] '' matches
INFO:__main__:struct 'b'*mut [kvm_bindings::x86_64::bindings::kvm_msr_list] '' matches
INFO:__main__:struct 'b'*mut [kvm_bindings::x86_64::bindings::kvm_cpuid2] '' matches
INFO:__main__:struct 'b'&mut [kvm_bindings::x86_64::bindings::kvm_msr_list] '' matches
INFO:__main__:struct 'b'&mut [kvm_bindings::x86_64::bindings::kvm_cpuid2] '' matches
INFO:__main__:struct 'b'<&kvm_bindings::x86_64::bindings::kvm_ioapic_state__bindgen_ty_1 as core::fmt::Debug>::'' matches
INFO:__main__:struct 'b'&[kvm_bindings::x86_64::bindings::kvm_ioapic_state__bindgen_ty_1] '' matches
INFO:__main__:Structure layout matches

License Acceptance

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check CONTRIBUTING.md.

PR Checklist

  • ~~[ ] If a specific issue led to this PR, this PR closes the issue.~~
  • [x] The description of changes is clear and encompassing.
  • ~~[ ] Any required documentation changes (code and docs) are included in this PR.~~
  • ~~[ ] API changes follow the Runbook for Firecracker API changes.~~
  • ~~[ ] User-facing changes are mentioned in CHANGELOG.md.~~
  • [x] All added/changed functionality is tested.
  • ~~[ ] New TODOs link to an issue.~~
  • [x] Commits meet contribution quality standards.

  • [x] This functionality cannot be added in rust-vmm.

zulinx86 avatar Mar 22 '24 21:03 zulinx86

Codecov Report

Attention: Patch coverage is 29.86340% with 1489 lines in your changes missing coverage. Please review.

Project coverage is 79.92%. Comparing base (7025008) to head (c3f6504).

Files Patch % Lines
src/vmm/src/io_uring/bindings.rs 30.37% 605 Missing :warning:
src/vmm/src/devices/virtio/net/gen/iff.rs 30.05% 398 Missing :warning:
src/vmm/src/arch_gen/x86/mpspec.rs 27.63% 330 Missing :warning:
src/vmm/src/devices/virtio/gen/virtio_net.rs 32.75% 117 Missing :warning:
src/vmm/src/devices/virtio/net/gen/if_tun.rs 30.76% 36 Missing :warning:
src/firecracker/src/main.rs 0.00% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4520      +/-   ##
==========================================
- Coverage   82.00%   79.92%   -2.08%     
==========================================
  Files         254      254              
  Lines       31195    29930    -1265     
==========================================
- Hits        25581    23923    -1658     
- Misses       5614     6007     +393     
Flag Coverage Δ
5.10-c5n.metal 79.74% <29.90%> (-2.28%) :arrow_down:
5.10-m5n.metal 79.72% <29.90%> (-2.29%) :arrow_down:
5.10-m6a.metal 78.91% <29.90%> (-2.40%) :arrow_down:
5.10-m6g.metal 77.04% <30.47%> (-2.01%) :arrow_down:
5.10-m6i.metal 79.72% <29.90%> (-2.28%) :arrow_down:
5.10-m7g.metal 77.04% <30.47%> (-2.01%) :arrow_down:
6.1-c5n.metal 79.74% <29.90%> (-2.28%) :arrow_down:
6.1-m5n.metal 79.72% <29.90%> (?)
6.1-m6a.metal 78.91% <29.90%> (-2.40%) :arrow_down:
6.1-m6g.metal 77.03% <30.47%> (-2.01%) :arrow_down:
6.1-m6i.metal 79.71% <29.90%> (-2.29%) :arrow_down:
6.1-m7g.metal 77.04% <30.47%> (-2.01%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Mar 22 '24 21:03 codecov[bot]

Huh, I didn't realize the bindings are included in the coverage reports. Should we exclude them? The bindgen generated unit tests are not a inside of test modules, so their lines are included in coverage reports, but since they have assert!s, all the assertion messages are considered "uncovered", which is nonsense.

roypat avatar Mar 25 '24 13:03 roypat

Closing this in favor of PR #4729.

zulinx86 avatar Aug 14 '24 10:08 zulinx86