MCPcopy Index your code
hub / github.com/codebench-dev/worker / getFirecrackerConfig

Function getFirecrackerConfig

options.go:14–53  ·  view source on GitHub ↗
(vmmID string)

Source from the content-addressed store, hash-verified

12)
13
14func getFirecrackerConfig(vmmID string) (firecracker.Config, error) {
15 socket := getSocketPath(vmmID)
16 return firecracker.Config{
17 SocketPath: socket,
18 KernelImagePath: "../../linux/vmlinux",
19 LogPath: fmt.Sprintf("%s.log", socket),
20 Drives: []models.Drive{{
21 DriveID: firecracker.String("1"),
22 // TODO: copy base rootfs and use a temp roots per VM
23 PathOnHost: firecracker.String("/tmp/rootfs-" + vmmID + ".ext4"),
24 IsRootDevice: firecracker.Bool(true),
25 IsReadOnly: firecracker.Bool(false),
26 RateLimiter: firecracker.NewRateLimiter(
27 // bytes/s
28 models.TokenBucket{
29 OneTimeBurst: firecracker.Int64(1024 * 1024), // 1 MiB/s
30 RefillTime: firecracker.Int64(500), // 0.5s
31 Size: firecracker.Int64(1024 * 1024),
32 },
33 // ops/s
34 models.TokenBucket{
35 OneTimeBurst: firecracker.Int64(100), // 100 iops
36 RefillTime: firecracker.Int64(1000), // 1s
37 Size: firecracker.Int64(100),
38 }),
39 }},
40 NetworkInterfaces: []firecracker.NetworkInterface{{
41 // Use CNI to get dynamic IP
42 CNIConfiguration: &firecracker.CNIConfiguration{
43 NetworkName: "fcnet",
44 IfName: "veth0",
45 },
46 }},
47 MachineCfg: models.MachineConfiguration{
48 VcpuCount: firecracker.Int64(1),
49 HtEnabled: firecracker.Bool(true),
50 MemSizeMib: firecracker.Int64(256),
51 },
52 }, nil
53}
54
55func getSocketPath(vmmID string) string {
56 filename := strings.Join([]string{

Callers 1

createAndStartVMFunction · 0.85

Calls 1

getSocketPathFunction · 0.85

Tested by

no test coverage detected