mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 08:47:56 +00:00
qemu: add support for SevGuest object
Signed-off-by: Jim Cadden <jcadden@ibm.com>
This commit is contained in:
parent
f0e9a35308
commit
a6cec2d38c
40
qemu/qemu.go
40
qemu/qemu.go
@ -230,6 +230,9 @@ const (
|
|||||||
|
|
||||||
// TDXGuest represents a TDX object
|
// TDXGuest represents a TDX object
|
||||||
TDXGuest ObjectType = "tdx-guest"
|
TDXGuest ObjectType = "tdx-guest"
|
||||||
|
|
||||||
|
// SEVGuest represents an SEV guest object
|
||||||
|
SEVGuest ObjectType = "sev-guest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Object is a qemu object representation.
|
// Object is a qemu object representation.
|
||||||
@ -258,6 +261,14 @@ type Object struct {
|
|||||||
|
|
||||||
// File is the device file
|
// File is the device file
|
||||||
File string
|
File string
|
||||||
|
|
||||||
|
// CBitPos is the location of the C-bit in a guest page table entry
|
||||||
|
// This is only relevant for sev-guest objects
|
||||||
|
CBitPos uint32
|
||||||
|
|
||||||
|
// ReducedPhysBits is the reduction in the guest physical address space
|
||||||
|
// This is only relevant for sev-guest objects
|
||||||
|
ReducedPhysBits uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid returns true if the Object structure is valid and complete.
|
// Valid returns true if the Object structure is valid and complete.
|
||||||
@ -272,6 +283,10 @@ func (object Object) Valid() bool {
|
|||||||
if object.ID == "" || object.File == "" || object.DeviceID == "" {
|
if object.ID == "" || object.File == "" || object.DeviceID == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
case SEVGuest:
|
||||||
|
if object.ID == "" || object.File == "" || object.CBitPos == 0 || object.ReducedPhysBits == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
@ -284,11 +299,9 @@ func (object Object) Valid() bool {
|
|||||||
func (object Object) QemuParams(config *Config) []string {
|
func (object Object) QemuParams(config *Config) []string {
|
||||||
var objectParams []string
|
var objectParams []string
|
||||||
var deviceParams []string
|
var deviceParams []string
|
||||||
|
var driveParams []string
|
||||||
var qemuParams []string
|
var qemuParams []string
|
||||||
|
|
||||||
deviceParams = append(deviceParams, string(object.Driver))
|
|
||||||
deviceParams = append(deviceParams, fmt.Sprintf(",id=%s", object.DeviceID))
|
|
||||||
|
|
||||||
switch object.Type {
|
switch object.Type {
|
||||||
case MemoryBackendFile:
|
case MemoryBackendFile:
|
||||||
objectParams = append(objectParams, string(object.Type))
|
objectParams = append(objectParams, string(object.Type))
|
||||||
@ -296,6 +309,8 @@ func (object Object) QemuParams(config *Config) []string {
|
|||||||
objectParams = append(objectParams, fmt.Sprintf(",mem-path=%s", object.MemPath))
|
objectParams = append(objectParams, fmt.Sprintf(",mem-path=%s", object.MemPath))
|
||||||
objectParams = append(objectParams, fmt.Sprintf(",size=%d", object.Size))
|
objectParams = append(objectParams, fmt.Sprintf(",size=%d", object.Size))
|
||||||
|
|
||||||
|
deviceParams = append(deviceParams, string(object.Driver))
|
||||||
|
deviceParams = append(deviceParams, fmt.Sprintf(",id=%s", object.DeviceID))
|
||||||
deviceParams = append(deviceParams, fmt.Sprintf(",memdev=%s", object.ID))
|
deviceParams = append(deviceParams, fmt.Sprintf(",memdev=%s", object.ID))
|
||||||
case TDXGuest:
|
case TDXGuest:
|
||||||
objectParams = append(objectParams, string(object.Type))
|
objectParams = append(objectParams, string(object.Type))
|
||||||
@ -303,14 +318,33 @@ func (object Object) QemuParams(config *Config) []string {
|
|||||||
if object.Debug {
|
if object.Debug {
|
||||||
objectParams = append(objectParams, ",debug=on")
|
objectParams = append(objectParams, ",debug=on")
|
||||||
}
|
}
|
||||||
|
deviceParams = append(deviceParams, string(object.Driver))
|
||||||
|
deviceParams = append(deviceParams, fmt.Sprintf(",id=%s", object.DeviceID))
|
||||||
deviceParams = append(deviceParams, fmt.Sprintf(",file=%s", object.File))
|
deviceParams = append(deviceParams, fmt.Sprintf(",file=%s", object.File))
|
||||||
|
case SEVGuest:
|
||||||
|
objectParams = append(objectParams, string(object.Type))
|
||||||
|
objectParams = append(objectParams, fmt.Sprintf(",id=%s", object.ID))
|
||||||
|
objectParams = append(objectParams, fmt.Sprintf(",cbitpos=%d", object.CBitPos))
|
||||||
|
objectParams = append(objectParams, fmt.Sprintf(",reduced-phys-bits=%d", object.ReducedPhysBits))
|
||||||
|
|
||||||
|
driveParams = append(driveParams, "if=pflash,format=raw,readonly=on")
|
||||||
|
driveParams = append(driveParams, fmt.Sprintf(",file=%s", object.File))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(deviceParams) > 0 {
|
||||||
qemuParams = append(qemuParams, "-device")
|
qemuParams = append(qemuParams, "-device")
|
||||||
qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
|
qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(objectParams) > 0 {
|
||||||
qemuParams = append(qemuParams, "-object")
|
qemuParams = append(qemuParams, "-object")
|
||||||
qemuParams = append(qemuParams, strings.Join(objectParams, ""))
|
qemuParams = append(qemuParams, strings.Join(objectParams, ""))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(driveParams) > 0 {
|
||||||
|
qemuParams = append(qemuParams, "-drive")
|
||||||
|
qemuParams = append(qemuParams, strings.Join(driveParams, ""))
|
||||||
|
}
|
||||||
|
|
||||||
return qemuParams
|
return qemuParams
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user