82
82
}
83
83
#[ repr( C ) ]
84
84
#[ derive( Default ) ]
85
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
85
86
pub struct __IncompleteArrayField < T > ( :: std:: marker:: PhantomData < T > , [ T ; 0 ] ) ;
86
87
impl < T > __IncompleteArrayField < T > {
87
88
#[ inline]
@@ -1426,6 +1427,7 @@ impl ::std::fmt::Debug for kvm_ioapic_state {
1426
1427
}
1427
1428
#[ repr( C ) ]
1428
1429
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
1430
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
1429
1431
pub struct kvm_regs {
1430
1432
pub rax : __u64 ,
1431
1433
pub rbx : __u64 ,
@@ -1643,7 +1645,9 @@ fn bindgen_test_layout_kvm_regs() {
1643
1645
}
1644
1646
#[ repr( C ) ]
1645
1647
#[ derive( Debug , Copy , Clone , PartialEq ) ]
1648
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
1646
1649
pub struct kvm_lapic_state {
1650
+ #[ cfg_attr( feature = "with-serde" , serde( with = "serde_big_array::BigArray" ) ) ]
1647
1651
pub regs : [ :: std:: os:: raw:: c_char ; 1024usize ] ,
1648
1652
}
1649
1653
#[ test]
@@ -1682,6 +1686,7 @@ impl Default for kvm_lapic_state {
1682
1686
}
1683
1687
#[ repr( C ) ]
1684
1688
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
1689
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
1685
1690
pub struct kvm_segment {
1686
1691
pub base : __u64 ,
1687
1692
pub limit : __u32 ,
@@ -1844,6 +1849,7 @@ fn bindgen_test_layout_kvm_segment() {
1844
1849
}
1845
1850
#[ repr( C ) ]
1846
1851
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
1852
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
1847
1853
pub struct kvm_dtable {
1848
1854
pub base : __u64 ,
1849
1855
pub limit : __u16 ,
@@ -1896,6 +1902,7 @@ fn bindgen_test_layout_kvm_dtable() {
1896
1902
}
1897
1903
#[ repr( C ) ]
1898
1904
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
1905
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
1899
1906
pub struct kvm_sregs {
1900
1907
pub cs : kvm_segment ,
1901
1908
pub ds : kvm_segment ,
@@ -2481,6 +2488,7 @@ fn bindgen_test_layout_kvm_fpu() {
2481
2488
}
2482
2489
#[ repr( C ) ]
2483
2490
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
2491
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
2484
2492
pub struct kvm_msr_entry {
2485
2493
pub index : __u32 ,
2486
2494
pub reserved : __u32 ,
@@ -2533,6 +2541,7 @@ fn bindgen_test_layout_kvm_msr_entry() {
2533
2541
}
2534
2542
#[ repr( C ) ]
2535
2543
#[ derive( Debug , Default ) ]
2544
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
2536
2545
pub struct kvm_msrs {
2537
2546
pub nmsrs : __u32 ,
2538
2547
pub pad : __u32 ,
@@ -2885,6 +2894,7 @@ fn bindgen_test_layout_kvm_cpuid() {
2885
2894
}
2886
2895
#[ repr( C ) ]
2887
2896
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
2897
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
2888
2898
pub struct kvm_cpuid_entry2 {
2889
2899
pub function : __u32 ,
2890
2900
pub index : __u32 ,
@@ -2992,6 +3002,7 @@ fn bindgen_test_layout_kvm_cpuid_entry2() {
2992
3002
}
2993
3003
#[ repr( C ) ]
2994
3004
#[ derive( Debug , Default ) ]
3005
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
2995
3006
pub struct kvm_cpuid2 {
2996
3007
pub nent : __u32 ,
2997
3008
pub padding : __u32 ,
@@ -3044,6 +3055,7 @@ fn bindgen_test_layout_kvm_cpuid2() {
3044
3055
}
3045
3056
#[ repr( C ) ]
3046
3057
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
3058
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
3047
3059
pub struct kvm_pit_channel_state {
3048
3060
pub count : __u32 ,
3049
3061
pub latched_count : __u16 ,
@@ -3341,6 +3353,7 @@ fn bindgen_test_layout_kvm_pit_state() {
3341
3353
}
3342
3354
#[ repr( C ) ]
3343
3355
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
3356
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
3344
3357
pub struct kvm_pit_state2 {
3345
3358
pub channels : [ kvm_pit_channel_state ; 3usize ] ,
3346
3359
pub flags : __u32 ,
@@ -3434,6 +3447,7 @@ fn bindgen_test_layout_kvm_reinject_control() {
3434
3447
}
3435
3448
#[ repr( C ) ]
3436
3449
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
3450
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
3437
3451
pub struct kvm_vcpu_events {
3438
3452
pub exception : kvm_vcpu_events__bindgen_ty_1 ,
3439
3453
pub interrupt : kvm_vcpu_events__bindgen_ty_2 ,
@@ -3448,6 +3462,7 @@ pub struct kvm_vcpu_events {
3448
3462
}
3449
3463
#[ repr( C ) ]
3450
3464
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
3465
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
3451
3466
pub struct kvm_vcpu_events__bindgen_ty_1 {
3452
3467
pub injected : __u8 ,
3453
3468
pub nr : __u8 ,
@@ -3523,6 +3538,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_1() {
3523
3538
}
3524
3539
#[ repr( C ) ]
3525
3540
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
3541
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
3526
3542
pub struct kvm_vcpu_events__bindgen_ty_2 {
3527
3543
pub injected : __u8 ,
3528
3544
pub nr : __u8 ,
@@ -3587,6 +3603,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_2() {
3587
3603
}
3588
3604
#[ repr( C ) ]
3589
3605
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
3606
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
3590
3607
pub struct kvm_vcpu_events__bindgen_ty_3 {
3591
3608
pub injected : __u8 ,
3592
3609
pub pending : __u8 ,
@@ -3651,6 +3668,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_3() {
3651
3668
}
3652
3669
#[ repr( C ) ]
3653
3670
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
3671
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
3654
3672
pub struct kvm_vcpu_events__bindgen_ty_4 {
3655
3673
pub smm : __u8 ,
3656
3674
pub pending : __u8 ,
@@ -3715,6 +3733,7 @@ fn bindgen_test_layout_kvm_vcpu_events__bindgen_ty_4() {
3715
3733
}
3716
3734
#[ repr( C ) ]
3717
3735
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
3736
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
3718
3737
pub struct kvm_vcpu_events__bindgen_ty_5 {
3719
3738
pub pending : __u8 ,
3720
3739
}
@@ -3861,6 +3880,7 @@ fn bindgen_test_layout_kvm_vcpu_events() {
3861
3880
}
3862
3881
#[ repr( C ) ]
3863
3882
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
3883
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
3864
3884
pub struct kvm_debugregs {
3865
3885
pub db : [ __u64 ; 4usize ] ,
3866
3886
pub dr6 : __u64 ,
@@ -3939,6 +3959,30 @@ pub struct kvm_xsave {
3939
3959
pub region : [ __u32 ; 1024usize ] ,
3940
3960
pub extra : __IncompleteArrayField < __u32 > ,
3941
3961
}
3962
+
3963
+ #[ cfg( feature = "with-serde" ) ]
3964
+ impl serde:: Serialize for kvm_xsave {
3965
+ fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
3966
+ where
3967
+ S : serde:: Serializer ,
3968
+ {
3969
+ self . region . as_ref ( ) . serialize ( serializer)
3970
+ }
3971
+ }
3972
+
3973
+ #[ cfg( feature = "with-serde" ) ]
3974
+ impl < ' de > serde:: Deserialize < ' de > for kvm_xsave {
3975
+ fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
3976
+ where
3977
+ D : serde:: Deserializer < ' de > ,
3978
+ {
3979
+ let mut xsave = kvm_xsave:: default ( ) ;
3980
+ let region = Vec :: < __u32 > :: deserialize ( deserializer) ?;
3981
+ xsave. region . copy_from_slice ( & region[ ..] ) ;
3982
+ Ok ( xsave)
3983
+ }
3984
+ }
3985
+
3942
3986
#[ test]
3943
3987
fn bindgen_test_layout_kvm_xsave ( ) {
3944
3988
const UNINIT : :: std:: mem:: MaybeUninit < kvm_xsave > = :: std:: mem:: MaybeUninit :: uninit ( ) ;
@@ -3985,6 +4029,7 @@ impl Default for kvm_xsave {
3985
4029
}
3986
4030
#[ repr( C ) ]
3987
4031
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
4032
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
3988
4033
pub struct kvm_xcr {
3989
4034
pub xcr : __u32 ,
3990
4035
pub reserved : __u32 ,
@@ -4037,6 +4082,7 @@ fn bindgen_test_layout_kvm_xcr() {
4037
4082
}
4038
4083
#[ repr( C ) ]
4039
4084
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
4085
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
4040
4086
pub struct kvm_xcrs {
4041
4087
pub nr_xcrs : __u32 ,
4042
4088
pub flags : __u32 ,
@@ -5032,6 +5078,7 @@ impl ::std::fmt::Debug for kvm_irq_level {
5032
5078
}
5033
5079
#[ repr( C ) ]
5034
5080
#[ derive( Copy , Clone ) ]
5081
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
5035
5082
pub struct kvm_irqchip {
5036
5083
pub chip_id : __u32 ,
5037
5084
pub pad : __u32 ,
@@ -5044,6 +5091,29 @@ pub union kvm_irqchip__bindgen_ty_1 {
5044
5091
pub pic : kvm_pic_state ,
5045
5092
pub ioapic : kvm_ioapic_state ,
5046
5093
}
5094
+
5095
+ #[ cfg( feature = "with-serde" ) ]
5096
+ impl serde:: Serialize for kvm_irqchip__bindgen_ty_1 {
5097
+ fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
5098
+ where
5099
+ S : serde:: Serializer ,
5100
+ {
5101
+ // SAFETY: Safe because this is a POD struct and we're only using the read result to
5102
+ // serialize the underlying bytes.
5103
+ unsafe { self . dummy . serialize ( serializer) }
5104
+ }
5105
+ }
5106
+ #[ cfg( feature = "with-serde" ) ]
5107
+ impl < ' de > serde:: Deserialize < ' de > for kvm_irqchip__bindgen_ty_1 {
5108
+ fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
5109
+ where
5110
+ D : serde:: Deserializer < ' de > ,
5111
+ {
5112
+ let dummy = serde_big_array:: BigArray :: deserialize ( deserializer) ?;
5113
+ assert_eq ! ( std:: mem:: size_of_val( & dummy) , std:: mem:: size_of:: <Self >( ) ) ;
5114
+ Ok ( Self { dummy } )
5115
+ }
5116
+ }
5047
5117
#[ test]
5048
5118
fn bindgen_test_layout_kvm_irqchip__bindgen_ty_1 ( ) {
5049
5119
const UNINIT : :: std:: mem:: MaybeUninit < kvm_irqchip__bindgen_ty_1 > =
@@ -9167,6 +9237,7 @@ fn bindgen_test_layout_kvm_vapic_addr() {
9167
9237
}
9168
9238
#[ repr( C ) ]
9169
9239
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
9240
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
9170
9241
pub struct kvm_mp_state {
9171
9242
pub mp_state : __u32 ,
9172
9243
}
@@ -11404,6 +11475,7 @@ fn bindgen_test_layout_kvm_irqfd() {
11404
11475
}
11405
11476
#[ repr( C ) ]
11406
11477
#[ derive( Debug , Default , Copy , Clone , PartialEq ) ]
11478
+ #[ cfg_attr( feature = "with-serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
11407
11479
pub struct kvm_clock_data {
11408
11480
pub clock : __u64 ,
11409
11481
pub flags : __u32 ,
0 commit comments