address of the other end of a point-to-point network device
:since:`(since 2.1.0)`.
-:since:`Since 1.2.12` route elements can also be added to define IP routes to
-add in the guest. The attributes of this element are described in the
-documentation for the ``route`` element in `network
-definitions <formatnetwork.html#static-routes>`__. This is used by the LXC
-driver.
+:since:`Since 1.2.12` route elements can also be added to define IP
+routes to add in the guest. The attributes of this element are
+described in the documentation for the ``route`` element in `network
+definitions <formatnetwork.html#static-routes>`__. This is used by the
+LXC driver for adding general routes within the container. :since:
+'Since 12.2.0' ``route`` elements are also user by the QEMU driver only in the
+case of a passt-based interface (``<backend type='passt'/>``) and only
+for default routes (done by specifying just the ``gateway``).
::
<mac address='52:54:00:3b:83:1a'/>
<source dev='enp1s0'/>
<ip address='10.30.0.5' prefix='24'/>
+ <route gateway='10.30.0.1'/>
</interface>
</devices>
...
}
}
+ /* Add default route(s) */
+ for (i = 0; i < net->guestIP.nroutes; i++) {
+ const virNetDevIPRoute *route = net->guestIP.routes[i];
+ g_autofree char *gateway = NULL;
+
+ if (!(gateway = virSocketAddrFormat(&route->gateway)))
+ return NULL;
+
+ /* validation has already guaranteed that there is at most 1
+ * IPv4 and 1 IPv6 route, and that they are only default
+ * routes (i.e. destination 0.0.0.0/0)
+ */
+
+ virCommandAddArgList(cmd, "--gateway", gateway, NULL);
+ }
+
/* Add port forwarding info */
for (i = 0; i < net->nPortForwards; i++) {
{
bool hasV4Addr = false;
bool hasV6Addr = false;
+ bool hasV4Route = false;
+ bool hasV6Route = false;
size_t i;
if (net->type == VIR_DOMAIN_NET_TYPE_USER ||
}
}
- if (net->guestIP.nroutes) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Invalid attempt to set network interface guest-side IP route, not supported by QEMU"));
- return -1;
+
+ for (i = 0; i < net->guestIP.nroutes; i++) {
+ const virNetDevIPRoute *route = net->guestIP.routes[i];
+
+ if (net->backend.type != VIR_DOMAIN_NET_BACKEND_PASST) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Invalid attempt to set network interface guest-side IP route, not supported for this interface type/backend"));
+ return -1;
+ }
+
+ switch (VIR_SOCKET_ADDR_FAMILY(&route->gateway)) {
+ case AF_INET:
+ if (hasV4Route) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("only one IPv4 default route can be specified for an interface using the passt backend"));
+ return -1;
+ }
+ hasV4Route = true;
+ break;
+ case AF_INET6:
+ if (hasV6Route) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("only one IPv6 default route can be specified for an interface using the passt backend"));
+ return -1;
+ }
+ hasV6Route = true;
+ break;
+ default:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("All <route> elements of an interface using the passt backend must be default routes, with an IPv4 or IPv6 gateway specified"));
+ return -1;
+ }
+
+ /* the only type of route that can be specified for passt is
+ * the default route, so none of the parameters except gateway
+ * are acceptable
+ */
+ if (VIR_SOCKET_ADDR_VALID(&route->address) ||
+ virNetDevIPRouteGetPrefix(route) != 0 ||
+ route->has_metric) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("<route> elements of an interface using the passt backend must be default routes, with only a gateway specified"));
+ return -1;
+ }
}
if (net->type == VIR_DOMAIN_NET_TYPE_VDPA) {
--address 172.17.2.0 \
--netmask 24 \
--address 2001:db8:ac10:fd01::feed \
+--gateway 172.17.2.1 \
--tcp-ports '2001:db8:ac10:fd01::1:10/22:2022,1000-1050,~1020,~1030-1040' \
--udp-ports '1.2.3.4%eth0/5000-5020:6000-6020,~5010-5015' \
--tcp-ports 80 \
<source dev='eth42'/>
<ip address='172.17.2.0' family='ipv4' prefix='24'/>
<ip address='2001:db8:ac10:fd01::feed' family='ipv6'/>
+ <route gateway='172.17.2.1'/>
<portForward proto='tcp' address='2001:db8:ac10:fd01::1:10'>
<range start='22' to='2022'/>
<range start='1000' end='1050'/>
--address 172.17.2.0 \
--netmask 24 \
--address 2001:db8:ac10:fd01::feed \
+--gateway 172.17.2.1 \
--tcp-ports '2001:db8:ac10:fd01::1:10/22:2022,1000-1050,~1020,~1030-1040' \
--udp-ports '1.2.3.4%eth0/5000-5020:6000-6020,~5010-5015' \
--tcp-ports 80 \
<source dev='eth42'/>
<ip address='172.17.2.0' family='ipv4' prefix='24'/>
<ip address='2001:db8:ac10:fd01::feed' family='ipv6'/>
+ <route gateway='172.17.2.1'/>
<portForward proto='tcp' address='2001:db8:ac10:fd01::1:10'>
<range start='22' to='2022'/>
<range start='1000' end='1050'/>
<source dev='eth42'/>
<ip address='172.17.2.0' family='ipv4' prefix='24'/>
<ip address='2001:db8:ac10:fd01::feed' family='ipv6'/>
+ <route gateway='172.17.2.1'/>
<portForward proto='tcp' address='2001:db8:ac10:fd01::1:10'>
<range start='22' to='2022'/>
<range start='1000' end='1050'/>
--address 172.17.2.0 \
--netmask 24 \
--address 2001:db8:ac10:fd01::feed \
+--gateway 2001:db8:ac10:fd01::beef \
--tcp-ports '2001:db8:ac10:fd01::1:10/22:2022,1000-1050,~1020,~1030-1040' \
--udp-ports '1.2.3.4%eth0/5000-5020:6000-6020,~5010-5015' \
--tcp-ports 80 \
<source dev='eth42'/>
<ip address='172.17.2.0' family='ipv4' prefix='24'/>
<ip address='2001:db8:ac10:fd01::feed' family='ipv6'/>
+ <route family='ipv6' gateway='2001:db8:ac10:fd01::beef'/>
<portForward proto='tcp' address='2001:db8:ac10:fd01::1:10'>
<range start='22' to='2022'/>
<range start='1000' end='1050'/>
<mac address='00:11:22:33:44:55'/>
<ip address='172.17.2.0' family='ipv4' prefix='24'/>
<ip address='2001:db8:ac10:fd01::feed' family='ipv6'/>
+ <route family='ipv6' gateway='2001:db8:ac10:fd01::beef'/>
<source dev='eth42'/>
<portForward proto='tcp' address='2001:db8:ac10:fd01::1:10'>
<range start='22' to='2022'/>