backend listener not required
PATCH 1/1 backend listener not required
Hello,
This simple patch tests if the VTPM backend is present or not (if the device file /dev/vtpm exists) and launch the backend listener only if it is present.
So if you only run HVM domains you don't need to build and load the VTPM backend (the module tpmbk). Of course, without the backend you won't be able to use VTPM inside a pv DomU.
Cheers,
Colin Didier
Signature · 1 line
Colin Didier http://cybione.org/~cdidier/
tools/vtpm_manager/manager/vtpmd.c +28 -11
@@ -66,6 +66,9 @@#define VTPM_TYPE_PVM_STRING "pvm"#define VTPM_TYPE_HVM_STRING "hvm" +// the backend is running or not? +static int be_exists; +struct vtpm_thread_params_s {vtpm_ipc_handle_t *tx_ipc_h;vtpm_ipc_handle_t *rx_ipc_h;
@@ -159,9 +162,15 @@*/ memset (&dmi_res->DMI_measurement,0xcc ,sizeof (TPM_DIGEST )); -if (vm_type ==VTPM_TYPE_PVM ) - vm_type_string = (BYTE *)&VTPM_TYPE_PVM_STRING ; -else +if (vm_type ==VTPM_TYPE_PVM ) { +if (be_exists) + vm_type_string = (BYTE *)&VTPM_TYPE_PVM_STRING ; +else { +vtpmlogerror (VTPM_LOG_VTPM ,"The backend is not running!\n" ); + status =TPM_IOERROR ; + goto abort_egress; + } + }else vm_type_string = (BYTE *)&VTPM_TYPE_HVM_STRING ;// Launch DMI
@@ -284,6 +293,7 @@// ------------------- Set up file ipc structures ---------- #ifdef DUMMY_BACKEND + be_exists = TRUE;if ( (vtpm_ipc_init (&tx_dummy_ipc_h,VTPM_DUMMY_TX_BE_FNAME ,O_RDWR , TRUE) !=0 ) || (vtpm_ipc_init (&rx_dummy_ipc_h,VTPM_DUMMY_RX_BE_FNAME ,O_RDWR , TRUE) !=0 ) ) {
@@ -294,10 +304,14 @@ tx_be_ipc_h = &tx_dummy_ipc_h; rx_be_ipc_h = &rx_dummy_ipc_h;#else -vtpm_ipc_init (&real_be_ipc_h,VTPM_BE_FNAME ,O_RDWR , FALSE); + be_exists =access (VTPM_BE_FNAME ,F_OK ) ==0 ? TRUE : FALSE; +if (be_exists) { +vtpm_ipc_init (&real_be_ipc_h,VTPM_BE_FNAME ,O_RDWR , FALSE); - tx_be_ipc_h = &real_be_ipc_h; - rx_be_ipc_h = &real_be_ipc_h; + tx_be_ipc_h = &real_be_ipc_h; + rx_be_ipc_h = &real_be_ipc_h; + }else +vtpmloginfo (VTPM_LOG_VTPM ,"There is no " VTPM_BE_FNAME ", so the backend listener is disabled (pv guest won't have a VTPM).\n" );#endif if ( (vtpm_ipc_init(&rx_tpm_ipc_h, VTPM_RX_TPM_FNAME, O_RDONLY, TRUE) != 0) ||
@@ -341,10 +355,12 @@vtpm_lock_init (); vtpm_globals->master_pid =pthread_self (); - -if (pthread_create (&be_thread,NULL , vtpm_manager_thread, &be_thread_params) !=0 ) { -vtpmlogerror (VTPM_LOG_VTPM ,"Failed to launch BE Thread.\n" ); -exit (-1 ); + +if (be_exists) { +if (pthread_create (&be_thread,NULL , vtpm_manager_thread, &be_thread_params) !=0 ) { +vtpmlogerror (VTPM_LOG_VTPM ,"Failed to launch BE Thread.\n" ); +exit (-1 ); + } }if (pthread_create (&dmi_thread,NULL , vtpm_manager_thread, &dmi_thread_params) !=0 ) {
@@ -359,7 +375,8 @@ }//Join the other threads until exit time. -pthread_join (be_thread,NULL ); +if (be_exists) +pthread_join (be_thread,NULL );pthread_join (dmi_thread,NULL );pthread_join (hp_thread,NULL );
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel