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

fix: Match Firecracker 1.0.0 API #385

Merged
merged 2 commits into from
Feb 7, 2022
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
19 changes: 14 additions & 5 deletions infrastructure/firecracker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func WithMicroVM(vm *models.MicroVM) ConfigOption {
cfg.MachineConfig = MachineConfig{
MemSizeMib: vm.Spec.MemoryInMb,
VcpuCount: vm.Spec.VCPU,
HTEnabled: false,
SMT: false,
}

cfg.NetDevices = []NetworkInterfaceConfig{}
Expand Down Expand Up @@ -115,6 +115,16 @@ func WithMicroVM(vm *models.MicroVM) ConfigOption {
cfg.BootSource.InitrdPath = &initrdPath
}

cfg.Mmds = &MMDSConfig{
NetworkInterfaces: []string{},
}

for _, iface := range vm.Spec.NetworkInterfaces {
if iface.AllowMetadataRequests {
cfg.Mmds.NetworkInterfaces = append(cfg.Mmds.NetworkInterfaces, iface.GuestDeviceName)
}
}

return nil
}
}
Expand Down Expand Up @@ -182,10 +192,9 @@ func createNetworkIface(iface *models.NetworkInterface, status *models.NetworkIn
}

netInt := &NetworkInterfaceConfig{
IfaceID: iface.GuestDeviceName,
HostDevName: hostDevName,
GuestMAC: macAddr,
AllowMMDSRequests: iface.AllowMetadataRequests,
IfaceID: iface.GuestDeviceName,
HostDevName: hostDevName,
GuestMAC: macAddr,
}

return netInt
Expand Down
15 changes: 11 additions & 4 deletions infrastructure/firecracker/testdata/vm_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
"machine-config": {
"vcpu_count": 2,
"mem_size_mib": 1024,
"ht_enabled": false,
"smt": false,
"track_dirty_pages": false
},
"balloon": null,
"network-interfaces": [],
"network-interfaces": [
{
"iface_id": "mdms1",
"host_dev_name": "tap0"
}
],
"mmds-config": {
"network_interfaces": ["mdms1"]
},
"vsock": null,
"logger": null,
"metrics": null,
"mmds-config": null
"metrics": null
}
14 changes: 6 additions & 8 deletions infrastructure/firecracker/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ type MachineConfig struct {
VcpuCount int64 `json:"vcpu_count"`
// MemSizeMib is the memory size in MiB.
MemSizeMib int64 `json:"mem_size_mib"`
// HTEnabled enables or disabled hyperthreading.
HTEnabled bool `json:"ht_enabled"`
// SMT enables or disabled hyperthreading.
SMT bool `json:"smt"`
// CPUTemplate is a CPU template that it is used to filter the CPU features exposed to the guest.
CPUTemplate *string `json:"cpu_template,omitempty"`
// TrackDirtyPages enables or disables dirty page tracking. Enabling allows incremental snapshots.
Expand Down Expand Up @@ -103,12 +103,6 @@ type NetworkInterfaceConfig struct {
HostDevName string `json:"host_dev_name"`
// GuestMAC is the mac address to use.
GuestMAC string `json:"guest_mac,omitempty"`
// AllowMMDSRequests is true the device model will reply to HTTP GET
// requests sent to the MMDS address via this interface. In this case,
// both ARP requests for `169.254.169.254` and TCP segments heading to the
// same address are intercepted by the device model, and do not reach
// the associated TAP device.
AllowMMDSRequests bool `json:"allow_mmds_requests"`
// RxRateLimiter is the rate limiter for received packages.
// RxRateLimiter *RateLimiterConfig `json:"rx_rate_limiter,omitempty"`
// TxRateLimiter is the rate limiter for transmitted packages.
Expand Down Expand Up @@ -149,6 +143,10 @@ type MetricsConfig struct {
type MMDSConfig struct {
// IPV4Address is the MMDS IPv4 configured address.
IPV4Address *string `json:"ipv4_address,omitempty"`
// NetworkInterfaces that has access to the metadata service.
NetworkInterfaces []string `json:"network_interfaces"`
// Version of the MMDS.
Version *string `json:"version,omitempty"`
}

type VsockDeviceConfig struct {
Expand Down