[libvirt] attach-device error: XML error: unknown device type

Hi, On Fedora 18 (libvirt 0.10.2.6-1) I'm trying to add a new serial device to a KVM VM with: virsh attach-device foobar /tmp/serial.xml and I keep getting: error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type with serial.xml: <serial type='file'> <source path='/tmp/serialfile'/> <target port='1'/> </serial> Though I tried it w/o the <target> tag, with and without the --config flag, and with and without the guest running. Assuming it's similar, I tried and was successful in adding this device via virt-manager, though it complains if the VM is running (which is fine). What am I doing wrong with the virsh attach-device command or XML? Thanks in advance. -- Chris Evich, RHCA, RHCE, RHCDS, RHCSS Quality Assurance Engineer e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214

On Wed, Jul 03, 2013 at 09:44:46AM -0400, Chris Evich wrote:
Hi,
On Fedora 18 (libvirt 0.10.2.6-1) I'm trying to add a new serial device to a KVM VM with:
virsh attach-device foobar /tmp/serial.xml
and I keep getting:
error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type
with serial.xml:
<serial type='file'> <source path='/tmp/serialfile'/> <target port='1'/> </serial>
Though I tried it w/o the <target> tag, with and without the --config flag, and with and without the guest running. Assuming it's similar, I tried and was successful in adding this device via virt-manager, though it complains if the VM is running (which is fine).
What am I doing wrong with the virsh attach-device command or XML?
There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML) Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 07/03/2013 07:46 AM, Daniel P. Berrange wrote:
What am I doing wrong with the virsh attach-device command or XML?
There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML)
Although that's about to change in libvirt 1.1.1: https://www.redhat.com/archives/libvir-list/2013-July/msg00125.html -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Jul 03, 2013 at 07:54:51AM -0600, Eric Blake wrote:
On 07/03/2013 07:46 AM, Daniel P. Berrange wrote:
What am I doing wrong with the virsh attach-device command or XML?
There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML)
Although that's about to change in libvirt 1.1.1: https://www.redhat.com/archives/libvir-list/2013-July/msg00125.html
Yes & no. Yes, libvirt will support hotplug, but that's only actually going to work for devices which are PCI based. eg virtio-serial and virtio-console. You can't hotplug <serial> or <paralle> devices which use the ISA bus, which is what Chris was trying todo here. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 03.07.2013 15:59, Daniel P. Berrange wrote:
On Wed, Jul 03, 2013 at 07:54:51AM -0600, Eric Blake wrote:
On 07/03/2013 07:46 AM, Daniel P. Berrange wrote:
What am I doing wrong with the virsh attach-device command or XML?
There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML)
Although that's about to change in libvirt 1.1.1: https://www.redhat.com/archives/libvir-list/2013-July/msg00125.html
Yes & no. Yes, libvirt will support hotplug, but that's only actually going to work for devices which are PCI based. eg virtio-serial and virtio-console. You can't hotplug <serial> or <paralle> devices which use the ISA bus, which is what Chris was trying todo here.
Daniel
But that's just a QEMU limitation. If QEMU learns to hotplug a device onto ISA bus, libvirt will allow it. Michal

On Wed, Jul 03, 2013 at 04:19:01PM +0200, Michal Privoznik wrote:
On 03.07.2013 15:59, Daniel P. Berrange wrote:
On Wed, Jul 03, 2013 at 07:54:51AM -0600, Eric Blake wrote:
On 07/03/2013 07:46 AM, Daniel P. Berrange wrote:
What am I doing wrong with the virsh attach-device command or XML?
There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML)
Although that's about to change in libvirt 1.1.1: https://www.redhat.com/archives/libvir-list/2013-July/msg00125.html
Yes & no. Yes, libvirt will support hotplug, but that's only actually going to work for devices which are PCI based. eg virtio-serial and virtio-console. You can't hotplug <serial> or <paralle> devices which use the ISA bus, which is what Chris was trying todo here.
But that's just a QEMU limitation. If QEMU learns to hotplug a device onto ISA bus, libvirt will allow it.
Did real ISA buses ever support hotplug ? I thought hotplug only came along when PCI buses arrived. I'm rather doubting anyone is going to do work for ISA device hotplug in QEMU Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 07/03/2013 10:21 AM, Daniel P. Berrange wrote:
On Wed, Jul 03, 2013 at 04:19:01PM +0200, Michal Privoznik wrote:
On 03.07.2013 15:59, Daniel P. Berrange wrote:
On Wed, Jul 03, 2013 at 07:54:51AM -0600, Eric Blake wrote:
On 07/03/2013 07:46 AM, Daniel P. Berrange wrote:
What am I doing wrong with the virsh attach-device command or XML?
There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML)
Although that's about to change in libvirt 1.1.1: https://www.redhat.com/archives/libvir-list/2013-July/msg00125.html
Yes & no. Yes, libvirt will support hotplug, but that's only actually going to work for devices which are PCI based. eg virtio-serial and virtio-console. You can't hotplug <serial> or <paralle> devices which use the ISA bus, which is what Chris was trying todo here.
But that's just a QEMU limitation. If QEMU learns to hotplug a device onto ISA bus, libvirt will allow it.
Did real ISA buses ever support hotplug ? I thought hotplug only came along when PCI buses arrived. I'm rather doubting anyone is going to do work for ISA device hotplug in QEMU
Daniel
IIRC they did not, I don't think PCI supported it even until later revisions. Even when it did, I only saw it on fairly big hardware and with specific devices. Either way, I'm concerned about the error message here, not that it doesn't work :D -- Chris Evich, RHCA, RHCE, RHCDS, RHCSS Quality Assurance Engineer e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214

On 07/03/2013 09:46 AM, Daniel P. Berrange wrote:
On Wed, Jul 03, 2013 at 09:44:46AM -0400, Chris Evich wrote:
Hi,
On Fedora 18 (libvirt 0.10.2.6-1) I'm trying to add a new serial device to a KVM VM with:
virsh attach-device foobar /tmp/serial.xml
and I keep getting:
error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type
with serial.xml:
<serial type='file'> <source path='/tmp/serialfile'/> <target port='1'/> </serial>
Though I tried it w/o the <target> tag, with and without the --config flag, and with and without the guest running. Assuming it's similar, I tried and was successful in adding this device via virt-manager, though it complains if the VM is running (which is fine).
What am I doing wrong with the virsh attach-device command or XML?
There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML)
Daniel
Oops, sorry, should have been more clear than "and with and without the guest running". * I see the 'unknown device type' error when guest is running and I run "virsh attach-device foobar /tmp/serial.xml --config". * I also get 'unknown device type' error when guest is NOT running, and I run "virsh attach...." both with or without '--config' flag. * I see the 'unknown device type' error inside the "details" window when the guest is running and I use virt-manager. * I do NOT get any error, and the device is attached, when I use virt-manager, and the guest is NOT running (or by clicking yes after getting error in above bullet). The main difference in using virt-manager, is that I'm selecting the file type and entering in the values manually instead of in an XML file. A loosely-related problem is with serial-hot plug (which is expected to not work). The error message reported under details is the same/similar 'device type error'. Whereas I was expecting something more specific like a "Can't hotplug this" error (see screenshot). Either way, the main thing I'm concerned about is the "cold-plug" + device-type error. Here's what I'm doing: [root@cevich ~]# virsh list --all Id Name State ---------------------------------------------------- 6 foobar running [root@cevich ~]# virsh attach-device foobar /tmp/serial.xml error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type [root@cevich ~]# virsh shutdown foobar Domain foobar is being shutdown [root@cevich ~]# virsh list --all Id Name State ---------------------------------------------------- - foobar shut off [root@cevich ~]# virsh attach-device foobar /tmp/serial.xml --config error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type [root@cevich ~]# virsh start foobar <see screenshot> Then... [root@cevich ~]# virsh shutdown foobar Domain foobar is being shutdown [root@cevich ~]# virsh list --all Id Name State ---------------------------------------------------- - foobar shut off [root@cevich ~]# virsh dumpxml foobar | grep -A2 "serial type='file'" <serial type='file'> <source path='/tmp/serialfile'/> <target port='1'/> -- Chris Evich, RHCA, RHCE, RHCDS, RHCSS Quality Assurance Engineer e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214

On 07/04/2013 02:34 AM, Chris Evich wrote:
On 07/03/2013 09:46 AM, Daniel P. Berrange wrote:
On Wed, Jul 03, 2013 at 09:44:46AM -0400, Chris Evich wrote:
Hi,
On Fedora 18 (libvirt 0.10.2.6-1) I'm trying to add a new serial device to a KVM VM with:
virsh attach-device foobar /tmp/serial.xml
and I keep getting:
error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type
with serial.xml:
<serial type='file'> <source path='/tmp/serialfile'/> <target port='1'/> </serial>
Though I tried it w/o the<target> tag, with and without the --config flag, and with and without the guest running. Assuming it's similar, I tried and was successful in adding this device via virt-manager, though it complains if the VM is running (which is fine).
What am I doing wrong with the virsh attach-device command or XML? There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML)
Daniel
Oops, sorry, should have been more clear than "and with and without the guest running".
* I see the 'unknown device type' error when guest is running and I run "virsh attach-device foobar /tmp/serial.xml --config".
* I also get 'unknown device type' error when guest is NOT running, and I run "virsh attach...." both with or without '--config' flag.
* I see the 'unknown device type' error inside the "details" window when the guest is running and I use virt-manager.
* I do NOT get any error, and the device is attached, when I use virt-manager, and the guest is NOT running (or by clicking yes after getting error in above bullet).
The main difference in using virt-manager, is that I'm selecting the file type and entering in the values manually instead of in an XML file.
A loosely-related problem is with serial-hot plug (which is expected to not work). The error message reported under details is the same/similar 'device type error'. Whereas I was expecting something more specific like a "Can't hotplug this" error (see screenshot).
This error is raised by the virDomainDeviceDefParse(), which should be a common device XML parser function not only focus on XML parser for hotplugging some device, so I think "Can't hotplug this" isn't appropriate in here at least. In addition, maybe, libvirt should add relevant character device parser function into the virDomainDeviceDefParse() such as virDomainSerialDefParseXML(), virDomainConsoleDefParseXML(), etc.
Either way, the main thing I'm concerned about is the "cold-plug" + device-type error. Here's what I'm doing:
[root@cevich ~]# virsh list --all Id Name State ---------------------------------------------------- 6 foobar running
[root@cevich ~]# virsh attach-device foobar /tmp/serial.xml error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type
[root@cevich ~]# virsh shutdown foobar Domain foobar is being shutdown
[root@cevich ~]# virsh list --all Id Name State ---------------------------------------------------- - foobar shut off
[root@cevich ~]# virsh attach-device foobar /tmp/serial.xml --config error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type
[root@cevich ~]# virsh start foobar
<see screenshot>
Then...
[root@cevich ~]# virsh shutdown foobar Domain foobar is being shutdown
[root@cevich ~]# virsh list --all Id Name State ---------------------------------------------------- - foobar shut off
[root@cevich ~]# virsh dumpxml foobar | grep -A2 "serial type='file'" <serial type='file'> <source path='/tmp/serialfile'/> <target port='1'/>
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 03.07.2013 20:34, Chris Evich wrote:
On 07/03/2013 09:46 AM, Daniel P. Berrange wrote:
On Wed, Jul 03, 2013 at 09:44:46AM -0400, Chris Evich wrote:
Hi,
On Fedora 18 (libvirt 0.10.2.6-1) I'm trying to add a new serial device to a KVM VM with:
virsh attach-device foobar /tmp/serial.xml
and I keep getting:
error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type
with serial.xml:
<serial type='file'> <source path='/tmp/serialfile'/> <target port='1'/> </serial>
Though I tried it w/o the <target> tag, with and without the --config flag, and with and without the guest running. Assuming it's similar, I tried and was successful in adding this device via virt-manager, though it complains if the VM is running (which is fine).
What am I doing wrong with the virsh attach-device command or XML?
There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML)
Daniel
Oops, sorry, should have been more clear than "and with and without the guest running".
* I see the 'unknown device type' error when guest is running and I run "virsh attach-device foobar /tmp/serial.xml --config".
* I also get 'unknown device type' error when guest is NOT running, and I run "virsh attach...." both with or without '--config' flag.
* I see the 'unknown device type' error inside the "details" window when the guest is running and I use virt-manager.
* I do NOT get any error, and the device is attached, when I use virt-manager, and the guest is NOT running (or by clicking yes after getting error in above bullet).
The main difference in using virt-manager, is that I'm selecting the file type and entering in the values manually instead of in an XML file.
This works as expected. Device attach implementation currently doesn't know how to handle <serial/> or any other character device. It doesn't matter if you're doing --live or --config hotplug. However, if you are trying virt-manager on a not running guest, then I guess virt-manager is just clever enough to redefine the domain and not call any hotplug API. This is equivalent to: # virsh destroy $guest # virsh edit $guest (insert desired chardev XML snippet) # virsh start $guest Michal
A loosely-related problem is with serial-hot plug (which is expected to not work). The error message reported under details is the same/similar 'device type error'. Whereas I was expecting something more specific like a "Can't hotplug this" error (see screenshot).
Yes, the error message can be misleading. Michal

On 07/04/2013 03:43 AM, Michal Privoznik wrote:
On 03.07.2013 20:34, Chris Evich wrote:
On 07/03/2013 09:46 AM, Daniel P. Berrange wrote:
On Wed, Jul 03, 2013 at 09:44:46AM -0400, Chris Evich wrote:
Hi,
On Fedora 18 (libvirt 0.10.2.6-1) I'm trying to add a new serial device to a KVM VM with:
virsh attach-device foobar /tmp/serial.xml
and I keep getting:
error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type
with serial.xml:
<serial type='file'> <source path='/tmp/serialfile'/> <target port='1'/> </serial>
Though I tried it w/o the <target> tag, with and without the --config flag, and with and without the guest running. Assuming it's similar, I tried and was successful in adding this device via virt-manager, though it complains if the VM is running (which is fine).
What am I doing wrong with the virsh attach-device command or XML?
There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML)
Daniel
Oops, sorry, should have been more clear than "and with and without the guest running".
* I see the 'unknown device type' error when guest is running and I run "virsh attach-device foobar /tmp/serial.xml --config".
* I also get 'unknown device type' error when guest is NOT running, and I run "virsh attach...." both with or without '--config' flag.
* I see the 'unknown device type' error inside the "details" window when the guest is running and I use virt-manager.
* I do NOT get any error, and the device is attached, when I use virt-manager, and the guest is NOT running (or by clicking yes after getting error in above bullet).
The main difference in using virt-manager, is that I'm selecting the file type and entering in the values manually instead of in an XML file.
This works as expected. Device attach implementation currently doesn't know how to handle <serial/> or any other character device. It doesn't matter if you're doing --live or --config hotplug. However, if you are trying virt-manager on a not running guest, then I guess virt-manager is just clever enough to redefine the domain and not call any hotplug API. This is equivalent to:
# virsh destroy $guest # virsh edit $guest (insert desired chardev XML snippet) # virsh start $guest
Michal
Thanks. So, possibly virt-manager is trying to do the attach-device thing, failing, then using a different interface. I guess that seems plausible. Though it would be nice if the libvirt docs were updated for this command, explaining it only works for hot-puggable "hardware" whether or not the --config option is used. Also the 'unknown device type' error is certainly troublesome at best, since it clearly does know what the type is, the XML is valid and should parse. In other words, the error is very different from the actual underlying problem, which makes for much more difficult troubleshooting and debugging. Should I open some bugs on this, or would they just get *NTFIX immediately? Thanks again. -- Chris Evich, RHCA, RHCE, RHCDS, RHCSS Quality Assurance Engineer e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214

On 05.07.2013 17:39, Chris Evich wrote:
On 07/04/2013 03:43 AM, Michal Privoznik wrote:
On 03.07.2013 20:34, Chris Evich wrote:
On 07/03/2013 09:46 AM, Daniel P. Berrange wrote:
On Wed, Jul 03, 2013 at 09:44:46AM -0400, Chris Evich wrote:
Hi,
On Fedora 18 (libvirt 0.10.2.6-1) I'm trying to add a new serial device to a KVM VM with:
virsh attach-device foobar /tmp/serial.xml
and I keep getting:
error: Failed to attach device from /tmp/serial.xml error: XML error: unknown device type
with serial.xml:
<serial type='file'> <source path='/tmp/serialfile'/> <target port='1'/> </serial>
Though I tried it w/o the <target> tag, with and without the --config flag, and with and without the guest running. Assuming it's similar, I tried and was successful in adding this device via virt-manager, though it complains if the VM is running (which is fine).
What am I doing wrong with the virsh attach-device command or XML?
There is no support for hotplug of any character device (that covers serial, parallel, console, channnel elements in the XML)
Daniel
Oops, sorry, should have been more clear than "and with and without the guest running".
* I see the 'unknown device type' error when guest is running and I run "virsh attach-device foobar /tmp/serial.xml --config".
* I also get 'unknown device type' error when guest is NOT running, and I run "virsh attach...." both with or without '--config' flag.
* I see the 'unknown device type' error inside the "details" window when the guest is running and I use virt-manager.
* I do NOT get any error, and the device is attached, when I use virt-manager, and the guest is NOT running (or by clicking yes after getting error in above bullet).
The main difference in using virt-manager, is that I'm selecting the file type and entering in the values manually instead of in an XML file.
This works as expected. Device attach implementation currently doesn't know how to handle <serial/> or any other character device. It doesn't matter if you're doing --live or --config hotplug. However, if you are trying virt-manager on a not running guest, then I guess virt-manager is just clever enough to redefine the domain and not call any hotplug API. This is equivalent to:
# virsh destroy $guest # virsh edit $guest (insert desired chardev XML snippet) # virsh start $guest
Michal
Thanks. So, possibly virt-manager is trying to do the attach-device thing, failing, then using a different interface. I guess that seems plausible. Though it would be nice if the libvirt docs were updated for this command, explaining it only works for hot-puggable "hardware" whether or not the --config option is used.
Also the 'unknown device type' error is certainly troublesome at best, since it clearly does know what the type is, the XML is valid and should parse. In other words, the error is very different from the actual underlying problem, which makes for much more difficult troubleshooting and debugging.
Should I open some bugs on this, or would they just get *NTFIX immediately?
Thanks again.
Please do open a bug. Michal
participants (5)
-
Alex Jia
-
Chris Evich
-
Daniel P. Berrange
-
Eric Blake
-
Michal Privoznik