mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
linux: generalize kick_all_vcpus to send any VcpuControl message
Previously, kick_all_vcpus() would only accept VmControl::RunState messages; extend it to accept any VmControl message type instead. This required adding the Clone trait to a few types. BUG=b:174705596 TEST=./test_all Change-Id: I3c8c42ee8a96ff151fa8f01ab067931bdff2b7b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2718281 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This commit is contained in:
parent
8a72afc44c
commit
2940980d2e
3 changed files with 10 additions and 10 deletions
16
src/linux.rs
16
src/linux.rs
|
@ -2603,18 +2603,18 @@ where
|
|||
)
|
||||
}
|
||||
|
||||
/// Signals all running VCPUs to vmexit, sends VmRunMode message to each VCPU tube, and tells
|
||||
/// `irq_chip` to stop blocking halted VCPUs. The tube message is set first because both the
|
||||
/// Signals all running VCPUs to vmexit, sends VcpuControl message to each VCPU tube, and tells
|
||||
/// `irq_chip` to stop blocking halted VCPUs. The channel message is set first because both the
|
||||
/// signal and the irq_chip kick could cause the VCPU thread to continue through the VCPU run
|
||||
/// loop.
|
||||
fn kick_all_vcpus(
|
||||
vcpu_handles: &[(JoinHandle<()>, mpsc::Sender<vm_control::VcpuControl>)],
|
||||
irq_chip: &dyn IrqChip,
|
||||
run_mode: &VmRunMode,
|
||||
message: VcpuControl,
|
||||
) {
|
||||
for (handle, tube) in vcpu_handles {
|
||||
if let Err(e) = tube.send(VcpuControl::RunState(run_mode.clone())) {
|
||||
error!("failed to send VmRunMode: {}", e);
|
||||
if let Err(e) = tube.send(message.clone()) {
|
||||
error!("failed to send VcpuControl: {}", e);
|
||||
}
|
||||
let _ = handle.kill(SIGRTMIN() + 0);
|
||||
}
|
||||
|
@ -2976,7 +2976,7 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
kick_all_vcpus(
|
||||
&vcpu_handles,
|
||||
linux.irq_chip.as_irq_chip(),
|
||||
&VmRunMode::Suspending,
|
||||
VcpuControl::RunState(VmRunMode::Suspending),
|
||||
);
|
||||
}
|
||||
Token::ChildSignal => {
|
||||
|
@ -3090,7 +3090,7 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
kick_all_vcpus(
|
||||
&vcpu_handles,
|
||||
linux.irq_chip.as_irq_chip(),
|
||||
&other,
|
||||
VcpuControl::RunState(other),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3267,7 +3267,7 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
kick_all_vcpus(
|
||||
&vcpu_handles,
|
||||
linux.irq_chip.as_irq_chip(),
|
||||
&VmRunMode::Exiting,
|
||||
VcpuControl::RunState(VmRunMode::Exiting),
|
||||
);
|
||||
for (handle, _) in vcpu_handles {
|
||||
if let Err(e) = handle.join() {
|
||||
|
|
|
@ -7,7 +7,7 @@ use gdbstub::arch::x86::reg::X86_64CoreRegs as CoreRegs;
|
|||
use vm_memory::GuestAddress;
|
||||
|
||||
/// Messages that can be sent to a vCPU to set/get its state from the debugger.
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum VcpuDebug {
|
||||
ReadMem(GuestAddress, usize),
|
||||
ReadRegs,
|
||||
|
|
|
@ -57,7 +57,7 @@ pub use crate::gdb::*;
|
|||
pub use hypervisor::MemSlot;
|
||||
|
||||
/// Control the state of a particular VM CPU.
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum VcpuControl {
|
||||
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
|
||||
Debug(VcpuDebug),
|
||||
|
|
Loading…
Reference in a new issue