Skip to content

Commit 3e217c1

Browse files
committed
rename ht_enabled to smt
Signed-off-by: alindima <[email protected]>
1 parent 11c8b26 commit 3e217c1

File tree

21 files changed

+105
-93
lines changed

21 files changed

+105
-93
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@
5757
interfaces. Specifying interfaces that allow forwarding requests to MMDS is done
5858
by adding the network interface's ID to the `network_interfaces` field of PUT
5959
`/mmds/config` request's body.
60-
- Configuring `ht_enabled: true` on aarch64 via the API is forbidden.
61-
- `ht_enabled` field is now optional on PUT `/machine-config`, defaulting to
60+
- Renamed `/machine-config` `ht_enabled` to `smt`.
61+
- `smt` field is now optional on PUT `/machine-config`, defaulting to
6262
`false`.
63+
- Configuring `smt: true` on aarch64 via the API is forbidden.
6364

6465
### Fixed
6566

docs/device-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ specification: [firecracker.yaml](./../src/api_server/swagger/firecracker.yaml).
6565
| | show_level | O | O | O | O | O |
6666
| | show_log_origin | O | O | O | O | O |
6767
| `MachineConfiguration` | cpu_template | O | O | O | O | O |
68-
| | ht_enabled | O | O | O | O | O |
68+
| | smt | O | O | O | O | O |
6969
| | mem_size_mib | O | O | O | O | O |
7070
| | track_dirty_pages | O | O | O | O | O |
7171
| | vcpu_count | O | O | O | O | O |
@@ -112,7 +112,7 @@ specification: [firecracker.yaml](./../src/api_server/swagger/firecracker.yaml).
112112
| | state | O | O | O | O | O |
113113
| | vmm_version | O | O | O | O | O |
114114
| `MachineConfiguration` | cpu_template | O | O | O | O | O |
115-
| | ht_enabled | O | O | O | O | O |
115+
| | smt | O | O | O | O | O |
116116
| | mem_size_mib | O | O | O | O | O |
117117
| | track_dirty_pages | O | O | O | O | O |
118118
| | vcpu_count | O | O | O | O | O |

docs/snapshotting/snapshot-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ curl --unix-socket /tmp/firecracker.socket -i \
333333
-d '{
334334
"vcpu_count": 2,
335335
"mem_size_mib": 1024,
336-
"ht_enabled": false,
336+
"smt": false,
337337
"track_dirty_pages": true
338338
}'
339339
```

src/api_server/src/parsed_request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ pub(crate) mod tests {
10191019
let body = "{ \
10201020
\"vcpu_count\": 0, \
10211021
\"mem_size_mib\": 0, \
1022-
\"ht_enabled\": false, \
1022+
\"smt\": false, \
10231023
\"cpu_template\": \"C3\" \
10241024
}";
10251025
sender

src/api_server/src/request/machine_configuration.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub(crate) fn parse_patch_machine_config(body: &Body) -> Result<ParsedRequest, E
5454
if vm_config.vcpu_count.is_none()
5555
&& vm_config.mem_size_mib.is_none()
5656
&& vm_config.cpu_template.is_none()
57-
&& vm_config.ht_enabled.is_none()
57+
&& vm_config.smt.is_none()
5858
{
5959
return method_to_error(Method::Patch);
6060
}
@@ -73,11 +73,11 @@ fn check_unsupported_fields(vm_config: &VmConfig) -> Result<(), Error> {
7373
));
7474
}
7575

76-
if let Some(true) = vm_config.ht_enabled {
77-
// ht_enabled: true is not supported on aarch64
76+
if let Some(true) = vm_config.smt {
77+
// smt: true is not supported on aarch64
7878
return Err(Error::Generic(
7979
StatusCode::BadRequest,
80-
"Enabling HyperThreading is not supported on aarch64".to_string(),
80+
"Enabling simultaneous multithreading is not supported on aarch64".to_string(),
8181
));
8282
}
8383

@@ -120,7 +120,7 @@ mod tests {
120120
let expected_config = VmConfig {
121121
vcpu_count: Some(8),
122122
mem_size_mib: Some(1024),
123-
ht_enabled: None,
123+
smt: None,
124124
cpu_template: None,
125125
track_dirty_pages: false,
126126
};
@@ -133,13 +133,13 @@ mod tests {
133133
let body = r#"{
134134
"vcpu_count": 8,
135135
"mem_size_mib": 1024,
136-
"ht_enabled": false,
136+
"smt": false,
137137
"track_dirty_pages": true
138138
}"#;
139139
let expected_config = VmConfig {
140140
vcpu_count: Some(8),
141141
mem_size_mib: Some(1024),
142-
ht_enabled: Some(false),
142+
smt: Some(false),
143143
cpu_template: None,
144144
track_dirty_pages: true,
145145
};
@@ -153,7 +153,7 @@ mod tests {
153153
let body = r#"{
154154
"vcpu_count": 8,
155155
"mem_size_mib": 1024,
156-
"ht_enabled": false,
156+
"smt": false,
157157
"cpu_template": "T2",
158158
"track_dirty_pages": true
159159
}"#;
@@ -164,7 +164,7 @@ mod tests {
164164
let expected_config = VmConfig {
165165
vcpu_count: Some(8),
166166
mem_size_mib: Some(1024),
167-
ht_enabled: Some(false),
167+
smt: Some(false),
168168
cpu_template: Some(CpuFeaturesTemplate::T2),
169169
track_dirty_pages: true,
170170
};
@@ -180,11 +180,11 @@ mod tests {
180180
assert!(parse_put_machine_config(&Body::new(body)).is_err());
181181
}
182182

183-
// 5. Test that setting `ht_enabled: true` is successful on x86_64 while on aarch64, it is not.
183+
// 5. Test that setting `smt: true` is successful on x86_64 while on aarch64, it is not.
184184
let body = r#"{
185185
"vcpu_count": 8,
186186
"mem_size_mib": 1024,
187-
"ht_enabled": true,
187+
"smt": true,
188188
"track_dirty_pages": true
189189
}"#;
190190

@@ -193,7 +193,7 @@ mod tests {
193193
let expected_config = VmConfig {
194194
vcpu_count: Some(8),
195195
mem_size_mib: Some(1024),
196-
ht_enabled: Some(true),
196+
smt: Some(true),
197197
cpu_template: None,
198198
track_dirty_pages: true,
199199
};
@@ -239,7 +239,7 @@ mod tests {
239239
let body = r#"{
240240
"vcpu_count": 8,
241241
"mem_size_mib": 1024,
242-
"ht_enabled": false
242+
"smt": false
243243
}"#;
244244
assert!(parse_patch_machine_config(&Body::new(body)).is_ok());
245245
}

src/api_server/swagger/firecracker.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ paths:
285285
description:
286286
Gets the machine configuration of the VM. When called before the PUT operation, it
287287
will return the default values for the vCPU count (=1), memory size (=128 MiB).
288-
By default Hyperthreading is disabled and there is no CPU Template.
288+
By default SMT is disabled and there is no CPU Template.
289289
operationId: getMachineConfiguration
290290
responses:
291291
200:
@@ -302,7 +302,7 @@ paths:
302302
description:
303303
Updates the Virtual Machine Configuration with the specified input.
304304
Firecracker starts with default values for vCPU count (=1) and memory size (=128 MiB).
305-
With Hyperthreading enabled, the vCPU count is restricted to be 1 or an even number,
305+
With SMT enabled, the vCPU count is restricted to be 1 or an even number,
306306
otherwise there are no restrictions regarding the vCPU count.
307307
If any of the parameters has an incorrect value, the whole update fails.
308308
operationId: putMachineConfiguration
@@ -925,17 +925,18 @@ definitions:
925925
MachineConfiguration:
926926
type: object
927927
description:
928-
Describes the number of vCPUs, memory size, Hyperthreading capabilities and
928+
Describes the number of vCPUs, memory size, SMT capabilities and
929929
the CPU template.
930930
required:
931931
- mem_size_mib
932932
- vcpu_count
933933
properties:
934934
cpu_template:
935935
$ref: "#/definitions/CpuTemplate"
936-
ht_enabled:
936+
smt:
937937
type: boolean
938-
description: Flag for enabling/disabling Hyperthreading. x86-only.
938+
description: Flag for enabling/disabling simultaneous multithreading. Can be enabled only on x86.
939+
default: false
939940
mem_size_mib:
940941
type: integer
941942
description: Memory size of VM

src/cpuid/src/transformer/amd.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ mod tests {
252252
assert_eq!(entry.ecx.read_bit(ecx::TOPOEXT_INDEX), true);
253253
}
254254

255-
fn check_update_amd_features_entry(cpu_count: u8, ht_enabled: bool) {
255+
fn check_update_amd_features_entry(cpu_count: u8, smt: bool) {
256256
use crate::cpu_leaf::leaf_0x80000008::*;
257257

258-
let vm_spec = VmSpec::new(0, cpu_count, ht_enabled).expect("Error creating vm_spec");
258+
let vm_spec = VmSpec::new(0, cpu_count, smt).expect("Error creating vm_spec");
259259
let mut entry = &mut kvm_cpuid_entry2 {
260260
function: LEAF_NUM,
261261
index: 0,
@@ -282,13 +282,13 @@ mod tests {
282282
fn check_update_extended_apic_id_entry(
283283
cpu_id: u8,
284284
cpu_count: u8,
285-
ht_enabled: bool,
285+
smt: bool,
286286
expected_core_id: u32,
287287
expected_threads_per_core: u32,
288288
) {
289289
use crate::cpu_leaf::leaf_0x8000001e::*;
290290

291-
let vm_spec = VmSpec::new(cpu_id, cpu_count, ht_enabled).expect("Error creating vm_spec");
291+
let vm_spec = VmSpec::new(cpu_id, cpu_count, smt).expect("Error creating vm_spec");
292292
let mut entry = &mut kvm_cpuid_entry2 {
293293
function: LEAF_NUM,
294294
index: 0,

src/cpuid/src/transformer/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ mod tests {
174174

175175
fn check_update_cache_parameters_entry(
176176
cpu_count: u8,
177-
ht_enabled: bool,
177+
smt: bool,
178178
cache_level: u32,
179179
expected_max_cpus_per_core: u32,
180180
) {
181181
use crate::cpu_leaf::leaf_cache_parameters::*;
182182

183-
let vm_spec = VmSpec::new(0, cpu_count, ht_enabled).expect("Error creating vm_spec");
183+
let vm_spec = VmSpec::new(0, cpu_count, smt).expect("Error creating vm_spec");
184184
let mut entry = &mut kvm_cpuid_entry2 {
185185
function: 0x0,
186186
index: 0,

src/cpuid/src/transformer/intel.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ mod tests {
162162

163163
fn check_update_deterministic_cache_entry(
164164
cpu_count: u8,
165-
ht_enabled: bool,
165+
smt: bool,
166166
cache_level: u32,
167167
expected_max_cores_per_package: u32,
168168
) {
169169
use crate::cpu_leaf::leaf_0x4::*;
170170

171-
let vm_spec = VmSpec::new(0, cpu_count, ht_enabled).expect("Error creating vm_spec");
171+
let vm_spec = VmSpec::new(0, cpu_count, smt).expect("Error creating vm_spec");
172172
let mut entry = &mut kvm_cpuid_entry2 {
173173
function: 0x0,
174174
index: 0,
@@ -192,15 +192,15 @@ mod tests {
192192

193193
fn check_update_extended_topology_entry(
194194
cpu_count: u8,
195-
ht_enabled: bool,
195+
smt: bool,
196196
index: u32,
197197
expected_apicid: u32,
198198
expected_num_logical_processors: u32,
199199
expected_level_type: u32,
200200
) {
201201
use crate::cpu_leaf::leaf_0xb::*;
202202

203-
let vm_spec = VmSpec::new(0, cpu_count, ht_enabled).expect("Error creating vm_spec");
203+
let vm_spec = VmSpec::new(0, cpu_count, smt).expect("Error creating vm_spec");
204204
let mut entry = &mut kvm_cpuid_entry2 {
205205
function: 0x0,
206206
index,

src/cpuid/src/transformer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ pub struct VmSpec {
3030
impl VmSpec {
3131
/// Creates a new instance of VmSpec with the specified parameters
3232
/// The brand string is deduced from the vendor_id
33-
pub fn new(cpu_index: u8, cpu_count: u8, ht_enabled: bool) -> Result<VmSpec, Error> {
33+
pub fn new(cpu_index: u8, cpu_count: u8, smt: bool) -> Result<VmSpec, Error> {
3434
let cpu_vendor_id = get_vendor_id_from_host().map_err(Error::InternalError)?;
3535

3636
Ok(VmSpec {
3737
cpu_vendor_id,
3838
cpu_index,
3939
cpu_count,
40-
cpu_bits: (cpu_count > 1 && ht_enabled) as u8,
40+
cpu_bits: (cpu_count > 1 && smt) as u8,
4141
brand_string: BrandString::from_vendor_id(&cpu_vendor_id),
4242
})
4343
}

0 commit comments

Comments
 (0)