[libvirt] virtio console: name=foo is not supported

MATSUDA, Daiki matsudadik at intellilink.co.jp
Tue Dec 13 04:02:53 UTC 2011

(2011/12/12 22:58), Daniel P. Berrange wrote:
> On Mon, Dec 12, 2011 at 10:18:23AM +0900, MATSUDA, Daiki wrote:
>>>> In addition, the QEMU guest agent requires specified socket. Virt IO
>>>> Console, too. But unfortunately libvirt does not support to xml tags
>>>> to give socket name options to QEMU for the QEMU guest agent and
>>>> Virt IO Console.
>>> Err, yes we do.
>>>       <channel type='unix'>
>>>         <source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
>>>         <target type='virtio' name='org.qemu.guest_agent.0'/>
>>>       </channel>
>> Yes, I confirmed that it can create the socket for guest agent and
>> communicate to guest.
>>> Or for the console
>>>       <console type='unix'>
>>>         <source mode='bind'
>> path='/var/lib/libvirt/qemu/f16x86_64.console'/>
>>>         <target type='virtio'/>
>>>       </channel>
>>> though you really want to use type=pty for consoles, so that
>> 'virsh console'
>>> works correctly.
>>> Daniel
>> But It is not enough. Because I use the socket for VirtIO console,
>> i.e. gives the option '-device virtconsole,chardev=...,name=foo' for
>> qemu.
>> And I read the source code, but found funny...
>> In src/conf/domain_conf.h, struct _virDomainChrDef is
>> struct _virDomainChrDef {
>>      ...
>>      union {
>>          int port; /* parallel, serial, console */
>>          virSocketAddrPtr addr; /* guestfwd */
>>          char *name; /* virtio */
>>      } target;
>>      ...
>> It is written that virtio must use char *name.
>> But in docs/schemas/domaincommon.rng and others, VirtIO Console use
>> only int port.
>> Thoug I do not understand that which should be used, I attaches the
>> patch for using *name.
> Neither is really relevant for virtio-console, it just provides one or more
> interactive console for admins.
> The name is only relevant when coming to create virtio serial channels
> for non-interactive use. eg the<channel>  elements.
> Daniel

My simple requirement is to give qemu the option such as
-device virtio-serial \
-chardev socket,path=/tmp/foo,server,nowait,id=foo \
-device virtconsole,chardev=foo,name=org.fedoraproject.console.foo
(e.g. http://fedoraproject.org/wiki/Features/VirtioSerial it has a 
little mistake not virtioconsole but virtconsole.)

But current libvirt source code does not accept name=... with 
virtconsole. Because 'virtconsole' is only added on 
qemuBuildVirtioSerialPortDevStr() in src/qemu/qemu_command.c when 
dev->deviceType is VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE and 'name=' is 
only added on some function when dev->deviceType is 

Similarly it is impossible to use <channel> instead of <console> for 
virtconsole because deviceType is set as VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL.

So, if it is possible to take 2 options port and name for <console> 
virtio, could you modify from union to struct on struct _vifDomainChrDef 
in src/conf/domain_conf.h ?


More information about the libvir-list mailing list