From ad664f54ff525b497171edf85a14059e4e860b25 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 8 Jul 2009 17:59:23 -0400 Subject: [PATCH] Fix docs and code disagreements for character devices. The 'pipe' character type wasn't documented. TCP uses a element, not We weren't doing strict validation for protocol and source mode values. --- docs/formatdomain.html | 18 +++++++++++++++++- docs/formatdomain.html.in | 17 ++++++++++++++++- src/domain_conf.c | 23 ++++++++++++++++++----- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.html b/docs/formatdomain.html index bb6da11afe..0b21c6bd25 100644 --- a/docs/formatdomain.html +++ b/docs/formatdomain.html @@ -180,6 +180,8 @@ Pseudo TTY
  • Host device proxy +
  • + Named pipe
  • TCP client/server
  • @@ -877,6 +879,20 @@ qemu-kvm -net nic,model=? /dev/null <source path="/dev/ttyS0"/> <target port="1"/> </serial> + ... +
    + Named pipe +
    +

    + The character device writes output to a named pipe. See pipe(7) for + more info. +

    +
    +      ...
    +      <serial type="pipe">
    +        <source path="/tmp/mypipe"/>
    +        <target port="1"/>
    +      </serial>
           ...
    TCP client/server @@ -889,7 +905,7 @@ qemu-kvm -net nic,model=? /dev/null ... <serial type="tcp"> <source mode="connect" host="0.0.0.0" service="2445"/> - <wiremode type="telnet"/> + <protocol type="telnet"/> <target port="1"/> </serial> ... diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 48d689dff3..191b03e541 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -839,6 +839,21 @@ qemu-kvm -net nic,model=? /dev/null </serial> ... +
    Named pipe
    + +

    + The character device writes output to a named pipe. See pipe(7) for + more info. +

    + +
    +      ...
    +      <serial type="pipe">
    +        <source path="/tmp/mypipe"/>
    +        <target port="1"/>
    +      </serial>
    +      ...
    +
    TCP client/server

    @@ -850,7 +865,7 @@ qemu-kvm -net nic,model=? /dev/null ... <serial type="tcp"> <source mode="connect" host="0.0.0.0" service="2445"/> - <wiremode type="telnet"/> + <protocol type="telnet"/> <target port="1"/> </serial> ... diff --git a/src/domain_conf.c b/src/domain_conf.c index 4056a868e2..f3e4c6c39c 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -1170,6 +1170,7 @@ error: * * * + * * * * @@ -1237,11 +1238,16 @@ virDomainChrDefParseXML(virConnectPtr conn, connectHost = virXMLPropString(cur, "host"); if (connectService == NULL) connectService = virXMLPropString(cur, "service"); - } else { + } else if (STREQ((const char *)mode, "bind")) { if (bindHost == NULL) bindHost = virXMLPropString(cur, "host"); if (bindService == NULL) bindService = virXMLPropString(cur, "service"); + } else { + virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("Unknown source mode '%s'"), + mode); + goto error; } if (def->type == VIR_DOMAIN_CHR_TYPE_UDP) @@ -1320,11 +1326,18 @@ virDomainChrDefParseXML(virConnectPtr conn, bindService = NULL; def->data.tcp.listen = 1; } - if (protocol != NULL && - STREQ(protocol, "telnet")) - def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET; - else + + if (protocol == NULL || + STREQ(protocol, "raw")) def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW; + else if (STREQ(protocol, "telnet")) + def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET; + else { + virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("Unknown protocol '%s'"), protocol); + goto error; + } + break; case VIR_DOMAIN_CHR_TYPE_UDP: