[libvirt PATCH v2 9/9] WIP: qemu-slirp: update to follow current spec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

The WIP specification is hosted on slirp wiki at this point:
https://gitlab.freedesktop.org/slirp/libslirp/-/wikis/Slirp-Helper

We would need more feedback from various parties (including libvirt,
podman, and other developpers) before declaring a frozen version.

So for now, follow it, and feedback welcome!

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
 src/qemu/qemu_slirp.c | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c
index e9b23f72a5..5e1fc1cf47 100644
--- a/src/qemu/qemu_slirp.c
+++ b/src/qemu/qemu_slirp.c
@@ -293,35 +293,21 @@ qemuSlirpStart(qemuSlirpPtr slirp,
         const virNetDevIPAddr *ip = net->guestIP.ips[i];
         g_autofree char *addr = NULL;
         const char *opt = "";
+        unsigned prefix = ip->prefix;
 
         if (!(addr = virSocketAddrFormat(&ip->address)))
             return -1;
 
-        if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET))
+        if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET)) {
             opt = "--net";
-        if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET6))
-            opt = "--prefix-ipv6";
-
-        virCommandAddArgFormat(cmd, "%s=%s", opt, addr);
-
-        if (ip->prefix) {
-            if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET)) {
-                virSocketAddr netmask;
-                g_autofree char *netmaskStr = NULL;
-
-                if (virSocketAddrPrefixToNetmask(ip->prefix, &netmask, AF_INET) < 0) {
-                    virReportError(VIR_ERR_INTERNAL_ERROR,
-                                   _("Failed to translate prefix %d to netmask"),
-                                   ip->prefix);
-                    return -1;
-                }
-                if (!(netmaskStr = virSocketAddrFormat(&netmask)))
-                    return -1;
-                virCommandAddArgFormat(cmd, "--mask=%s", netmaskStr);
-            }
-            if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET6))
-                virCommandAddArgFormat(cmd, "--prefix-length-ipv6=%u", ip->prefix);
+            prefix = prefix ?: 24;
+        }
+        if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET6)) {
+            opt = "--net6";
+            prefix = prefix ?: 64;
         }
+
+        virCommandAddArgFormat(cmd, "%s=%s/%u", opt, addr, prefix);
     }
 
     if (qemuSlirpHasFeature(slirp, QEMU_SLIRP_FEATURE_DBUS_ADDRESS)) {
-- 
2.25.0.rc2.1.g09a9a1a997





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux