Skip to content

Commit e9e51f8

Browse files
Merge pull request #38 from cloudify-incubator/add-tpm-device
add-tpm-device
2 parents 8956432 + 256ef66 commit e9e51f8

5 files changed

Lines changed: 20 additions & 0 deletions

File tree

cloudify_libvirt/common.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def gen_xml_template(kwargs, template_params, default_template):
7676
serial_devices = []
7777
usb_devices = []
7878
pci_devices = []
79+
tpm_devices = []
7980
for device in passthrough_devices:
8081
if device.get('type') == 'serial':
8182
if 'source_path' in device and 'target_port' in device:
@@ -94,12 +95,18 @@ def gen_xml_template(kwargs, template_params, default_template):
9495
'bus': device.get('bus'),
9596
'slot': device.get('slot'),
9697
'function': device.get('function')})
98+
elif device.get('type') == 'tpm':
99+
if 'path' in device:
100+
tpm_devices.append({
101+
'path': device.get('path')})
97102
if serial_devices:
98103
params.update({'serial_devices': serial_devices})
99104
if usb_devices:
100105
params.update({'usb_devices': usb_devices})
101106
if pci_devices:
102107
params.update({'pci_devices': pci_devices})
108+
if tpm_devices:
109+
params.update({'tpm_devices': tpm_devices})
103110
if not isinstance(template_content, str):
104111
template_content = template_content.decode("utf-8")
105112
xmlconfig = filters.render_template(template_content, params)

cloudify_libvirt/templates/domain.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
</source>
7070
</hostdev>
7171
{% endfor %}
72+
{% for tpm_device in tpm_devices %}
73+
<tpm model='tpm-tis'>
74+
<backend type='passthrough'>
75+
<device path='{{ tpm_device.path }}'/>
76+
</backend>
77+
</tpm>
78+
{% endfor %}
7279
</devices>
7380
<on_crash>restart</on_crash>
7481
<on_reboot>restart</on_reboot>

plugin.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ data_types:
169169
bus: 0x01
170170
slot: 0x00
171171
function: 0x1
172+
- type: tpm
173+
path: /dev/tpm0
172174
default: []
173175

174176
node_types:

plugin_1_4.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ data_types:
179179
bus: 0x01
180180
slot: 0x00
181181
function: 0x1
182+
- type: tpm
183+
path: /dev/tpm0
182184
default: []
183185

184186
node_types:

v2_plugin.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ data_types:
179179
bus: 0x01
180180
slot: 0x00
181181
function: 0x1
182+
- type: tpm
183+
path: /dev/tpm0
182184
default: []
183185

184186
node_types:

0 commit comments

Comments
 (0)