Hide Forgot
Description of problem: as bug 994124#6 mentioned getfd/closefd command and i check it in {"execute":"query-commands"} but it did not execute correctly. Version-Release number of selected component (if applicable): host info: # uname -r && rpm -q qemu-kvm 2.6.32-413.el6.x86_64 qemu-kvm-0.12.1.2-2.398.el6.x86_64 How reproducible: 100% Steps to Reproduce: 1.boot guest with QMP server. 2.connect to QMP and check it. {"execute":"qmp_capabilities"} {"return": {}} {"execute":"query-commands"} {"return": [...{"name": "getfd"}, {"name": "closefd"}...]} 3.execute getfd/closefd commands. (qemu) ? getfd getfd getfd name -- receive a file descriptor via SCM rights and assign it a name (qemu) ? closefd closefd closefd name -- close a file descriptor previously passed via SCM rights (qemu) getfd sluo No file descriptor supplied via SCM_RIGHTS (qemu) closefd sluo File descriptor named 'sluo' not found { "execute": "getfd", "arguments": { "fdname": "fd1" } } {"error": {"class": "FdNotSupplied", "desc": "No file descriptor supplied via SCM_RIGHTS", "data": {}}} { "execute": "closefd", "arguments": { "fdname": "fd1" } } {"error": {"class": "FdNotFound", "desc": "File descriptor named 'fd1' not found", "data": {"name": "fd1"}}} Actual results: Expected results: Add QMP/HMP support for the getfd/closefd command. getfd ----- Receive a file descriptor via SCM rights and assign it a name. Example: -> { "execute": "getfd", "arguments": { "fdname": "fd1" } } <- { "return": xx } closefd ------- Close a file descriptor previously passed via SCM rights. Example: -> { "execute": "closefd", "arguments": { "fdname": "fd1" } } <- { "return": xx } Additional info:
What's the problem here? Did you even try to pass a fd to QEMU? You have to have another process to pass QEMU a fd before you can use getfd. Besides, you run getfd in the monitor that got the fd sent to. That is, if you're running HMP then the sending process has to send the fd to the HMP socket; you won't see a fd sent to QMP in HMP.
(In reply to Luiz Capitulino from comment #1) > What's the problem here? Did you even try to pass a fd to QEMU? > > You have to have another process to pass QEMU a fd before you can use getfd. > Besides, you run getfd in the monitor that got the fd sent to. That is, if > you're running HMP then the sending process has to send the fd to the HMP > socket; you won't see a fd sent to QMP in HMP. Ok, tried it as your instructor as following, it worked well. host info: # uname -r && rpm -q qemu-kvm 2.6.32-413.el6.x86_64 qemu-kvm-0.12.1.2-2.398.el6.x86_64 Steps and results: 1. Start QEMU with a QMP UDP socket. e.g:...-chardev socket,id=test,path=/tmp/qmp-monitor,server,nowait -mon chardev=test,mode=control 2. Build the attached program and run it, like this: (1) Get the pass-fd.c from : https://bugzilla.redhat.com/show_bug.cgi?id=959308#c27 # cc -Wall -o pass-fd pass-fd.c # touch /tmp/foo.txt # ./pass-fd /tmp/foo.txt /tmp/qmp-monitor sent fd 3 3. Find out QEMU's pid with ps and enter its /proc/*/fd dir, like: # pidof qemu-kvm 18706 # cd /proc/18706/fd 4. Do a ls -la and verify that /tmp/foo.txt is listed. fd]# ls -la ... lrwx------. 1 root root 64 Aug 28 22:48 35 -> /tmp/foo.txt ... 5. Connect to the QMP socket and run: # nc -U /tmp/qmp-monitor {"QMP": {"version": {"qemu": {"micro": 1, "minor": 12, "major": 0}, "package": "(qemu-kvm-0.12.1.2)"}, "capabilities": []}} {"execute":"qmp_capabilities"} {"return": {}} { "execute": "getfd", "arguments": { "fdname": "foo" } } {"return": {}} { "execute": "closefd", "arguments": { "fdname": "foo" } } {"return": {}} 6. Check it: # pidof qemu-kvm 18706 # cd /proc/18706/fd fd]# ls -la ... <------------/tmp/foo.txt was not listed here. Base on above, it works for me now, so close it, thanks for your kindly reminds. Best Regards, sluo