RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1001994 - add QMP/HMP support for the getfd/closefd command
Summary: add QMP/HMP support for the getfd/closefd command
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.5
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Luiz Capitulino
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-08-28 09:32 UTC by Sibiao Luo
Modified: 2013-08-29 03:05 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-08-29 03:05:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Sibiao Luo 2013-08-28 09:32:44 UTC
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:

Comment 1 Luiz Capitulino 2013-08-28 13:12:46 UTC
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.

Comment 2 Sibiao Luo 2013-08-29 03:05:07 UTC
(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


Note You need to log in before you can comment on or make changes to this bug.