Skip to content

Commit

Permalink
feat(machine/xen): Introduce Xen support
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Stan <[email protected]>
  • Loading branch information
andreistan26 committed Apr 10, 2024
1 parent 1cbcbcf commit 7952808
Show file tree
Hide file tree
Showing 6 changed files with 755 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ require (
oras.land/oras-go/v2 v2.5.0
sdk.kraft.cloud v0.5.5-0.20240410102038-8d0f0333b17a
sigs.k8s.io/kustomize/kyaml v0.14.3
xenbits.xenproject.org/git-http/xen.git/tools/golang/xenlight v0.0.0-20240402142354-17cf285d87e2
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1695,3 +1695,5 @@ sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
xenbits.xenproject.org/git-http/xen.git/tools/golang/xenlight v0.0.0-20240402142354-17cf285d87e2 h1:f3OAMM0NgzlqWqZnuTIz6B6HPK1pGGfgKH6S94kYEWY=
xenbits.xenproject.org/git-http/xen.git/tools/golang/xenlight v0.0.0-20240402142354-17cf285d87e2/go.mod h1:tbZ4iMnk8RWkXPxTiCGdAw3hCOa3feShlf3sBh50uIc=
28 changes: 28 additions & 0 deletions machine/platform/register_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"kraftkit.sh/internal/set"
"kraftkit.sh/machine/firecracker"
"kraftkit.sh/store"
"kraftkit.sh/machine/xen"
)

var firecrackerV1alpha1Driver = func(ctx context.Context, opts ...any) (machinev1alpha1.MachineService, error) {
Expand Down Expand Up @@ -43,6 +44,30 @@ var firecrackerV1alpha1Driver = func(ctx context.Context, opts ...any) (machinev
)
}

var xenV1alpha1Driver = func(ctx context.Context, opts ...any) (machinev1alpha1.MachineService, error) {
service, err := xen.NewMachineV1alpha1Service(ctx)
if err != nil {
return nil, err
}

embeddedStore, err := store.NewEmbeddedStore[machinev1alpha1.MachineSpec, machinev1alpha1.MachineStatus](
filepath.Join(
config.G[config.KraftKit](ctx).RuntimeDir,
"machinev1alpha1",
),
)
if err != nil {
return nil, err
}

return machinev1alpha1.NewMachineServiceHandler(
ctx,
service,
zip.WithStore[machinev1alpha1.MachineSpec, machinev1alpha1.MachineStatus](embeddedStore, zip.StoreRehydrationSpecNil),
zip.WithBefore(storePlatformFilter(PlatformXen)),
)
}

func unixVariantStrategies() map[Platform]*Strategy {
// TODO(jake-ciolek): The firecracker driver has a dependency on github.com/containernetworking/plugins/pkg/ns via
// github.com/firecracker-microvm/firecracker-go-sdk
Expand All @@ -51,5 +76,8 @@ func unixVariantStrategies() map[Platform]*Strategy {
PlatformFirecracker: {
NewMachineV1alpha1: firecrackerV1alpha1Driver,
},
PlatformXen: {
NewMachineV1alpha1: xenV1alpha1Driver,
},
}
}
15 changes: 15 additions & 0 deletions machine/xen/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2024, Unikraft GmbH and The KraftKit Authors.
// Licensed under the BSD-3-Clause License (the "License").
// You may not use this file except in compliance with the License.
package xen

import (
"encoding/gob"

"xenbits.xenproject.org/git-http/xen.git/tools/golang/xenlight"
)

func init() {
gob.Register(xenlight.Domid(0))
}
Loading

0 comments on commit 7952808

Please sign in to comment.