workhorsy / py-cpuinfo

A module for getting CPU info with pure Python
MIT License
311 stars 60 forks source link

Broken Qemu guest CPU flag parsing on Ubuntu 17.04 POWER8 #68

Closed workhorsy closed 7 years ago

workhorsy commented 7 years ago

Copied this bug from @gut https://github.com/workhorsy/py-cpuinfo/pull/46#issuecomment-295249321.

@workhorsy Hi, thanks for your 3.1.0 release update! I tried it on my Ubuntu 17.10 POWER8 virtual machine and it looks broken at the moment:

$ python ./cpuinfo/cpuinfo.py
Traceback (most recent call last):
  File "./cpuinfo/cpuinfo.py", line 1830, in <module>
    main()
  File "./cpuinfo/cpuinfo.py", line 1797, in main
    info = get_cpu_info()
  File "./cpuinfo/cpuinfo.py", line 1774, in get_cpu_info
    CopyNewFields(info, _get_cpu_info_from_ibm_pa_features())
  File "./cpuinfo/cpuinfo.py", line 1335, in _get_cpu_info_from_ibm_pa_features
    left, right = value.split(' ')
ValueError: too many values to unpack

And this is the reason:

$ lsprop /proc/device-tree/cpus/*/ibm,pa-features
/proc/device-tree/cpus/PowerPC,POWER8@0/ibm,pa-features
                 18 00 f6 3f c7 c0 80 f0 80 00 00 00 00 00 00 00...?............
                 00 00 80 00 80 00 80 00 80 00                  ..........
/proc/device-tree/cpus/PowerPC,POWER8@8/ibm,pa-features
                 18 00 f6 3f c7 c0 80 f0 80 00 00 00 00 00 00 00...?............
                 00 00 80 00 80 00 80 00 80 00                  ..........

Whereas when running on the host it's:

$ lsprop /proc/device-tree/cpus/*/ibm,pa-features
/proc/device-tree/cpus/PowerPC,POWER8@20/ibm,pa-features
                 0600f63f c70080c0
/proc/device-tree/cpus/PowerPC,POWER8@28/ibm,pa-features
                 0600f63f c70080c0
/proc/device-tree/cpus/PowerPC,POWER8@30/ibm,pa-features
                 0600f63f c70080c0
/proc/device-tree/cpus/PowerPC,POWER8@60/ibm,pa-features
                 0600f63f c70080c0
/proc/device-tree/cpus/PowerPC,POWER8@70/ibm,pa-features
                 0600f63f c70080c0
/proc/device-tree/cpus/PowerPC,POWER8@a0/ibm,pa-features
                 0600f63f c70080c0
/proc/device-tree/cpus/PowerPC,POWER8@a8/ibm,pa-features
                 0600f63f c70080c0
/proc/device-tree/cpus/PowerPC,POWER8@e0/ibm,pa-features
                 0600f63f c70080c0
/proc/device-tree/cpus/PowerPC,POWER8@e8/ibm,pa-features
                 0600f63f c70080c0
/proc/device-tree/cpus/PowerPC,POWER8@f0/ibm,pa-features
                 0600f63f c70080c0

ps: it worked as expected on the host (also an Ubuntu 17.10):

$ python ./cpuinfo/cpuinfo.py
cpuinfo version: (3, 1, 0)
Vendor ID:
Hardware Raw:
Brand: POWER8E (raw), altivec supported
Hz Advertised: 3.6900 GHz
Hz Actual: 3.6900 GHz
Hz Advertised Raw: (3690000000, 0)
Hz Actual Raw: (3690000000, 0)
Arch: PPC_64
Bits: 64
Count: 80
Raw Arch String: ppc64le
L2 Cache Size:
L2 Cache Line Size:
L2 Cache Associativity:
Stepping:
Model:
Family:
Processor Type:
Extended Model:
Extended Family:
Flags: dabr, dabrx, dsisr, fpu, lp, mmu, pp, rislb, run, slb, sprg3, ugr_in_dscr

I hope it helps.

gut commented 7 years ago

On #46 you asked me about the virtual machine software I'm using.

I'm using kvm along with libvirt. Below the parameters as dumped by qemu log:

LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -name guest=gut-233.10,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-55-gut-233.10/master-key.aes -machine pseries-yakkety,accel=kvm,usb=off -m 4096 -realtime mlock=off -smp 16,sockets=1,cores=2,threads=8 -uuid f88f4b57-aba2-4349-98ab-8b995bdb1581 -display none -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-55-gut-233.10/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -boot strict=on -device pci-ohci,id=usb,bus=pci.0,addr=0x1 -device spapr-vscsi,id=scsi0,reg=0x2000 -drive file=/home/gut/disk.qcow2,format=qcow2,if=none,id=drive-scsi0-0-0-0,serial=fc4c56cc-3bd3-4692-96ee-3c6e41e24f47,cache=none,werror=stop,rerror=stop,aio=threads -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 -netdev tap,fd=25,id=hostnet0 -device spapr-vlan,netdev=hostnet0,id=net0,mac=52:54:00:55:0f:99,reg=0x1000 -chardev pty,id=charserial0 -device spapr-vty,chardev=charserial0,reg=0x30000000 -msg timestamp=on

Please tell me if you need any more info. I'm glad to help

workhorsy commented 7 years ago

Thanks @gut.

Does the output of lsprop /proc/device-tree/cpus/*/ibm,pa-features really have all those dots and question marks in it? Or is that a formatting issue?

18 00 f6 3f c7 c0 80 f0 80 00 00 00 00 00 00 00...?............

gut commented 7 years ago

It's indeed dots and question marks:

$ lsprop /proc/device-tree/cpus/*/ibm,pa-features | hexdump  -C
00000000  2f 70 72 6f 63 2f 64 65  76 69 63 65 2d 74 72 65  |/proc/device-tre|
00000010  65 2f 63 70 75 73 2f 50  6f 77 65 72 50 43 2c 50  |e/cpus/PowerPC,P|
00000020  4f 57 45 52 38 40 30 2f  69 62 6d 2c 70 61 2d 66  |OWER8@0/ibm,pa-f|
00000030  65 61 74 75 72 65 73 0a  09 09 20 31 38 20 30 30  |eatures... 18 00|
00000040  20 66 36 20 33 66 20 63  37 20 63 30 20 38 30 20  | f6 3f c7 c0 80 |
00000050  66 30 20 38 30 20 30 30  20 30 30 20 30 30 20 30  |f0 80 00 00 00 0|
00000060  30 20 30 30 20 30 30 20  30 30 2e 2e 2e 3f 2e 2e  |0 00 00 00...?..|
00000070  2e 2e 2e 2e 2e 2e 2e 2e  2e 2e 0a 09 09 20 30 30  |............. 00|
00000080  20 30 30 20 38 30 20 30  30 20 38 30 20 30 30 20  | 00 80 00 80 00 |
00000090  38 30 20 30 30 20 38 30  20 30 30 20 20 20 20 20  |80 00 80 00     |
000000a0  20 20 20 20 20 20 20 20  20 20 20 20 20 2e 2e 2e  |             ...|
000000b0  2e 2e 2e 2e 2e 2e 2e 0a  2f 70 72 6f 63 2f 64 65  |......../proc/de|
000000c0  76 69 63 65 2d 74 72 65  65 2f 63 70 75 73 2f 50  |vice-tree/cpus/P|
000000d0  6f 77 65 72 50 43 2c 50  4f 57 45 52 38 40 38 2f  |owerPC,POWER8@8/|
000000e0  69 62 6d 2c 70 61 2d 66  65 61 74 75 72 65 73 0a  |ibm,pa-features.|
000000f0  09 09 20 31 38 20 30 30  20 66 36 20 33 66 20 63  |.. 18 00 f6 3f c|
00000100  37 20 63 30 20 38 30 20  66 30 20 38 30 20 30 30  |7 c0 80 f0 80 00|
00000110  20 30 30 20 30 30 20 30  30 20 30 30 20 30 30 20  | 00 00 00 00 00 |
00000120  30 30 2e 2e 2e 3f 2e 2e  2e 2e 2e 2e 2e 2e 2e 2e  |00...?..........|
00000130  2e 2e 0a 09 09 20 30 30  20 30 30 20 38 30 20 30  |..... 00 00 80 0|
00000140  30 20 38 30 20 30 30 20  38 30 20 30 30 20 38 30  |0 80 00 80 00 80|
00000150  20 30 30 20 20 20 20 20  20 20 20 20 20 20 20 20  | 00             |
00000160  20 20 20 20 20 2e 2e 2e  2e 2e 2e 2e 2e 2e 2e 0a  |     ...........|
00000170
workhorsy commented 7 years ago

@gut how it that? The master branch should work now.

gut commented 7 years ago

It worked:

$ python cpuinfo/cpuinfo.py
cpuinfo version: (3, 1, 0)
Vendor ID:
Hardware Raw:
Brand: POWER8E (raw), altivec supported
Hz Advertised: 3.4250 GHz
Hz Actual: 3.4250 GHz
Hz Advertised Raw: (3425000000, 0)
Hz Actual Raw: (3425000000, 0)
Arch: PPC_64
Bits: 64
Count: 16
Raw Arch String: ppc64le
L2 Cache Size:
L2 Cache Line Size:
L2 Cache Associativity:
Stepping:
Model:
Family:
Processor Type:
Extended Model:
Extended Family:
Flags: dabr, dabrx, dsisr, fpu, lp, mmu, pp, rislb, run, slb, sprg3

Great job! Thanks

workhorsy commented 7 years ago

Nice!

gut commented 7 years ago

@workhorsy : erm, sorry. I reported Ubuntu 17.10 but it's 17.04 actually. Would you mind changing the title?

workhorsy commented 7 years ago

ok