2013-06-26 09:45:06 +08:00
|
|
|
#
|
2013-10-28 04:59:46 +08:00
|
|
|
# Copyright 2011, 2013 Red Hat, Inc.
|
2013-10-28 04:59:47 +08:00
|
|
|
# Copyright 2013 IBM Corporation
|
2013-06-26 09:45:06 +08:00
|
|
|
#
|
2018-04-04 21:35:41 +08:00
|
|
|
# This work is licensed under the GNU GPLv2 or later.
|
2018-03-21 03:00:02 +08:00
|
|
|
# See the COPYING file in the top-level directory.
|
2013-06-26 09:45:06 +08:00
|
|
|
|
2018-03-21 00:18:35 +08:00
|
|
|
from .device import Device
|
2018-03-21 00:27:37 +08:00
|
|
|
from ..xmlbuilder import XMLProperty
|
2013-06-26 09:45:06 +08:00
|
|
|
|
|
|
|
|
2018-03-21 00:18:35 +08:00
|
|
|
class DeviceTpm(Device):
|
2018-03-21 22:53:34 +08:00
|
|
|
XML_NAME = "tpm"
|
2013-06-26 09:45:06 +08:00
|
|
|
|
2018-06-09 05:42:41 +08:00
|
|
|
VERSION_1_2 = "1.2"
|
|
|
|
VERSION_2_0 = "2.0"
|
|
|
|
VERSIONS = [VERSION_1_2, VERSION_2_0]
|
|
|
|
|
2013-07-16 00:18:23 +08:00
|
|
|
TYPE_PASSTHROUGH = "passthrough"
|
2018-06-09 05:42:41 +08:00
|
|
|
TYPE_EMULATOR = "emulator"
|
|
|
|
TYPES = [TYPE_PASSTHROUGH, TYPE_EMULATOR]
|
2013-06-26 09:45:06 +08:00
|
|
|
|
2013-07-16 00:18:23 +08:00
|
|
|
MODEL_TIS = "tpm-tis"
|
2018-06-09 05:42:40 +08:00
|
|
|
MODEL_CRB = "tpm-crb"
|
|
|
|
MODELS = [MODEL_TIS, MODEL_CRB]
|
2013-06-26 09:45:06 +08:00
|
|
|
|
2018-09-02 05:50:31 +08:00
|
|
|
type = XMLProperty("./backend/@type")
|
|
|
|
version = XMLProperty("./backend/@version")
|
|
|
|
model = XMLProperty("./@model")
|
|
|
|
device_path = XMLProperty("./backend/device/@path")
|
2018-06-09 05:42:41 +08:00
|
|
|
|
|
|
|
|
2018-09-02 05:50:31 +08:00
|
|
|
##################
|
|
|
|
# Default config #
|
|
|
|
##################
|
2018-06-09 05:42:41 +08:00
|
|
|
|
2018-09-02 05:50:31 +08:00
|
|
|
def set_defaults(self, guest):
|
|
|
|
if not self.type:
|
|
|
|
self.type = self.TYPE_PASSTHROUGH
|
|
|
|
if not self.model:
|
|
|
|
self.model = self.MODEL_TIS
|