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

David Evensky
2011-11-17T17:13:45Z

Avi, sure:

evensky@waltz:~$ gcc supported-cpuid.c -o supported-cpuid
evensky@waltz:~$ ./supported-cpuid
Returned entries: 37
func 00000000 ind 00000000 flags 00000000 -> 0000000d 756e6547 6c65746e 49656e69
func 00000001 ind 00000000 flags 00000000 -> 000206a7 01100800 16b82203 0f8bfbff
func 00000002 ind 00000000 flags 00000006 -> 76035a01 00f0b2ff 00000000 00ca0000
func 00000003 ind 00000000 flags 00000000 -> 00000000 00000000 00000000 00000000
func 00000004 ind 00000000 flags 00000001 -> 1c004121 01c0003f 0000003f 00000000
func 00000004 ind 00000001 flags 00000001 -> 1c004122 01c0003f 0000003f 00000000
func 00000004 ind 00000002 flags 00000001 -> 1c004143 01c0003f 000001ff 00000000
func 00000004 ind 00000003 flags 00000001 -> 1c03c163 03c0003f 00000fff 00000006
func 00000004 ind 00000004 flags 00000001 -> 00000000 00000000 00000000 00000000
func 00000005 ind 00000000 flags 00000000 -> 00000040 00000040 00000003 00021120
func 00000006 ind 00000000 flags 00000000 -> 00000077 00000002 00000009 00000000
func 00000007 ind 00000000 flags 00000000 -> 00000000 00000000 00000000 00000000
func 00000008 ind 00000000 flags 00000000 -> 00000000 00000000 00000000 00000000
func 00000009 ind 00000000 flags 00000000 -> 00000000 00000000 00000000 00000000
func 0000000a ind 00000000 flags 00000000 -> 07300403 00000000 00000000 00000603
func 0000000b ind 00000000 flags 00000001 -> 00000001 00000002 00000100 00000001
func 0000000b ind 00000001 flags 00000001 -> 00000004 00000004 00000201 00000001
func 0000000b ind 00000002 flags 00000001 -> 00000000 00000000 00000002 00000001
func 0000000c ind 00000000 flags 00000000 -> 00000000 00000000 00000000 00000000
func 0000000d ind 00000000 flags 00000001 -> 00000007 00000340 00000340 00000000
func 0000000d ind 00000001 flags 00000001 -> 00000001 00000000 00000000 00000000
func 80000001 ind 00000000 flags 00000000 -> 00000000 00000000 00000001 28100800
func 0000000d ind 00000003 flags 00000001 -> 00000000 00000000 00000000 00000000
func 0000000d ind 00000004 flags 00000001 -> 00000000 00000000 00000000 00000000
func 0000000d ind 00000005 flags 00000001 -> 00000000 00000000 00000000 00000000
func 80000005 ind 00000000 flags 00000000 -> 00000000 00000000 00000000 00000000
func 80000000 ind 00000000 flags 00000000 -> 80000008 00000000 00000000 00000000
func 80000001 ind 00000000 flags 00000000 -> 00000000 00000000 00000001 28100800
func 80000002 ind 00000000 flags 00000000 -> 20202020 49202020 6c65746e 20295228
func 80000003 ind 00000000 flags 00000000 -> 65726f43 294d5428 2d376920 30323632
func 80000004 ind 00000000 flags 00000000 -> 5043204d 20402055 30372e32 007a4847
func 80000005 ind 00000000 flags 00000000 -> 00000000 00000000 00000000 00000000
func 80000006 ind 00000000 flags 00000000 -> 00000000 00000000 01006040 00000000
func 80000007 ind 00000000 flags 00000000 -> 00000000 00000000 00000000 00000100
func 80000008 ind 00000000 flags 00000000 -> 00003024 00000000 00000000 00000000
func 40000000 ind 00000000 flags 00000000 -> 00000000 4b4d564b 564b4d56 0000004d
func 40000001 ind 00000000 flags 00000000 -> 0100001b 00000000 00000000 00000000

\dae

On Thu, Nov 17, 2011 at 06:49:16PM +0200, Avi Kivity wrote:
> 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
>

> #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;
> }