Skip to content

Commit

Permalink
vfio-ioctls: Remove conditional compilation to x86_64 for mshv feature
Browse files Browse the repository at this point in the history
We are planning to add support for ARM64 on cloud hypervisor side. Thus,
remove the conditional compilation for target_arch x86_64.

Signed-off-by: Jinank Jain <[email protected]>
  • Loading branch information
jinankjain authored and Jinank Jain committed Apr 1, 2024
1 parent 0daff4d commit 8b2b3b2
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions crates/vfio-ioctls/src/vfio_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ use kvm_bindings::{
};
#[cfg(all(feature = "kvm", not(test)))]
use kvm_ioctls::DeviceFd as KvmDeviceFd;
#[cfg(all(feature = "mshv", target_arch = "x86_64", not(test)))]
#[cfg(all(feature = "mshv", not(test)))]
use mshv_bindings::{
mshv_device_attr, MSHV_DEV_VFIO_GROUP, MSHV_DEV_VFIO_GROUP_ADD, MSHV_DEV_VFIO_GROUP_DEL,
};
#[cfg(all(feature = "mshv", target_arch = "x86_64", not(test)))]
#[cfg(all(feature = "mshv", not(test)))]
use mshv_ioctls::DeviceFd as MshvDeviceFd;
#[cfg(all(
any(feature = "kvm", all(feature = "mshv", target_arch = "x86_64")),
any(feature = "kvm", feature = "mshv"),
not(test)
))]
use std::os::unix::io::FromRawFd;
Expand All @@ -45,7 +45,7 @@ use std::os::unix::io::FromRawFd;
enum DeviceFdInner {
#[cfg(all(feature = "kvm", not(test)))]
Kvm(KvmDeviceFd),
#[cfg(all(feature = "mshv", target_arch = "x86_64", not(test)))]
#[cfg(all(feature = "mshv", not(test)))]
Mshv(MshvDeviceFd),
}

Expand All @@ -69,12 +69,12 @@ impl VfioDeviceFd {
}
}
/// Create an VfioDeviceFd from an MSHV DeviceFd
#[cfg(all(feature = "mshv", target_arch = "x86_64", not(test)))]
#[cfg(all(feature = "mshv", not(test)))]
pub fn new_from_mshv(fd: MshvDeviceFd) -> Self {
VfioDeviceFd(DeviceFdInner::Mshv(fd))
}
/// Extract the MSHV DeviceFd from an VfioDeviceFd
#[cfg(all(feature = "mshv", target_arch = "x86_64", not(test)))]
#[cfg(all(feature = "mshv", not(test)))]
pub fn to_mshv(self) -> Result<MshvDeviceFd> {
match self {
VfioDeviceFd(DeviceFdInner::Mshv(fd)) => Ok(fd),
Expand All @@ -84,7 +84,7 @@ impl VfioDeviceFd {
}
/// Try to duplicate an VfioDeviceFd
#[cfg(all(
any(feature = "kvm", all(feature = "mshv", target_arch = "x86_64")),
any(feature = "kvm", feature = "mshv"),
not(test)
))]
pub fn try_clone(&self) -> Result<Self> {
Expand All @@ -101,7 +101,7 @@ impl VfioDeviceFd {
Ok(VfioDeviceFd(DeviceFdInner::Kvm(kvm_fd)))
}
}
#[cfg(all(feature = "mshv", target_arch = "x86_64"))]
#[cfg(feature = "mshv")]
DeviceFdInner::Mshv(fd) => {
// SAFETY: FFI call to libc
let dup_fd = unsafe { libc::dup(fd.as_raw_fd()) };
Expand Down Expand Up @@ -243,7 +243,7 @@ impl VfioContainer {
}

// Add the new group object to the hypervisor driver.
#[cfg(any(feature = "kvm", all(feature = "mshv", target_arch = "x86_64")))]
#[cfg(any(feature = "kvm", feature = "mshv"))]
if let Err(e) = self.device_add_group(&group) {
let _ = vfio_syscall::unset_group_container(&group, self);
return Err(e);
Expand All @@ -264,7 +264,7 @@ impl VfioContainer {
// - one reference cloned in VfioDevice.drop() and passed into here
// - one reference held by the groups hashmap
if Arc::strong_count(&group) == 3 {
#[cfg(any(feature = "kvm", all(feature = "mshv", target_arch = "x86_64")))]
#[cfg(any(feature = "kvm", feature = "mshv"))]
match self.device_del_group(&group) {
Ok(_) => {}
Err(e) => {
Expand Down Expand Up @@ -350,7 +350,7 @@ impl VfioContainer {
}

#[cfg(all(
any(feature = "kvm", all(feature = "mshv", target_arch = "x86_64")),
any(feature = "kvm", feature = "mshv"),
not(test)
))]
fn device_set_group(&self, group: &VfioGroup, add: bool) -> Result<()> {
Expand All @@ -374,7 +374,7 @@ impl VfioContainer {
fd.set_device_attr(&dev_attr)
.map_err(VfioError::SetDeviceAttr)
}
#[cfg(all(feature = "mshv", target_arch = "x86_64"))]
#[cfg(feature = "mshv")]
DeviceFdInner::Mshv(fd) => {
let flag = if add {
MSHV_DEV_VFIO_GROUP_ADD
Expand Down Expand Up @@ -403,7 +403,7 @@ impl VfioContainer {
/// # Parameters
/// * group: target VFIO group
#[cfg(all(
any(feature = "kvm", all(feature = "mshv", target_arch = "x86_64")),
any(feature = "kvm", feature = "mshv"),
not(test)
))]
fn device_add_group(&self, group: &VfioGroup) -> Result<()> {
Expand All @@ -417,7 +417,7 @@ impl VfioContainer {
/// # Parameters
/// * group: target VFIO group
#[cfg(all(
any(feature = "kvm", all(feature = "mshv", target_arch = "x86_64")),
any(feature = "kvm", feature = "mshv"),
not(test)
))]
fn device_del_group(&self, group: &VfioGroup) -> Result<()> {
Expand Down

0 comments on commit 8b2b3b2

Please sign in to comment.