[libvirt] [PATCH 2/2 v3] Add support for multiple serial ports into the Xen driver

Michal Novotny minovotn at redhat.com
Mon Feb 21 09:16:22 UTC 2011


On 02/18/2011 06:09 PM, Eric Blake wrote:
> On 02/18/2011 07:11 AM, Michal Novotny wrote:
>> Hi,
>> this is the patch to add support for multiple serial ports to the
>> libvirt Xen driver. It support both old style (serial = "pty") and
>> new style (serial = [ "/dev/ttyS0", "/dev/ttyS1" ]) definition and
>> tests for xml2sexpr, sexpr2xml and xmconfig have been added as well.
>>
>> @@ -5991,10 +6031,28 @@ xenDaemonFormatSxpr(virConnectPtr conn,
>>                   virBufferAddLit(&buf, "(parallel none)");
>>               }
>>               if (def->serials) {
>> -                virBufferAddLit(&buf, "(serial ");
>> -                if (xenDaemonFormatSxprChr(def->serials[0],&buf)<  0)
>> -                    goto error;
>> -                virBufferAddLit(&buf, ")");
>> +                if ((def->nserials>  1) || (def->serials[0]->target.port != 0)) {
>> +                    virBufferAddLit(&buf, "(serial (");
>> +                    for (i = 0; i<  def->nserials; i++) {
>> +                        /* If first port is not set we put none instead */
>> +                        if (def->serials[0]->target.port>  i) {
>> +                            int ii;
>> +                            for (ii = 0; ii<  def->serials[0]->target.port - i; ii++)
>> +                                virBufferAddLit(&buf, "none ");
>> +                        }
>> +                        if (xenDaemonFormatSxprChr(def->serials[i],&buf)<  0)
> I don't think we are guaranteed that def->serials[i] are in port order
> (back to my concerns in patch 1/2 about parsing XML that is interleaved
> out of order).  I think you need this pseudocode:
>
> maxport = -1
> foreach i in def->nserials
>    if def->serials[i]->port>  maxport then maxport = def->serials[i]->port
> for i = 0; i<  maxport {
>    foreach j in def->nserials
>      if def->serials[j]->port == i {
>        output def->serials[j]; continue outer loop;
>      }
>    output none
> }
>
> for both sxpr and xm formatters
Oh, ok. Makes sense. Also, I think I'll take your code (XML) from your 
reply on part 1/2 to implement it as another test case because I think 
it may be worth it :)

Michal

-- 
Michal Novotny<minovotn at redhat.com>, RHCE
Virtualization Team (xen userspace), Red Hat




More information about the libvir-list mailing list