Add an api to map a vm capability type into a string to be used for display
purposes.
This commit is contained in:
parent
cdc5b9e7b1
commit
13f4cf6c6b
@ -370,22 +370,22 @@ vm_inject_nmi(struct vmctx *ctx, int vcpu)
|
|||||||
return (ioctl(ctx->fd, VM_INJECT_NMI, &vmnmi));
|
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
|
int
|
||||||
vm_capability_name2type(const char *capname)
|
vm_capability_name2type(const char *capname)
|
||||||
{
|
{
|
||||||
int i;
|
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++) {
|
for (i = 0; capstrmap[i].name != NULL && capname != NULL; i++) {
|
||||||
if (strcmp(capstrmap[i].name, capname) == 0)
|
if (strcmp(capstrmap[i].name, capname) == 0)
|
||||||
return (capstrmap[i].type);
|
return (capstrmap[i].type);
|
||||||
@ -394,6 +394,19 @@ vm_capability_name2type(const char *capname)
|
|||||||
return (-1);
|
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
|
int
|
||||||
vm_get_capability(struct vmctx *ctx, int vcpu, enum vm_cap_type cap,
|
vm_get_capability(struct vmctx *ctx, int vcpu, enum vm_cap_type cap,
|
||||||
int *retval)
|
int *retval)
|
||||||
|
@ -70,6 +70,7 @@ int vm_inject_event2(struct vmctx *ctx, int vcpu, enum vm_event_type type,
|
|||||||
int vm_lapic_irq(struct vmctx *ctx, int vcpu, int vector);
|
int vm_lapic_irq(struct vmctx *ctx, int vcpu, int vector);
|
||||||
int vm_inject_nmi(struct vmctx *ctx, int vcpu);
|
int vm_inject_nmi(struct vmctx *ctx, int vcpu);
|
||||||
int vm_capability_name2type(const char *capname);
|
int vm_capability_name2type(const char *capname);
|
||||||
|
const char *vm_capability_type2name(int type);
|
||||||
int vm_get_capability(struct vmctx *ctx, int vcpu, enum vm_cap_type cap,
|
int vm_get_capability(struct vmctx *ctx, int vcpu, enum vm_cap_type cap,
|
||||||
int *retval);
|
int *retval);
|
||||||
int vm_set_capability(struct vmctx *ctx, int vcpu, enum vm_cap_type cap,
|
int vm_set_capability(struct vmctx *ctx, int vcpu, enum vm_cap_type cap,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user