Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Commit 908ce9b

Browse files
RuoqingHerbradford
authored andcommitted
riscv64: Enable set_device_attr doc test
Originally `set_device_attr` uses VFIO device for testing, but that's not available yet on RISC-V 64-bit platform, the QEMU patch [1] and kernel patch [2] are not upstreamed. Disabling VFIO device test for RISC-V at the time being. [1] https://lore.kernel.org/all/[email protected]/ [2] https://github.com/ventanamicro/linux/tree/dev-upstream Signed-off-by: Ruoqing He <[email protected]>
1 parent 6ac9f42 commit 908ce9b

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

src/ioctls/device.rs

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,36 +41,46 @@ impl DeviceFd {
4141
///
4242
/// # Example
4343
///
44+
/// Configuring a VFIO device using `set_device_attr`. Note that VFIO
45+
/// devices are not yet available on RISC-V The patch for QEMU:
46+
/// https://lore.kernel.org/all/[email protected]/
47+
/// and patch for linux kernel
48+
/// https://github.com/ventanamicro/linux/tree/dev-upstream are both not
49+
/// upstreamed. Disabling VFIO device test for RISC-V at the time being.
50+
///
4451
/// ```rust
4552
/// # extern crate kvm_ioctls;
4653
/// # extern crate kvm_bindings;
4754
/// # use kvm_ioctls::Kvm;
48-
/// # use kvm_bindings::{
49-
/// kvm_device_type_KVM_DEV_TYPE_VFIO,
50-
/// KVM_DEV_VFIO_GROUP, KVM_DEV_VFIO_GROUP_ADD, KVM_CREATE_DEVICE_TEST
51-
/// };
5255
/// let kvm = Kvm::new().unwrap();
5356
/// let vm = kvm.create_vm().unwrap();
5457
///
55-
/// let mut device = kvm_bindings::kvm_create_device {
56-
/// type_: kvm_device_type_KVM_DEV_TYPE_VFIO,
57-
/// fd: 0,
58-
/// flags: KVM_CREATE_DEVICE_TEST,
59-
/// };
58+
/// #[cfg(not(target_arch = "riscv64"))]
59+
/// {
60+
/// # use kvm_bindings::{
61+
/// # kvm_device_type_KVM_DEV_TYPE_VFIO,
62+
/// # KVM_DEV_VFIO_GROUP, KVM_DEV_VFIO_GROUP_ADD, KVM_CREATE_DEVICE_TEST
63+
/// # };
64+
/// let mut device = kvm_bindings::kvm_create_device {
65+
/// type_: kvm_device_type_KVM_DEV_TYPE_VFIO,
66+
/// fd: 0,
67+
/// flags: KVM_CREATE_DEVICE_TEST,
68+
/// };
6069
///
61-
/// let device_fd = vm
62-
/// .create_device(&mut device)
63-
/// .expect("Cannot create KVM device");
70+
/// let device_fd = vm
71+
/// .create_device(&mut device)
72+
/// .expect("Cannot create KVM device");
6473
///
65-
/// let dist_attr = kvm_bindings::kvm_device_attr {
66-
/// group: KVM_DEV_VFIO_GROUP,
67-
/// attr: u64::from(KVM_DEV_VFIO_GROUP_ADD),
68-
/// addr: 0x0,
69-
/// flags: 0,
70-
/// };
74+
/// let dist_attr = kvm_bindings::kvm_device_attr {
75+
/// group: KVM_DEV_VFIO_GROUP,
76+
/// attr: u64::from(KVM_DEV_VFIO_GROUP_ADD),
77+
/// addr: 0x0,
78+
/// flags: 0,
79+
/// };
7180
///
72-
/// if (device_fd.has_device_attr(&dist_attr).is_ok()) {
73-
/// device_fd.set_device_attr(&dist_attr).unwrap();
81+
/// if (device_fd.has_device_attr(&dist_attr).is_ok()) {
82+
/// device_fd.set_device_attr(&dist_attr).unwrap();
83+
/// }
7484
/// }
7585
/// ```
7686
pub fn set_device_attr(&self, device_attr: &kvm_device_attr) -> Result<()> {

0 commit comments

Comments
 (0)