g_free(def->backend.tap);
g_free(def->backend.vhost);
- g_free(def->teaming.persistent);
+ virDomainNetTeamingInfoFree(def->teaming);
g_free(def->virtPortProfile);
g_free(def->script);
g_free(def->downscript);
}
}
- if (teamingType) {
- int tmpTeaming;
+ if (teamingType || teamingPersistent) {
+ def->teaming = g_new0(virDomainNetTeamingInfo, 1);
- if ((tmpTeaming = virDomainNetTeamingTypeFromString(teamingType)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown teaming type '%s'"),
- teamingType);
- goto error;
+ if (teamingType) {
+ int tmpTeaming;
+
+ if ((tmpTeaming = virDomainNetTeamingTypeFromString(teamingType)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown teaming type '%s'"),
+ teamingType);
+ goto error;
+ }
+ def->teaming->type = tmpTeaming;
}
- def->teaming.type = tmpTeaming;
+
+ def->teaming->persistent = g_steal_pointer(&teamingPersistent);
}
- def->teaming.persistent = g_steal_pointer(&teamingPersistent);
rv = virXPathULong("string(./tune/sndbuf)", ctxt, &def->tune.sndbuf);
if (rv >= 0) {
virBufferAddLit(buf, "</tune>\n");
}
- if (def->teaming.type != VIR_DOMAIN_NET_TEAMING_TYPE_NONE) {
+ if (def->teaming && def->teaming->type != VIR_DOMAIN_NET_TEAMING_TYPE_NONE) {
virBufferAsprintf(buf, "<teaming type='%s'",
- virDomainNetTeamingTypeToString(def->teaming.type));
- virBufferEscapeString(buf, " persistent='%s'", def->teaming.persistent);
+ virDomainNetTeamingTypeToString(def->teaming->type));
+ virBufferEscapeString(buf, " persistent='%s'", def->teaming->persistent);
virBufferAddLit(buf, "/>\n");
}
if (def->linkstate) {
char *tap;
char *vhost;
} backend;
- virDomainNetTeamingInfo teaming;
+ virDomainNetTeamingInfoPtr teaming;
union {
virDomainChrSourceDefPtr vhostuser;
struct {
return -1;
}
- if (net->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT) {
- if (!net->teaming.persistent) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("teaming persistent attribute must be set if teaming type is 'transient'"));
- return -1;
- }
- } else {
- if (net->teaming.persistent) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("teaming persistent attribute not allowed if teaming type is '%s'"),
- virDomainNetTeamingTypeToString(net->teaming.type));
- return -1;
+ if (net->teaming) {
+ if (net->teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT) {
+ if (!net->teaming->persistent) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("teaming persistent attribute must be set if teaming type is 'transient'"));
+ return -1;
+ }
+ } else {
+ if (net->teaming->persistent) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("teaming persistent attribute not allowed if teaming type is '%s'"),
+ virDomainNetTeamingTypeToString(net->teaming->type));
+ return -1;
+ }
}
}
if (net->mtu)
virBufferAsprintf(&buf, ",host_mtu=%u", net->mtu);
- if (net->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT)
+ if (net->teaming && net->teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT)
virBufferAddLit(&buf, ",failover=on");
}
if (qemuBuildRomStr(&buf, dev->info) < 0)
return NULL;
- if (dev->parentnet &&
- dev->parentnet->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT &&
- dev->parentnet->teaming.persistent) {
+ if (dev->parentnet && dev->parentnet->teaming &&
+ dev->parentnet->teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT &&
+ dev->parentnet->teaming->persistent) {
virBufferAsprintf(&buf, ",failover_pair_id=%s",
- dev->parentnet->teaming.persistent);
+ dev->parentnet->teaming->persistent);
}
return virBufferContentAndReset(&buf);
return -1;
}
- if (net->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT &&
+ if (net->teaming && net->teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT &&
actualType != VIR_DOMAIN_NET_TYPE_HOSTDEV) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("interface %s - teaming transient device must be type='hostdev', not '%s'"),
* the device will be auto-unplugged by QEMU during
* migration.
*/
- if (hostdev->parentnet &&
- hostdev->parentnet->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT) {
+ if (hostdev->parentnet && hostdev->parentnet->teaming &&
+ hostdev->parentnet->teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT) {
continue;
}
return -1;
}
- if (net->teaming.type != VIR_DOMAIN_NET_TEAMING_TYPE_NONE &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_FAILOVER)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtio-net failover (teaming) is not supported with this QEMU binary"));
- return -1;
- }
- if (net->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT
- && !virDomainNetIsVirtioModel(net)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("virtio-net teaming persistent interface must be <model type='virtio'/>, not '%s'"),
- virDomainNetGetModelString(net));
- return -1;
- }
- if (net->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT &&
- net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV &&
- net->type != VIR_DOMAIN_NET_TYPE_NETWORK) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("virtio-net teaming transient interface must be type='hostdev', not '%s'"),
- virDomainNetTypeToString(net->type));
- return -1;
+ if (net->teaming) {
+ if (net->teaming->type != VIR_DOMAIN_NET_TEAMING_TYPE_NONE &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_FAILOVER)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtio-net failover (teaming) is not supported with this QEMU binary"));
+ return -1;
+ }
+ if (net->teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT
+ && !virDomainNetIsVirtioModel(net)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("virtio-net teaming persistent interface must be <model type='virtio'/>, not '%s'"),
+ virDomainNetGetModelString(net));
+ return -1;
+ }
+ if (net->teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT &&
+ net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV &&
+ net->type != VIR_DOMAIN_NET_TYPE_NETWORK) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("virtio-net teaming transient interface must be type='hostdev', not '%s'"),
+ virDomainNetTypeToString(net->type));
+ return -1;
+ }
}
if (net->coalesce && !qemuValidateNetSupportsCoalesce(net->type)) {