[libvirt] [PATCH 1/2 v3] Fix virDomainChrDefParseTargetXML() to parse the target port if available

Eric Blake eblake at redhat.com
Mon Feb 21 16:01:29 UTC 2011


On 02/21/2011 02:38 AM, Michal Novotny wrote:
> [snip]
>> We've got other code in domain_conf.c that assigns ports
>> to the first available slot; for example, look near line 5628 at how
>> virtio-serial ports are assigned using maxport and traversal of all
>> previously assigned ports.
>>
> Is the code correct there?
> 
> The code is:
> 
>         if (chr->info.type ==
> VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL &&
>             chr->info.addr.vioserial.port == 0) {
>             int maxport = 0;

virtio-serial has to start at port 1 (not 0, which is reserved), so
maxport starts at 0...

>             chr->info.addr.vioserial.port = maxport + 1;

and the assignment guarantees 1 or greater.  But serial and parallel
support port 0, so start maxport at -1  instead of 0, to reuse the same
logic.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110221/7a83cb90/attachment-0001.sig>


More information about the libvir-list mailing list