
pedant's quick glance: ;-) On Thu, Jan 25, 2007 at 03:52:03PM +0000, Mark McLoughlin wrote:
@@ -761,6 +813,61 @@ static int qemudParseXML(struct qemud_se }
+static char * +qemudNetworkIfaceConnect(struct qemud_server *server, + struct qemud_vm *vm, + struct qemud_vm_net_def *net) +{
.....
+ + snprintf(tapfdstr, sizeof(tapfdstr), "tap,fd=%d,script=", tapfd); + + return strdup(tapfdstr); ^^^^^^^^^^^^^^^^^^^ where is allocation check?
if ((p = strdup(tapfdstr))) return p;
+ + no_memory: + qemudReportError(server, VIR_ERR_NO_MEMORY, "tapfds"); + error: + if (tapfd != -1) + close(tapfd); + return NULL; +} @@ -1653,6 +1774,18 @@ char *qemudGenerateXML(struct qemud_serv net->mac[3], net->mac[4], net->mac[5]) < 0) goto no_memory;
+ if (net->type == QEMUD_NET_NETWORK) { + if (qemudBufferPrintf(&buf, " <network name='%s", net->dst.network.name) < 0) + goto no_memory; + + if (net->dst.network.tapifname[0] != '\0' && + qemudBufferPrintf(&buf, " tapifname='%s'", net->dst.network.tapifname) < 0) + goto no_memory; + + if (qemudBufferPrintf(&buf, "/>\n") < 0) + goto no_memory; + } + if (qemudBufferPrintf(&buf, " </interface>\n") < 0) ^^^^^^
There is also BufferAdd() which is cheaper than Printf if you needn't any string formatting.
goto no_memory;
Karel -- Karel Zak <kzak@redhat.com>