From nobody Thu May 15 17:16:51 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1505209104563281.0501546240555; Tue, 12 Sep 2017 02:38:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48C3F13A54; Tue, 12 Sep 2017 09:38:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0708F5C1A1; Tue, 12 Sep 2017 09:38:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 38C50180884A; Tue, 12 Sep 2017 09:38:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8C9X6uv005438 for ; Tue, 12 Sep 2017 05:33:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6764B6062A; Tue, 12 Sep 2017 09:33:06 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCF3D17CD7; Tue, 12 Sep 2017 09:33:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 48C3F13A54 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 12 Sep 2017 11:32:52 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH 4/5] conf: Allow usernet to have an address X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 12 Sep 2017 09:38:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1075520 Currently, all that users can specify for an interface type of 'user' is the common attributes: PCI address, NIC model (and that's basically it). However, some need to configure other address range than the default one. Signed-off-by: Michal Privoznik --- Notes: Frankly, I'm not that convinced about this one. I mean, this puts IP addresses into net->hostIP while we are configuring guest side of the SLIRP. However, it just feels better to have the IP addresses under than under . Which actually is the other option. So it's either: =20 =20 for net->hostIP, or it's: =20 =20 for net->guestIP. I went for the former one, but I don't have a strong opinion on that. docs/formatdomain.html.in | 13 ++++++- docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 5 +-- .../qemuxml2argv-net-user-addr.xml | 42 ++++++++++++++++++= ++++ .../qemuxml2xmlout-net-user-addr.xml | 1 + tests/qemuxml2xmltest.c | 1 + 6 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-user-addr.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-user-addr.x= ml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8ca7637a4..65a8886ee 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4701,7 +4701,14 @@ starting from 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 t= heir - VMs to have outgoing access. + VMs to have outgoing access. However, since + 3.8.0, it is possible to override the default network by + including source element. The element can have ip= + element for each IPv4 and IPv6. The element has family + attribute which accepts ipv4 and ipv6 valu= es. + Then there's address attribute for specifying IP address + corresponding to the family. Optionally, the default prefix length c= an be + overridden via prefix attribute.

=20
@@ -4711,6 +4718,10 @@
   ...
   <interface type=3D'user'>
     <mac address=3D"00:11:22:33:44:55"/>
+    <source>
+      <ip family=3D'ipv4' address=3D'172.17.2.0' prefix=3D'24'/>
+      <ip family=3D'ipv6' address=3D'2001:db8:ac10:fd01::' prefix=3D'64=
'/>
+    </source>
   </interface>
 </devices>
 ...
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index c9a4f7a9a..7b5292bd3 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2428,6 +2428,11 @@ user + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 676fc0f34..ef236757a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5214,12 +5214,13 @@ static int virDomainNetDefValidate(const virDomainNetDef *net) { if ((net->hostIP.nroutes || net->hostIP.nips) && - net->type !=3D VIR_DOMAIN_NET_TYPE_ETHERNET) { + net->type !=3D VIR_DOMAIN_NET_TYPE_ETHERNET && + net->type !=3D VIR_DOMAIN_NET_TYPE_USER) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid attempt to set network interface " "host-side IP route and/or address info on " "interface of type '%s'. This is only supported " - "on interfaces of type 'ethernet'"), + "on interfaces of type 'ethernet' and 'user'"), virDomainNetTypeToString(net->type)); return -1; } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user-addr.xml b/tests/= qemuxml2argvdata/qemuxml2argv-net-user-addr.xml new file mode 100644 index 000000000..65362d8aa --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-user-addr.xml @@ -0,0 +1,42 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + +
+ + +
+ + + + + + + + +
+ + + + + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-user-addr.xml b/te= sts/qemuxml2xmloutdata/qemuxml2xmlout-net-user-addr.xml new file mode 120000 index 000000000..fd909ec24 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-user-addr.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/qemuxml2argv-net-user-addr.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 0a87cedf2..99b15ad0c 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -531,6 +531,7 @@ mymain(void) DO_TEST("misc-uuid", NONE); DO_TEST("net-vhostuser", NONE); DO_TEST("net-user", NONE); + DO_TEST("net-user-addr", NONE); DO_TEST("net-virtio", NONE); DO_TEST("net-virtio-device", NONE); DO_TEST("net-virtio-disable-offloads", NONE); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list