virt-install: Add --tpm backend.source support

E.g.
    virt-install \
    ... \
    --tpm model=tpm-tis,backend.type=emulator,backend.version=2.0,\
          backend.source.type=dir,backend.source.path=/some/dir

  It results in the following domain xml:
  <backend type="emulator" version="2.0">
    <source type="dir" path="/some/dir"/>
  </backend>

Signed-off-by: Lin Ma <lma@suse.de>
This commit is contained in:
Lin Ma 2024-11-13 15:09:28 +08:00 committed by Pavel Hrdina
parent 7e4f7ae3d8
commit fd48e0be57
4 changed files with 8 additions and 2 deletions

View File

@ -749,7 +749,9 @@
</active_pcr_banks>
</tpm>
<tpm model="tpm-tis">
<backend type="emulator" version="2.0" debug="3"/>
<backend type="emulator" version="2.0" debug="3">
<source type="dir" path="/some/dir"/>
</backend>
</tpm>
<graphics type="sdl" display=":3.4" xauth="/tmp/.Xauthority">
<ab>cd</ab>

View File

@ -796,7 +796,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
--tpm passthrough,model=tpm-crb,path=/dev/tpm0,backend.encryption.secret=11111111-2222-3333-4444-5555555555,backend.persistent_state=yes,active_pcr_banks.sha1=on,active_pcr_banks.sha256=yes,active_pcr_banks.sha384=yes,active_pcr_banks.sha512=yes,version=2.0
--tpm model=tpm-tis,backend.type=emulator,backend.version=2.0,backend.debug=3
--tpm model=tpm-tis,backend.type=emulator,backend.version=2.0,backend.debug=3,backend.source.type=dir,backend.source.path=/some/dir
--watchdog ib700,action=pause

View File

@ -4310,6 +4310,8 @@ class ParserTPM(VirtCLIParser):
cls.add_arg("backend.persistent_state",
"persistent_state", is_onoff=True)
cls.add_arg("backend.debug", "debug")
cls.add_arg("backend.source.type", "source_type")
cls.add_arg("backend.source.path", "source_path")
cls.add_arg("active_pcr_banks.sha1",
"active_pcr_banks.sha1", is_onoff=True)

View File

@ -42,6 +42,8 @@ class DeviceTpm(Device):
persistent_state = XMLProperty(
"./backend/@persistent_state", is_yesno=True)
debug = XMLProperty("./backend/@debug")
source_type = XMLProperty("./backend/source/@type")
source_path = XMLProperty("./backend/source/@path")
active_pcr_banks = XMLChildProperty(_ActivePCRBanks, is_single=True)