Skip to content

Instantly share code, notes, and snippets.

@stefano-garzarella
Created March 7, 2023 13:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
vsock: get local CID using the available ioctl
#!/usr/bin/env python3
import socket
import struct
import fcntl
with open("/dev/vsock", "rb") as fd:
r = fcntl.ioctl(fd, socket.IOCTL_VM_SOCKETS_GET_LOCAL_CID, " ")
cid = struct.unpack("I", r)[0]
print("Local CID: {}".format(cid))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment