qemu: add support for tdx-guest object

support tdx-guest guest objects

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2021-03-30 16:17:46 -06:00
parent 7fbc685865
commit 3141894033

View File

@ -227,6 +227,9 @@ type ObjectType string
const (
// MemoryBackendFile represents a guest memory mapped file.
MemoryBackendFile ObjectType = "memory-backend-file"
// TDXGuest represents a TDX object
TDXGuest ObjectType = "tdx-guest"
)
// Object is a qemu object representation.
@ -249,6 +252,12 @@ type Object struct {
// Size is the object size in bytes
Size uint64
// Debug this is a debug object
Debug bool
// File is the device file
File string
}
// Valid returns true if the Object structure is valid and complete.
@ -259,6 +268,11 @@ func (object Object) Valid() bool {
return false
}
case TDXGuest:
if object.ID == "" || object.File == "" || object.DeviceID == "" {
return false
}
default:
return false
}
@ -283,6 +297,13 @@ func (object Object) QemuParams(config *Config) []string {
objectParams = append(objectParams, fmt.Sprintf(",size=%d", object.Size))
deviceParams = append(deviceParams, fmt.Sprintf(",memdev=%s", object.ID))
case TDXGuest:
objectParams = append(objectParams, string(object.Type))
objectParams = append(objectParams, fmt.Sprintf(",id=%s", object.ID))
if object.Debug {
objectParams = append(objectParams, ",debug=on")
}
deviceParams = append(deviceParams, fmt.Sprintf(",file=%s", object.File))
}
qemuParams = append(qemuParams, "-device")