Skip to content

Commit 30d4dfd

Browse files
committed
add impl From<kvm_xsave> for kvm_xsave2
Construct an kvm_xsave2 with length set to 0. Useful when only a kvm_xsave is at hand, but an API demands a kvm_xsave2, so the kvm_xsave needs to converted into a Xsave with empty flexible array. Signed-off-by: Patrick Roy <[email protected]>
1 parent 884af6d commit 30d4dfd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kvm-bindings/src/x86_64/fam_wrappers.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ pub struct kvm_xsave2 {
113113
pub xsave: kvm_xsave,
114114
}
115115

116+
impl From<kvm_xsave> for kvm_xsave2 {
117+
fn from(xsave: kvm_xsave) -> Self {
118+
kvm_xsave2 { len: 0, xsave }
119+
}
120+
}
121+
116122
// SAFETY:
117123
// - `kvm_xsave2` is a POD
118124
// - `kvm_xsave2` contains a flexible array member as its final field, due to `kvm_xsave` containing

0 commit comments

Comments
 (0)