Index: lib/libvmmapi/vmmapi.h =================================================================== --- lib/libvmmapi/vmmapi.h +++ lib/libvmmapi/vmmapi.h @@ -33,6 +33,8 @@ #include #include +#include +#include #include #include @@ -76,6 +78,8 @@ VM_PCIROM, }; +__BEGIN_DECLS + /* * Get the length and name of the memory segment identified by 'segid'. * Note that system memory segments are identified with a nul name. @@ -117,6 +121,7 @@ int vm_create(const char *name); int vm_get_device_fd(struct vmctx *ctx); struct vmctx *vm_open(const char *name); +void vm_close(struct vmctx *ctx); void vm_destroy(struct vmctx *ctx); int vm_parse_memsize(const char *optarg, size_t *memsize); int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s); @@ -263,4 +268,6 @@ int vm_snapshot_req(struct vm_snapshot_meta *meta); int vm_restore_time(struct vmctx *ctx); +__END_DECLS + #endif /* _VMMAPI_H_ */ Index: lib/libvmmapi/vmmapi.c =================================================================== --- lib/libvmmapi/vmmapi.c +++ lib/libvmmapi/vmmapi.c @@ -140,6 +140,15 @@ return (NULL); } +void +vm_close(struct vmctx *vm) +{ + assert(vm != NULL); + + close(vm->fd); + free(vm); +} + void vm_destroy(struct vmctx *vm) {