*********
PV image means the guest OS should be modified in XEN. The following are the steps of how to create a PV image which support vtpm for XEN. BTW, you should have following prerequisites if you want to use vtpm feature.
Prerequisites:
--------------
- You must have an x86 machine with a TPM on the motherboard.
- Compile and install the Xen tree as usual; be sure that the vTPM domains are enabled when you run configure.
- Compiling the LINUX dom0 kernel without TPM driver or blacklisting the module
--------------
Then I will use the easiest type of guest OS (ubuntu 12.10) to make as an example :
Step 1 create file system
1. Create an empty file to hold the PV image.
#dd if=/dev/zero of=ubt-pv.img bs=1 count=1 seek=10G
2. Formatting the newly created file.
you may format the file to be other file system types.
3.
Mount the file as a loop device
#mount –o loop ubt-pv.img
/mnt/
4. We can use debootstrap command to generate system files.
# debootstrap wheezy /mnt/ http://http.debian.net/debian/
or you can create a clean operation system on your host ,then copy the "/" contents to /mnt
Step 2 Build PV kernel
The domU kernel used by domains with vtpms must include the xen-tpmfront.ko driver. It can be built directly into the kernel or as a module. And the kernel patches you can find at
git clone https://github.com/trust2virt/domuKernel.git
1. #make menuconfig
processor type and feathers –> pavavirtualized guest support
device drivers ---> network device support---> xen network device frontend driver -- built-in
device drivers ---> character devices ---> TPM Hardware Support ----> XEN TPM interface --- built-in
check the .config, make sure the following CONFIGs are set to y:
CONFIG_XEN
CONFIG_PARAVIRT
CONFIG_PARAVIRT_GUEST
CONFIG_XEN_BLKDEV_FRONTEND
CONFIG_XEN_NETDEV_FRONTEND
CONFIG_HVC_XEN
CONFIG_HVC_XEN_FRONTEND
CONFIG_TCG_TPM
CONFIG_TCG_XEN
2. build
#make
3. install
#make modules_install INSTALL_MOD_PATH=/mnt/
#make install INSTALL_PATH=/mnt/boot
4. create grub.cfg file
#mkdir /mnt/boot/grub
#cd /mnt/boot/grub
#touch grub.cfg
file content as below:
default 0
timeout 5
title ubt-pv
root (hd0)
kernel /boot/vmlinuz-version root=/dev/xvda1 ro
initrd /boot/initrd-version.img
5. #umount /mnt
then the ubu-pv.img is DONE!
6. create PV configure file
kernel="/usr/local/lib/xen/boot/pv-grub-x86_64.gz"
extra="(hd0)/boot/grub/grub.conf"
vcpus = 1
memory = 1024
name = "ubtPV-2"
vif = [ 'bridge=xenbr0' ]
disk = [ 'file:/opt/pv-image/ubtpv.img,xvda1,w']
vtpm=["backend=vtpm2"] // vtpm2 is the backend device of PV
7. #xl create
# xl list
DONE!