]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Revert "libxl: implement virDomainInterfaceStats"
authorJim Fehlig <jfehlig@suse.com>
Tue, 8 Dec 2015 15:04:40 +0000 (08:04 -0700)
committerJim Fehlig <jfehlig@suse.com>
Tue, 8 Dec 2015 15:04:40 +0000 (08:04 -0700)
This reverts commit d2e5538b16e325d9095f3ccb0dac88bbd9fc98f0.

A migration regression was introduced by this commit. When migrating
a domain, its active XML is sent to the destination libvirtd, where
it is parsed as inactive XML. d2e5538b copied the libxl generated
interface name into the active config, which was being passed to the
migration destination and being parsed into inactive config. Attempting
to start the config could result in failure if an interface with the
same generated name already exists.

The qemu driver behaves similarly, but the parser contains a hack to
skip interface names starting with 'vnet' when parsing inactive XML.
We could extend the hack to skip names starting with 'vif' too, but a
better fix would be to expose these hypervisor-specific interface name
prefixes in capabilities. See the following discussion thread for more
details

https://www.redhat.com/archives/libvir-list/2015-December/msg00262.html

For the pending 1.3.0 release, it is best to revert d2e5538b. It can
be added again post release, after moving the prefix to capabilities.

src/libxl/libxl_domain.c
src/libxl/libxl_driver.c

index ef929740affdc21ba5245c4fa65f5ceb4190616e..40dcea171c06746d7e49ae3a73a01e0c3d014c4e 100644 (file)
@@ -728,17 +728,6 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
         }
     }
 
-    if ((vm->def->nnets)) {
-        size_t i;
-
-        for (i = 0; i < vm->def->nnets; i++) {
-            virDomainNetDefPtr net = vm->def->nets[i];
-
-            if (STRPREFIX(net->ifname, "vif"))
-                VIR_FREE(net->ifname);
-        }
-    }
-
     if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name) > 0) {
         if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
             VIR_DEBUG("Failed to remove domain XML for %s", vm->def->name);
@@ -898,31 +887,6 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void *for_callback)
     libxl_event_free(ctx, ev);
 }
 
-/*
- * Create interface names for the network devices in parameter def.
- * Names are created with the pattern 'vif<domid>.<devid><suffix>'.
- * devid is extracted from the network devices in the d_config
- * parameter. User-provided interface names are skipped.
- */
-static void
-libxlDomainCreateIfaceNames(virDomainDefPtr def, libxl_domain_config *d_config)
-{
-    size_t i;
-
-    for (i = 0; i < def->nnets && i < d_config->num_nics; i++) {
-        virDomainNetDefPtr net = def->nets[i];
-        libxl_device_nic *x_nic = &d_config->nics[i];
-        const char *suffix =
-            x_nic->nictype != LIBXL_NIC_TYPE_VIF ? "-emu" : "";
-
-        if (net->ifname)
-            continue;
-
-        ignore_value(virAsprintf(&net->ifname, "vif%d.%d%s",
-                                 def->id, x_nic->devid, suffix));
-    }
-}
-
 
 /*
  * Start a domain through libxenlight.
@@ -1063,7 +1027,6 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
     if (libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->deathW))
         goto cleanup_dom;
 
-    libxlDomainCreateIfaceNames(vm->def, &d_config);
 
     if ((dom_xml = virDomainDefFormat(vm->def, 0)) == NULL)
         goto cleanup_dom;
index 05041305a32c878c371cd9676bae16c6a8d7d299..35d7fae892a60db6519468eddeeb541dc47058ff 100644 (file)
@@ -58,7 +58,6 @@
 #include "virhostdev.h"
 #include "network/bridge_driver.h"
 #include "locking/domain_lock.h"
-#include "virstats.h"
 
 #define VIR_FROM_THIS VIR_FROM_LIBXL
 
@@ -4643,56 +4642,6 @@ libxlDomainIsUpdated(virDomainPtr dom)
     return ret;
 }
 
-static int
-libxlDomainInterfaceStats(virDomainPtr dom,
-                          const char *path,
-                          virDomainInterfaceStatsPtr stats)
-{
-    libxlDriverPrivatePtr driver = dom->conn->privateData;
-    virDomainObjPtr vm;
-    ssize_t i;
-    int ret = -1;
-
-    if (!(vm = libxlDomObjFromDomain(dom)))
-        goto cleanup;
-
-    if (virDomainInterfaceStatsEnsureACL(dom->conn, vm->def) < 0)
-        goto cleanup;
-
-    if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
-        goto cleanup;
-
-    if (!virDomainObjIsActive(vm)) {
-        virReportError(VIR_ERR_OPERATION_INVALID,
-                       "%s", _("domain is not running"));
-        goto endjob;
-    }
-
-    /* Check the path is one of the domain's network interfaces. */
-    for (i = 0; i < vm->def->nnets; i++) {
-        if (vm->def->nets[i]->ifname &&
-            STREQ(vm->def->nets[i]->ifname, path)) {
-            ret = 0;
-            break;
-        }
-    }
-
-    if (ret == 0)
-        ret = virNetInterfaceStats(path, stats);
-    else
-        virReportError(VIR_ERR_INVALID_ARG,
-                       _("'%s' is not a known interface"), path);
-
- endjob:
-    if (!libxlDomainObjEndJob(driver, vm))
-        vm = NULL;
-
- cleanup:
-    if (vm)
-        virObjectUnlock(vm);
-    return ret;
-}
-
 static int
 libxlDomainGetTotalCPUStats(libxlDriverPrivatePtr driver,
                             virDomainObjPtr vm,
@@ -5474,7 +5423,6 @@ static virHypervisorDriver libxlHypervisorDriver = {
     .nodeGetCellsFreeMemory = libxlNodeGetCellsFreeMemory, /* 1.1.1 */
     .domainMemoryStats = libxlDomainMemoryStats, /* 1.3.0 */
     .domainGetCPUStats = libxlDomainGetCPUStats, /* 1.3.0 */
-    .domainInterfaceStats = libxlDomainInterfaceStats, /* 1.3.0 */
     .connectDomainEventRegister = libxlConnectDomainEventRegister, /* 0.9.0 */
     .connectDomainEventDeregister = libxlConnectDomainEventDeregister, /* 0.9.0 */
     .domainManagedSave = libxlDomainManagedSave, /* 0.9.2 */