Skip to content
This repository was archived by the owner on Sep 7, 2021. It is now read-only.

Commit 7361fad

Browse files
committed
Addressed PR feedback
Changed licenses, fixed compilation annotations, created separate files for explicitly-defined Windows data structures, and moved all tests to a module at the end of the file.
1 parent 69f29f5 commit 7361fad

File tree

9 files changed

+1467
-476
lines changed

9 files changed

+1467
-476
lines changed

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ version = "0.1.0"
44
authors = ["Jenny Mankin <[email protected]>",
55
"Timo Kreuzer <[email protected]>",
66
"Alessandro Pilotti <[email protected]>"]
7+
description = "Hypervisor-agnostic abstraction crate over virtual CPU functionality"
8+
repository = "https://github.com/rust-vmm/vmm-vcpu"
9+
readme = "README.md"
10+
license = "Apache-2.0 or MIT"
711

812
[dependencies]
913
byteorder = "*"

LICENSE renamed to LICENSE-APACHE

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/

LICENSE-MIT

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Permission is hereby granted, free of charge, to any
2+
person obtaining a copy of this software and associated
3+
documentation files (the "Software"), to deal in the
4+
Software without restriction, including without
5+
limitation the rights to use, copy, modify, merge,
6+
publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software
8+
is furnished to do so, subject to the following
9+
conditions:
10+
11+
The above copyright notice and this permission notice
12+
shall be included in all copies or substantial portions
13+
of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.
24+

src/arm.rs

+10-22
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
// Copyright 2018-2019 CrowdStrike, Inc.
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License"); you may
4-
// not use this file except in compliance with the License. You may obtain
5-
// a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
// License for the specific language governing permissions and limitations
13-
// under the License.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
143

15-
///
16-
/// Use kvm_bindings behind the scenes as these are architectural structures and
17-
/// not actually KVM-dependent, but export as generically-named data
18-
/// structures to be consumed by any VMM's vCPU implementation
19-
///
4+
/// ARM-specific data structures.
205
6+
///
217
/// Type of CPU to present to the guest, and the optional features it should have.
228
///
23-
/// pub struct kvm_vcpu_init {
24-
/// pub target: __u32,
25-
/// pub features: [__u32; 7usize],
26-
/// }
27-
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
9+
#[cfg(windows)]
10+
pub struct VcpuInit {
11+
pub target: u32,
12+
pub features: [u32; 7usize],
13+
}
14+
15+
#[cfg(unix)]
2816
pub use kvm_bindings::kvm_vcpu_init as VcpuInit;

src/lib.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
// Copyright 2018-2019 CrowdStrike, Inc.
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License"); you may
4-
// not use this file except in compliance with the License. You may obtain
5-
// a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
// License for the specific language governing permissions and limitations
13-
// under the License.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
pub mod vcpu;
145

156
#[cfg(unix)]
167
extern crate kvm_bindings;
178

18-
pub mod vcpu;
19-
209
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
2110
pub mod x86_64;
2211

src/vcpu.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2018-2019 CrowdStrike, Inc.
2-
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-License-Identifier: Apache-2.0 or MIT
33
//
44
// Portions Copyright 2018 Cloudbase Solutions Srl
5-
// SPDX-License-Identifier: Apache-2.0
5+
// SPDX-License-Identifier: Apache-2.0 or MIT
66
//
77
// Portions Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
88
// SPDX-License-Identifier: Apache-2.0 OR MIT
@@ -15,32 +15,15 @@
1515
1616
use std::{io, result};
1717

18-
///
19-
/// Generic types used in the virtual CPU trait definition and exported for
20-
/// public consumption.
21-
///
22-
/// These types use kvm_bindings under the hood, as they are not necessarily KVM-
23-
/// specific, but rather generic x86/x86/ARM structures. Generic naming makes
24-
/// them more intuitive for consumption by non-KVM VMMs.
25-
///
2618
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
2719
pub use arm::VcpuInit;
2820

2921
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
3022
pub use x86_64::{
31-
DescriptorTable, FpuState, MsrEntries, MsrEntry, SegmentRegister, SpecialRegisters,
32-
StandardRegisters,
23+
StandardRegisters, SpecialRegisters, FpuState, MsrEntries, MsrEntry,
24+
CpuId, LapicState
3325
};
3426

35-
///
36-
/// Generic types used in the virtual CPU trait definition and exported for
37-
/// public consumption.
38-
///
39-
/// These types are explicitly defined in x86_64
40-
///
41-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
42-
pub use x86_64::{CpuId, LapicState};
43-
4427
///
4528
/// Reasons for vCPU exits.
4629
///

0 commit comments

Comments
 (0)