domain: make port optional for network disks

Only sheepdog actually required it in the code, and we can use 7000 as the
default---the same value that QEMU uses for the simple "sheepdog:VOLUME"
syntax.  With this change, the schema can be fixed to allow no port.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2013-03-21 12:53:51 +01:00 committed by Osier Yang
parent c820fbff9f
commit 8110a8249d
4 changed files with 13 additions and 9 deletions

View File

@ -1700,31 +1700,37 @@
<th> Protocol </th> <th> Protocol </th>
<th> Meaning </th> <th> Meaning </th>
<th> Number of hosts </th> <th> Number of hosts </th>
<th> Default port </th>
</tr> </tr>
<tr> <tr>
<td> nbd </td> <td> nbd </td>
<td> a server running nbd-server </td> <td> a server running nbd-server </td>
<td> only one </td> <td> only one </td>
<td> 10809 </td>
</tr> </tr>
<tr> <tr>
<td> iscsi </td> <td> iscsi </td>
<td> an iSCSI server </td> <td> an iSCSI server </td>
<td> only one </td> <td> only one </td>
<td> 3260 </td>
</tr> </tr>
<tr> <tr>
<td> rbd </td> <td> rbd </td>
<td> monitor servers of RBD </td> <td> monitor servers of RBD </td>
<td> one or more </td> <td> one or more </td>
<td> 6789 </td>
</tr> </tr>
<tr> <tr>
<td> sheepdog </td> <td> sheepdog </td>
<td> one of the sheepdog servers (default is localhost:7000) </td> <td> one of the sheepdog servers (default is localhost:7000) </td>
<td> zero or one </td> <td> zero or one </td>
<td> 7000 </td>
</tr> </tr>
<tr> <tr>
<td> gluster </td> <td> gluster </td>
<td> a server running glusterd daemon </td> <td> a server running glusterd daemon </td>
<td> only one </td> <td> only one </td>
<td> 24007 </td>
</tr> </tr>
</table> </table>
gluster supports "tcp", "rdma", "unix" as valid values for the gluster supports "tcp", "rdma", "unix" as valid values for the

View File

@ -1114,9 +1114,11 @@
<ref name="ipAddr"/> <ref name="ipAddr"/>
</choice> </choice>
</attribute> </attribute>
<optional>
<attribute name="port"> <attribute name="port">
<ref name="unsignedInt"/> <ref name="unsignedInt"/>
</attribute> </attribute>
</optional>
</group> </group>
<group> <group>
<attribute name="transport"> <attribute name="transport">

View File

@ -4111,11 +4111,6 @@ virDomainDiskDefParseXML(virCapsPtr caps,
goto error; goto error;
} }
hosts[nhosts - 1].port = virXMLPropString(child, "port"); hosts[nhosts - 1].port = virXMLPropString(child, "port");
if (!hosts[nhosts - 1].port) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("missing port for host"));
goto error;
}
} }
} }
child = child->next; child = child->next;

View File

@ -2763,7 +2763,8 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
} else { } else {
/* only one host is supported now */ /* only one host is supported now */
virBufferAsprintf(&opt, "file=sheepdog:%s:%s:", virBufferAsprintf(&opt, "file=sheepdog:%s:%s:",
disk->hosts->name, disk->hosts->port); disk->hosts->name,
disk->hosts->port ? disk->hosts->port : "7000");
virBufferEscape(&opt, ',', ",", "%s,", disk->src); virBufferEscape(&opt, ',', ",", "%s,", disk->src);
} }
break; break;