PATCH [base vtpm and libxl patches 6/6] add vtpm support to libxl
Add support for vtpm=["VTPM_SPEC",...] to domain config files. Also add commands vtpm-attach, vtpm-list, and vtpm-detach.
Signed off by Matthew Fioravante [email protected]
---
Changes since previous:
* Rebased to latest xen
* Updated xl.cfg and xl manpages
docs/man/xl.cfg.pod.5 +29 -0
@@ -298,6 +298,35 @@ Specifies the networking provision (both emulated network adapters, and Xen virtual interfaces) to provided to the guest. See F<docs/misc/xl-network-configuration.markdown>. +=item B<vtpm=[ "VTPM_SPEC_STRING", "VTPM_SPEC_STRING", ...]> + +Specifies the virtual trusted platform module to be +provided to the guest. Please see F<docs/misc/vtpm.txt> +for more details. + +Each B<VTPM_SPEC_STRING> is a comma-separated list of C<KEY=VALUE> +settings, from the following list: + +=over 4 + +=item C<backend=DOMAIN> + +Specify the backend domain name of id. This value must be +set if you are using the vtpm domain model. If this domain +is a guest, the backend should be set to the vtpm domain name. +If this domain is a vtpm, the backend should be set to the +vtpm manager domain name. The default value is domain 0, +which should be used if you are running the vtpm process model. + +=item C<uuid=UUID> + +Specify the uuid of this vtpm device. The uuid is used to uniquely +identify the vtpm device. You can create one using the uuidgen +program on unix systems. If left unspecified, a new uuid +will be randomly generated everytime the domain boots. + +=back + =item B<vfb=[ "VFB_SPEC_STRING", "VFB_SPEC_STRING", ...]> Specifies the paravirtual framebuffer devices which should be supplied
docs/man/xl.pod.1 +25 -0
@@ -1101,6 +1101,31 @@ List virtual network interfaces for a domain. =back +=head2 VTPM DEVICES + +=over 4 + +=item B<vtpm-attach> I<domain-id> I<vtpm-device> + +Creates a new vtpm device in the domain specified by I<domain-id>. +I<vtpm-device> describes the device to attach, using the same format as the +B<vtpm> string in the domain config file. See L<xl.cfg> for +more information. + +=item B<vtpm-detach> I<domain-id> I<devid|uuid> + +Removes the vtpm device from the domain specified by I<domain-id>. +I<devid> is the numeric device id given to the virtual trusted +platform module device. You will need to run B<xl vtpm-list> to determine that number. +Alternatively the I<uuid> of the vtpm can be used to +select the virtual device to detach. + +=item B<vtpm-list> I<domain-id> + +List virtual trusted platform modules for a domain. + +=back + =head1 PCI PASS-THROUGH =over 4
tools/libxl/libxl.c +247 -0
265 lines not on this page · raw message
tools/libxl/libxl.h +19 -1
@@ -478,13 +478,14 @@ typedef struct {libxl_domain_create_info c_info;libxl_domain_build_info b_info; -int num_disks, num_nics, num_pcidevs, num_vfbs, num_vkbs; +int num_disks, num_nics, num_pcidevs, num_vfbs, num_vkbs, num_vtpms;libxl_device_disk *disks;libxl_device_nic *nics;libxl_device_pci *pcidevs;libxl_device_vfb *vfbs;libxl_device_vkb *vkbs; +libxl_device_vtpm *vtpms;libxl_action_on_shutdown on_poweroff;libxl_action_on_shutdown on_reboot;
@@ -745,6 +746,23 @@ libxl_device_nic *libxl_device_nic_list(libxl_ctx *ctx, uint32_t domid, int *numint libxl_device_nic_getinfo (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic,libxl_nicinfo *nicinfo); +/* Virtual TPMs */ +int libxl_device_vtpm_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vtpm *vtpm, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vtpm_remove(libxl_ctx *ctx, uint32_t domid, + libxl_device_vtpm *vtpm, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; +int libxl_device_vtpm_destroy(libxl_ctx *ctx, uint32_t domid, + libxl_device_vtpm *vtpm, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; + +libxl_device_vtpm *libxl_device_vtpm_list (libxl_ctx *ctx,uint32_t domid,int *num); +int libxl_device_vtpm_getinfo (libxl_ctx *ctx,uint32_t domid, +libxl_device_vtpm *vtpm,libxl_vtpminfo *vtpminfo); +/* Keyboard */ int libxl_device_vkb_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb,const libxl_asyncop_how *ao_how)
tools/libxl/libxl_create.c +39 -3
77 lines not on this page · raw message
tools/libxl/libxl_device.c +1 -0
@@ -515,6 +515,7 @@ void libxl__multidev_prepared(libxl__egc *egc, DEFINE_DEVICES_ADD(disk) DEFINE_DEVICES_ADD(nic) +DEFINE_DEVICES_ADD(vtpm)#undef DEFINE_DEVICES_ADD
tools/libxl/libxl_internal.h +9 -0
@@ -954,6 +954,7 @@ _hidden int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk); _hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,uint32_t domid); +_hidden int libxl__device_vtpm_setdefault(libxl__gc *gc, libxl_device_vtpm *vtpm); _hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb); _hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb); _hidden int libxl__device_pci_setdefault(libxl__gc *gc, libxl_device_pci *pci);
@@ -1975,6 +1976,10 @@ _hidden void libxl__device_nic_add(libxl__egc *egc, uint32_t domid, libxl_device_nic *nic, libxl__ao_device *aodev); +_hidden void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid, +libxl_device_vtpm *vtpm, +libxl__ao_device *aodev); +/* Internal function to connect a vkb device */ _hidden int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid,libxl_device_vkb *vkb);
@@ -2407,6 +2412,10 @@ _hidden void libxl__add_nics(libxl__egc *egc, libxl__ao *ao, uint32_t domid, libxl_domain_config *d_config, libxl__multidev *multidev); +_hidden void libxl__add_vtpms(libxl__egc *egc, libxl__ao *ao, uint32_t domid, +libxl_domain_config *d_config, +libxl__multidev *multidev); +/*----- device model creation -----*/ /* First layer; wraps libxl__spawn_spawn. */
tools/libxl/libxl_types.idl +18 -0
@@ -395,6 +395,12 @@ libxl_device_pci = Struct("device_pci", [ ("permissive", bool), ]) +libxl_device_vtpm = Struct("device_vtpm", [ + ("backend_domid", libxl_domid), + ("devid", libxl_devid), + ("uuid", libxl_uuid), +]) + libxl_diskinfo = Struct("diskinfo", [ ("backend", string), ("backend_id", uint32),
@@ -418,6 +424,18 @@ libxl_nicinfo = Struct("nicinfo", [ ("rref_rx", integer), ], dir=DIR_OUT) +libxl_vtpminfo = Struct("vtpminfo", [ + ("backend", string), + ("backend_id", uint32), + ("frontend", string), + ("frontend_id", uint32), + ("devid", libxl_devid), + ("state", integer), + ("evtch", integer), + ("rref", integer), + ("uuid", libxl_uuid), + ], dir=DIR_OUT) + libxl_vcpuinfo = Struct("vcpuinfo", [ ("vcpuid", uint32), ("cpu", uint32),
tools/libxl/libxl_types_internal.idl +1 -0
@@ -19,6 +19,7 @@ libxl__device_kind = Enumeration("device_kind", [ (5, "VFB"), (6, "VKBD"), (7, "CONSOLE"), + (8, "VTPM"), ]) libxl__console_backend = Enumeration("console_backend", [
tools/libxl/libxl_utils.c +29 -0
@@ -463,6 +463,35 @@ int libxl_pipe(libxl_ctx *ctx, int pipes[2])return 0 ; } +int libxl_uuid_to_device_vtpm (libxl_ctx *ctx,uint32_t domid, +libxl_uuid * uuid,libxl_device_vtpm *vtpm) +{ +libxl_device_vtpm *vtpms; +int nb, i; +int rc; + + vtpms =libxl_device_vtpm_list (ctx, domid, &nb); +if (!vtpms) +return ERROR_FAIL ; + +memset (vtpm,0 ,sizeof (libxl_device_vtpm)); + rc =1 ; +for (i =0 ; i < nb; ++i) { +if (!libxl_uuid_compare (uuid, &vtpms[i].uuid)) { + vtpm->backend_domid = vtpms[i].backend_domid; + vtpm->devid = vtpms[i].devid; +libxl_uuid_copy (&vtpm->uuid, &vtpms[i].uuid); + rc =0 ; +break ; + } + } + +for (i=0 ; i<nb; i++) +libxl_device_vtpm_dispose (&vtpms[i]); +free (vtpms); +return rc; +} +int libxl_mac_to_device_nic (libxl_ctx *ctx,uint32_t domid,const char *mac,libxl_device_nic *nic) {
tools/libxl/libxl_utils.h +5 -0
@@ -64,6 +64,11 @@ int libxl_devid_to_device_nic(libxl_ctx *ctx, uint32_t domid, int devid,int libxl_vdev_to_device_disk (libxl_ctx *ctx,uint32_t domid,const char *vdev,libxl_device_disk *disk); +int libxl_uuid_to_device_vtpm (libxl_ctx *ctx,uint32_t domid, +libxl_uuid *uuid,libxl_device_vtpm *vtpm); +int libxl_devid_to_device_vtpm (libxl_ctx *ctx,uint32_t domid, +int devid,libxl_device_vtpm *vtpm); +int libxl_bitmap_alloc (libxl_ctx *ctx,libxl_bitmap *bitmap,int n_bits);/* Allocated bimap is from malloc, libxl_bitmap_dispose() to be * called by the application when done. */
tools/libxl/xl.h +3 -0
@@ -79,6 +79,9 @@ int main_networkdetach(int argc, char **argv);int main_blockattach (int argc,char **argv);int main_blocklist (int argc,char **argv);int main_blockdetach (int argc,char **argv); +int main_vtpmattach (int argc,char **argv); +int main_vtpmlist (int argc,char **argv); +int main_vtpmdetach (int argc,char **argv);int main_uptime (int argc,char **argv);int main_tmem_list (int argc,char **argv);int main_tmem_freeze (int argc,char **argv);
tools/libxl/xl_cmdimpl.c +169 -3
202 lines not on this page · raw message
tools/libxl/xl_cmdtable.c +15 -0
@@ -338,6 +338,21 @@ struct cmd_spec cmd_table[] = {"Destroy a domain's virtual block device" ,"<Domain> <DevId>" , }, + { "vtpm-attach", + &main_vtpmattach,0 ,1 , +"Create a new virtual TPM device" , +"<Domain> [uuid=<uuid>] [backend=<BackDomain>]" , + }, + { "vtpm-list", + &main_vtpmlist,0 ,0 , +"List virtual TPM devices for a domain" , +"<Domain(s)>" , + }, + { "vtpm-detach", + &main_vtpmdetach,0 ,1 , +"Destroy a domain's virtual TPM device" , +"<Domain> <DevId|uuid>" , + }, { "uptime", &main_uptime,0 ,0 , "Print uptime for all/some domains",
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel