tpm: add TPM emulator backend
An emulated backend doesn't require any path, since libvirt will take care of finding the emulator and managing the storage. However, the version to emulate can be specified. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
67cb191e82
commit
fa32aea416
|
@ -148,6 +148,9 @@
|
||||||
<device path="/dev/tpm0"/>
|
<device path="/dev/tpm0"/>
|
||||||
</backend>
|
</backend>
|
||||||
</tpm>
|
</tpm>
|
||||||
|
<tpm model="tpm-crb">
|
||||||
|
<backend type="emulator" version="2.0"/>
|
||||||
|
</tpm>
|
||||||
<graphics type="vnc" port="-1"/>
|
<graphics type="vnc" port="-1"/>
|
||||||
<watchdog model="ib700" action="pause"/>
|
<watchdog model="ib700" action="pause"/>
|
||||||
<memballoon model="virtio"/>
|
<memballoon model="virtio"/>
|
||||||
|
@ -322,6 +325,9 @@
|
||||||
<device path="/dev/tpm0"/>
|
<device path="/dev/tpm0"/>
|
||||||
</backend>
|
</backend>
|
||||||
</tpm>
|
</tpm>
|
||||||
|
<tpm model="tpm-crb">
|
||||||
|
<backend type="emulator" version="2.0"/>
|
||||||
|
</tpm>
|
||||||
<graphics type="vnc" port="-1"/>
|
<graphics type="vnc" port="-1"/>
|
||||||
<watchdog model="ib700" action="pause"/>
|
<watchdog model="ib700" action="pause"/>
|
||||||
<memballoon model="virtio"/>
|
<memballoon model="virtio"/>
|
||||||
|
|
|
@ -450,6 +450,7 @@ cache.mode=emulate,cache.level=3 \
|
||||||
--watchdog ib700,action=pause \
|
--watchdog ib700,action=pause \
|
||||||
--tpm passthrough,model=tpm-tis,path=/dev/tpm0 \
|
--tpm passthrough,model=tpm-tis,path=/dev/tpm0 \
|
||||||
--tpm passthrough,model=tpm-crb,path=/dev/tpm0 \
|
--tpm passthrough,model=tpm-crb,path=/dev/tpm0 \
|
||||||
|
--tpm emulator,model=tpm-crb,version=2.0 \
|
||||||
--rng egd,backend_host=127.0.0.1,backend_service=8000,backend_type=udp,backend_mode=bind,backend_connect_host=foo,backend_connect_service=708 \
|
--rng egd,backend_host=127.0.0.1,backend_service=8000,backend_type=udp,backend_mode=bind,backend_connect_host=foo,backend_connect_service=708 \
|
||||||
--panic iobase=0x506 \
|
--panic iobase=0x506 \
|
||||||
""", "singleton-config-2")
|
""", "singleton-config-2")
|
||||||
|
|
|
@ -2448,6 +2448,7 @@ _register_virt_parser(ParserTPM)
|
||||||
_add_device_address_args(ParserTPM)
|
_add_device_address_args(ParserTPM)
|
||||||
ParserTPM.add_arg("type", "type")
|
ParserTPM.add_arg("type", "type")
|
||||||
ParserTPM.add_arg("model", "model")
|
ParserTPM.add_arg("model", "model")
|
||||||
|
ParserTPM.add_arg("version", "version")
|
||||||
ParserTPM.add_arg("device_path", "path")
|
ParserTPM.add_arg("device_path", "path")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,15 @@ from ..xmlbuilder import XMLProperty
|
||||||
class DeviceTpm(Device):
|
class DeviceTpm(Device):
|
||||||
XML_NAME = "tpm"
|
XML_NAME = "tpm"
|
||||||
|
|
||||||
|
VERSION_1_2 = "1.2"
|
||||||
|
VERSION_2_0 = "2.0"
|
||||||
|
VERSION_DEFAULT = "default"
|
||||||
|
VERSIONS = [VERSION_1_2, VERSION_2_0]
|
||||||
|
|
||||||
TYPE_PASSTHROUGH = "passthrough"
|
TYPE_PASSTHROUGH = "passthrough"
|
||||||
|
TYPE_EMULATOR = "emulator"
|
||||||
TYPE_DEFAULT = "default"
|
TYPE_DEFAULT = "default"
|
||||||
TYPES = [TYPE_PASSTHROUGH]
|
TYPES = [TYPE_PASSTHROUGH, TYPE_EMULATOR]
|
||||||
|
|
||||||
MODEL_TIS = "tpm-tis"
|
MODEL_TIS = "tpm-tis"
|
||||||
MODEL_CRB = "tpm-crb"
|
MODEL_CRB = "tpm-crb"
|
||||||
|
@ -29,6 +35,8 @@ class DeviceTpm(Device):
|
||||||
def get_pretty_type(tpm_type):
|
def get_pretty_type(tpm_type):
|
||||||
if tpm_type == DeviceTpm.TYPE_PASSTHROUGH:
|
if tpm_type == DeviceTpm.TYPE_PASSTHROUGH:
|
||||||
return _("Passthrough device")
|
return _("Passthrough device")
|
||||||
|
if tpm_type == DeviceTpm.TYPE_EMULATOR:
|
||||||
|
return _("Emulated device")
|
||||||
return tpm_type
|
return tpm_type
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -45,6 +53,7 @@ class DeviceTpm(Device):
|
||||||
"""
|
"""
|
||||||
users = {
|
users = {
|
||||||
"device_path": [self.TYPE_PASSTHROUGH],
|
"device_path": [self.TYPE_PASSTHROUGH],
|
||||||
|
"version": [self.TYPE_EMULATOR],
|
||||||
}
|
}
|
||||||
|
|
||||||
if users.get(propname):
|
if users.get(propname):
|
||||||
|
@ -54,7 +63,20 @@ class DeviceTpm(Device):
|
||||||
|
|
||||||
type = XMLProperty("./backend/@type",
|
type = XMLProperty("./backend/@type",
|
||||||
default_cb=lambda s: s.TYPE_PASSTHROUGH)
|
default_cb=lambda s: s.TYPE_PASSTHROUGH)
|
||||||
|
|
||||||
|
def _get_default_version(self):
|
||||||
|
if not self.supports_property("version"):
|
||||||
|
return None
|
||||||
|
return self.VERSION_1_2
|
||||||
|
version = XMLProperty("./backend/@version",
|
||||||
|
default_cb=_get_default_version)
|
||||||
model = XMLProperty("./@model",
|
model = XMLProperty("./@model",
|
||||||
default_cb=lambda s: s.MODEL_TIS)
|
default_cb=lambda s: s.MODEL_TIS)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_default_device_path(self):
|
||||||
|
if not self.supports_property("device_path"):
|
||||||
|
return None
|
||||||
|
return "/dev/tpm0"
|
||||||
device_path = XMLProperty("./backend/device/@path",
|
device_path = XMLProperty("./backend/device/@path",
|
||||||
default_cb=lambda s: "/dev/tpm0")
|
default_cb=_get_default_device_path)
|
||||||
|
|
Loading…
Reference in New Issue