Re: kvm-tools: can't seem to set guest_mac and KVM_GET_SUPPORTED_CPUID failed.

Avi Kivity
2011-11-17T16:50:05Z

[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]

On 11/17/2011 06:29 PM, David Evensky wrote:
> Avi,
>
> evensky@waltz:~/megatux/vmatic$ perl -e 'for $cnt (1..10000){ $o=`taskset 0x01 ./4sasha`; chomp($o); $histogram{$o}++}; for $o (sort keys %histogram){print "$o: $histogram{$o}\n"}'
> KVM_GET_SUPPORTED_CPUID returned -1 with errno 7: 3
> Returned entries: 31: 9995
> Returned entries: 32: 1
> Returned entries: 64: 1
> evensky@waltz:~/megatux/vmatic$ perl -e 'for $cnt (1..10000){ $o=`taskset 0x02 ./4sasha`; chomp($o); $histogram{$o}++}; for $o (sort keys %histogram){print "$o: $histogram{$o}\n"}'
> KVM_GET_SUPPORTED_CPUID returned -1 with errno 7: 1
> Returned entries: 31: 9999
> evensky@waltz:~/megatux/vmatic$ perl -e 'for $cnt (1..10000){ $o=`taskset 0x03 ./4sasha`; chomp($o); $histogram{$o}++}; for $o (sort keys %histogram){print "$o: $histogram{$o}\n"}'
> KVM_GET_SUPPORTED_CPUID returned -1 with errno 7: 3
> Returned entries: 31: 9995
> Returned entries: 57: 1
> Returned entries: 58: 1
> evensky@waltz:~/megatux/vmatic$ perl -e 'for $cnt (1..10000){ $o=`taskset 0x04 ./4sasha`; chomp($o); $histogram{$o}++}; for $o (sort keys %histogram){print "$o: $histogram{$o}\n"}'
> Returned entries: 31: 10000
> evensky@waltz:~/megatux/vmatic$ perl -e 'for $cnt (1..10000){ $o=`taskset 0x08 ./4sasha`; chomp($o); $histogram{$o}++}; for $o (sort keys %histogram){print "$o: $histogram{$o}\n"}'
> KVM_GET_SUPPORTED_CPUID returned -1 with errno 7: 1
> Returned entries: 31: 9998
> Returned entries: 54: 1
>

Please run the attached program (which works for me, btw).

--
error compiling committee.c: too many arguments to function

[-- Attachment #2: supported-cpuid.c --]
[-- Type: text/x-csrc, Size: 1008 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/kvm.h>

int main(void)
{
struct kvm_cpuid2 *cpuid;
int kvm, r = 0, i, j;

for (i = 0; i < 1000000; ++i) {
kvm = open("/dev/kvm", O_RDWR);
cpuid = malloc(sizeof(*cpuid) + sizeof(struct kvm_cpuid_entry2) * 100);
cpuid->nent = 100;

r = ioctl(kvm, KVM_GET_SUPPORTED_CPUID, cpuid);
if (r)
printf("KVM_GET_SUPPORTED_CPUID returned %d with errno %d\n", r, errno);
else if (cpuid->nent > 31) {
printf("Returned entries: %d\n", cpuid->nent);
for (j = 0; j < cpuid->nent; ++j) {
struct kvm_cpuid_entry2 *e = &cpuid->entries[j];

printf("func %08x ind %08x flags %08x -> %08x %08x %08x %08x\n",
e->function, e->index, e->flags,
e->eax, e->ebx, e->ecx, e->edx);
}
return 1;
}

free(cpuid);
close(kvm);
}

return 0;
}