diff --git a/qemu/qemu.go b/qemu/qemu.go index 53ac898407..3e6550f139 100644 --- a/qemu/qemu.go +++ b/qemu/qemu.go @@ -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")