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

Eric Blake eblake at redhat.com
Fri Feb 18 17:09:46 UTC 2011


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 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/20110218/ef85cd4d/attachment-0001.sig>


More information about the libvir-list mailing list