I'm using VirtualBox API to manage VMs. It's possible to enable network trace using API, just as command line? Invoking command line with API captures invalid traffic.
Command line:
VBoxManage modifyvm myvm --nictrace2 on --nictracefile2 ~/test.pcap
Example code
Code: Select all
vb = virtualbox.VirtualBox()
vm = vb.find_machine("myvm")
snap = vm.find_snapshot("snapshot1")
session1 = virtualbox.Session()
vm.create_session(session=session1)
restoring = session1.machine.restore_snapshot(snap)
restoring.wait_for_completion(300000)
session1.unlock_machine()
# add network trace code using API here
# If invoking command line "VBoxManage modifyvm myvm --nictrace2 on --nictracefile2 ~/test.pcap" , the pcap generated is invalid - Wireshark shows nothing.
... laugh_vm_process()