mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Internal change
PiperOrigin-RevId: 727079732
This commit is contained in:
@@ -41,6 +41,7 @@ go_library(
|
||||
"bluepill_arm64_unsafe.go",
|
||||
"bluepill_fault.go",
|
||||
"bluepill_unsafe.go",
|
||||
"config.go",
|
||||
"context.go",
|
||||
"filters.go",
|
||||
"filters_amd64.go",
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2025 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build !false
|
||||
// +build !false
|
||||
|
||||
package kvm
|
||||
|
||||
// Config sets configuration options for each platform instance.
|
||||
type Config struct{}
|
||||
|
||||
func (*machine) applyConfig(config *Config) error { return nil }
|
||||
@@ -92,7 +92,7 @@ func OpenDevice(devicePath string) (*fd.FD, error) {
|
||||
}
|
||||
|
||||
// New returns a new KVM-based implementation of the platform interface.
|
||||
func New(deviceFile *fd.FD) (*KVM, error) {
|
||||
func New(deviceFile *fd.FD, config Config) (*KVM, error) {
|
||||
fd := deviceFile.FD()
|
||||
|
||||
// Ensure global initialization is done.
|
||||
@@ -122,7 +122,7 @@ func New(deviceFile *fd.FD) (*KVM, error) {
|
||||
deviceFile.Close()
|
||||
|
||||
// Create a VM context.
|
||||
machine, err := newMachine(int(vm))
|
||||
machine, err := newMachine(int(vm), &config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -185,7 +185,7 @@ func (k *KVM) NewContext(pkgcontext.Context) platform.Context {
|
||||
type constructor struct{}
|
||||
|
||||
func (*constructor) New(f *fd.FD) (platform.Platform, error) {
|
||||
return New(f)
|
||||
return New(f, Config{})
|
||||
}
|
||||
|
||||
func (*constructor) OpenDevice(devicePath string) (*fd.FD, error) {
|
||||
|
||||
@@ -42,6 +42,7 @@ const (
|
||||
KVM_GET_VCPU_EVENTS = 0x8040ae9f
|
||||
KVM_SET_VCPU_EVENTS = 0x4040aea0
|
||||
KVM_SET_DEVICE_ATTR = 0x4018aee1
|
||||
KVM_ENABLE_CAP = 0x4068aea3
|
||||
)
|
||||
|
||||
// KVM exit reasons.
|
||||
|
||||
@@ -48,7 +48,7 @@ func kvmTest(t testHarness, setup func(*KVM), fn func(*vCPU) bool) {
|
||||
if err != nil {
|
||||
t.Fatalf("error opening device file: %v", err)
|
||||
}
|
||||
k, err := New(deviceFile)
|
||||
k, err := New(deviceFile, Config{})
|
||||
if err != nil {
|
||||
t.Fatalf("error creating KVM instance: %v", err)
|
||||
}
|
||||
|
||||
@@ -267,11 +267,15 @@ func (m *machine) createVCPU(id int) *vCPU {
|
||||
var forceMappingEntireAddressSpace = false
|
||||
|
||||
// newMachine returns a new VM context.
|
||||
func newMachine(vm int) (*machine, error) {
|
||||
func newMachine(vm int, config *Config) (*machine, error) {
|
||||
// Create the machine.
|
||||
m := &machine{fd: vm}
|
||||
m.available.L = &m.mu
|
||||
|
||||
if err := m.applyConfig(config); err != nil {
|
||||
panic(fmt.Sprintf("error setting config parameters: %s", err))
|
||||
}
|
||||
|
||||
// Pull the maximum vCPUs.
|
||||
m.getMaxVCPU()
|
||||
log.Debugf("The maximum number of vCPUs is %d.", m.maxVCPUs)
|
||||
@@ -876,3 +880,10 @@ func seccompMmapRules(m *machine) {
|
||||
m.machinePoolIndex = i
|
||||
machinePoolMu.Unlock()
|
||||
}
|
||||
|
||||
type kvmEnableCap struct {
|
||||
capability uint32
|
||||
flags uint32
|
||||
args [4]uint64
|
||||
pad [64]uint8
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user