Hi!I'm currently attempting to use qemu's DBUS display from within a go application, using the godbus <https://pkg.go.dev/github.com/godbus/dbus/v5> library. However, I'm hitting some roadblocks, and this is probably because I'm a bit confused about how qemu's peer-to-peer dbus connection works, and it's not explained in the documentation.
I invoke QEMU with the following argument -display dbus,p2p=yesand then connect to QMP through a separate UNIX socket. From my understanding, I need to listen on the socket separately in the program, and then pass qemu the file descriptor over QMP and run add_client.
In the same program I listen to the socket, and start waiting for a connection. Then, on another thread, get a file descriptor for the socket by first dialing it. Here's my code for that
sock, err := net.Dial("unix", "/tmp/qemudbus.sock") if err != nil { return err } uc, ok := sock.(*net.UnixConn) if !ok {return fmt.Errorf("Could not cast Conn to UnixConn")
} file, err := uc.File()I then pass this file descriptor to QEMU using QMP (I'm using DigitalOcean's qmp library)
res, err := mon.RunWithFile([]byte(`{"execute": "getfd", "arguments": {"fdname": "dbusmon"}}`), file) And add the dbus client: res, err = mon.Run([]byte(`{"execute": "add_client", "arguments": {"protocol": "@dbus-display", "fdname": "dbusmon"}}`))This seems to work fine, as I'm then (apparently) able to make a DBUS connection with that socket without any error.
However, when I then try to do anything with that connection (In this case I'm attempting to introspect /org/qemu/Display1/VM), the call hangs and never returns.
node, err := introspect.Call(session.Object("org.qemu.Display1.VM", "/org/qemu/Display1/VM"))I'm not sure what's going wrong here, but I suspect I'm obtaining the file descriptor wrong (am I supposed to dial the socket?) or I'm doing things in the wrong order.
Thanks in advance for any help. Regards, Elijah R
publickey - elijah@elijahr.dev - a0a86704.asc
Description: application/pgp-keys
signature.asc
Description: OpenPGP digital signature