[libvirt] [PATCHv2 05/10] libxl: pass ipaddr to libxl toolstack

Marek Marczykowski-Górecki marmarek at invisiblethingslab.com
Tue Feb 10 02:17:23 UTC 2015


On Thu, Feb 05, 2015 at 03:36:17PM -0700, Jim Fehlig wrote:
> Marek Marczykowski-Górecki wrote:
> > Do not silently ignore its value. LibXL support only one address, so
> > refuse multiple IPs.
> >
> > Signed-off-by: Marek Marczykowski-Górecki <marmarek at invisiblethingslab.com>
> > ---
> >  src/libxl/libxl_conf.c   |  5 +++++
> >  src/libxl/libxl_domain.c | 11 +++++++++++
> >  2 files changed, 16 insertions(+)
> >
> > diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> > index c9f8ad5..4730585 100644
> > --- a/src/libxl/libxl_conf.c
> > +++ b/src/libxl/libxl_conf.c
> > @@ -1133,6 +1133,11 @@ libxlMakeNic(virDomainDefPtr def,
> >          case VIR_DOMAIN_NET_TYPE_ETHERNET:
> >              if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
> >                  return -1;
> > +            if (l_nic->nips > 0) {
> > +                x_nic->ip = virSocketAddrFormat(&l_nic->ips[0]->address);
> > +                if (!x_nic->ip)
> > +                    return -1;
> > +            }
> >   
> 
> IP address should be supported on VIR_DOMAIN_NET_TYPE_NETWORK interface
> types too.  The domainXML docs even contain an example
> 
> http://libvirt.org/formatdomain.html#ipconfig

Updated patch below.

-----8<-----
From c1bd7134d4d70a06229243c41284eb37daa35f38 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
 <marmarek at invisiblethingslab.com>
Date: Thu, 5 Feb 2015 05:59:30 +0100
Subject: [PATCH] libxl: pass ipaddr to libxl toolstack
Cc: Marek Marczykowski-Górecki <marmarek at invisiblethingslab.com>

Do not silently ignore its value. LibXL support only one address, so
refuse multiple IPs.

Signed-off-by: Marek Marczykowski-Górecki <marmarek at invisiblethingslab.com>
---
 src/libxl/libxl_conf.c   | 11 +++++++++++
 src/libxl/libxl_domain.c | 12 ++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index c9f8ad5..ec0f67a 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1133,6 +1133,11 @@ libxlMakeNic(virDomainDefPtr def,
         case VIR_DOMAIN_NET_TYPE_ETHERNET:
             if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
                 return -1;
+            if (l_nic->nips > 0) {
+                x_nic->ip = virSocketAddrFormat(&l_nic->ips[0]->address);
+                if (!x_nic->ip)
+                    return -1;
+            }
             break;
         case VIR_DOMAIN_NET_TYPE_NETWORK:
         {
@@ -1150,6 +1155,12 @@ libxlMakeNic(virDomainDefPtr def,
                 return -1;
             }
 
+            if (l_nic->nips > 0) {
+                x_nic->ip = virSocketAddrFormat(&l_nic->ips[0]->address);
+                if (!x_nic->ip)
+                    return -1;
+            }
+
             if ((brname = virNetworkGetBridgeName(network))) {
                 if (VIR_STRDUP(x_nic->bridge, brname) < 0)
                     fail = true;
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 856cfb4..f0eaf6c 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -482,6 +482,18 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
         STRNEQ(def->os.type, "hvm"))
         dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
 
+    if (dev->type == VIR_DOMAIN_DEVICE_NET &&
+            (dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+             dev->data.net->type == VIR_DOMAIN_NET_TYPE_ETHERNET ||
+             dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK)) {
+        if (dev->data.net->nips > 1) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                    _("multiple IP addresses not supported on device type %s"),
+                    virDomainNetTypeToString(dev->data.net->type));
+            return -1;
+        }
+    }
+
     if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV ||
         (dev->type == VIR_DOMAIN_DEVICE_NET &&
          dev->data.net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) {
-- 
1.8.3.1

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150210/96b6027e/attachment-0001.sig>


More information about the libvir-list mailing list