mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
Update vtpm driver following the recent changes to the
xenbus driver and its semantics. Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
This commit is contained in:
1 parent
e426054787
commit
b588d4451a
15 files changed
+659
-373
No files matched your search
@@ -293,7 +293,7 @@ class VmxImageHandler(ImageHandler):
|
||||
ret.append("-bridge")
|
||||
ret.append("%s" % bridge)
|
||||
if name == 'vtpm':
|
||||
instance = sxp.child_value(info, 'instance')
|
||||
instance = sxp.child_value(info, 'pref_instance')
|
||||
ret.append("-instance")
|
||||
ret.append("%s" % instance)
|
||||
return ret
|
||||
|
||||
@@ -38,10 +38,10 @@ class TPMifController(DevController):
|
||||
def getDeviceDetails(self, config):
|
||||
"""@see DevController.getDeviceDetails"""
|
||||
|
||||
devid = int(sxp.child_value(config, 'instance', '0'))
|
||||
devid = int(sxp.child_value(config, 'pref_instance', '0'))
|
||||
log.info("The domain has a TPM with instance %d." % devid)
|
||||
|
||||
back = { 'instance' : "%i" % devid }
|
||||
back = { 'pref_instance' : "%i" % devid }
|
||||
front = { 'handle' : "%i" % devid }
|
||||
|
||||
return (devid, back, front)
|
||||
|
||||
@@ -220,11 +220,9 @@ gopts.var('netif', val='no|yes',
|
||||
fn=set_bool, default=0,
|
||||
use="Make the domain a network interface backend.")
|
||||
|
||||
gopts.var('tpmif', val='frontend=DOM',
|
||||
fn=append_value, default=[],
|
||||
use="""Make the domain a TPM interface backend. If frontend is given,
|
||||
the frontend in that domain is connected to this backend (not
|
||||
completely implemented, yet)""")
|
||||
gopts.var('tpmif', val='no|yes',
|
||||
fn=append_value, default=0,
|
||||
use="Make the domain a TPM interface backend.")
|
||||
|
||||
gopts.var('disk', val='phy:DEV,VDEV,MODE[,DOM]',
|
||||
fn=append_value, default=[],
|
||||
@@ -273,9 +271,13 @@ gopts.var('vif', val="type=TYPE,mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,b
|
||||
|
||||
gopts.var('vtpm', val="instance=INSTANCE,backend=DOM",
|
||||
fn=append_value, default=[],
|
||||
use="""Add a tpm interface. On the backend side us the the given
|
||||
instance as virtual TPM instance. Use the backend in the given
|
||||
domain.""")
|
||||
use="""Add a TPM interface. On the backend side use the given
|
||||
instance as virtual TPM instance. The given number is merely the
|
||||
preferred instance number. The hotplug script will determine
|
||||
which instance number will actually be assigned to the domain.
|
||||
The associtation between virtual machine and the TPM instance
|
||||
number can be found in /etc/xen/vtpm.db. Use the backend in the
|
||||
given domain.""")
|
||||
|
||||
gopts.var('nics', val="NUM",
|
||||
fn=set_int, default=1,
|
||||
@@ -465,34 +467,20 @@ def configure_vtpm(config_devs, vals):
|
||||
if instance == "VTPMD":
|
||||
instance = "0"
|
||||
else:
|
||||
try:
|
||||
if int(instance) == 0:
|
||||
err('VM config error: vTPM instance must not be 0.')
|
||||
except ValueError:
|
||||
err('Vm config error: could not parse instance number.')
|
||||
if instance != None:
|
||||
try:
|
||||
if int(instance) == 0:
|
||||
err('VM config error: vTPM instance must not be 0.')
|
||||
except ValueError:
|
||||
err('Vm config error: could not parse instance number.')
|
||||
backend = d.get('backend')
|
||||
config_vtpm = ['vtpm']
|
||||
if instance:
|
||||
config_vtpm.append(['instance', instance])
|
||||
config_vtpm.append(['pref_instance', instance])
|
||||
if backend:
|
||||
config_vtpm.append(['backend', backend])
|
||||
config_devs.append(['device', config_vtpm])
|
||||
|
||||
def configure_tpmif(config_devs, vals):
|
||||
"""Create the config for virtual TPM interfaces.
|
||||
"""
|
||||
tpmif = vals.tpmif
|
||||
tpmif_n = 1
|
||||
for idx in range(0, tpmif_n):
|
||||
if idx < len(tpmif):
|
||||
d = tpmif[idx]
|
||||
frontend = d.get('frontend')
|
||||
config_tpmif = ['tpmif']
|
||||
if frontend:
|
||||
config_tpmif.append(['frontend', frontend])
|
||||
config_devs.append(['device', config_tpmif])
|
||||
|
||||
|
||||
def configure_vifs(config_devs, vals):
|
||||
"""Create the config for virtual network interfaces.
|
||||
"""
|
||||
@@ -685,22 +673,6 @@ def preprocess_vtpm(vals):
|
||||
vtpms.append(d)
|
||||
vals.vtpm = vtpms
|
||||
|
||||
def preprocess_tpmif(vals):
|
||||
if not vals.tpmif: return
|
||||
tpmifs = []
|
||||
for tpmif in vals.tpmif:
|
||||
d = {}
|
||||
a = tpmif.split(',')
|
||||
for b in a:
|
||||
(k, v) = b.strip().split('=', 1)
|
||||
k = k.strip()
|
||||
v = v.strip()
|
||||
if k not in ['frontend']:
|
||||
err('Invalid tpmif specifier: ' + vtpm)
|
||||
d[k] = v
|
||||
tpmifs.append(d)
|
||||
vals.tpmif = tpmifs
|
||||
|
||||
def preprocess_ip(vals):
|
||||
if vals.ip or vals.dhcp != 'off':
|
||||
dummy_nfs_server = '1.2.3.4'
|
||||
@@ -791,7 +763,6 @@ def preprocess(vals):
|
||||
preprocess_nfs(vals)
|
||||
preprocess_vnc(vals)
|
||||
preprocess_vtpm(vals)
|
||||
preprocess_tpmif(vals)
|
||||
|
||||
def make_domain(opts, config):
|
||||
"""Create, build and start a domain.
|
||||
|
||||