char *internal = NULL;
char *nic_name = NULL;
char *hostnet_name = NULL;
+ char *vlan = NULL;
if (VIR_ALLOC(def) < 0) {
virReportOOMError(conn);
xmlStrEqual(cur->name, BAD_CAST "state")) {
nic_name = virXMLPropString(cur, "nic");
hostnet_name = virXMLPropString(cur, "hostnet");
+ vlan = virXMLPropString(cur, "vlan");
}
}
cur = cur->next;
def->hostnet_name = hostnet_name;
nic_name = hostnet_name = NULL;
+ def->vlan = -1;
+ if (vlan && virStrToLong_i(vlan, NULL, 10, &def->vlan) < 0) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <state> 'vlan' attribute"));
+ goto error;
+ }
+
switch (def->type) {
case VIR_DOMAIN_NET_TYPE_NETWORK:
if (network == NULL) {
VIR_FREE(internal);
VIR_FREE(nic_name);
VIR_FREE(hostnet_name);
+ VIR_FREE(vlan);
return def;
virBufferEscapeString(buf, " nic='%s'", def->nic_name);
if (def->hostnet_name)
virBufferEscapeString(buf, " hostnet='%s'", def->hostnet_name);
+ if (def->vlan > 0)
+ virBufferVSprintf(buf, " vlan='%d'", def->vlan);
virBufferAddLit(buf, "/>\n");
}
char *nic, *host;
int tapfd = -1;
+ net->vlan = i;
+
if ((qemuCmdFlags & QEMUD_CMD_FLAG_NET_NAME) &&
qemuAssignNetNames(def, net) < 0)
goto no_memory;
- if (qemuBuildNicStr(conn, net, NULL, ',', i, &nic) < 0)
+ if (qemuBuildNicStr(conn, net, NULL, ',', net->vlan, &nic) < 0)
goto error;
ADD_ARG_LIT("-net");
(*tapfds)[(*ntapfds)++] = tapfd;
}
- if (qemuBuildHostNetStr(conn, net, NULL, ',', i, tapfd, &host) < 0)
+ if (qemuBuildHostNetStr(conn, net, NULL, ',',
+ net->vlan, tapfd, &host) < 0)
goto error;
ADD_ARG_LIT("-net");