Skip to content

Commit 16f1e19

Browse files
bchaliosShadowCurse
authored andcommitted
kvm-ioctls: use KvmIrqRouting in set_gsi_routing
Use the FamStructWrapper when calling the ioctl. Signed-off-by: Babis Chalios <bchalios@amazon.es>
1 parent fe315c9 commit 16f1e19

File tree

1 file changed

+6
-5
lines changed
  • kvm-ioctls/src/ioctls

1 file changed

+6
-5
lines changed

kvm-ioctls/src/ioctls/vm.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ impl VmFd {
606606
/// # extern crate kvm_ioctls;
607607
/// extern crate kvm_bindings;
608608
/// # use kvm_ioctls::Kvm;
609-
/// use kvm_bindings::kvm_irq_routing;
609+
/// use kvm_bindings::KvmIrqRouting;
610610
///
611611
/// let kvm = Kvm::new().unwrap();
612612
/// let vm = kvm.create_vm().unwrap();
@@ -622,18 +622,19 @@ impl VmFd {
622622
/// })
623623
/// .expect("Cannot create KVM vAIA device.");
624624
///
625-
/// let irq_routing = kvm_irq_routing::default();
625+
/// let irq_routing = KvmIrqRouting::new(0).unwrap();
626626
/// vm.set_gsi_routing(&irq_routing).unwrap();
627627
/// ```
628628
#[cfg(any(
629629
target_arch = "x86_64",
630630
target_arch = "aarch64",
631631
target_arch = "riscv64"
632632
))]
633-
pub fn set_gsi_routing(&self, irq_routing: &kvm_irq_routing) -> Result<()> {
633+
pub fn set_gsi_routing(&self, irq_routing: &KvmIrqRouting) -> Result<()> {
634634
// SAFETY: Safe because we allocated the structure and we know the kernel
635635
// will read exactly the size of the structure.
636-
let ret = unsafe { ioctl_with_ref(self, KVM_SET_GSI_ROUTING(), irq_routing) };
636+
let ret =
637+
unsafe { ioctl_with_ref(self, KVM_SET_GSI_ROUTING(), irq_routing.as_fam_struct_ref()) };
637638
if ret == 0 {
638639
Ok(())
639640
} else {
@@ -2669,7 +2670,7 @@ mod tests {
26692670
fn test_set_gsi_routing() {
26702671
let kvm = Kvm::new().unwrap();
26712672
let vm = kvm.create_vm().unwrap();
2672-
let irq_routing = kvm_irq_routing::default();
2673+
let irq_routing = KvmIrqRouting::new(0).unwrap();
26732674

26742675
// Expect failure for x86 since the irqchip is not created yet.
26752676
#[cfg(target_arch = "x86_64")]

0 commit comments

Comments
 (0)