Skip to content

Commit 81dd5a9

Browse files
stefano-garzarellajiangliu
authored andcommitted
vhost_kern: add vhost_msg_v2 bindings
Add structs and tests for the C 'struct vhost_msg_v2' type supported by vhost-kern. Signed-off-by: Stefano Garzarella <[email protected]>
1 parent c489e2b commit 81dd5a9

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/vhost_kern/vhost_binding.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub const VHOST_IOTLB_ACCESS_FAIL: raw::c_uchar = 4;
3030
pub const VHOST_IOTLB_BATCH_BEGIN: raw::c_uchar = 5;
3131
pub const VHOST_IOTLB_BATCH_END: raw::c_uchar = 6;
3232
pub const VHOST_IOTLB_MSG: raw::c_int = 1;
33+
pub const VHOST_IOTLB_MSG_V2: raw::c_uint = 2;
3334
pub const VHOST_PAGE_SIZE: raw::c_uint = 4096;
3435
pub const VHOST_VIRTIO: raw::c_uint = 175;
3536
pub const VHOST_VRING_LITTLE_ENDIAN: raw::c_uint = 0;
@@ -172,6 +173,34 @@ impl Default for vhost_msg__bindgen_ty_1 {
172173
}
173174
}
174175

176+
#[repr(C)]
177+
#[derive(Copy, Clone)]
178+
pub struct vhost_msg_v2 {
179+
pub type_: raw::c_uint,
180+
pub reserved: raw::c_uint,
181+
pub __bindgen_anon_1: vhost_msg_v2__bindgen_ty_1,
182+
}
183+
184+
impl Default for vhost_msg_v2 {
185+
fn default() -> Self {
186+
unsafe { ::std::mem::zeroed() }
187+
}
188+
}
189+
190+
#[repr(C)]
191+
#[derive(Copy, Clone)]
192+
pub union vhost_msg_v2__bindgen_ty_1 {
193+
pub iotlb: vhost_iotlb_msg,
194+
pub padding: [raw::c_uchar; 64usize],
195+
_bindgen_union_align: [u64; 8usize],
196+
}
197+
198+
impl Default for vhost_msg_v2__bindgen_ty_1 {
199+
fn default() -> Self {
200+
unsafe { ::std::mem::zeroed() }
201+
}
202+
}
203+
175204
#[repr(C)]
176205
#[derive(Debug, Default, Copy, Clone)]
177206
pub struct vhost_memory_region {
@@ -323,6 +352,34 @@ mod tests {
323352
);
324353
}
325354

355+
#[test]
356+
fn bindgen_test_layout_vhost_msg_v2__bindgen_ty_1() {
357+
assert_eq!(
358+
::std::mem::size_of::<vhost_msg_v2__bindgen_ty_1>(),
359+
64usize,
360+
concat!("Size of: ", stringify!(vhost_msg_v2__bindgen_ty_1))
361+
);
362+
assert_eq!(
363+
::std::mem::align_of::<vhost_msg_v2__bindgen_ty_1>(),
364+
8usize,
365+
concat!("Alignment of ", stringify!(vhost_msg_v2__bindgen_ty_1))
366+
);
367+
}
368+
369+
#[test]
370+
fn bindgen_test_layout_vhost_msg_v2() {
371+
assert_eq!(
372+
::std::mem::size_of::<vhost_msg_v2>(),
373+
72usize,
374+
concat!("Size of: ", stringify!(vhost_msg_v2))
375+
);
376+
assert_eq!(
377+
::std::mem::align_of::<vhost_msg_v2>(),
378+
8usize,
379+
concat!("Alignment of ", stringify!(vhost_msg_v2))
380+
);
381+
}
382+
326383
#[test]
327384
fn bindgen_test_layout_vhost_memory_region() {
328385
assert_eq!(

0 commit comments

Comments
 (0)