Fix docs and code disagreements for character devices.

The 'pipe' character type wasn't documented.
TCP uses a <protocol> element, not <wire>
We weren't doing strict validation for protocol and source mode values.
This commit is contained in:
Cole Robinson 2009-07-08 17:59:23 -04:00
parent fe7cb869a8
commit ad664f54ff
3 changed files with 51 additions and 7 deletions

View File

@ -180,6 +180,8 @@
<a href="#elementsCharPTY">Pseudo TTY</a>
</li><li>
<a href="#elementsCharHost">Host device proxy</a>
</li><li>
<a href="#elementsCharPipe">Named pipe</a>
</li><li>
<a href="#elementsCharTCP">TCP client/server</a>
</li><li>
@ -877,6 +879,20 @@ qemu-kvm -net nic,model=? /dev/null
&lt;source path="/dev/ttyS0"/&gt;
&lt;target port="1"/&gt;
&lt;/serial&gt;
...</pre>
<h5>
<a name="elementsCharPipe" id="elementsCharPipe">Named pipe</a>
</h5>
<p>
The character device writes output to a named pipe. See pipe(7) for
more info.
</p>
<pre>
...
&lt;serial type="pipe"&gt;
&lt;source path="/tmp/mypipe"/&gt;
&lt;target port="1"/&gt;
&lt;/serial&gt;
...</pre>
<h5>
<a name="elementsCharTCP" id="elementsCharTCP">TCP client/server</a>
@ -889,7 +905,7 @@ qemu-kvm -net nic,model=? /dev/null
...
&lt;serial type="tcp"&gt;
&lt;source mode="connect" host="0.0.0.0" service="2445"/&gt;
&lt;wiremode type="telnet"/&gt;
&lt;protocol type="telnet"/&gt;
&lt;target port="1"/&gt;
&lt;/serial&gt;
...</pre>

View File

@ -839,6 +839,21 @@ qemu-kvm -net nic,model=? /dev/null
&lt;/serial&gt;
...</pre>
<h5><a name="elementsCharPipe">Named pipe</a></h5>
<p>
The character device writes output to a named pipe. See pipe(7) for
more info.
</p>
<pre>
...
&lt;serial type="pipe"&gt;
&lt;source path="/tmp/mypipe"/&gt;
&lt;target port="1"/&gt;
&lt;/serial&gt;
...</pre>
<h5><a name="elementsCharTCP">TCP client/server</a></h5>
<p>
@ -850,7 +865,7 @@ qemu-kvm -net nic,model=? /dev/null
...
&lt;serial type="tcp"&gt;
&lt;source mode="connect" host="0.0.0.0" service="2445"/&gt;
&lt;wiremode type="telnet"/&gt;
&lt;protocol type="telnet"/&gt;
&lt;target port="1"/&gt;
&lt;/serial&gt;
...</pre>

View File

@ -1170,6 +1170,7 @@ error:
* <serial type="tcp">
* <source mode="bind" host="0.0.0.0" service="2445"/>
* <target port="1"/>
* <protocol type='raw'/>
* </serial>
*
* <serial type="udp">
@ -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: