### Start VM Python API Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Starts a VM from a specified image and kernel path. Includes methods to check if the VM is ready and to wait until it is. ```python # Or just direct specify a created image and run a VM from it # Use verbose=True if you want to see boot script and screen session tips vm = VM("/path/to/images_home/my-image") vm.start(kernel="/path/to/kernel") # Wait several minutes for the VM to be ready, or you can check by: if vm.is_ready(): pass # Or use this API to wait: if vm.wait_until_ready(timeout=180): pass ``` -------------------------------- ### Install syzqemuctl Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Install the syzqemuctl package using pip. Ensure you have Python 3.8+. ```bash pip install syzqemuctl ``` -------------------------------- ### Run a VM from Image CLI Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Starts a virtual machine from a specified disk image, requiring a kernel path. Supports snapshot mode to discard disk changes on shutdown. ```bash syzqemuctl run my-image --kernel /path/to/kernel ``` ```bash syzqemuctl run my-image --kernel /path/to/kernel --snapshot ``` -------------------------------- ### Stop and Cleanup VM Python API Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Provides methods to stop a VM with options for waiting and forcing, and to clean up its runtime. Force is useful after a failed start, and wait is useful before reusing an image. ```python # Use wait=True and force=True when you need runtime cleanup to fully converge. vm.stop(wait=True, force=True, timeout=20) vm.cleanup_runtime(timeout=20) # force=True is useful after a failed start. # wait=True is useful before reusing an image. ``` -------------------------------- ### Initialize Syzqemuctl CLI Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Initializes syzqemuctl with a specified images home directory. This is the first step before performing other operations. ```bash syzqemuctl init --images-home /path/to/images ``` -------------------------------- ### Create a Disk Image CLI Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Creates a new disk image. Optionally specify a custom size in MB; otherwise, it uses the default template. ```bash syzqemuctl create my-image [--size 3072] # --size INT for specifying a custom disk size in MB (copies from default template if omitted) ``` -------------------------------- ### List Images CLI Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Lists all available disk images. ```bash syzqemuctl list ``` -------------------------------- ### Initialize Syzqemuctl Python API Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Initializes the global configuration and ImageManager for syzqemuctl. The API defaults to quiet mode; set verbose=True for more output. ```python from syzqemuctl import global_conf, ImageManager, VM images_home = "/path/to/images_home" # API defaults to quiet (verbose=False); pass verbose=True to see informational prints global_conf.initialize(images_home, force=False) manager = ImageManager(images_home) manager.initialize(force=False) manager.create("my-image") ``` -------------------------------- ### Restart VM CLI Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Restarts a VM. ```bash syzqemuctl restart my-image ``` -------------------------------- ### Copy Files to/from VM CLI Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Copies files or directories between the local system and a VM. Supports copying to and from the VM, and handling directories. ```bash syzqemuctl cp local_file my-image:/remote/path # Copy to VM ``` ```bash syzqemuctl cp my-image:/remote/file local_path # Copy from VM ``` ```bash syzqemuctl cp local_dir my-image:/remote/ # Copy local_dir to VM ``` ```bash syzqemuctl cp local_dir/ my-image:/remote/ # Copy local_dir/* to VM ``` -------------------------------- ### VM Context Manager and Operations Python API Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Demonstrates using a VM context manager for automatic connection/disconnection, and performing file copy and command execution operations with optional timeouts. ```python # You need to use this context manager to auto-connect/disconnect with vm: vm.copy_to_vm("/path/to/local/file", "/path/to/vm/remote/file", timeout=600) stdout, stderr = vm.execute("uname -a", timeout=30) print(f"stdout: {stdout}\nstderr: {stderr}") # timeout is optional and defaults to None. # It limits the total duration of a single execute/copy operation. # After a timeout, reconnect before issuing the next SSH/SCP request. ``` -------------------------------- ### Check VM Status CLI Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Checks the current status of a specified image or VM. ```bash syzqemuctl status my-image ``` -------------------------------- ### Execute Commands in VM CLI Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Executes a command within a running VM. It is recommended to wrap the command in double quotes. ```bash syzqemuctl exec my-image "uname -a" # You'd better wrap the command with double quotes ``` -------------------------------- ### Stop VM CLI Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Stops a running VM. ```bash syzqemuctl stop my-image ``` -------------------------------- ### Delete Image CLI Source: https://github.com/qgrain/syzqemuctl/blob/main/README.md Deletes a specified disk image. ```bash syzqemuctl delete my-image ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.