]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
read network config in OpenVZ driver
authorDaniel Veillard <veillard@redhat.com>
Mon, 22 Sep 2008 15:21:44 +0000 (15:21 +0000)
committerDaniel Veillard <veillard@redhat.com>
Mon, 22 Sep 2008 15:21:44 +0000 (15:21 +0000)
* src/openvz_conf.c: patch from Evgeniy Sokolov to read
  network config in OpenVZ driver.
Daniel

ChangeLog
NEWS
src/openvz_conf.c

index 1a919a0ba962ed20ef4ce2b58b2f994d1c38a95f..15f5092ee59c5f0cd08ddbc5390541f1a86420c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Sep 22 17:14:25 CEST 2008 Daniel Veillard <veillard@redhat.com>
+
+       * src/openvz_conf.c: patch from Evgeniy Sokolov to read
+         network config in OpenVZ driver.
+
 Thu Sep 18 11:19:00 BST 2008 Daniel P. Berrange <berrange@redhat.com>
 
        * libvirt.spec.in: Remove commands which were deleting
diff --git a/NEWS b/NEWS
index 34bab84d04dfb2bb4a8e41f147d2c0592a2a3f4a..771519e0ea0888ec63445a015406e273e9fc416f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,100 @@
        http://libvirt.org/news.html
 
 
+0.4.5: Sep 8 2008:
+   - New features: NETNS support for Linux containers (Dan Smith),
+          unified XML domain and network parsing for all drivers (Daniel
+          Berrange), OpenVZ features improvements (Evgeniy Sokolov),
+          OpenVZ and Linux containers support now default, USB device
+          passthrough for QEmu/KVM (Guido Günther), storage pool source
+          discovery (David Lively)
+   - Portability: fixes for MinGW (Atsushi SAKAI and Daniel Berrange),
+          detection of xen lib improvement (David Lively),
+          storage backend portability for SLES (David Lively),
+          fix make distclean and distcheck (Jim Meyering),
+          fix build failures on RHEL4, lot of MinGW portability fixes (Atsushi
+          SAKAI and Daniel Berrange), HTML generation fix, -lpthread explicit
+          linking when needed (Jim Meyering)
+   - Documentation: various typo fixes (Anton Protopopov, Toth
+          István, Atsushi SAKAI, Nguyen Anh Quynh),
+          Java bindings docs, remove Xen centric
+          comments (Guido Günther), various typo in comments (Chris
+          Lalancette), docs and API comments fixes (Charles Duffy),
+          how to contribute to open source link (Richard Jones),
+          memory unit fixups (matthew chan)
+   - Bug fixes: memory leaks and testing for OOM (Daniel Berrange),
+          do_open driver bug(Evgeniy Sokolov), don't use polkit auth when
+          running as non-root (Daniel Berrange), boot of CDRom devices
+          in QEmu/KVM (Daniel Berrange), fix OpenVZ probe function (Evgeniy
+          Sokolov), ID related lookup fixes in OpenVZ (Evgeniy Sokolov),
+          pool cration for netfs (Cole Robinson), check for migrate support
+          with QEmu (Guido Günther), check against double create with QEmu
+          (Guido Günther), broken open failure detection in QEmu (Guido
+          Günther), UUID string conversions in QEmu (Guido Günther),
+          various small cleanup and bug fixes (Daniel Berrange), ID
+          related fixes in the test driver (Daniel Berrange), better error
+          reporting on XML parsing (Daniel Berrange), empty CD-ROM source
+          device section (Chris Lalancette), avoid crashes for interface
+          without a name in QEmu (Guido Günther), provide the real
+          vncport (Charles Duffy), fix forward delay (Daniel Berrange),
+          new VM state is initialized to be SHUTOFF (Daniel Berrange),
+          virsh attach-disk bug fixes (Chris Lalancette), veth clash
+          of device names (Dan Smith), connection lookup fixes on
+          storage creation (Cole Robinson), parted call fix (Cole Robinson),
+          use "server" option when using serial/telnet with QEmu (Mark
+          McLoughlin), duplicate virInitialize calls (Nguyen Anh Quynh),
+          many fixes to virExec and related functions (Daniel Berrange),
+          size of disk without partitions (Cole Robinson), creating and
+          cleaning up logical volumes with target path (Cole Robinson),
+          fix reporting of virConnectOpen problems (Daniel Berrange),
+          veth cleanup at shutdown (Dan Smith), lookup of Xen VMs after define
+          (Cole Robinson), fix emulator reported capabilities (Cole Robinson),
+          avoid segfault on KVM CD eject (Cole Robinson), fix disk ordering
+          and avoid duplicate in QEmu XML parsing (Cole Robinson), update
+          domain XML after device hotplug (Cole Robinson), use poweroff instead
+          of halt when shutting down a Xen domain (John Levon), don't dump core
+          of Xen domain live by default (John Levon), vgcreate command line
+          size bug (Jim Fehlig),  signed/unsigned issue in probing file
+          (Cole Robinson), Fix Xen domains without PVFB console (Daniel
+          Berrange), OpenVZ config read bug fix (Evgeniy Sokolov).
+          
+   - Improvements: improved failure diagnostic for TAP (Jim Meyering),
+          better exec and error diagnostic for OpenVZ commands (Evgeniy
+          Sokolov), OpenVZ auto start and stop of domains (Evgeniy Sokolov),
+          OpenVZ domain cpu time consumption (Evgeniy Sokolov), virsh
+          shutdown improvements and test (Jim Meyering), better report of
+          XML well formedness errors (Richard Jones), new XML elements
+          (Daniel Berrange), virsh "edit" command (Richard Jones), save
+          UUID of OpenVZ domains (Evgeniy Sokolov), improve xen blocks
+          statistics (Chris Lalancette), gnulib updates (Jim Meyering),
+          allow to add disk as USB devices (Guido Günther), LXC container
+          process should survive libvirtd restarts (Daniel Berrange), allow
+          to define static host domain configs, number of CPU used by
+          OpenVZ domains (Evgeniy Sokolov), private root fs for LXC (Daniel
+          Berrange), storage source information in storage pools (David Lively),
+          virsh reports attach and detach success (Cole Robinson), detect
+          failure in QEmu eject command (Cole Robinson), add support for
+          eect on floppy and SCSI cdroms for QEmu (Cole Robinson), LXC
+          hypervisor version extraction (Dan Smith), Augeas config file support
+          (Daniel Berrange), support for a domain name in network
+          config (JJ Reynolds).
+   - Cleanups: Python verbosity cleanup (Ryan Scott),
+          space and tabs cleanups (Atsushi SAKAI), OpenVZ and LXC drivers
+          cleanup and unification of XML handling (Daniel Berrange), updates
+          to Relax-NG XML schemas (John Levon and Daniel Berrange), more
+          printf format checkings (Jim Meyering), VIR_FREE related cleanups
+          (Jim Meyering), integer string parsing cleanup (Evgeniy Sokolov),
+          initial OpenVZ xml refactoring (Evgeniy Sokolov), better error
+          message on domain redefine (Charles Duffy), check XML files against
+          the RNG Schemas (Daniel Berrange), const-correctness in virsh
+          (Richard Jones and Jim Meyering), const-correctness and cleanups
+          in LXC and OpenVZ drivers (Daniel Berrange), virFileLinkPointsTo
+          rewrite (Jim Meyering), cleanup of the conditional compilation
+          of C files (Daniel Berrange), shell quoting fixes (Jim Meyering),
+          parallel build support (James Morris and Jim Meyering), new
+          convenenience virFileReadLimFD function (Jim Meyering).  
+
+
 0.4.4: Jun 25 2008:
    - Bug fixes: QEmu network serialization (Kaitlin Rupert), internal
           memory allocation fixes (Chris Lalancette Jim Meyering), virsh
index 34c77b1f649712471962d94e8e30b992a9a01a5c..aa8493a85dee48e7b5cbb5f376af7a2753fc8aad 100644 (file)
@@ -151,6 +151,146 @@ char *openvzMacToString(const unsigned char *mac)
     return strdup(str);
 }
 
+/*parse MAC from view: 00:18:51:8F:D9:F3
+  return -1 - error
+          0 - OK
+*/
+static int openvzParseMac(const char *macaddr, unsigned char *mac)
+{
+    int ret;
+    ret = sscanf((const char *)macaddr, "%02X:%02X:%02X:%02X:%02X:%02X",
+               (unsigned int*)&mac[0],
+               (unsigned int*)&mac[1],
+               (unsigned int*)&mac[2],
+               (unsigned int*)&mac[3],
+               (unsigned int*)&mac[4],
+               (unsigned int*)&mac[5]) ;
+    if (ret == 6)
+        return 0;
+
+    return -1;
+}
+
+static virDomainNetDefPtr
+openvzReadNetworkConf(virConnectPtr conn, int veid) {
+    int ret;
+    virDomainNetDefPtr net = NULL;
+    virDomainNetDefPtr new_net;
+    char temp[4096];
+    char *token, *saveptr = NULL;
+
+    /*parse routing network configuration*
+     * Sample from config:
+     *   IP_ADDRESS="1.1.1.1 1.1.1.2"
+     *   splited IPs by space
+     */
+    ret = openvzReadConfigParam(veid, "IP_ADDRESS", temp, sizeof(temp));
+    if (ret < 0) {
+        openvzError(conn, VIR_ERR_INTERNAL_ERROR,
+                 _("Cound not read 'IP_ADDRESS' from config for container %d"),
+                  veid);
+        goto error;
+    } else if (ret > 0) {
+        token = strtok_r(temp, " ", &saveptr);
+        while (token != NULL) {
+            new_net = NULL;
+            if (VIR_ALLOC(new_net) < 0)
+                goto no_memory;
+            new_net->next = net;
+            net = new_net;
+
+            net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
+            net->data.ethernet.ipaddr = strdup(token);
+
+            if (net->data.ethernet.ipaddr == NULL)
+                goto no_memory;
+
+            token = strtok_r(NULL, " ", &saveptr);
+        }
+    }
+
+    /*parse bridge devices*/
+    /*Sample from config:
+     *NETIF="ifname=eth10,mac=00:18:51:C1:05:EE,host_ifname=veth105.10,host_mac=00:18:51:8F:D9:F3"
+     *devices splited by ';'
+     */
+    ret = openvzReadConfigParam(veid, "NETIF", temp, sizeof(temp));
+    if (ret < 0) {
+        openvzError(conn, VIR_ERR_INTERNAL_ERROR,
+                     _("Cound not read 'NETIF' from config for container %d"),
+                     veid);
+        goto error;
+    } else if (ret > 0) {
+        token = strtok_r(temp, ";", &saveptr);
+        while (token != NULL) {
+            /*add new device to list*/
+            new_net = NULL;
+            if (VIR_ALLOC(new_net) < 0)
+                goto no_memory;
+            new_net->next = net;
+            net = new_net;
+
+            net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
+
+            char *p = token, *next = token;
+            char cpy_temp[32];
+            int len;
+
+            /*parse string*/
+            do {
+                while (*next != '\0' && *next != ',') next++;
+                if (STRPREFIX(p, "ifname=")) {
+                    p += 7;
+                    len = next - p;
+                    if (len > 16) {
+                        openvzError(conn, VIR_ERR_INTERNAL_ERROR,
+                                _("Too long network device name"));
+                        goto error;
+                    }
+
+                    if (VIR_ALLOC_N(net->data.bridge.brname, len+1) < 0)
+                        goto no_memory;
+
+                    strncpy(net->data.bridge.brname, p, len);
+                    net->data.bridge.brname[len] = '\0';
+                } else if (STRPREFIX(p, "host_ifname=")) {
+                    p += 12;
+                    //skip in libvirt
+                } else if (STRPREFIX(p, "mac=")) {
+                    p += 4;
+                    len = next - p;
+                    if (len != 17) { //should be 17
+                        openvzError(conn, VIR_ERR_INTERNAL_ERROR,
+                              _("Wrong length MAC address"));
+                        goto error;
+                    }
+                    strncpy(cpy_temp, p, len);
+                    cpy_temp[len] = '\0';
+                    if (openvzParseMac(cpy_temp, net->mac)<0) {
+                        openvzError(conn, VIR_ERR_INTERNAL_ERROR,
+                              _("Wrong MAC address"));
+                        goto error;
+                    }
+                } else if (STRPREFIX(p, "host_mac=")) {
+                    p += 9;
+                    //skip in libvirt
+                }
+                p = ++next;
+            } while (p < token + strlen(token));
+
+            token = strtok_r(NULL, ";", &saveptr);
+        }
+    }
+
+    return net;
+no_memory:
+    openvzError(conn, VIR_ERR_NO_MEMORY, NULL);
+error:
+    virDomainNetDefFree(net);
+    return NULL;
+}
+
+
 /* Free all memory associated with a openvz_driver structure */
 void
 openvzFreeDriver(struct openvz_driver *driver)
@@ -243,6 +383,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
 
         /* XXX load rest of VM config data .... */
 
+        dom->def->nets = openvzReadNetworkConf(NULL, veid);
+
         if (prev) {
             prev->next = dom;
         } else {