shirou / gopsutil

psutil for golang
Other
10.28k stars 1.56k forks source link

Improve AIX Support #1651

Closed Dylan-M closed 1 month ago

Dylan-M commented 1 month ago

Implement additional AIX support

I have very little Golang experience. So... please point out anything I'm doing wrong from Golang perspective Also anything I can do to improve efficiency of some of the things I had to do as loops to pick something out of several lines. Or really, anything else. I don't take offense, unless you're rude about it. Constructive criticism is always welcome.

This should now support all packages except process, which I don't have the time to develop (process is very in-depth)

Added:

Partially addresses #1490

Dylan-M commented 1 month ago

@shirou If you're at all concerned about AIX support, I'm willing to be a code owner for the AIX portions only to help alleviate that. Alternatively, I can help you get set up with an emulated AIX system to work from.

Dylan-M commented 1 month ago

Unrelated to this PR, but for my future reference, could you let me know the best way to set up an AIX emulation environment? Would QEMU be a good option?

Yes, but not using libvirt (virsh or the gui virt-manager). I scoured the internet, and played around a lot, to get this to work. It is a combination of other peoples' work, and my own knowledge. I only have it working for AIX 7.2 at this time, still working on 7.3.

# AIX 7.2 PowerPC "POWER9"
sudo qemu-system-ppc64 -M pseries,ic-mode=xics -cpu POWER9 \
  -smp 4,sockets=4,cores=2,threads=2,maxcpus=16 \
  -m 4096 \
  -name aix_7200-04-02-2027 \
  -netdev bridge,id=net0,br=virbr0 \
  -device spapr-vlan,netdev=net0,mac=52:54:00:49:53:14 \
  -device virtio-scsi,id=scsi0 \
  -drive file=/var/lib/libvirt/images/aix7.2-ppc64.qcow2,if=none,id=drive-scsi0-0-0-0,format=qcow2,cache=none \
  -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 \
  -drive file=/path/to/iso/aix/7.2/aix_7200-04-02-2027_1of2_072020.iso,format=raw,media=cdrom,cache=unsafe

You can edit the cpu line, I've had it working with just smp 1 and memory of -m 2048.

EDIT: This was the command I used to create my disk image: sudo qemu-img create -f qcow2 /var/lib/libvirt/images/aix7.2-ppc64.qcow2 50G

Would you also be interested in my little test/sample program that I used to actually test this manually? I can dump it into a gist.

Dylan-M commented 1 month ago

Here is the test program gist

https://gist.github.com/Dylan-M/3dd22484c7fa30e6826ede5566e291eb