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

add QEMU pvpanic ISA device #596

Merged
merged 24 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 4 additions & 6 deletions bin/propolis-server/src/lib/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::serial::Serial;
use crate::server::CrucibleBackendMap;
pub use nexus_client::Client as NexusClient;

use anyhow::Result;
use anyhow::{Context, Result};

// Arbitrary ROM limit for now
const MAX_ROM_SIZE: usize = 0x20_0000;
Expand Down Expand Up @@ -292,11 +292,9 @@ impl<'a> MachineInitializer<'a> {
if let Some(ref registry) = self.producer_registry {
let producer =
crate::stats::PvpanicProducer::new(uuid, pvpanic);
registry.register_producer(producer).map_err(|error| {
anyhow::anyhow!(
"failed to register PVPANIC Oximeter producer: {error}"
)
})?;
registry.register_producer(producer).context(
"failed to register PVPANIC Oximeter producer",
)?;
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion bin/propolis-server/src/lib/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,13 @@ impl ServerSpecBuilder {
},
)?;

let builder =
let mut builder =
SpecBuilder::new(properties.vcpus, properties.memory, enable_pcie);

builder.add_pvpanic_device(components::devices::QemuPvpanic {
enable_isa: true,
})?;

Ok(Self { builder })
}

Expand Down
16 changes: 16 additions & 0 deletions crates/propolis-api-types/src/instance_spec/v0/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ impl SpecBuilder {
}
}

/// Adds a QEMU pvpanic device.
pub fn add_pvpanic_device(
&mut self,
pvpanic: components::devices::QemuPvpanic,
) -> Result<&Self, SpecBuilderError> {
if self.spec.devices.qemu_pvpanic.is_some() {
return Err(SpecBuilderError::DeviceNameInUse(
"pvpanic".to_string(),
));
}

self.spec.devices.qemu_pvpanic = Some(pvpanic);

Ok(self)
}

#[cfg(feature = "falcon")]
pub fn set_softnpu_pci_port(
&mut self,
Expand Down
13 changes: 13 additions & 0 deletions crates/propolis-api-types/src/instance_spec/v0/mod.rs
hawkw marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ pub struct DeviceSpecV0 {
pub network_devices: HashMap<SpecKey, NetworkDeviceV0>,
pub serial_ports: HashMap<SpecKey, components::devices::SerialPort>,
pub pci_pci_bridges: HashMap<SpecKey, components::devices::PciPciBridge>,

/// This field has a default value (`None`) to allow for
hawkw marked this conversation as resolved.
Show resolved Hide resolved
/// backwards-compatibility when upgrading from a Propolis
/// version that does not support this device. If the pvpanic device was not
/// present in the spec being deserialized, a `None` will be produced,
/// rather than rejecting the spec.
#[serde(default)]
/// Skip serializing this field if it is `None`. This is so that Propolis
/// versions with support for this device are backwards-compatible with
/// older versions that don't, as long as the spec doesn't define a pvpanic
/// device --- if there is no panic device, skipping the field from the spec
/// means that the older version will still accept the spec.
#[serde(skip_serializing_if = "Option::is_none")]
pub qemu_pvpanic: Option<components::devices::QemuPvpanic>,
hawkw marked this conversation as resolved.
Show resolved Hide resolved

#[cfg(feature = "falcon")]
Expand Down
1 change: 1 addition & 0 deletions openapi/propolis-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@
},
"qemu_pvpanic": {
hawkw marked this conversation as resolved.
Show resolved Hide resolved
"nullable": true,
"description": "This field has a default value (`None`) to allow for backwards-compatibility when upgrading from a Propolis version that does not support this device. If the pvpanic device was not present in the spec being deserialized, a `None` will be produced, rather than rejecting the spec. Skip serializing this field if it is `None`. This is so that Propolis versions with support for this device are backwards-compatible with older versions that don't, as long as the spec doesn't define a pvpanic device --- if there is no panic device, skipping the field from the spec means that the older version will still accept the spec.",
"allOf": [
{
"$ref": "#/components/schemas/QemuPvpanic"
Expand Down
Loading