Open CorneliaStreet1 opened 4 months ago
Why are you using workstation? Just use panda/qemu/kvm with the original qcow. You can install software into the qcow filesystem as needed. You can't take a snapshot with qemu/kvm that can then be loaded into panda, but after modifying the filesystem with qemu/kvm you can boot it under panda and then take a new snapshot.
Also try interacting with your guest instead of using the python interface, it's likely printing something other than a PS1 style prompt via the serial console which is causing your exception. You can run python3 -m pandare.qcows x86_64
to get a command that you can use to launch the generic x86_64 images interactively.
Why are you using workstation? Just use panda/qemu/kvm with the original qcow. You can install software into the qcow filesystem as needed. You can't take a snapshot with qemu/kvm that can then be loaded into panda, but after modifying the filesystem with qemu/kvm you can boot it under panda and then take a new snapshot.
Also try interacting with your guest instead of using the python interface, it's likely printing something other than a PS1 style prompt via the serial console which is causing your exception. You can run
python3 -m pandare.qcows x86_64
to get a command that you can use to launch the generic x86_64 images interactively.
I'm just an undergraduate student majoring in Computer Science and Technology who use Panda for my undergraduate project. I'm not very familiar with this field. That's why I was using workstation(It's very stupid).
I followed your guidance to boot the original image using Panda (specifically, ./panda/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2), then enabled networking, and installed software (i.e., modified the file system). After that, I rebooted this qcow2 under Panda and took a new snapshot named "root." However, it seems that this snapshot cannot be used with PyPanda.
What issues might there be with my steps?
Here are my steps:
./panda-system-x86_64 -hda ~/.panda/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2 -nographic -m 1G
Then, I wrote a short Python code to test if the new snapshot is usable, and PyPanda threw a timeout exception. I think my code is correct, it's very simple:
from pandare import Panda
panda = Panda(generic="x86_64")
@panda.queue_blocking def run_cmd():
panda.revert_sync("root")
print(panda.run_serial_cmd("ls"))
panda.end_analysis()
panda.run()
but I got the exception:
PANDA[core]:os_familyno=2 bits=64 os_details=ubuntu:4.15.0-72-generic-noaslr-nokaslr
[PYPANDA] Panda args: [/usr/local/build/x86_64-softmmu/libpanda-x86_64.so -L /usr/local/build/pc-bios /home/jyq/.panda/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2 -display none -m 1024 -serial unix:/tmp/pypanda_s3loy_jeb,server,nowait -monitor unix:/tmp/pypanda_m93csxqt4,server,nowait]
Traceback (most recent call last):
File "/home/jyq/PyPandaCode/run_cmd.py", line 25, in
Does Panda have any special requirements for newly created snapshots? Is the timing of when I save the snapshot incorrect? What is the correct timing to save the snapshot? Should I save the snapshot before entering the username 'root,' or after entering the username but before entering the password, or after successfully logging in? Or is there a problem with the way I took the snapshot? Please help me, I would greatly appreciate it.
If you want to use a new snapshot with run_serial_command
the snapshot will need to be taken after you log in and there's a command prompt for it to type commands into.
I don't think there's much documentation around this (sorry!) it's not a feature that gets much use. If you want to help fix that PRs are always welcome :)
Here are my steps:
However, it does NOT work for me. Is there an issue with the timing of creating the "root" snapshot at the login screen? Should I create the snapshot after entering the login username "root" or before?
Here is the trace: File "/usr/local/lib/python3.10/dist-packages/pandare/utils.py", line 106, in wrapper return func(*args, *kwargs) File "/home/test/PycharmProjects/graduationProject/check/main_copy_20240407.py", line 77, in my_runcmd print(panda.run_serial_cmd("ls -a /")) File "/usr/local/lib/python3.10/dist-packages/pandare/utils.py", line 106, in wrapper return func(args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/pandare/panda.py", line 2416, in run_serial_cmd result = self.serial_console.expect(timeout=timeout) File "/usr/local/lib/python3.10/dist-packages/pandare/panda_expect.py", line 435, in expect raise TimeoutExpired(f"{self.name} Read message \n{full_buffer}\n") pandare.panda_expect.TimeoutExpired: serial Read message [bytearray(b'l')]