Skip to content
Merged
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
45 changes: 0 additions & 45 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1306,51 +1306,6 @@ pub enum InstanceAutoRestartPolicy {
BestEffort,
}

/// A required CPU platform for an instance.
///
/// When an instance specifies a required CPU platform:
///
/// - The system may expose (to the VM) new CPU features that are only present
/// on that platform (or on newer platforms of the same lineage that also
/// support those features).
/// - The instance must run on hosts that have CPUs that support all the
/// features of the supplied platform.
///
/// That is, the instance is restricted to hosts that have the CPUs which
/// support all features of the required platform, but in exchange the CPU
/// features exposed by the platform are available for the guest to use. Note
/// that this may prevent an instance from starting (if the hosts that could run
/// it are full but there is capacity on other incompatible hosts).
///
/// If an instance does not specify a required CPU platform, then when
/// it starts, the control plane selects a host for the instance and then
/// supplies the guest with the "minimum" CPU platform supported by that host.
/// This maximizes the number of hosts that can run the VM if it later needs to
/// migrate to another host.
///
/// In all cases, the CPU features presented by a given CPU platform are a
/// subset of what the corresponding hardware may actually support; features
/// which cannot be used from a virtual environment or do not have full
/// hypervisor support may be masked off. See RFD 314 for specific CPU features
/// in a CPU platform.
#[derive(
Copy, Clone, Debug, Deserialize, Serialize, JsonSchema, Eq, PartialEq,
)]
#[serde(rename_all = "snake_case")]
pub enum InstanceCpuPlatform {
/// An AMD Milan-like CPU platform.
AmdMilan,

/// An AMD Turin-like CPU platform.
// Note that there is only Turin, not Turin Dense - feature-wise there are
// collapsed together as the guest-visible platform is the same.
// If the two must be distinguished for instance placement, we'll want to
// track whatever the motivating constraint is more explicitly. CPU
// families, and especially the vendor code names, don't necessarily promise
// details about specific processor packaging choices.
AmdTurin,
}

// AFFINITY GROUPS

/// Affinity policy used to describe "what to do when a request cannot be satisfied"
Expand Down
17 changes: 9 additions & 8 deletions nexus/db-model/src/instance_cpu_platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use crate::SledCpuFamily;

use super::impl_enum_type;
use nexus_types::external_api::instance as instance_api;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit, not a big deal: I don't think we're particularly consistent about this, but elsewhere, I feel like I've often seen these imports renamed to external, instead, so that you can reference it as external::InstanceCpuPlatform. but instance_api is fine too, and doesn't particularly bother me.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd looked for use nexus_types::external_api:: in nexus/db-model/src and saw this pattern, though using external does seem like a nice name to use for the reason you describe.. either way, I think you might be thinking about a different part of Nexus maybe?

use serde::{Deserialize, Serialize};

impl_enum_type!(
Expand All @@ -24,6 +25,7 @@ impl_enum_type!(

AmdMilan => b"amd_milan"
AmdTurin => b"amd_turin"
AmdTurinV2 => b"amd_turin_v2"
);

impl InstanceCpuPlatform {
Expand All @@ -37,29 +39,28 @@ impl InstanceCpuPlatform {
&[SledCpuFamily::AmdMilan, SledCpuFamily::AmdTurin]
}
Self::AmdTurin => &[SledCpuFamily::AmdTurin],
Self::AmdTurinV2 => &[SledCpuFamily::AmdTurin],
}
}
}

impl From<omicron_common::api::external::InstanceCpuPlatform>
for InstanceCpuPlatform
{
fn from(value: omicron_common::api::external::InstanceCpuPlatform) -> Self {
use omicron_common::api::external::InstanceCpuPlatform as ApiPlatform;
impl From<instance_api::InstanceCpuPlatform> for InstanceCpuPlatform {
fn from(value: instance_api::InstanceCpuPlatform) -> Self {
use instance_api::InstanceCpuPlatform as ApiPlatform;
match value {
ApiPlatform::AmdMilan => Self::AmdMilan,
ApiPlatform::AmdTurin => Self::AmdTurin,
ApiPlatform::AmdTurinV2 => Self::AmdTurinV2,
}
}
}

impl From<InstanceCpuPlatform>
for omicron_common::api::external::InstanceCpuPlatform
{
impl From<InstanceCpuPlatform> for instance_api::InstanceCpuPlatform {
fn from(value: InstanceCpuPlatform) -> Self {
match value {
InstanceCpuPlatform::AmdMilan => Self::AmdMilan,
InstanceCpuPlatform::AmdTurin => Self::AmdTurin,
InstanceCpuPlatform::AmdTurinV2 => Self::AmdTurinV2,
}
}
}
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
///
/// This must be updated when you change the database schema. Refer to
/// schema/crdb/README.adoc in the root of this repository for details.
pub const SCHEMA_VERSION: Version = Version::new(263, 0, 0);
pub const SCHEMA_VERSION: Version = Version::new(264, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -28,6 +28,7 @@ pub static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
// | leaving the first copy as an example for the next person.
// v
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
KnownVersion::new(264, "instance-cpu-type-turin-v2"),
KnownVersion::new(263, "external-jumbo-frames"),
KnownVersion::new(262, "rename-ip-pool-reservation-type"),
KnownVersion::new(261, "remove-add-zones-with-mupdate-override"),
Expand Down
5 changes: 5 additions & 0 deletions nexus/db-model/src/vmm_cpu_platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ impl_enum_type!(
SledDefault => b"sled_default"
AmdMilan => b"amd_milan"
AmdTurin => b"amd_turin"
AmdTurinV2 => b"amd_turin_v2"
);

impl VmmCpuPlatform {
Expand All @@ -46,6 +47,9 @@ impl VmmCpuPlatform {
Self::AmdTurin => {
Some(&[SledCpuFamily::AmdTurin, SledCpuFamily::AmdTurinDense])
}
Self::AmdTurinV2 => {
Some(&[SledCpuFamily::AmdTurin, SledCpuFamily::AmdTurinDense])
}

// VMMs get the "sled default" CPU platform when an instance starts
// up on a sled that hasn't reported a well-known CPU family. Assume
Expand All @@ -61,6 +65,7 @@ impl From<InstanceCpuPlatform> for VmmCpuPlatform {
match value {
InstanceCpuPlatform::AmdMilan => Self::AmdMilan,
InstanceCpuPlatform::AmdTurin => Self::AmdTurin,
InstanceCpuPlatform::AmdTurinV2 => Self::AmdTurinV2,
}
}
}
Loading
Loading