Skip to content

Commit

Permalink
chore: Remove redundant prefixing
Browse files Browse the repository at this point in the history
Since `use kvm_bindings::*` is in effect, remove redundant prefixing to
keep the code clean.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
  • Loading branch information
TimePrinciple authored and roypat committed Oct 23, 2024
1 parent 65c754c commit 2b4eec5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
28 changes: 14 additions & 14 deletions src/ioctls/vcpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ impl VcpuFd {
/// // KVM_GET_REG_LIST on Aarch64 demands that the vcpus be initialized.
/// #[cfg(target_arch = "aarch64")]
/// {
/// let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default();
/// let mut kvi = kvm_bindings::kvm_vcpu_init::default();
/// vm.get_preferred_target(&mut kvi).unwrap();
/// vcpu.vcpu_init(&kvi).expect("Cannot initialize vcpu");
///
Expand Down Expand Up @@ -2321,7 +2321,7 @@ mod tests {
}

let mut vcpu_fd = vm.create_vcpu(0).unwrap();
let mut kvi = kvm_bindings::kvm_vcpu_init::default();
let mut kvi = kvm_vcpu_init::default();
vm.get_preferred_target(&mut kvi).unwrap();
kvi.features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2;
vcpu_fd.vcpu_init(&kvi).unwrap();
Expand Down Expand Up @@ -2784,7 +2784,7 @@ mod tests {

// KVM defines valid targets as 0 to KVM_ARM_NUM_TARGETS-1, so pick a big raw number
// greater than that as target to be invalid
let kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init {
let kvi = kvm_vcpu_init {
target: 300,
..Default::default()
};
Expand All @@ -2808,7 +2808,7 @@ mod tests {
coalesced_mmio_ring: None,
};

let device_attr = kvm_bindings::kvm_device_attr {
let device_attr = kvm_device_attr {
group: KVM_ARM_VCPU_PMU_V3_CTRL,
attr: u64::from(KVM_ARM_VCPU_PMU_V3_INIT),
addr: 0x0,
Expand Down Expand Up @@ -2926,7 +2926,7 @@ mod tests {
let vm = kvm.create_vm().unwrap();
let vcpu = vm.create_vcpu(0).unwrap();

let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default();
let mut kvi = kvm_vcpu_init::default();

vm.get_preferred_target(&mut kvi)
.expect("Cannot get preferred target");
Expand All @@ -2940,7 +2940,7 @@ mod tests {
let vm = kvm.create_vm().unwrap();
let vcpu = vm.create_vcpu(0).unwrap();

let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default();
let mut kvi = kvm_vcpu_init::default();
vm.get_preferred_target(&mut kvi)
.expect("Cannot get preferred target");
vcpu.vcpu_init(&kvi).expect("Cannot initialize vcpu");
Expand All @@ -2966,7 +2966,7 @@ mod tests {
let vm = kvm.create_vm().unwrap();
let vcpu = vm.create_vcpu(0).unwrap();

let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default();
let mut kvi = kvm_vcpu_init::default();
vm.get_preferred_target(&mut kvi)
.expect("Cannot get preferred target");
vcpu.vcpu_init(&kvi).expect("Cannot initialize vcpu");
Expand Down Expand Up @@ -3007,7 +3007,7 @@ mod tests {
let err = vcpu.get_reg_list(&mut reg_list).unwrap_err();
assert!(err.errno() == libc::ENOEXEC);

let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default();
let mut kvi = kvm_vcpu_init::default();
vm.get_preferred_target(&mut kvi)
.expect("Cannot get preferred target");
vcpu.vcpu_init(&kvi).expect("Cannot initialize vcpu");
Expand Down Expand Up @@ -3321,7 +3321,7 @@ mod tests {
let vm = kvm.create_vm().unwrap();
let vcpu = vm.create_vcpu(0).unwrap();

let dist_attr = kvm_bindings::kvm_device_attr {
let dist_attr = kvm_device_attr {
group: KVM_ARM_VCPU_PMU_V3_CTRL,
attr: u64::from(KVM_ARM_VCPU_PMU_V3_INIT),
addr: 0x0,
Expand All @@ -3330,10 +3330,10 @@ mod tests {

vcpu.has_device_attr(&dist_attr).unwrap_err();
vcpu.set_device_attr(&dist_attr).unwrap_err();
let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default();
let mut kvi: kvm_vcpu_init = kvm_vcpu_init::default();
vm.get_preferred_target(&mut kvi)
.expect("Cannot get preferred target");
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PSCI_0_2 | 1 << KVM_ARM_VCPU_PMU_V3;
kvi.features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2 | 1 << KVM_ARM_VCPU_PMU_V3;
vcpu.vcpu_init(&kvi).unwrap();
vcpu.has_device_attr(&dist_attr).unwrap();
vcpu.set_device_attr(&dist_attr).unwrap();
Expand All @@ -3346,14 +3346,14 @@ mod tests {
let vm = kvm.create_vm().unwrap();
let vcpu = vm.create_vcpu(0).unwrap();

let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default();
let mut kvi = kvm_vcpu_init::default();
vm.get_preferred_target(&mut kvi)
.expect("Cannot get preferred target");
if kvm.check_extension(Cap::ArmPtrAuthAddress) {
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PTRAUTH_ADDRESS;
kvi.features[0] |= 1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS;
}
if kvm.check_extension(Cap::ArmPtrAuthGeneric) {
kvi.features[0] |= 1 << kvm_bindings::KVM_ARM_VCPU_PTRAUTH_GENERIC;
kvi.features[0] |= 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC;
}
vcpu.vcpu_init(&kvi).unwrap();
}
Expand Down
30 changes: 15 additions & 15 deletions src/ioctls/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,7 @@ impl AsRawFd for VmFd {
#[cfg(test)]
#[cfg(target_arch = "aarch64")]
pub(crate) fn create_gic_device(vm: &VmFd, flags: u32) -> DeviceFd {
let mut gic_device = kvm_bindings::kvm_create_device {
let mut gic_device = kvm_create_device {
type_: kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3,
fd: 0,
flags,
Expand All @@ -1940,8 +1940,8 @@ pub(crate) fn create_gic_device(vm: &VmFd, flags: u32) -> DeviceFd {
#[cfg(test)]
#[cfg(target_arch = "aarch64")]
pub(crate) fn set_supported_nr_irqs(vgic: &DeviceFd, nr_irqs: u32) {
let vgic_attr = kvm_bindings::kvm_device_attr {
group: kvm_bindings::KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
let vgic_attr = kvm_device_attr {
group: KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
attr: 0,
addr: &nr_irqs as *const u32 as u64,
flags: 0,
Expand All @@ -1958,9 +1958,9 @@ pub(crate) fn set_supported_nr_irqs(vgic: &DeviceFd, nr_irqs: u32) {
#[cfg(test)]
#[cfg(target_arch = "aarch64")]
pub(crate) fn request_gic_init(vgic: &DeviceFd) {
let vgic_attr = kvm_bindings::kvm_device_attr {
group: kvm_bindings::KVM_DEV_ARM_VGIC_GRP_CTRL,
attr: u64::from(kvm_bindings::KVM_DEV_ARM_VGIC_CTRL_INIT),
let vgic_attr = kvm_device_attr {
group: KVM_DEV_ARM_VGIC_GRP_CTRL,
attr: u64::from(KVM_DEV_ARM_VGIC_CTRL_INIT),
addr: 0,
flags: 0,
};
Expand All @@ -1977,7 +1977,7 @@ pub(crate) fn request_gic_init(vgic: &DeviceFd) {
#[cfg(test)]
#[cfg(target_arch = "riscv64")]
pub(crate) fn create_aia_device(vm: &VmFd, flags: u32) -> DeviceFd {
let mut aia_device = kvm_bindings::kvm_create_device {
let mut aia_device = kvm_create_device {
type_: kvm_device_type_KVM_DEV_TYPE_RISCV_AIA,
fd: 0,
flags,
Expand All @@ -1995,9 +1995,9 @@ pub(crate) fn create_aia_device(vm: &VmFd, flags: u32) -> DeviceFd {
#[cfg(test)]
#[cfg(target_arch = "riscv64")]
pub(crate) fn set_supported_nr_irqs(vaia: &DeviceFd, nr_irqs: u32) {
let vaia_attr = kvm_bindings::kvm_device_attr {
group: kvm_bindings::KVM_DEV_RISCV_AIA_GRP_CONFIG,
attr: u64::from(kvm_bindings::KVM_DEV_RISCV_AIA_CONFIG_SRCS),
let vaia_attr = kvm_device_attr {
group: KVM_DEV_RISCV_AIA_GRP_CONFIG,
attr: u64::from(KVM_DEV_RISCV_AIA_CONFIG_SRCS),
addr: &nr_irqs as *const u32 as u64,
flags: 0,
};
Expand All @@ -2013,9 +2013,9 @@ pub(crate) fn set_supported_nr_irqs(vaia: &DeviceFd, nr_irqs: u32) {
#[cfg(test)]
#[cfg(target_arch = "riscv64")]
pub(crate) fn request_aia_init(vaia: &DeviceFd) {
let vaia_attr = kvm_bindings::kvm_device_attr {
group: kvm_bindings::KVM_DEV_RISCV_AIA_GRP_CTRL,
attr: u64::from(kvm_bindings::KVM_DEV_RISCV_AIA_CTRL_INIT),
let vaia_attr = kvm_device_attr {
group: KVM_DEV_RISCV_AIA_GRP_CTRL,
attr: u64::from(KVM_DEV_RISCV_AIA_CTRL_INIT),
addr: 0,
flags: 0,
};
Expand Down Expand Up @@ -2129,7 +2129,7 @@ mod tests {

// On ARM/arm64, a GICv2 is created. It's better to check ahead whether GICv2
// can be emulated or not.
let mut gic_device = kvm_bindings::kvm_create_device {
let mut gic_device = kvm_create_device {
type_: kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2,
fd: 0,
flags: KVM_CREATE_DEVICE_TEST,
Expand Down Expand Up @@ -2588,7 +2588,7 @@ mod tests {
fn test_get_preferred_target() {
let kvm = Kvm::new().unwrap();
let vm = kvm.create_vm().unwrap();
let mut kvi: kvm_bindings::kvm_vcpu_init = kvm_bindings::kvm_vcpu_init::default();
let mut kvi = kvm_vcpu_init::default();
vm.get_preferred_target(&mut kvi).unwrap();
}

Expand Down

0 comments on commit 2b4eec5

Please sign in to comment.