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

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

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]