Add low latency per-cpu power management
Refactor low latency compute per-cpu power management out of stx-nova into libvirt qemu hook Story: 2004610 Task: 28508 Change-Id: I80432b36c4e71d957db51f1742ef87fb519acce2 Signed-off-by: Daniel Chavolla <daniel.chavolla@windriver.com>
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
COPY_LIST="$PKG_BASE/files/* $CGCS_BASE/downloads/swtpm-0.1.0-253eac5.tar.gz"
|
||||
TIS_PATCH_VER=0
|
||||
TIS_PATCH_VER=1
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
%define name swtpm
|
||||
%define version 0.1.0
|
||||
#WRS
|
||||
#STX
|
||||
#%define release 1
|
||||
%define release 2%{?_tis_dist}.%{tis_patch_ver}
|
||||
|
||||
# Valid crypto subsystems are 'freebl' and 'openssl'
|
||||
#WRS
|
||||
#STX
|
||||
#%if "%{crypto_subsystem}" == ""
|
||||
%define crypto_subsystem openssl
|
||||
#%endif
|
||||
@@ -15,7 +15,7 @@
|
||||
Summary: TPM Emulator
|
||||
Name: %{name}
|
||||
Version: %{version}
|
||||
#WRS
|
||||
#STX
|
||||
#Release: %{release}.dev2%{?dist}
|
||||
Release: %{release}
|
||||
License: BSD
|
||||
@@ -23,9 +23,8 @@ Group: Applications/Emulators
|
||||
Source: %{name}-%{version}-253eac5.tar.gz
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||
|
||||
#WRS
|
||||
Source1: qemu
|
||||
Source2: setup_vtpm
|
||||
#STX
|
||||
Source1: setup_vtpm
|
||||
|
||||
|
||||
# due to gnutls backlevel API:
|
||||
@@ -49,11 +48,11 @@ BuildRequires: libtasn1-tools
|
||||
BuildRequires: kernel-modules-extra
|
||||
%endif
|
||||
|
||||
#WRS
|
||||
#STX
|
||||
BuildRequires: openssl-devel
|
||||
Requires: openssl
|
||||
|
||||
#WRS
|
||||
#STX
|
||||
Requires: seabios-bin >= 1.10.2-3
|
||||
|
||||
Requires: fuse expect libtpms >= 0.6.0
|
||||
@@ -94,7 +93,7 @@ Summary: Tools for the TPM emulator
|
||||
License: BSD
|
||||
Group: Applications/Emulators
|
||||
Requires: swtpm fuse
|
||||
#WRS
|
||||
#STX
|
||||
#Requires: trousers >= 0.3.9 tpm-tools >= 1.3.8-6 expect bash net-tools gnutls-utils
|
||||
Requires: trousers >= 0.3.9 expect bash net-tools gnutls-utils
|
||||
|
||||
@@ -106,9 +105,8 @@ Tools for the TPM emulator from the swtpm package
|
||||
%attr( 755, root, root) %{_bindir}/swtpm
|
||||
%{_mandir}/man8/swtpm.8*
|
||||
|
||||
#WRS
|
||||
#STX
|
||||
/etc/libvirt/setup_vtpm
|
||||
/etc/libvirt/hooks/qemu
|
||||
|
||||
|
||||
%files cuse
|
||||
@@ -158,7 +156,7 @@ Tools for the TPM emulator from the swtpm package
|
||||
|
||||
%build
|
||||
|
||||
#WRS
|
||||
#STX
|
||||
./bootstrap.sh
|
||||
%configure \
|
||||
--prefix=/usr \
|
||||
@@ -180,13 +178,12 @@ make %{?_smp_mflags} check
|
||||
make %{?_smp_mflags} install DESTDIR=${RPM_BUILD_ROOT}
|
||||
rm -f ${RPM_BUILD_ROOT}%{_libdir}/*.a ${RPM_BUILD_ROOT}%{_libdir}/*.la
|
||||
|
||||
#WRS
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/libvirt/hooks
|
||||
#STX
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/libvirt
|
||||
|
||||
install -m 0500 %{SOURCE1} $RPM_BUILD_ROOT/etc/libvirt/hooks/qemu
|
||||
install -m 0500 %{SOURCE2} $RPM_BUILD_ROOT/etc/libvirt/setup_vtpm
|
||||
install -m 0500 %{SOURCE1} $RPM_BUILD_ROOT/etc/libvirt/setup_vtpm
|
||||
|
||||
# WRS: Don't set (or remove on uninstall): SELINUX Policy and contexts
|
||||
# STX: Don't set (or remove on uninstall): SELINUX Policy and contexts
|
||||
#%post cuse
|
||||
#if [ -n "$(type -p semodule)" ]; then
|
||||
# for pp in /usr/share/swtpm/*.pp ; do
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2017 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# This script logs to user.log
|
||||
#
|
||||
# An instance with vTPM enable will have a QEMU config section in its XML file.
|
||||
# e.g.
|
||||
# <qemu:commandline xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">
|
||||
# <qemu:arg value="-device"/>
|
||||
# <qemu:arg value="tpm-tis,tpmdev=tpm-tpm0,id=tpm0"/>
|
||||
# <qemu:arg value="-bios"/>
|
||||
# <qemu:arg value="/guest/bios.bin"/>
|
||||
# <qemu:arg value="-tpmdev"/>
|
||||
# <qemu:arg value="cuse-tpm,id=tpm-tpm0,path=/dev/vtpm-instance-000001ad,cancel-path=/dev/null"/>
|
||||
# </qemu:commandline>
|
||||
#
|
||||
# For more information see the vTPM HLD in /folk/cgts/docs/security/
|
||||
#
|
||||
# The script is called with the following parameters
|
||||
# e.g. /etc/libvirt/hooks/qemu <guest_name> <operation>
|
||||
#
|
||||
|
||||
# Save the instance's XML. The guest qemu hook scrips are given the full XML description
|
||||
# on their stdin.
|
||||
XML_DATA=$(/bin/cat)
|
||||
|
||||
GUEST_NAME=$1
|
||||
|
||||
shift
|
||||
OPERATION=$*
|
||||
|
||||
logger -p info -t $0 "hook qemu file guest $GUEST_NAME with operation $OPERATION"
|
||||
|
||||
VTPM_OPER=""
|
||||
|
||||
if [ "$OPERATION" == "prepare begin -" ]; then
|
||||
|
||||
# Get the instance's uuid
|
||||
UUID=$(echo $XML_DATA | grep -oP '(?<=<uuid>).*?(?=</uuid>)')
|
||||
if [ -z "$UUID" ]; then
|
||||
# This should not happen
|
||||
logger -p err -t $0 "Failed to retrieve uuid for guest $GUEST_NAME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Grab the qemu line "<qemu:arg value='cuse-tpm ... "
|
||||
LINE=$(echo $XML_DATA | grep -oP "(?<=<qemu:arg value=')[^<]+" | grep cuse-tpm )
|
||||
if [ -z "$LINE" ]; then
|
||||
# We do not setup a vTPM but we need to check if this Guest has previous vTPM data
|
||||
# and if so delete it. This can happen when we Resize a Guest with a flavor that
|
||||
# does not contain the vTPM extra spec xml data.
|
||||
VTPM_OPER="clear"
|
||||
else
|
||||
# Extract the device name
|
||||
VTPM=$(echo $LINE | tail -n1 | grep -Po '(?<=,path=)[^ ]+' | cut -d ',' -f1)
|
||||
if [ -z "$VTPM" ]; then
|
||||
# This instance does not require a vTPM. See comment above regarding "clear".
|
||||
VTPM_OPER="clear"
|
||||
else
|
||||
logger -p info -t $0 "Found vTPM configuration for guest $GUEST_NAME"
|
||||
VTPM_OPER="setup"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Setup the vTPM device
|
||||
/etc/libvirt/setup_vtpm "$VTPM_OPER" "/dev/vtpm-$GUEST_NAME" "$UUID" 2>&1 > /dev/null
|
||||
rc=$?
|
||||
if [[ $rc != 0 ]]; then
|
||||
logger -p err -t $0 "setup_vtpm failed with return value $rc for device $VTPM and guest $UUID"
|
||||
# Do not return error if we were just doing a clear
|
||||
if [ "$VTPM_OPER" != "clear" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user