mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
build: Consolidate "gdb" build feature into "guest_debug"
This simplifies the CI process but also logical with the existing functionality under "guest_debug" (dumping guest memory). Fixes: #4679 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
b8503b5f45
commit
06eb82d239
3
.github/workflows/build.yaml
vendored
3
.github/workflows/build.yaml
vendored
@ -42,9 +42,6 @@ jobs:
|
||||
- name: Build (default features + tdx)
|
||||
run: cargo rustc --locked --bin cloud-hypervisor --features "tdx" -- -D warnings
|
||||
|
||||
- name: Build (default features + gdb)
|
||||
run: cargo rustc --locked --bin cloud-hypervisor --features "gdb" -- -D warnings
|
||||
|
||||
- name: Build (default features + guest_debug)
|
||||
run: cargo rustc --locked --bin cloud-hypervisor --features "guest_debug" -- -D warnings
|
||||
|
||||
|
7
.github/workflows/quality.yaml
vendored
7
.github/workflows/quality.yaml
vendored
@ -62,13 +62,6 @@ jobs:
|
||||
command: clippy
|
||||
args: --locked --all --all-targets --tests -- -D warnings
|
||||
|
||||
- name: Clippy (default features + gdb)
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
use-cross: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }}
|
||||
command: clippy
|
||||
args: --locked --all --all-targets --tests --features "gdb" -- -D warnings
|
||||
|
||||
- name: Clippy (default features + guest_debug)
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
|
@ -55,7 +55,6 @@ wait-timeout = "0.2.0"
|
||||
|
||||
[features]
|
||||
default = ["kvm"]
|
||||
gdb = ["vmm/gdb"]
|
||||
guest_debug = ["vmm/guest_debug"]
|
||||
kvm = ["vmm/kvm"]
|
||||
mshv = ["vmm/mshv"]
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
This feature allows remote guest debugging using GDB. Note that this feature is only supported on x86_64/KVM.
|
||||
|
||||
To enable debugging with GDB, build with the `gdb` feature enabled:
|
||||
To enable debugging with GDB, build with the `guest_debug` feature enabled:
|
||||
|
||||
```bash
|
||||
cargo build --features gdb
|
||||
cargo build --features guest_debug
|
||||
```
|
||||
|
||||
To use the `--gdb` option, specify the Unix Domain Socket with `--path` that Cloud Hypervisor will use to communicate with the host's GDB:
|
||||
@ -44,4 +44,4 @@ Continuing.
|
||||
|
||||
Breakpoint 1, 0x00000000001121b7 in ?? ()
|
||||
(gdb)
|
||||
```
|
||||
```
|
||||
|
22
src/main.rs
22
src/main.rs
@ -29,7 +29,7 @@ use vmm_sys_util::terminal::Terminal;
|
||||
enum Error {
|
||||
#[error("Failed to create API EventFd: {0}")]
|
||||
CreateApiEventFd(#[source] std::io::Error),
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Failed to create Debug EventFd: {0}")]
|
||||
CreateDebugEventFd(#[source] std::io::Error),
|
||||
#[error("Failed to open hypervisor interface (is hypervisor interface available?): {0}")]
|
||||
@ -58,10 +58,10 @@ enum Error {
|
||||
BareEventMonitor,
|
||||
#[error("Error doing event monitor I/O: {0}")]
|
||||
EventMonitorIo(std::io::Error),
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Error parsing --gdb: {0}")]
|
||||
ParsingGdb(option_parser::OptionParserError),
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Error parsing --gdb: path required")]
|
||||
BareGdb,
|
||||
#[error("Error creating log file: {0}")]
|
||||
@ -391,7 +391,7 @@ fn create_app<'a>(
|
||||
.group("vm-config"),
|
||||
);
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let app = app.arg(
|
||||
Arg::new("gdb")
|
||||
.long("gdb")
|
||||
@ -528,7 +528,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
|
||||
|
||||
let hypervisor = hypervisor::new().map_err(Error::CreateHypervisor)?;
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let gdb_socket_path = if let Some(gdb_config) = cmd_arguments.value_of("gdb") {
|
||||
let mut parser = OptionParser::new();
|
||||
parser.add("path");
|
||||
@ -542,9 +542,9 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let debug_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::CreateDebugEventFd)?;
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let vm_debug_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::CreateDebugEventFd)?;
|
||||
|
||||
let vmm_thread = vmm::start_vmm_thread(
|
||||
@ -554,11 +554,11 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
|
||||
api_evt.try_clone().unwrap(),
|
||||
http_sender,
|
||||
api_request_receiver,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
gdb_socket_path,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
debug_evt.try_clone().unwrap(),
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_evt.try_clone().unwrap(),
|
||||
&seccomp_action,
|
||||
hypervisor,
|
||||
@ -730,7 +730,7 @@ mod unit_tests {
|
||||
sgx_epc: None,
|
||||
numa: None,
|
||||
watchdog: false,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
gdb: false,
|
||||
platform: None,
|
||||
};
|
||||
|
@ -6,8 +6,7 @@ edition = "2021"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
gdb = ["kvm", "gdbstub", "gdbstub_arch"]
|
||||
guest_debug = ["kvm"]
|
||||
guest_debug = ["kvm", "gdbstub", "gdbstub_arch"]
|
||||
kvm = ["hypervisor/kvm", "vfio-ioctls/kvm", "vm-device/kvm", "pci/kvm"]
|
||||
mshv = ["hypervisor/mshv", "vfio-ioctls/mshv", "vm-device/mshv", "pci/mshv"]
|
||||
tdx = ["arch/tdx", "hypervisor/tdx"]
|
||||
|
@ -379,7 +379,7 @@ pub struct VmParams<'a> {
|
||||
pub sgx_epc: Option<Vec<&'a str>>,
|
||||
pub numa: Option<Vec<&'a str>>,
|
||||
pub watchdog: bool,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
pub gdb: bool,
|
||||
pub platform: Option<&'a str>,
|
||||
}
|
||||
@ -411,7 +411,7 @@ impl<'a> VmParams<'a> {
|
||||
let numa: Option<Vec<&str>> = args.values_of("numa").map(|x| x.collect());
|
||||
let watchdog = args.is_present("watchdog");
|
||||
let platform = args.value_of("platform");
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let gdb = args.is_present("gdb");
|
||||
VmParams {
|
||||
cpus,
|
||||
@ -437,7 +437,7 @@ impl<'a> VmParams<'a> {
|
||||
sgx_epc,
|
||||
numa,
|
||||
watchdog,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
gdb,
|
||||
platform,
|
||||
}
|
||||
@ -2315,7 +2315,7 @@ pub struct VmConfig {
|
||||
pub numa: Option<Vec<NumaConfig>>,
|
||||
#[serde(default)]
|
||||
pub watchdog: bool,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
pub gdb: bool,
|
||||
pub platform: Option<PlatformConfig>,
|
||||
}
|
||||
@ -2703,7 +2703,7 @@ impl VmConfig {
|
||||
None
|
||||
};
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let gdb = vm_params.gdb;
|
||||
|
||||
let mut config = VmConfig {
|
||||
@ -2730,7 +2730,7 @@ impl VmConfig {
|
||||
sgx_epc,
|
||||
numa,
|
||||
watchdog: vm_params.watchdog,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
gdb,
|
||||
platform,
|
||||
};
|
||||
@ -3340,7 +3340,7 @@ mod tests {
|
||||
sgx_epc: None,
|
||||
numa: None,
|
||||
watchdog: false,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
gdb: false,
|
||||
platform: None,
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ use crate::coredump::{
|
||||
NT_PRSTATUS,
|
||||
};
|
||||
use crate::device_manager::DeviceManager;
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use crate::gdb::{get_raw_tid, Debuggable, DebuggableError};
|
||||
use crate::memory_manager::MemoryManager;
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
@ -29,18 +29,18 @@ use crate::GuestMemoryMmap;
|
||||
use crate::CPU_MANAGER_SNAPSHOT_ID;
|
||||
use acpi_tables::{aml, aml::Aml, sdt::Sdt};
|
||||
use anyhow::anyhow;
|
||||
#[cfg(all(target_arch = "aarch64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
|
||||
use arch::aarch64::regs;
|
||||
use arch::EntryPoint;
|
||||
use arch::NumaNodes;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use devices::gic::Gic;
|
||||
use devices::interrupt_controller::InterruptController;
|
||||
#[cfg(all(target_arch = "aarch64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
|
||||
use gdbstub_arch::aarch64::reg::AArch64CoreRegs as CoreRegs;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use gdbstub_arch::x86::reg::{X86SegmentRegs, X86_64CoreRegs as CoreRegs};
|
||||
#[cfg(all(target_arch = "aarch64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
|
||||
use hypervisor::aarch64::StandardRegisters;
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use hypervisor::arch::x86::msr_index;
|
||||
@ -48,7 +48,7 @@ use hypervisor::arch::x86::msr_index;
|
||||
use hypervisor::arch::x86::CpuIdEntry;
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use hypervisor::arch::x86::MsrEntry;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use hypervisor::arch::x86::{SpecialRegisters, StandardRegisters};
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use hypervisor::kvm::kvm_bindings;
|
||||
@ -73,7 +73,7 @@ use tracer::trace_scoped;
|
||||
use vm_device::BusDevice;
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use vm_memory::ByteValued;
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use vm_memory::{Bytes, GuestAddressSpace};
|
||||
use vm_memory::{GuestAddress, GuestMemoryAtomic};
|
||||
use vm_migration::{
|
||||
@ -83,7 +83,7 @@ use vm_migration::{
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vmm_sys_util::signal::{register_signal_handler, SIGRTMIN};
|
||||
|
||||
#[cfg(all(target_arch = "aarch64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
|
||||
/// Extract the specified bits of a 64-bit integer.
|
||||
/// For example, to extrace 2 bits from offset 1 (zero based) of `6u64`,
|
||||
/// following expression should return 3 (`0b11`):
|
||||
@ -154,11 +154,11 @@ pub enum Error {
|
||||
#[error("Error initializing PMU: {0}")]
|
||||
InitPmu(#[source] hypervisor::HypervisorCpuError),
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Error during CPU debug: {0}")]
|
||||
CpuDebug(#[source] hypervisor::HypervisorCpuError),
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Error translating virtual address: {0}")]
|
||||
TranslateVirtualAddress(#[source] anyhow::Error),
|
||||
|
||||
@ -448,7 +448,7 @@ pub struct CpuManager {
|
||||
exit_evt: EventFd,
|
||||
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
|
||||
reset_evt: EventFd,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_evt: EventFd,
|
||||
vcpu_states: Vec<VcpuState>,
|
||||
selected_cpu: u8,
|
||||
@ -601,7 +601,7 @@ impl CpuManager {
|
||||
vm: Arc<dyn hypervisor::Vm>,
|
||||
exit_evt: EventFd,
|
||||
reset_evt: EventFd,
|
||||
#[cfg(feature = "gdb")] vm_debug_evt: EventFd,
|
||||
#[cfg(feature = "guest_debug")] vm_debug_evt: EventFd,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
seccomp_action: SeccompAction,
|
||||
vm_ops: Arc<dyn VmOps>,
|
||||
@ -723,7 +723,7 @@ impl CpuManager {
|
||||
vcpu_states,
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_evt,
|
||||
selected_cpu: 0,
|
||||
vcpus: Vec::with_capacity(usize::from(config.max_vcpus)),
|
||||
@ -837,7 +837,7 @@ impl CpuManager {
|
||||
) -> Result<()> {
|
||||
let reset_evt = self.reset_evt.try_clone().unwrap();
|
||||
let exit_evt = self.exit_evt.try_clone().unwrap();
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let vm_debug_evt = self.vm_debug_evt.try_clone().unwrap();
|
||||
let panic_exit_evt = self.exit_evt.try_clone().unwrap();
|
||||
let vcpu_kill_signalled = self.vcpus_kill_signalled.clone();
|
||||
@ -974,7 +974,7 @@ impl CpuManager {
|
||||
#[cfg(feature = "kvm")]
|
||||
VmExit::Debug => {
|
||||
info!("VmExit::Debug");
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
{
|
||||
vcpu_pause_signalled.store(true, Ordering::SeqCst);
|
||||
let raw_tid = get_raw_tid(vcpu_id as usize);
|
||||
@ -1457,7 +1457,7 @@ impl CpuManager {
|
||||
pptt
|
||||
}
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
fn get_regs(&self, cpu_id: u8) -> Result<StandardRegisters> {
|
||||
self.vcpus[usize::from(cpu_id)]
|
||||
.lock()
|
||||
@ -1467,7 +1467,7 @@ impl CpuManager {
|
||||
.map_err(Error::CpuDebug)
|
||||
}
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
fn set_regs(&self, cpu_id: u8, regs: &StandardRegisters) -> Result<()> {
|
||||
self.vcpus[usize::from(cpu_id)]
|
||||
.lock()
|
||||
@ -1477,7 +1477,7 @@ impl CpuManager {
|
||||
.map_err(Error::CpuDebug)
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
fn get_sregs(&self, cpu_id: u8) -> Result<SpecialRegisters> {
|
||||
self.vcpus[usize::from(cpu_id)]
|
||||
.lock()
|
||||
@ -1487,7 +1487,7 @@ impl CpuManager {
|
||||
.map_err(Error::CpuDebug)
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
fn set_sregs(&self, cpu_id: u8, sregs: &SpecialRegisters) -> Result<()> {
|
||||
self.vcpus[usize::from(cpu_id)]
|
||||
.lock()
|
||||
@ -1497,7 +1497,7 @@ impl CpuManager {
|
||||
.map_err(Error::CpuDebug)
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
fn translate_gva(&self, cpu_id: u8, gva: u64) -> Result<u64> {
|
||||
let (gpa, _) = self.vcpus[usize::from(cpu_id)]
|
||||
.lock()
|
||||
@ -1524,7 +1524,7 @@ impl CpuManager {
|
||||
/// - FEAT_LVA
|
||||
/// - FEAT_LPA2
|
||||
///
|
||||
#[cfg(all(target_arch = "aarch64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
|
||||
fn translate_gva(&self, cpu_id: u8, gva: u64) -> Result<u64> {
|
||||
let tcr_el1: u64 = self.vcpus[usize::from(cpu_id)]
|
||||
.lock()
|
||||
@ -2090,7 +2090,7 @@ impl Snapshottable for CpuManager {
|
||||
impl Transportable for CpuManager {}
|
||||
impl Migratable for CpuManager {}
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
impl Debuggable for CpuManager {
|
||||
#[cfg(feature = "kvm")]
|
||||
fn set_guest_debug(
|
||||
|
@ -64,7 +64,7 @@ mod coredump;
|
||||
pub mod cpu;
|
||||
pub mod device_manager;
|
||||
pub mod device_tree;
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
mod gdb;
|
||||
pub mod interrupt;
|
||||
pub mod memory_manager;
|
||||
@ -154,17 +154,17 @@ pub enum Error {
|
||||
#[error("Error creation API server's socket {0:?}")]
|
||||
CreateApiServerSocket(#[source] io::Error),
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Failed to start the GDB thread: {0}")]
|
||||
GdbThreadSpawn(io::Error),
|
||||
|
||||
/// GDB request receive error
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Error receiving GDB request: {0}")]
|
||||
GdbRequestRecv(#[source] RecvError),
|
||||
|
||||
/// GDB response send error
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Error sending GDB request: {0}")]
|
||||
GdbResponseSend(#[source] SendError<gdb::GdbResponse>),
|
||||
|
||||
@ -266,19 +266,19 @@ pub fn start_vmm_thread(
|
||||
api_event: EventFd,
|
||||
api_sender: Sender<ApiRequest>,
|
||||
api_receiver: Receiver<ApiRequest>,
|
||||
#[cfg(feature = "gdb")] debug_path: Option<PathBuf>,
|
||||
#[cfg(feature = "gdb")] debug_event: EventFd,
|
||||
#[cfg(feature = "gdb")] vm_debug_event: EventFd,
|
||||
#[cfg(feature = "guest_debug")] debug_path: Option<PathBuf>,
|
||||
#[cfg(feature = "guest_debug")] debug_event: EventFd,
|
||||
#[cfg(feature = "guest_debug")] vm_debug_event: EventFd,
|
||||
seccomp_action: &SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
) -> Result<thread::JoinHandle<Result<()>>> {
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let gdb_hw_breakpoints = hypervisor.get_guest_debug_hw_bps();
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let (gdb_sender, gdb_receiver) = std::sync::mpsc::channel();
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let gdb_debug_event = debug_event.try_clone().map_err(Error::EventFdClone)?;
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let gdb_vm_debug_event = vm_debug_event.try_clone().map_err(Error::EventFdClone)?;
|
||||
|
||||
let http_api_event = api_event.try_clone().map_err(Error::EventFdClone)?;
|
||||
@ -303,9 +303,9 @@ pub fn start_vmm_thread(
|
||||
let mut vmm = Vmm::new(
|
||||
vmm_version.to_string(),
|
||||
api_event,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
debug_event,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_event,
|
||||
vmm_seccomp_action,
|
||||
hypervisor,
|
||||
@ -316,7 +316,7 @@ pub fn start_vmm_thread(
|
||||
|
||||
vmm.control_loop(
|
||||
Arc::new(api_receiver),
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
Arc::new(gdb_receiver),
|
||||
)
|
||||
})
|
||||
@ -344,7 +344,7 @@ pub fn start_vmm_thread(
|
||||
)?;
|
||||
}
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
if let Some(debug_path) = debug_path {
|
||||
let target = gdb::GdbStub::new(
|
||||
gdb_sender,
|
||||
@ -374,9 +374,9 @@ pub struct Vmm {
|
||||
exit_evt: EventFd,
|
||||
reset_evt: EventFd,
|
||||
api_evt: EventFd,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
debug_evt: EventFd,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_evt: EventFd,
|
||||
version: String,
|
||||
vm: Option<Vm>,
|
||||
@ -462,8 +462,8 @@ impl Vmm {
|
||||
fn new(
|
||||
vmm_version: String,
|
||||
api_evt: EventFd,
|
||||
#[cfg(feature = "gdb")] debug_evt: EventFd,
|
||||
#[cfg(feature = "gdb")] vm_debug_evt: EventFd,
|
||||
#[cfg(feature = "guest_debug")] debug_evt: EventFd,
|
||||
#[cfg(feature = "guest_debug")] vm_debug_evt: EventFd,
|
||||
seccomp_action: SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
exit_evt: EventFd,
|
||||
@ -488,7 +488,7 @@ impl Vmm {
|
||||
.add_event(&api_evt, EpollDispatch::Api)
|
||||
.map_err(Error::Epoll)?;
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
epoll
|
||||
.add_event(&debug_evt, EpollDispatch::Debug)
|
||||
.map_err(Error::Epoll)?;
|
||||
@ -498,9 +498,9 @@ impl Vmm {
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
api_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
debug_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_evt,
|
||||
version: vmm_version,
|
||||
vm: None,
|
||||
@ -537,7 +537,7 @@ impl Vmm {
|
||||
if self.vm.is_none() {
|
||||
let exit_evt = self.exit_evt.try_clone().map_err(VmError::EventFdClone)?;
|
||||
let reset_evt = self.reset_evt.try_clone().map_err(VmError::EventFdClone)?;
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let vm_debug_evt = self
|
||||
.vm_debug_evt
|
||||
.try_clone()
|
||||
@ -552,7 +552,7 @@ impl Vmm {
|
||||
Arc::clone(vm_config),
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_evt,
|
||||
&self.seccomp_action,
|
||||
self.hypervisor.clone(),
|
||||
@ -633,7 +633,7 @@ impl Vmm {
|
||||
|
||||
let exit_evt = self.exit_evt.try_clone().map_err(VmError::EventFdClone)?;
|
||||
let reset_evt = self.reset_evt.try_clone().map_err(VmError::EventFdClone)?;
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let debug_evt = self
|
||||
.vm_debug_evt
|
||||
.try_clone()
|
||||
@ -648,7 +648,7 @@ impl Vmm {
|
||||
vm_config,
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
debug_evt,
|
||||
Some(source_url),
|
||||
restore_cfg.prefault,
|
||||
@ -702,7 +702,7 @@ impl Vmm {
|
||||
|
||||
let exit_evt = self.exit_evt.try_clone().map_err(VmError::EventFdClone)?;
|
||||
let reset_evt = self.reset_evt.try_clone().map_err(VmError::EventFdClone)?;
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let debug_evt = self
|
||||
.vm_debug_evt
|
||||
.try_clone()
|
||||
@ -724,7 +724,7 @@ impl Vmm {
|
||||
config,
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
debug_evt,
|
||||
&self.seccomp_action,
|
||||
self.hypervisor.clone(),
|
||||
@ -1146,7 +1146,7 @@ impl Vmm {
|
||||
let reset_evt = self.reset_evt.try_clone().map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error cloning reset EventFd: {}", e))
|
||||
})?;
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let debug_evt = self.vm_debug_evt.try_clone().map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error cloning debug EventFd: {}", e))
|
||||
})?;
|
||||
@ -1159,7 +1159,7 @@ impl Vmm {
|
||||
self.vm_config.clone().unwrap(),
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
debug_evt,
|
||||
&self.seccomp_action,
|
||||
self.hypervisor.clone(),
|
||||
@ -1642,7 +1642,7 @@ impl Vmm {
|
||||
fn control_loop(
|
||||
&mut self,
|
||||
api_receiver: Arc<Receiver<ApiRequest>>,
|
||||
#[cfg(feature = "gdb")] gdb_receiver: Arc<Receiver<gdb::GdbRequest>>,
|
||||
#[cfg(feature = "guest_debug")] gdb_receiver: Arc<Receiver<gdb::GdbRequest>>,
|
||||
) -> Result<()> {
|
||||
const EPOLL_EVENTS_LEN: usize = 100;
|
||||
|
||||
@ -1929,7 +1929,7 @@ impl Vmm {
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
EpollDispatch::Debug => {
|
||||
// Consume the events.
|
||||
for _ in 0..self.debug_evt.read().map_err(Error::EventFdRead)? {
|
||||
@ -1949,7 +1949,7 @@ impl Vmm {
|
||||
.map_err(Error::GdbResponseSend)?;
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "gdb"))]
|
||||
#[cfg(not(feature = "guest_debug"))]
|
||||
EpollDispatch::Debug => {}
|
||||
}
|
||||
}
|
||||
@ -1985,9 +1985,9 @@ mod unit_tests {
|
||||
Vmm::new(
|
||||
"dummy".to_string(),
|
||||
EventFd::new(EFD_NONBLOCK).unwrap(),
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
EventFd::new(EFD_NONBLOCK).unwrap(),
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
EventFd::new(EFD_NONBLOCK).unwrap(),
|
||||
SeccompAction::Allow,
|
||||
hypervisor::new().unwrap(),
|
||||
@ -2056,7 +2056,7 @@ mod unit_tests {
|
||||
sgx_epc: None,
|
||||
numa: None,
|
||||
watchdog: false,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
gdb: false,
|
||||
platform: None,
|
||||
}))
|
||||
|
@ -23,7 +23,7 @@ use crate::coredump::{
|
||||
use crate::cpu;
|
||||
use crate::device_manager::{Console, DeviceManager, DeviceManagerError, PtyPair};
|
||||
use crate::device_tree::DeviceTree;
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use crate::gdb::{Debuggable, DebuggableError, GdbRequestPayload, GdbResponsePayload};
|
||||
use crate::memory_manager::{
|
||||
Error as MemoryManagerError, MemoryManager, MemoryManagerSnapshotData,
|
||||
@ -51,9 +51,9 @@ use devices::gic::{Gic, GIC_V3_ITS_SNAPSHOT_ID};
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use devices::interrupt_controller::{self, InterruptController};
|
||||
use devices::AcpiNotificationFlags;
|
||||
#[cfg(all(target_arch = "aarch64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
|
||||
use gdbstub_arch::aarch64::reg::AArch64CoreRegs as CoreRegs;
|
||||
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use gdbstub_arch::x86::reg::X86_64CoreRegs as CoreRegs;
|
||||
use hypervisor::{HypervisorVmError, VmOps};
|
||||
use linux_loader::cmdline::Cmdline;
|
||||
@ -294,7 +294,7 @@ pub enum Error {
|
||||
#[error("Invalid TDX payload type")]
|
||||
InvalidPayloadType,
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Error debugging VM: {0:?}")]
|
||||
Debug(DebuggableError),
|
||||
|
||||
@ -494,7 +494,7 @@ impl Vm {
|
||||
vm: Arc<dyn hypervisor::Vm>,
|
||||
exit_evt: EventFd,
|
||||
reset_evt: EventFd,
|
||||
#[cfg(feature = "gdb")] vm_debug_evt: EventFd,
|
||||
#[cfg(feature = "guest_debug")] vm_debug_evt: EventFd,
|
||||
seccomp_action: &SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
activate_evt: EventFd,
|
||||
@ -528,9 +528,9 @@ impl Vm {
|
||||
#[cfg(not(feature = "tdx"))]
|
||||
let force_iommu = false;
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
let stop_on_boot = config.lock().unwrap().gdb;
|
||||
#[cfg(not(feature = "gdb"))]
|
||||
#[cfg(not(feature = "guest_debug"))]
|
||||
let stop_on_boot = false;
|
||||
|
||||
let device_manager = DeviceManager::new(
|
||||
@ -576,7 +576,7 @@ impl Vm {
|
||||
vm.clone(),
|
||||
exit_evt_clone,
|
||||
reset_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_evt,
|
||||
hypervisor.clone(),
|
||||
seccomp_action.clone(),
|
||||
@ -719,7 +719,7 @@ impl Vm {
|
||||
config: Arc<Mutex<VmConfig>>,
|
||||
exit_evt: EventFd,
|
||||
reset_evt: EventFd,
|
||||
#[cfg(feature = "gdb")] vm_debug_evt: EventFd,
|
||||
#[cfg(feature = "guest_debug")] vm_debug_evt: EventFd,
|
||||
seccomp_action: &SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
activate_evt: EventFd,
|
||||
@ -778,7 +778,7 @@ impl Vm {
|
||||
vm,
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_evt,
|
||||
seccomp_action,
|
||||
hypervisor,
|
||||
@ -804,7 +804,7 @@ impl Vm {
|
||||
vm_config: Arc<Mutex<VmConfig>>,
|
||||
exit_evt: EventFd,
|
||||
reset_evt: EventFd,
|
||||
#[cfg(feature = "gdb")] vm_debug_evt: EventFd,
|
||||
#[cfg(feature = "guest_debug")] vm_debug_evt: EventFd,
|
||||
source_url: Option<&str>,
|
||||
prefault: bool,
|
||||
seccomp_action: &SeccompAction,
|
||||
@ -849,7 +849,7 @@ impl Vm {
|
||||
vm,
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_evt,
|
||||
seccomp_action,
|
||||
hypervisor,
|
||||
@ -864,7 +864,7 @@ impl Vm {
|
||||
config: Arc<Mutex<VmConfig>>,
|
||||
exit_evt: EventFd,
|
||||
reset_evt: EventFd,
|
||||
#[cfg(feature = "gdb")] vm_debug_evt: EventFd,
|
||||
#[cfg(feature = "guest_debug")] vm_debug_evt: EventFd,
|
||||
seccomp_action: &SeccompAction,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
activate_evt: EventFd,
|
||||
@ -906,7 +906,7 @@ impl Vm {
|
||||
vm,
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
vm_debug_evt,
|
||||
seccomp_action,
|
||||
hypervisor,
|
||||
@ -2574,7 +2574,7 @@ impl Vm {
|
||||
self.memory_manager.lock().unwrap().snapshot_data()
|
||||
}
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
pub fn debug_request(
|
||||
&mut self,
|
||||
gdb_request: &GdbRequestPayload,
|
||||
@ -2991,7 +2991,7 @@ impl Migratable for Vm {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gdb")]
|
||||
#[cfg(feature = "guest_debug")]
|
||||
impl Debuggable for Vm {
|
||||
fn set_guest_debug(
|
||||
&self,
|
||||
|
Loading…
Reference in New Issue
Block a user