-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (44 loc) · 1.15 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"context"
"os"
"github.com/firecracker-microvm/firecracker-go-sdk"
"github.com/firecracker-microvm/firecracker-go-sdk/client/models"
)
func main() {
ctx := context.TODO()
machine, err := firecracker.NewMachine(ctx, firecracker.Config{
SocketPath: "./firecracker.sock",
KernelImagePath: "./vmlinux-5.10.225",
KernelArgs: "console=ttyS0 reboot=k panic=1 pci=off",
Drives: []models.Drive{{
IsRootDevice: firecracker.Bool(true),
IsReadOnly: firecracker.Bool(false),
PathOnHost: firecracker.String("./ubuntu-24.04.ext4"),
DriveID: firecracker.String("rootfs"),
}},
MachineCfg: models.MachineConfiguration{
VcpuCount: firecracker.Int64(2),
MemSizeMib: firecracker.Int64(1024),
},
NetworkInterfaces: []firecracker.NetworkInterface{
{
CNIConfiguration: &firecracker.CNIConfiguration{
NetworkName: "fcnet",
IfName: "veth0",
BinPath: []string{"/opt/cni/bin"},
},
},
},
})
if err != nil {
panic(err)
}
if err := machine.Start(ctx); err != nil {
panic(err)
}
<-make(chan os.Signal, 1)
if err := machine.Shutdown(ctx); err != nil {
panic(err)
}
}