From c61104df475fc73f3b2ca5330f7c3bde9b5ad834 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 11 Dec 2019 13:02:07 +0000 Subject: [PATCH] vmm: Port to latest vmm-sys-util The signal handling for vCPU signals has changed in the latest release so switch to the new API. Signed-off-by: Rob Bradford --- Cargo.lock | 30 +++++++++++++++--------------- Cargo.toml | 2 +- devices/Cargo.toml | 2 +- net_gen/Cargo.toml | 2 +- net_util/Cargo.toml | 2 +- pci/Cargo.toml | 2 +- qcow/Cargo.toml | 2 +- vfio/Cargo.toml | 2 +- vhost_rs/Cargo.toml | 2 +- vhost_user_backend/Cargo.toml | 2 +- vm-virtio/Cargo.toml | 2 +- vmm/Cargo.toml | 2 +- vmm/src/cpu.rs | 21 +++++---------------- 13 files changed, 31 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f03f745de..bf592b7e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ dependencies = [ "vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)", "vm-virtio 0.1.0", "vmm 0.1.0", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -234,7 +234,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -333,7 +333,7 @@ name = "kvm-bindings" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -343,7 +343,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kvm-bindings 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -421,7 +421,7 @@ dependencies = [ name = "net_gen" version = "0.1.0" dependencies = [ - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -435,7 +435,7 @@ dependencies = [ "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -460,7 +460,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "vm-allocator 0.1.0", "vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -571,7 +571,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "remain 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -978,7 +978,7 @@ dependencies = [ "vm-allocator 0.1.0", "vm-device 0.1.0", "vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -997,7 +997,7 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1009,7 +1009,7 @@ dependencies = [ "vhost_rs 0.1.0", "vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)", "vm-virtio 0.1.0", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1073,7 +1073,7 @@ dependencies = [ "vm-allocator 0.1.0", "vm-device 0.1.0", "vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1102,7 +1102,7 @@ dependencies = [ "vm-allocator 0.1.0", "vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)", "vm-virtio 0.1.0", - "vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1115,7 +1115,7 @@ dependencies = [ [[package]] name = "vmm-sys-util" -version = "0.2.1" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1274,7 +1274,7 @@ dependencies = [ "checksum virtio-bindings 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff512178285488516ed85f15b5d0113a7cdb89e9e8a760b269ae4f02b84bd6b" "checksum vm-memory 0.1.0 (git+https://github.com/rust-vmm/vm-memory)" = "" "checksum vmm-sys-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "46996f56aeae31fbc0532ae57a944e00089302f03b18c10c76eebfd9249f4a6c" -"checksum vmm-sys-util 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6ebb6ba7ba5653b69bfd3fab8c8c363945c0d3f616a6a1592e12122c3be4724e" +"checksum vmm-sys-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f4588e216e77682850f4ae35ec855c2517f93d671a2578d2a32d20bf8a73de38" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" diff --git a/Cargo.toml b/Cargo.toml index 79851194a..95948838f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ virtio-bindings = "0.1.0" vmm = { path = "vmm" } vm-device = { path = "vm-device" } vm-memory = { git = "https://github.com/rust-vmm/vm-memory" } -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" vm-virtio = { path = "vm-virtio" } [dev-dependencies] diff --git a/devices/Cargo.toml b/devices/Cargo.toml index 6becc82fc..2fadaa9dd 100644 --- a/devices/Cargo.toml +++ b/devices/Cargo.toml @@ -11,7 +11,7 @@ kvm-ioctls = "0.4.0" libc = "0.2.60" log = "0.4.8" vm-memory = { git = "https://github.com/rust-vmm/vm-memory" } -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" [dev-dependencies] tempfile = "3.1.0" diff --git a/net_gen/Cargo.toml b/net_gen/Cargo.toml index 6db077ada..4e28dcb79 100644 --- a/net_gen/Cargo.toml +++ b/net_gen/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" authors = ["The Chromium OS Authors"] [dependencies] -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" diff --git a/net_util/Cargo.toml b/net_util/Cargo.toml index 529aaa0d0..bbb998317 100644 --- a/net_util/Cargo.toml +++ b/net_util/Cargo.toml @@ -7,7 +7,7 @@ authors = ["The Chromium OS Authors"] libc = "0.2.60" rand = "0.7.0" serde = "1.0.98" -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" net_gen = { path = "../net_gen" } diff --git a/pci/Cargo.toml b/pci/Cargo.toml index 9b95903fc..968248b56 100644 --- a/pci/Cargo.toml +++ b/pci/Cargo.toml @@ -11,4 +11,4 @@ devices = { path = "../devices" } libc = "0.2.60" log = "0.4.8" vm-memory = { git = "https://github.com/rust-vmm/vm-memory" } -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" diff --git a/qcow/Cargo.toml b/qcow/Cargo.toml index 09a33acb9..cd2f86685 100755 --- a/qcow/Cargo.toml +++ b/qcow/Cargo.toml @@ -13,7 +13,7 @@ byteorder = "1.3.2" libc = "0.2.60" log = "0.4.8" remain = "0.1.3" -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" [dev-dependencies] tempfile = "3.1.0" diff --git a/vfio/Cargo.toml b/vfio/Cargo.toml index 7fd4d4aa0..044a4c0d7 100644 --- a/vfio/Cargo.toml +++ b/vfio/Cargo.toml @@ -14,7 +14,7 @@ pci = { path = "../pci" } vfio-bindings = "0.1.0" vm-allocator = { path = "../vm-allocator" } vm-device = { path = "../vm-device" } -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" [dependencies.vm-memory] git = "https://github.com/rust-vmm/vm-memory" diff --git a/vhost_rs/Cargo.toml b/vhost_rs/Cargo.toml index 240e7ba35..923392764 100644 --- a/vhost_rs/Cargo.toml +++ b/vhost_rs/Cargo.toml @@ -15,7 +15,7 @@ vhost-user-slave = [] [dependencies] bitflags = "1.1.0" libc = "0.2.60" -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" [dependencies.vm-memory] git = "https://github.com/rust-vmm/vm-memory" diff --git a/vhost_user_backend/Cargo.toml b/vhost_user_backend/Cargo.toml index daf84e20f..42a34a355 100644 --- a/vhost_user_backend/Cargo.toml +++ b/vhost_user_backend/Cargo.toml @@ -14,7 +14,7 @@ epoll = ">=4.0.1" libc = "0.2.66" vm-memory = { git = "https://github.com/rust-vmm/vm-memory" } vm-virtio = { path = "../vm-virtio" } -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" [dependencies.vhost_rs] path = "../vhost_rs" diff --git a/vm-virtio/Cargo.toml b/vm-virtio/Cargo.toml index 3f1fc3dec..4ed5e6605 100644 --- a/vm-virtio/Cargo.toml +++ b/vm-virtio/Cargo.toml @@ -22,7 +22,7 @@ tempfile = "3.1.0" virtio-bindings = { git = "https://github.com/rust-vmm/virtio-bindings", version = "0.1", features = ["virtio-v5_0_0"]} vm-allocator = { path = "../vm-allocator" } vm-device = { path = "../vm-device" } -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" [dependencies.vhost_rs] path = "../vhost_rs" diff --git a/vmm/Cargo.toml b/vmm/Cargo.toml index 8d6fd7d81..6a0698715 100644 --- a/vmm/Cargo.toml +++ b/vmm/Cargo.toml @@ -31,7 +31,7 @@ serde_json = ">=1.0.9" vfio = { path = "../vfio", optional = true } vm-allocator = { path = "../vm-allocator" } vm-virtio = { path = "../vm-virtio" } -vmm-sys-util = ">=0.2.1" +vmm-sys-util = ">=0.3.1" signal-hook = "0.1.10" [dependencies.linux-loader] diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 08b9aeabe..649a9eab6 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -28,9 +28,7 @@ use kvm_ioctls::*; use vm_memory::{Address, GuestAddress, GuestMemoryMmap}; use vmm_sys_util::eventfd::EventFd; -use vmm_sys_util::signal::{register_signal_handler, validate_signal_num}; - -const VCPU_RTSIG_OFFSET: i32 = 0; +use vmm_sys_util::signal::{register_signal_handler, SIGRTMIN}; // Debug I/O port #[cfg(target_arch = "x86_64")] @@ -439,9 +437,8 @@ impl VcpuState { fn signal_thread(&self) { if let Some(handle) = self.handle.as_ref() { - let signum = validate_signal_num(VCPU_RTSIG_OFFSET, true).unwrap(); unsafe { - libc::pthread_kill(handle.as_pthread_t(), signum); + libc::pthread_kill(handle.as_pthread_t(), SIGRTMIN()); } } } @@ -549,18 +546,10 @@ impl CpuManager { thread::Builder::new() .name(format!("vcpu{}", vcpu.id)) .spawn(move || { - unsafe { - extern "C" fn handle_signal(_: i32, _: *mut siginfo_t, _: *mut c_void) { - } - // This uses an async signal safe handler to kill the vcpu handles. - register_signal_handler( - VCPU_RTSIG_OFFSET, - vmm_sys_util::signal::SignalHandler::Siginfo(handle_signal), - true, - 0, - ) + extern "C" fn handle_signal(_: i32, _: *mut siginfo_t, _: *mut c_void) {} + // This uses an async signal safe handler to kill the vcpu handles. + register_signal_handler(SIGRTMIN(), handle_signal) .expect("Failed to register vcpu signal handler"); - } vcpu.configure(entry_addr, &vm_memory, cpuid) .expect("Failed to configure vCPU");