Skip to content

Commit 76735de

Browse files
authored
Merge pull request #244 from Wenzel/fix/ci
build.rs: fix println
2 parents 5d9f543 + ddce5a9 commit 76735de

File tree

11 files changed

+168
-94
lines changed

11 files changed

+168
-94
lines changed

.github/workflows/ci.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ jobs:
293293
toolchain: stable
294294
components: clippy
295295

296-
- name: Set up Python 3.7 🐍
296+
- name: Set up Python 3.8 🐍
297297
uses: actions/setup-python@v1
298298
with:
299-
python-version: '3.7'
299+
python-version: '3.8'
300300

301301
- uses: actions/checkout@v1
302302

@@ -328,10 +328,6 @@ jobs:
328328
- name: smoke test
329329
run: python3 -c 'from microvmi import Microvmi, DriverType, CommonInitParamsPy, DriverInitParamsPy, KVMInitParamsPy'
330330

331-
# setup docker cache to speedup rest of the job
332-
- name: Docker Layer Caching
333-
uses: satackey/[email protected]
334-
335331
- name: Build Wheels with manylinux
336332
run: nox -r -s generate_wheels -- --features xen,kvm,virtualbox,mflow --release
337333
working-directory: python

Cargo.lock

+93-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+29-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ crate-type = ["cdylib", "lib"]
1515

1616
[features]
1717
# Xen driver
18-
xen = ["xenctrl", "xenstore-rs", "xenforeignmemory", "xenevtchn", "xenvmevent-sys", "libc"]
18+
xen = [
19+
"xenctrl",
20+
"xenstore-rs",
21+
"xenforeignmemory",
22+
"xenevtchn",
23+
"xenvmevent-sys",
24+
"libc",
25+
]
1926
# KVM driver
2027
kvm = ["kvmi"]
2128
# VirtualBox driver
@@ -34,17 +41,24 @@ nix = "^0.23.0"
3441
enum-iterator = "0.7.0"
3542
thiserror = "1.0"
3643
libc = { version = "0.2.58", optional = true }
37-
xenctrl = { version = "=0.4.7", optional = true }
44+
xenctrl = { version = "=0.6.0", optional = true }
3845
xenstore-rs = { version = "=0.3.2", optional = true }
3946
xenforeignmemory = { version = "=0.2.3", optional = true }
4047
xenevtchn = { version = "=0.1.6", optional = true }
4148
xenvmevent-sys = { version = "=0.1.3", optional = true }
4249
kvmi = { version = "0.4.0", optional = true }
4350
fdp = { version = "=0.2.5", optional = true }
44-
winapi = { version = "0.3", features = ["tlhelp32", "winnt", "handleapi", "securitybaseapi"], optional = true }
51+
winapi = { version = "0.3", features = [
52+
"tlhelp32",
53+
"winnt",
54+
"handleapi",
55+
"securitybaseapi",
56+
], optional = true }
4557
widestring = { version = "0.4", optional = true }
4658
ntapi = { version = "0.3", optional = true }
47-
vid-sys = { version = "=0.3.0", features = ["deprecated-apis"], optional = true }
59+
vid-sys = { version = "=0.3.0", features = [
60+
"deprecated-apis",
61+
], optional = true }
4862
memflow = { version = "0.1.5", optional = true }
4963

5064
[dev-dependencies]
@@ -78,8 +92,16 @@ section = "libs"
7892
priority = "optional"
7993
# add generated libmicrovmi.h header
8094
assets = [
81-
["target/release/libmicrovmi.so", "usr/lib/libmicrovmi.so", "644"],
82-
["target/release/capi/libmicrovmi.h", "usr/include/libmicrovmi.h", "644"],
95+
[
96+
"target/release/libmicrovmi.so",
97+
"usr/lib/libmicrovmi.so",
98+
"644",
99+
],
100+
[
101+
"target/release/capi/libmicrovmi.h",
102+
"usr/include/libmicrovmi.h",
103+
"644",
104+
],
83105
]
84106

85107
[package.metadata.release]
@@ -89,6 +111,4 @@ assets = [
89111
disable-publish = true
90112

91113
[workspace]
92-
members = [
93-
"python"
94-
]
114+
members = ["python"]

build.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,5 @@ fn main() {
3838

3939
println!("cargo:rerun-if-changed=src/capi.rs");
4040
// if it has been removed
41-
println!(
42-
"{}",
43-
format!("cargo:rerun-if-changed={}", &out_path.display())
44-
);
41+
println!("cargo:rerun-if-changed={}", &out_path.display());
4542
}

python/noxfile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
CUR_DIR = Path(__file__).parent
77

88
# default sessions for nox
9-
nox.options.sessions = ["fmt", "lint", "type", "test"]
9+
nox.options.sessions = ["fmt", "lint", "test"]
1010

1111

1212
@nox.session
1313
def fmt(session):
14-
session.install("black==20.8b1")
14+
session.install("black==24.2.0")
1515
# note: black doesn't support setup.cfg
1616
# so we hardcode the config here
1717
session.run("black", "--line-length", "120", ".")

python/requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
setuptools-rust
2-
setuptools==65.5.1
1+
setuptools-rust==1.1.2
2+
setuptools==59.6.0
33
wheel
44
toml==0.10.2

python/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ impl MicrovmiExt {
118118
size: usize,
119119
) -> PyResult<(&'p PyBytes, u64)> {
120120
let mut bytes_read: u64 = 0;
121-
let pybuffer: &PyBytes = PyBytes::new_with(py, size, |mut buffer| {
121+
let pybuffer: &PyBytes = PyBytes::new_with(py, size, |buffer| {
122122
self.driver
123-
.read_physical(paddr, &mut buffer, &mut bytes_read)
123+
.read_physical(paddr, buffer, &mut bytes_read)
124124
.ok();
125125
Ok(())
126126
})?;

src/api/mod.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ pub mod events;
88
pub mod params;
99
pub mod registers;
1010

11-
bitflags! {
12-
pub struct Access: u32 {
13-
const R=0b00000001;
14-
const W=0b00000010;
15-
const X=0b00000100;
16-
const NIL=0b00000000;
17-
const RW=Self::R.bits | Self::W.bits;
18-
const WX=Self::W.bits | Self::X.bits;
19-
const RX=Self::R.bits | Self::X.bits;
20-
const RWX=Self::R.bits | Self::W.bits | Self::X.bits;
11+
#[allow(clippy::bad_bit_mask)]
12+
mod flags {
13+
bitflags! {
14+
pub struct Access: u32 {
15+
const NIL=0b00000000;
16+
const R=0b00000001;
17+
const W=0b00000010;
18+
const X=0b00000100;
19+
const RW=Self::R.bits | Self::W.bits;
20+
const WX=Self::W.bits | Self::X.bits;
21+
const RX=Self::R.bits | Self::X.bits;
22+
const RWX=Self::R.bits | Self::W.bits | Self::X.bits;
23+
}
2124
}
2225
}
26+
pub use flags::Access;
2327

2428
///Represents the available hypervisor VMI drivers supported by libmicrovmi
2529
#[repr(C)]

src/driver/kvm.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
use std::convert::From;
21
use std::convert::TryFrom;
32
use std::convert::TryInto;
43
use std::error::Error;
5-
use std::mem;
6-
use std::vec::Vec;
74

85
use kvmi::constants::PAGE_SIZE;
96
#[cfg(test)] // only needed for tests
@@ -130,7 +127,7 @@ impl<T: KVMIntrospectable> Kvm<T> {
130127

131128
// set vec_events size
132129
let vcpu_count = kvm.get_vcpu_count()?;
133-
kvm.vec_events.resize_with(vcpu_count.try_into()?, || None);
130+
kvm.vec_events.resize_with(vcpu_count.into(), || None);
134131

135132
// enable CR event intercept by default
136133
// (interception will take place when CR register will be specified)
@@ -323,7 +320,7 @@ impl<T: KVMIntrospectable> Introspectable for Kvm<T> {
323320
};
324321

325322
let vcpu = kvmi_event.vcpu;
326-
let vcpu_index: usize = vcpu.try_into()?;
323+
let vcpu_index: usize = vcpu.into();
327324
self.vec_events[vcpu_index] = Some(kvmi_event);
328325

329326
Ok(Some(Event {
@@ -343,9 +340,9 @@ impl<T: KVMIntrospectable> Introspectable for Kvm<T> {
343340
EventReplyType::Continue => KVMiEventReply::Continue,
344341
};
345342
// get KVMiEvent associated with this VCPU
346-
let vcpu_index: usize = event.vcpu.try_into()?;
347-
let kvmi_event = mem::replace(&mut self.vec_events[vcpu_index], None).unwrap();
348-
Ok(self.kvmi.reply(&kvmi_event, kvm_reply_type)?)
343+
let vcpu_index: usize = event.vcpu.into();
344+
let kvmi_event = &mut self.vec_events[vcpu_index].take().unwrap();
345+
Ok(self.kvmi.reply(kvmi_event, kvm_reply_type)?)
349346
}
350347

351348
fn get_driver_type(&self) -> DriverType {

0 commit comments

Comments
 (0)