Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make qemu debug port output configurable #552

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/propolis-server/src/lib/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ impl<'a> MachineInitializer<'a> {
}

pub fn initialize_qemu_debug_port(&self) -> Result<(), Error> {
// TODO: Make the output file configurable
let dbg = QemuDebugPort::create(&self.machine.bus_pio);
let debug_file = std::fs::File::create("debug.out")?;
let poller = chardev::BlockingFileOutput::new(debug_file);
Expand Down
2 changes: 2 additions & 0 deletions bin/propolis-standalone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ name = "testvm"
cpus = 4
bootrom = "/path/to/bootrom/OVMF_CODE.fd"
memory = 1024
# File path to store qemu debug port output (optional)
# qemu_debug_file = "/path/to/output"

[block_dev.alpine_iso]
type = "file"
Expand Down
16 changes: 13 additions & 3 deletions bin/propolis-standalone/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,10 +834,20 @@ fn setup_instance(
ps2_ctrl.attach(pio, chipset.as_ref());
inv.register(&ps2_ctrl)?;

let debug_file = std::fs::File::create("debug.out")?;
let debug_out = chardev::BlockingFileOutput::new(debug_file);
// Qemu debug IO port
let debug_device = hw::qemu::debug::QemuDebugPort::create(pio);
debug_out.attach(Arc::clone(&debug_device) as Arc<dyn BlockingSource>);
match &config.main.qemu_debug_file {
Some(path) => {
let debug_file = std::fs::File::create(path)?;
let debug_out = chardev::BlockingFileOutput::new(debug_file);
debug_out
.attach(Arc::clone(&debug_device) as Arc<dyn BlockingSource>);
}
None => {
// Send output bytes to the bit bucket
debug_device.set_consumer(Some(chardev::null_blocking_consumer()));
}
};
inv.register(&debug_device)?;

for (name, dev) in config.devices.iter() {
Expand Down
2 changes: 2 additions & 0 deletions crates/propolis-standalone-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::collections::BTreeMap;
use std::path::PathBuf;

use serde::{Deserialize, Serialize};
use strum::FromRepr;
Expand Down Expand Up @@ -50,6 +51,7 @@ pub struct Main {
pub bootrom: String,
pub memory: usize,
pub use_reservoir: Option<bool>,
pub qemu_debug_file: Option<PathBuf>,
pub cpuid_profile: Option<String>,
}

Expand Down
7 changes: 7 additions & 0 deletions lib/propolis/src/chardev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,10 @@ impl ConsumerCell {
}
}
}

/// Build a [`BlockingSourceConsumer`] which silently consumes any output bytes
pub fn null_blocking_consumer() -> BlockingSourceConsumer {
Box::new(|_buf| {
// Simply do nothing with the buffer
})
}
Loading