Bug 1152478
| Summary: | Execute QMP: "getfd.." will show error: No file descriptor supplied via SCM_RIGHTS | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | langfang <flang> | ||||||
| Component: | qemu-kvm-rhev | Assignee: | Luiz Capitulino <lcapitulino> | ||||||
| Status: | CLOSED NOTABUG | QA Contact: | Virtualization Bugs <virt-bugs> | ||||||
| Severity: | medium | Docs Contact: | |||||||
| Priority: | low | ||||||||
| Version: | 7.1 | CC: | amberzapp, armbru, flang, hhuang, juzhang, lcapitulino, qiguo, sluo, virt-maint, xfu, xiaohli, yiwei | ||||||
| Target Milestone: | rc | ||||||||
| Target Release: | --- | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Whiteboard: | |||||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||||
| Doc Text: | Story Points: | --- | |||||||
| Clone Of: | Environment: | ||||||||
| Last Closed: | 2014-10-30 14:23:53 UTC | Type: | Bug | ||||||
| Regression: | --- | Mount Type: | --- | ||||||
| Documentation: | --- | CRM: | |||||||
| Verified Versions: | Category: | --- | |||||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||||
| Embargoed: | |||||||||
| Attachments: |
|
||||||||
|
Description
langfang
2014-10-14 08:59:24 UTC
Created attachment 946767 [details]
/proc/$qemi-pid/fd contents
The fd listing you attached to the BZ doesn't show /tmp/foo.txt. The reason is probably because the pass-fd program you're using has a stupid bug. I've fixed it and will attach a new one here. Also, you have to execute the test-case in this order: 1. Run QEMU 2. Send the file-description by using the pass-fd program 3. Kill the pass-fd program 4. Only then connect to the QMP socket to run the getfd command In other words, don't connect to the QMP socket before running the pass-fd program, otherwise things will just not work. Please, close this BZ as NOTABUG if things work now. PS: I've tested qemu-kvm and qemu-kvm-rhev myself, they work. But I'll let you close the BZ. Created attachment 951875 [details]
fixed pass-fd program
(In reply to Luiz Capitulino from comment #4) > Created attachment 951875 [details] > fixed pass-fd program Test on latest version: Host # uname -r 3.10.0-191.el7.x86_64 # rpm -q qemu-kvm-rhev qemu-kvm-rhev-2.1.2-5.el7.x86_64 Guest:rhel7 Steps: 1.Boot guest ...-chardev socket,id=test,path=/tmp/qmp-monitor,server,nowait -mon chardev=test,mode=control... 2.Get the pass-fd program from comment4 $ cc -Wall -o pass-fd pass-fd.c $ touch /tmp/foo.txt # ./pass-fd /tmp/foo.txt /tmp/qmp-monitor sent fd 3 the ./pass-fd /tmp/foo.txt /tmp/qmp-monitor 3.Kill pass-fd program 4.telnet $ip 4444 {"execute":"qmp_capabilities"} {"return": {}} { "execute": "getfd", "arguments": { "fdname": "foo" } } {"return": {}} Test on latest qemu-kvm version(qemu-kvm-1.5.3-75.el7.x86_64),work well { "execute": "getfd", "arguments": { "fdname": "foo" } } {"return": {}} BUt i hit the same error info when i try to "add-fd/getfd" the second time.The steps as same as above: Resutls: # nc -U /tmp/qmp-monitor {"QMP": {"version": {"qemu": {"micro": 2, "minor": 1, "major": 2}, "package": " (qemu-kvm-rhev-2.1.2-5.el7)"}, "capabilities": []}} {"execute":"qmp_capabilities"} {"return": {}} { "execute": "add-fd", "arguments": { "fdset-id": 1 } } {"return": {"fd": 84, "fdset-id": 1}} { "execute": "add-fd", "arguments": { "fdset-id": 1 } } {"error": {"class": "GenericError", "desc": "No file descriptor supplied via SCM_RIGHTS"}} { "execute": "query-fdsets"} {"return": [{"fds": [{"fd": 84}], "fdset-id": 1}]} { "execute": "add-fd", "arguments": { "fdset-id": 1 } } {"error": {"class": "GenericError", "desc": "No file descriptor supplied via SCM_RIGHTS"}} Hi, Luiz Is this the expect result? thanks best regards fang lang Yes, because you can add an FD, which as passed via SCM_RIGHTS, only once. As there's no getfd bug, I'm closing this as NOTABUG. Hi, Luiz
when i try to "add-fd/getfd" the first time,i hit the same error.
Resutls:
nc -U /tmp/qmp-monitor
{"QMP": {"version": {"qemu": {"micro": 92, "minor": 8, "major": 2}, "package": "(qemu-kvm-rhev-2.9.0-0.el7.patchwork201703291116)"}, "capabilities": []}}
{"execute":"qmp_capabilities"}
{"return": {}}
{"execute":"getfd","arguments":{"fdname":"/home/foo1"}}
{"error": {"class": "GenericError", "desc": "No file descriptor supplied via SCM_RIGHTS"}}
{ "execute": "query-fdsets"}
{"return": []}
{ "execute": "add-fd", "arguments": { "fdset-id": 1 } }
{"error": {"class": "GenericError", "desc": "No file descriptor supplied via SCM_RIGHTS"}}
Is this the expect result?
thanks
yiqian
It's hard to tell without knowing what you're doing. For example, if you're not using another program to send the fd then what you're very probably doing this wrong and the result is the expect one. What I recommend if for you to try the steps from comment 3. If you have any issues, please open a new BZ. (In reply to Luiz Capitulino from comment #8) > It's hard to tell without knowing what you're doing. For example, if you're > not using another program to send the fd then what you're very probably > doing this wrong and the result is the expect one. > > What I recommend if for you to try the steps from comment 3. If you have any > issues, please open a new BZ. Hi Luiz, I test this case in qemu-img-3.1.0-4.module+el8+2681+819ab34d.x86_64 & kernel-4.18.0-57.el8.x86_64, and hit this issue, too. Please help to see whether my operations are right, if right, I will open a new bug for rhel8. 1.Test steps: (1)boot guest with commands: -chardev socket,id=test,path=/tmp/qmp-monitor,server,nowait \ -mon chardev=test,mode=control \ -qmp tcp:0:4441,server,nowait \ (2)use your Comment 4's pass fd program: [root@ibm-x3250m6-07 qemu-sh]# gcc -g -Wall -o pass-fd pass-fd.c [root@ibm-x3250m6-07 qemu-sh]# touch /tmp/foo.txt [root@ibm-x3250m6-07 qemu-sh]# ./pass-fd /tmp/foo.txt /tmp/qmp-monitor (3)then use "Ctrl + c" to kill pass fd program: [root@ibm-x3250m6-07 qemu-sh]# ./pass-fd /tmp/foo.txt /tmp/qmp-monitor sent fd 3 ^C (4)connect qmp and execute "getfd" operation: [root@ibm-x3250m6-07 qemu-sh]# telnet 10.73.73.87 4441 Trying 10.73.73.87... Connected to 10.73.73.87. Escape character is '^]'. {"QMP": {"version": {"qemu": {"micro": 0, "minor": 1, "major": 3}, "package": "qemu-kvm-3.1.0-4.module+el8+2681+819ab34d"}, "capabilities": []}} {"execute":"qmp_capabilities"} {"return": {}} { "execute": "getfd", "arguments": { "fdname": "foo" } } {"error": {"class": "GenericError", "desc": "No file descriptor supplied via SCM_RIGHTS"}} Oh, good memories :) But I think the guy you need is Markus. QEMU receives file descriptors with SCM_RIGHTS from Unix domain sockets, and buffers them until * QEMU code (such as QMP command getfd) retrieves them, or * another SCM_RIGHTS message is received, or * the socket is closed. Your test case behaves as intended: when the pass-fd process terminates, the connection gets closed, and the buffered file descriptors get closed. The new connection (telnet) starts with a clean slate, i.e. *no* file descriptors buffered. getfd duly fails. To test getfd with pass-fd, pass-fd needs to send the getfd command itself. Note that iotest case 045 already covers getfd and setfd. Perhaps that test can satisfy your needs. Hi Markus! This test procedure is not working for me. I followed the steps above to test if get fd works and failed. I am using qemu-2.5+dfsg-5ubuntu10.31. Here are the steps that I took: 1. Booted qemu with "-chardev socket,id=test,path=/tmp/qmp-monitor,server,nowait -mon chardev=test,mode=control" added to the arguments. 2. Did 'cd /proc/$qemu_pid/fd' and 'ls -la /tmp/qmp-monitor': showed up correctly 3. Run pass_fd program (did not kill it): ./pass-fd /tmp/foo.txt /tmp/qmp-monitor 4. In another terminal use QMP to run getfd: Got "No file descriptor supplied via SCM_RIGHTS" What is the correct way to do this? You mentioned the test pass-fd should run the getfd command itself. Why is that necessary for Qemu to get the file descriptor? Thank you in advance! I would like to use getfd to be able to hotplug tap devices into a running qemu vm. I would really appreciate some help! The buffer I mentioned in comment#11 is per monitor (really: per underlying character device). The file descriptors you passed with pass_fd got buffered in the monitor it connected to. Your step 4 uses *another* monitor, which had none buffered, so getfd failed as you described. Hi Markus, Thanks to you I realized I was connecting to the wrong monitor to do getfd (I had two, one on the unix socket /tmp/qmp-monitor and one on telnet). The test is working now, thank you! |