summaryrefslogtreecommitdiffstats
path: root/lib/libvmmapi/vmmapi.c
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2012-10-12 17:39:28 +0000
committerneel <neel@FreeBSD.org>2012-10-12 17:39:28 +0000
commita62f9562ca8f5ed0f5099962cb864c87a2a2865c (patch)
tree8c0a42d0cf44ed4856c3e677b3a0e2066ed430c8 /lib/libvmmapi/vmmapi.c
parent97c20149fa1e35f2bcc34d8b7058467aa8d51d80 (diff)
downloadFreeBSD-src-a62f9562ca8f5ed0f5099962cb864c87a2a2865c.zip
FreeBSD-src-a62f9562ca8f5ed0f5099962cb864c87a2a2865c.tar.gz
Add an api to map a vm capability type into a string to be used for display
purposes.
Diffstat (limited to 'lib/libvmmapi/vmmapi.c')
-rw-r--r--lib/libvmmapi/vmmapi.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index e083fde..fdbbbcb 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -370,22 +370,22 @@ vm_inject_nmi(struct vmctx *ctx, int vcpu)
return (ioctl(ctx->fd, VM_INJECT_NMI, &vmnmi));
}
+static struct {
+ const char *name;
+ int type;
+} capstrmap[] = {
+ { "hlt_exit", VM_CAP_HALT_EXIT },
+ { "mtrap_exit", VM_CAP_MTRAP_EXIT },
+ { "pause_exit", VM_CAP_PAUSE_EXIT },
+ { "unrestricted_guest", VM_CAP_UNRESTRICTED_GUEST },
+ { 0 }
+};
+
int
vm_capability_name2type(const char *capname)
{
int i;
- static struct {
- const char *name;
- int type;
- } capstrmap[] = {
- { "hlt_exit", VM_CAP_HALT_EXIT },
- { "mtrap_exit", VM_CAP_MTRAP_EXIT },
- { "pause_exit", VM_CAP_PAUSE_EXIT },
- { "unrestricted_guest", VM_CAP_UNRESTRICTED_GUEST },
- { 0 }
- };
-
for (i = 0; capstrmap[i].name != NULL && capname != NULL; i++) {
if (strcmp(capstrmap[i].name, capname) == 0)
return (capstrmap[i].type);
@@ -394,6 +394,19 @@ vm_capability_name2type(const char *capname)
return (-1);
}
+const char *
+vm_capability_type2name(int type)
+{
+ int i;
+
+ for (i = 0; capstrmap[i].name != NULL; i++) {
+ if (capstrmap[i].type == type)
+ return (capstrmap[i].name);
+ }
+
+ return (NULL);
+}
+
int
vm_get_capability(struct vmctx *ctx, int vcpu, enum vm_cap_type cap,
int *retval)
OpenPOWER on IntegriCloud