Index: root/xen-unstable.hg/tools/python/xen/xend/image.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/xend/image.py +++ root/xen-unstable.hg/tools/python/xen/xend/image.py @@ -27,7 +27,7 @@ from xen.xend.XendError import VmError from xen.xend.XendLogging import log from xen.xend.server.netif import randomMAC from xen.xend.xenstore.xswatch import xswatch - +from xen.xend.server.tpmif import getInstanceFromDir xc = xen.lowlevel.xc.xc() @@ -303,8 +303,10 @@ class HVMImageHandler(ImageHandler): ret.append("-net") ret.append("tap,vlan=%d,bridge=%s" % (nics, bridge)) if name == 'vtpm': - instance = sxp.child_value(info, 'pref_instance') - ret.append("-instance") + instance = xen.xend.server.tpmif.getInstanceFromDir(self.vm.getName()) + if instance == 0: + instance = -1 + ret.append("-vtpm_instance") ret.append("%s" % instance) return ret Index: root/xen-unstable.hg/tools/python/xen/xend/server/tpmif.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/xend/server/tpmif.py +++ root/xen-unstable.hg/tools/python/xen/xend/server/tpmif.py @@ -25,7 +25,7 @@ from xen.xend import sxp from xen.xend.XendLogging import log from xen.xend.XendError import XendError from xen.xend import XendRoot -from xen.xend.XendDomainInfo import DEV_MIGRATE_TEST +import xen.xend.XendDomainInfo from xen.xend.server.DevController import DevController @@ -35,6 +35,18 @@ import re xroot = XendRoot.instance() +def getInstanceFromDir(domName): + fd = os.popen("cd /etc/xen/scripts/ ;" + "source vtpm-common.sh ;" + "echo ; echo \"INSTANCE = \" $(vtpmdb_find_instance %s)" % + (domName), 'r') + for line in fd.readlines(): + inst = re.search('INSTANCE ', line) + if inst: + lst = re.split("=",line) + return int(lst[1]) + return -1 + class TPMifController(DevController): """TPM interface controller. Handles all TPM devices for a domain. @@ -52,7 +64,7 @@ class TPMifController(DevController): if inst == -1: inst = int(sxp.child_value(config, 'instance' , '0')) - log.info("The domain has a TPM with instance %d and devid %d.", + log.info("The domain has a TPM with preferred instance %d and devid %d.", inst, devid) back = { 'pref_instance' : "%i" % inst, 'resume' : "%s" % (self.vm.getResume()) } Index: root/xen-unstable.hg/tools/python/xen/xm/create.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/xm/create.py +++ root/xen-unstable.hg/tools/python/xen/xm/create.py @@ -637,7 +637,7 @@ def configure_hvm(config_image, vals): args = [ 'device_model', 'pae', 'vcpus', 'boot', 'fda', 'fdb', 'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw', 'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'sdl', 'display', - 'acpi', 'apic', 'xauthority', 'usb', 'usbdevice' ] + 'acpi', 'apic', 'xauthority', 'usb', 'usbdevice', 'vtpm' ] for a in args: if (vals.__dict__[a]): config_image.append([a, vals.__dict__[a]])