[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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

But we're getting closer!

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

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]