From d1dbb3078245b44186f6b3f09b6e66fe98b4bede Mon Sep 17 00:00:00 2001
From: Michal Privoznik 10.0.2.15
. The default router will be
10.0.2.2
and the DNS server will be 10.0.2.3
.
This networking is the only option for unprivileged users who need their
- VMs to have outgoing access.
+ VMs to have outgoing access. Since 3.8.0
+ it is possible to override the default network address by
+ including an ip
element specifying an IPv4
+ address in its one mandatory attribute, address
.
+ Optionally, a second ip
element with a
+ family
attribute set to "ipv6" can be
+ specified to add an IPv6 address to the interface.
+ address
. Optionally, address
+ prefix
can be specified.
@@ -4705,6 +4713,8 @@ ... <interface type='user'> <mac address="00:11:22:33:44:55"/> + <ip family='ipv4' address='172.17.2.0' prefix='24'/> + <ip family='ipv6' address='2001:db8:ac10:fd01::' prefix='64'/> </interface> </devices> ...diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 05f8e9488e..305019b66c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3342,7 +3342,14 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, if (dev->type == VIR_DOMAIN_DEVICE_NET) { const virDomainNetDef *net = dev->data.net; - if (net->guestIP.nroutes || net->guestIP.nips) { + 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")); + goto cleanup; + } + } else if (net->guestIP.nroutes || net->guestIP.nips) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Invalid attempt to set network interface " "guest-side IP route and/or address info, " diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user-addr.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-user-addr.xml new file mode 100644 index 0000000000..0b5f151989 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-user-addr.xml @@ -0,0 +1,41 @@ +