Bug 982304 - virsh attach-device XML error with valid XML
virsh attach-device XML error with valid XML
Status: CLOSED NEXTRELEASE
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.4
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: Michal Privoznik
Virtualization Bugs
:
Depends On:
Blocks: 983616
  Show dependency treegraph
 
Reported: 2013-07-08 11:39 EDT by Chris Evich
Modified: 2013-08-08 01:58 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 983616 (view as bug list)
Environment:
Last Closed: 2013-07-11 10:32:25 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Chris Evich 2013-07-08 11:39:43 EDT
Description of problem:
With valid XML, attaching a device with 'virsh attach-device' gives inaccurate & confusing error, or doesn't work when virt-manager does.

error: Failed to attach device from /tmp/serial.xml
error: XML error: unknown device type


Version-Release number of selected component (if applicable):
libvirt-0.10.2-18.el6_4.8.x86_64

How reproducible:
Very

Steps to Reproduce:

Scenario A-
1. Create qemu-kvm domain, OS doesn't matter.
2. Start domain
3. virsh attach-device foobar /tmp/serial.xml

Scenario B-
1. Shutdown/destroy qemu-kvm domain.
2. Confirm domain is NOT running.
3. virsh attach-device foobar /tmp/serial.xml --config

Scenario C-
1. start qemu-kvm domain, OS doesn't matter
2. Open domain in virt-manager, click add device
3. Manually add file-backed serial device as in XML.
4. Review error in 'details' box of error dialog.
5. Click Yes, restart domain.
6. Device attached and working as expected.


Actual results:

Scenario A- "error: XML error: unknown device type" suggests XML parsing problem, but XML is valid though device is not hot-plugable.

Scenario B- "error: XML error: unknown device type" when device is known, XML is valid, and supported for off-line attachment (Scenario C)

Scenario C- Error dialog, offering to perform off-line device addition.  Detail box concludes with: "error: XML error: unknown device type".


Expected results:

Scenario A- An error message indicating device could not be hotplugged.

Scenario B- Serial device is successfully attached to off-line domain.

Scenario C- Any device attachable via virt-manager, should be attachable in similar way through virsh attach-device command.

Additional info:

Mailing list thread: https://www.redhat.com/archives/libvir-list/2013-July/msg00202.html

XML used was:

<serial type='file'>
  <source path='/tmp/serialfile'/>
  <target port='1'/>
</serial>

where /tmp/serialfile does not already exist.
Comment 1 Michal Privoznik 2013-07-11 02:58:04 EDT
(In reply to Chris Evich from comment #0)
> Description of problem:
> With valid XML, attaching a device with 'virsh attach-device' gives
> inaccurate & confusing error, or doesn't work when virt-manager does.
> 
> error: Failed to attach device from /tmp/serial.xml
> error: XML error: unknown device type
> 
> 
> Version-Release number of selected component (if applicable):
> libvirt-0.10.2-18.el6_4.8.x86_64
> 
> How reproducible:
> Very
> 
> Steps to Reproduce:
> 
> Scenario A-
> 1. Create qemu-kvm domain, OS doesn't matter.
> 2. Start domain
> 3. virsh attach-device foobar /tmp/serial.xml
> 
> Scenario B-
> 1. Shutdown/destroy qemu-kvm domain.
> 2. Confirm domain is NOT running.
> 3. virsh attach-device foobar /tmp/serial.xml --config
> 
> Scenario C-
> 1. start qemu-kvm domain, OS doesn't matter
> 2. Open domain in virt-manager, click add device
> 3. Manually add file-backed serial device as in XML.
> 4. Review error in 'details' box of error dialog.
> 5. Click Yes, restart domain.
> 6. Device attached and working as expected.
> 
> 
> Actual results:
> 
> Scenario A- "error: XML error: unknown device type" suggests XML parsing
> problem, but XML is valid though device is not hot-plugable.
> 
> Scenario B- "error: XML error: unknown device type" when device is known,
> XML is valid, and supported for off-line attachment (Scenario C)
> 
> Scenario C- Error dialog, offering to perform off-line device addition. 
> Detail box concludes with: "error: XML error: unknown device type".
> 

I think the real bug is confusing error message.

> 
> Expected results:
> 
> Scenario A- An error message indicating device could not be hotplugged.
> 
> Scenario B- Serial device is successfully attached to off-line domain.
> 
> Scenario C- Any device attachable via virt-manager, should be attachable in
> similar way through virsh attach-device command.

I think when coldplugging a device, virt-manager just dumps domain XML, inserts the device XML snip and re-define domain. Question is - do we want virsh attach-device --config to do the same?

> 
> Additional info:
> 
> Mailing list thread:
> https://www.redhat.com/archives/libvir-list/2013-July/msg00202.html
> 
> XML used was:
> 
> <serial type='file'>
>   <source path='/tmp/serialfile'/>
>   <target port='1'/>
> </serial>
> 
> where /tmp/serialfile does not already exist.
Comment 2 Michal Privoznik 2013-07-11 07:46:30 EDT
Patch proposed upstream:

https://www.redhat.com/archives/libvir-list/2013-July/msg00679.html
Comment 3 Michal Privoznik 2013-07-11 10:32:25 EDT
I've just pushed patches upstream:

commit 95ff6a3993436daa3d1bb46ffc9d3be3530c00a6
Author:     Michal Privoznik <mprivozn@redhat.com>
AuthorDate: Thu Jul 11 13:24:20 2013 +0200
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Thu Jul 11 16:19:10 2013 +0200

    qemu: Fix hot (un-)plug error codes and messages
    
    With current code, error reporting for unsupported devices for hot plug,
    unplug and update is total mess. The VIR_ERR_CONFIG_UNSUPPORTED error
    code is reported instead of VIR_ERR_OPERATION_UNSUPPORTED. Moreover, the
    error messages are not helping to find the root cause (lack of
    implementation).

commit 38f151fe9b2e3f235fa8537b06f21ee7d42aed72
Author:     Michal Privoznik <mprivozn@redhat.com>
AuthorDate: Thu Jul 11 12:18:36 2013 +0200
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Thu Jul 11 16:19:00 2013 +0200

    conf: Rework virDomainDeviceDefParse
    
    When adding a new domain device, it is fairly easy to forget to add
    corresponding piece into virDomainDeviceDefParse. However, if the
    internal structure is changed to one bit switch() the compiler will warn
    about not handled enum item.

commit b63ea467617e3cbee4282ab2e5e780b4119cef3d
Author:     Michal Privoznik <mprivozn@redhat.com>
AuthorDate: Thu Jul 11 11:20:34 2013 +0200
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Thu Jul 11 16:07:04 2013 +0200

    conf: Extend device types handled by virDomainDeviceDefParse
    
    Not all device types are currently parsed in virDomainDeviceDefParse,
    Since all needed functions do exist, nothing holds us back to make the
    implementation complete. Similarly, the virDomainDeviceDefFree needs to
    be updated as well.

CVE-2013-2230-49-gb0cb524
Comment 4 Chris Evich 2013-07-11 10:35:56 EDT
Oh yes, good error message here is certainly first step to make this much better:

    error: Operation not supported: persistent detach
        of device 'memballoon' is not supported

This is much more helpful!
Comment 5 Chris Evich 2013-07-11 10:42:28 EDT
(In reply to Michal Privoznik from comment #1)
> (In reply to Chris Evich from comment #0)
> > Expected results:
> > 
> > Scenario A- An error message indicating device could not be hotplugged.
> > 
> > Scenario B- Serial device is successfully attached to off-line domain.
> > 
> > Scenario C- Any device attachable via virt-manager, should be attachable in
> > similar way through virsh attach-device command.
> 
> I think when coldplugging a device, virt-manager just dumps domain XML,
> inserts the device XML snip and re-define domain. Question is - do we want
> virsh attach-device --config to do the same?

I cloned just this part into Bug 983616 since it's a separate problem.

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