Martin Polednik has uploaded a new change for review.
Change subject: [WIP]vdsm: add support for TPM device passthrough ......................................................................
[WIP]vdsm: add support for TPM device passthrough
This patch adds basic support for TPM (to be expanded) passthrough, which allows VM to be given access directly to host's TPM module.
Currently missing: reporting host's tpm status (nonexistant / passed to VM / available)
Engine constraints: vm with assigned TPM cannot be allowed to migrate, host cannot pass single TPM to multiple VMs using passthrough protocol (currently only supported protocol http://wiki.qemu.org/Features/TPM)
Change-Id: I53a77a0977d367d1066e85590dd35b18bb5fa32a Signed-off-by: Martin Polednik mpoledni@redhat.com --- M tests/vmTests.py M vdsm/vm.py M vdsm_api/vdsmapi-schema.json 3 files changed, 90 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/20649/1
diff --git a/tests/vmTests.py b/tests/vmTests.py index 1f69f0a..b879e5f 100644 --- a/tests/vmTests.py +++ b/tests/vmTests.py @@ -114,6 +114,20 @@ smartcard = vm.SmartCardDevice(self.conf, self.log, **dev) self.assertXML(smartcard.getXML(), smartcardXML)
+ def testTpmXML(self): + tpmXML = """ + <tpm model="tpm-tis"> + <backend type="passthrough"> + <device path="/dev/tpm0"/> + </backend> + </tpm> + """ + dev = {'device': 'tpm', + 'specParams': {'type': 'passthrough', + 'path': '/dev/tpm0', 'model': 'tpm-tis'}} + tpm = vm.TpmDevice(self.conf, self.log, **dev) + self.assertXML(tpm.getXML(), tpmXML) + def testFeaturesXML(self): featuresXML = """ <features> diff --git a/vdsm/vm.py b/vdsm/vm.py index 0c12334..d73e83e 100644 --- a/vdsm/vm.py +++ b/vdsm/vm.py @@ -1673,6 +1673,26 @@ return card
+class TpmDevice(VmDevice): + def getXML(self): + """ + Add tpm section to domain xml + + <tpm model='tpm-tis'> + <backend type='passthrough'> + <device path='/dev/tpm0'> + </backend> + </tpm> + """ + tpm = self.createXmlElem(self.device, None) + tpm.setAttrs(**{'model': self.specParams['model']}) + backend = tpm.appendChildWithArgs('backend', + type=self.specParams['type']) + backend.appendChildWithArgs('device', + path=self.specParams['path']) + return tpm + + class RedirDevice(VmDevice): def getXML(self): """ diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json index 73889d1..1be8e9d 100644 --- a/vdsm_api/vdsmapi-schema.json +++ b/vdsm_api/vdsmapi-schema.json @@ -1832,7 +1832,7 @@ ## {'enum': 'VmDeviceType', 'data': ['disk', 'interface', 'video', 'sound', 'controller', 'balloon', - 'channel', 'console', 'smartcard']} + 'channel', 'console', 'tpm', 'smartcard']}
## # @VmDiskDeviceType: @@ -2590,6 +2590,61 @@ 'address': 'VmDeviceAddress', 'alias': 'str', 'deviceId': 'UUID'}}
## +# @VmTpmDeviceType: +# +# An enumeration of VM tpm device types. +# +# @passthrough: use hosts TPM +# +# Since: 4.10.3 +## +{'enum': 'VmTpmDeviceType', 'data': ['passthrough']} + +## +# @VmTpmDeviceModel: +# +# An enumeration of VM tpm device modes. +# +# @tpm-tis: TODO +# +# Since: 4.10.3 +## +{'enum': 'VmTpmDeviceModel', 'data': ['tpm-tis']} + +## +# @VmTpmDeviceSpecParams: +# +# Additional VM tpm device parameters. +# +# @type: #optional Protocol used by tpmdevice (defaults to @passthrough) +# +# @model: #optional Model of TPM device (defaults to @tpm-tis) +# +# @path: #optional Path to hosts device TPM (defaults to /dev/tpm0) +# +# Since: 4.10.3 +## +{'type': 'VmTpmDeviceSpecParams', + 'data': {'*model': 'VmTpmDeviceModel', + '*path': 'str', + '*type': 'VmTpmDeviceType'}} + +## +# @VmTpmDevice: +# +# Properties of a VM tpm device. +# +# @deviceType: The device type (always @tpm) +# +# @specParams: #optional Additional device parameters +# +# Since: 4.10.3 +## +{'type': 'VmTpmDevice', + 'data': {'deviceType': 'VmDeviceType', + '*specParams': 'VmTpmDeviceSpecParams'}} + +## # @VmSmartcardDeviceProtocol: # # An enumeration of VM smartcard device protocols.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP]vdsm: add support for TPM device passthrough ......................................................................
Patch Set 1: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/5116/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/4312/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/5190/ : FAILURE
Saggi Mizrahi has posted comments on this change.
Change subject: [WIP]vdsm: add support for TPM device passthrough ......................................................................
Patch Set 1:
One of SaggiMizrahi's automated scripts discovered this patch might require his approval. Please wait until he had time to check it out.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: add support for TPM device passthrough ......................................................................
Patch Set 2: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/6306/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/7196/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/7085/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: add support for TPM device passthrough ......................................................................
Patch Set 3:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/6309/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/7199/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/7088/ : SUCCESS
Francesco Romani has posted comments on this change.
Change subject: vdsm: add support for TPM device passthrough ......................................................................
Patch Set 3: Code-Review-1
(2 comments)
-1 for the trailing spaces
http://gerrit.ovirt.org/#/c/20649/3/vdsm/vm.py File vdsm/vm.py:
Line 1823: </backend> Line 1824: </tpm> Line 1825: """ Line 1826: tpm = self.createXmlElem(self.device, None) Line 1827: tpm.setAttrs(**{'model': self.specParams['model']}) why do we need here the splat operator (**{}) and not a plain simple parameter passing like
model=self.specParams['model']
? Line 1828: backend = tpm.appendChildWithArgs('backend', Line 1829: type=self.specParams['mode']) Line 1830: backend.appendChildWithArgs('device', Line 1831: path=self.specParams['path'])
http://gerrit.ovirt.org/#/c/20649/3/vdsm_api/vdsmapi-schema.json File vdsm_api/vdsmapi-schema.json:
Line 2659: ## Line 2660: {'type': 'VmTpmDeviceSpecParams', Line 2661: 'data': {'model': 'VmTpmDeviceModel', Line 2662: 'path': 'str', Line 2663: 'mode': 'VmTpmDeviceMode'}} trailing spaces Line 2664: Line 2665: ## Line 2666: # @VmTpmDevice: Line 2667: #
Martin Polednik has posted comments on this change.
Change subject: vdsm: add support for TPM device passthrough ......................................................................
Patch Set 4: Verified+1
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: add support for TPM device passthrough ......................................................................
Patch Set 4:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/6315/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/7205/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/7098/ : SUCCESS
Francesco Romani has posted comments on this change.
Change subject: vdsm: add support for TPM device passthrough ......................................................................
Patch Set 4: Code-Review+1
(1 comment)
http://gerrit.ovirt.org/#/c/20649/4/vdsm_api/vdsmapi-schema.json File vdsm_api/vdsmapi-schema.json:
Line 2678: {'type': 'VmTpmDevice', Line 2679: 'data': {'deviceType': 'VmDeviceType', 'device': 'VmTpmDeviceType', Line 2680: 'specParams': 'VmTpmDeviceSpecParams'}} Line 2681: Line 2682: ## This seems a loto of stuff for such a simple change but maybe I'm missing something... I'm ok with this in the end. Line 2683: # @VmSmartcardDeviceProtocol: Line 2684: # Line 2685: # An enumeration of VM smartcard device protocols. Line 2686: #
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm: add support for TPM device passthrough ......................................................................
Patch Set 4: Code-Review+2
Dan Kenigsberg has submitted this change and it was merged.
Change subject: vdsm: add support for TPM device passthrough ......................................................................
vdsm: add support for TPM device passthrough
Libvirt has basic support for TPM passthrough, which allows VM to be given access directly to host's TPM module.
Engine constraints: vm with assigned TPM cannot be allowed to migrate, host cannot pass single TPM to multiple VMs using passthrough protocol (currently only supported protocol http://wiki.qemu.org/Features/TPM)
Change-Id: I53a77a0977d367d1066e85590dd35b18bb5fa32a Signed-off-by: Martin Polednik mpoledni@redhat.com Reviewed-on: http://gerrit.ovirt.org/20649 Reviewed-by: Francesco Romani fromani@redhat.com Reviewed-by: Dan Kenigsberg danken@redhat.com --- M tests/vmTests.py M vdsm/vm.py M vdsm_api/vdsmapi-schema.json 3 files changed, 107 insertions(+), 1 deletion(-)
Approvals: Dan Kenigsberg: Looks good to me, approved Francesco Romani: Looks good to me, but someone else must approve Martin Polednik: Verified
vdsm-patches@lists.fedorahosted.org