Bug 603851

Summary: QMP: Can't reuse same 'id' when netdev_add fails
Product: Red Hat Enterprise Linux 6 Reporter: Luiz Capitulino <lcapitulino>
Component: qemu-kvmAssignee: Markus Armbruster <armbru>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.0CC: akong, juzhang, llim, mkenneth, tburke, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.86.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-07-08 05:36:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 559201    

Description Luiz Capitulino 2010-06-14 17:23:33 UTC
Description of problem:

If the netdev_add command fails, the 'id' issued with it is not freed and can't be reused in subsequent calls.

Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.73.el6

How reproducible:


Steps to Reproduce:
1. Run qemu-kvm with a QMP connection:

# qemu-kvm [...] -qmp tcp:localhost:4444,server

2. Connect with telnet and issue the capabilities command:

$ telnet localhost 4444
{ "execute": "qmp_capabilities" }

2. Issue an obviously wrong netdev_add command

{ "execute": "netdev_add", "arguments": { "type": "foobar", "id": "netdev1" } }

3. Issue the right one

{ "execute": "netdev_add", "arguments": { "type": "user", "id": "netdev1" } }

Actual results:

The valid command fails.

Expected results:

It should work, there's no reason to fail.

Additional info:

I have the impression that 'id' is leaking, but I didn't investigate further.

Comment 1 RHEL Program Management 2010-06-14 17:42:56 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for
inclusion.

Comment 2 Luiz Capitulino 2010-06-21 17:34:38 UTC
A patch to fix this issue has been submitted upstream:

http://lists.gnu.org/archive/html/qemu-devel/2010-06/msg02553.html

Comment 6 juzhang 2010-07-08 05:35:25 UTC
Reproduced on qemu-kvm-0.12.1.2-2.77.el6

Using the verification steps
After step4
{"error": {"class": "DuplicateId", "desc": "Duplicate ID 'hostnet2' for netdev", "data": {"object": "netdev", "id": "hostnet2"}}}

Verified on qemu-kvm-0.12.1.2-2.90.el6,pass

Steps:
1. boot guest enable qmp
#/usr/libexec/qemu-kvm -m 4G -smp 4 -drive file=/root/zhangjunyi/rhel6.64.qcow2,if=none,id=drive-virtio-disk0,boot=on,cache=none,format=qcow2 -device virtio-blk-pci,bus=pci.0,drive=drive-virtio-disk0,id=virtio-disk0  -device virtio-balloon-pci -cpu qemu64,+sse2,+x2apic -monitor stdio -vnc :10 -qmp tcp:0:4445,server,nowait -drive file=/root/zhangjunyi/boot.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,drive=drive-ide0-1-0 -boot order=cdn,menu=on -net none
2.Connect with telnet and issue the capabilities command:
$ telnet 10.66.91.89 4444
{ "execute": "qmp_capabilities" }
3.Issue an obviously wrong netdev_add command
{ "execute": "netdev_add", "arguments": { "type":"tap1","id":"hostnet2"}}

4. Issue the right one

{ "execute": "netdev_add", "arguments": { "type":"tap","id":"hostnet2"}}

5. repeat step4

{ "execute": "netdev_add", "arguments": { "type":"tap","id":"hostnet2"}}

Results:
After step3
{"error": {"class": "InvalidParameterValue", "desc": "Parameter 'type' expects a netdev backend type", "data": {"name": "type", "expected": "a netdev backend type"}}}

After step4
{"return": {}},hostnet2 was added.
(qemu) info network 
VLAN 0 devices:
Devices not on any VLAN:
  hostnet2: ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown

After step5
{"error": {"class": "DuplicateId", "desc": "Duplicate ID 'hostnet2' for netdev", "data": {"object": "netdev", "id": "hostnet2"}}}

Comment 7 juzhang 2010-07-08 05:36:44 UTC
according to comment6,close this issue.