[--target target] [--mac mac] [--script script] [--model model]
[--inbound average,peak,burst,floor] [--outbound average,peak,burst]
[--alias alias] [--managed] [--print-xml]
+ [--source-mode mode]
Attach a new network interface to the domain.
interfaces or bridges,
*hostdev* to indicate connection using a passthrough of PCI device
-on the host.
+on the host,
+
+*vhostuser* to indicate connection using a virtio transport protocol.
``source`` indicates the source of the connection. The source depends
on the type of the interface:
*hostdev* the PCI address of the host's interface formatted
as domain:bus:slot.function.
+*vhostuser* the path to UNIX socket (control plane)
+
``--target`` is used to specify the tap/macvtap device to be used to
connect the domain to the source. Names starting with 'vnet' are
considered as auto-generated and are blanked out/regenerated each
that the interface should be managed, which means detached and reattached
from/to the host by libvirt.
+``--source-mode`` is mandatory for *vhostuser* interface and accepts values
+*server* and *client* that control whether hypervisor waits for the other
+process to connect, or initiates connection, respectively.
+
If ``--print-xml`` is specified, then the XML of the interface that would be
attached is printed instead.
}
+char **
+virshDomainInterfaceSourceModeCompleter(vshControl *ctl G_GNUC_UNUSED,
+ const vshCmd *cmd G_GNUC_UNUSED,
+ unsigned int flags)
+{
+ char **ret = NULL;
+ size_t i;
+
+ virCheckFlags(0, NULL);
+
+ ret = g_new0(char *, VIRSH_DOMAIN_INTERFACE_SOURCE_MODE_LAST);
+
+ for (i = 0; i < VIRSH_DOMAIN_INTERFACE_SOURCE_MODE_LAST; i++)
+ ret[i] = g_strdup(virshDomainInterfaceSourceModeTypeToString(i));
+
+ return ret;
+}
+
+
char **
virshDomainHostnameSourceCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
.type = VSH_OT_BOOL,
.help = N_("libvirt will automatically detach/attach the device from/to host")
},
+ {.name = "source-mode",
+ .type = VSH_OT_STRING,
+ .completer = virshDomainInterfaceSourceModeCompleter,
+ .help = N_("mode attribute of <source/> element")
+ },
{.name = NULL}
};
+VIR_ENUM_IMPL(virshDomainInterfaceSourceMode,
+ VIRSH_DOMAIN_INTERFACE_SOURCE_MODE_LAST,
+ "server",
+ "client");
+
/* parse inbound and outbound which are in the format of
* 'average,peak,burst,floor', in which peak and burst are optional,
* thus 'average,,burst' and 'average,peak' are also legal. */
const char *mac = NULL, *target = NULL, *script = NULL,
*type = NULL, *source = NULL, *model = NULL,
*inboundStr = NULL, *outboundStr = NULL, *alias = NULL;
+ const char *sourceModeStr = NULL;
+ int sourceMode = -1;
virNetDevBandwidthRate inbound, outbound;
virDomainNetType typ;
int ret;
vshCommandOptStringReq(ctl, cmd, "model", &model) < 0 ||
vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 ||
vshCommandOptStringReq(ctl, cmd, "inbound", &inboundStr) < 0 ||
- vshCommandOptStringReq(ctl, cmd, "outbound", &outboundStr) < 0)
+ vshCommandOptStringReq(ctl, cmd, "outbound", &outboundStr) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-mode", &sourceModeStr) < 0)
return false;
/* check interface type */
return false;
}
+ if (sourceModeStr &&
+ (sourceMode = virshDomainInterfaceSourceModeTypeFromString(sourceModeStr)) < 0) {
+ vshError(ctl, _("Invalid source mode: %s"), sourceModeStr);
+ return false;
+ }
+
if (inboundStr) {
memset(&inbound, 0, sizeof(inbound));
if (virshParseRateStr(ctl, inboundStr, &inbound) < 0)
break;
}
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+ if (sourceMode < 0) {
+ vshError(ctl, _("source-mode is mandatory"));
+ return false;
+ }
+ virBufferAsprintf(&buf, "<source type='unix' path='%s' mode='%s'/>\n",
+ source,
+ virshDomainInterfaceSourceModeTypeToString(sourceMode));
+ break;
+
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_ETHERNET:
- case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
case VIR_DOMAIN_NET_TYPE_MCAST: