[PATCH 1/3] libxl: add libxl_domain_config to libxlDomainObjPrivate

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

 



This new field in libxlDomainObjPrivate is named "config"
and is kept while the domain is active. For now, "config"
will be used in libxlDomainStartCallback to set
network interface names based on domid and
libxl_device_nic devid that is set in the config on domain
create.

Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
---
 src/libxl/libxl_domain.c | 34 ++++++++++++++++++++++++----------
 src/libxl/libxl_domain.h |  1 +
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 40dcea1..60ef3a0 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -709,6 +709,11 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
 
     vm->def->id = -1;
 
+    if (priv->config) {
+        libxl_domain_config_dispose(priv->config);
+        VIR_FREE(priv->config);
+    }
+
     if (priv->deathW) {
         libxl_evdisable_domain_death(cfg->ctx, priv->deathW);
         priv->deathW = NULL;
@@ -897,7 +902,7 @@ int
 libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
                  bool start_paused, int restore_fd)
 {
-    libxl_domain_config d_config;
+    libxl_domain_config *d_config = NULL;
     virDomainDefPtr def = NULL;
     virObjectEventPtr event = NULL;
     libxlSavefileHeader hdr;
@@ -914,7 +919,10 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
     virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
     libxl_asyncprogress_how aop_console_how;
 
-    libxl_domain_config_init(&d_config);
+    if (VIR_ALLOC(d_config) < 0)
+        return ret;
+
+    libxl_domain_config_init(d_config);
 
     cfg = libxlDriverConfigGet(driver);
     /* If there is a managed saved state restore it instead of starting
@@ -960,10 +968,10 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
     }
 
     if (libxlBuildDomainConfig(driver->reservedGraphicsPorts, vm->def,
-                               cfg->ctx, &d_config) < 0)
+                               cfg->ctx, d_config) < 0)
         goto cleanup;
 
-    if (cfg->autoballoon && libxlDomainFreeMem(cfg->ctx, &d_config) < 0)
+    if (cfg->autoballoon && libxlDomainFreeMem(cfg->ctx, d_config) < 0)
         goto cleanup;
 
     if (virHostdevPrepareDomainDevices(hostdev_mgr, LIBXL_DRIVER_NAME,
@@ -987,19 +995,20 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
     /* Unlock virDomainObj while creating the domain */
     virObjectUnlock(vm);
 
+    priv->config = d_config;
     aop_console_how.for_callback = vm;
     aop_console_how.callback = libxlConsoleCallback;
     if (restore_fd < 0) {
-        ret = libxl_domain_create_new(cfg->ctx, &d_config,
+        ret = libxl_domain_create_new(cfg->ctx, d_config,
                                       &domid, NULL, &aop_console_how);
     } else {
 #ifdef LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS
         params.checkpointed_stream = 0;
-        ret = libxl_domain_create_restore(cfg->ctx, &d_config, &domid,
+        ret = libxl_domain_create_restore(cfg->ctx, d_config, &domid,
                                           restore_fd, &params, NULL,
                                           &aop_console_how);
 #else
-        ret = libxl_domain_create_restore(cfg->ctx, &d_config, &domid,
+        ret = libxl_domain_create_restore(cfg->ctx, d_config, &domid,
                                           restore_fd, NULL, &aop_console_how);
 #endif
     }
@@ -1009,11 +1018,11 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
         if (restore_fd < 0)
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("libxenlight failed to create new domain '%s'"),
-                           d_config.c_info.name);
+                           d_config->c_info.name);
         else
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("libxenlight failed to restore domain '%s'"),
-                           d_config.c_info.name);
+                           d_config->c_info.name);
         goto release_dom;
     }
 
@@ -1061,6 +1070,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
     if (event)
         libxlDomainEventQueue(driver, event);
 
+    d_config = NULL;
     ret = 0;
     goto cleanup;
 
@@ -1078,7 +1088,11 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
     virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState);
 
  cleanup:
-    libxl_domain_config_dispose(&d_config);
+    if (d_config) {
+        libxl_domain_config_dispose(d_config);
+        VIR_FREE(d_config);
+        priv->config = NULL;
+    }
     VIR_FREE(dom_xml);
     VIR_FREE(managed_save_path);
     virDomainDefFree(def);
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 44b3e0b..52ee726 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -65,6 +65,7 @@ struct _libxlDomainObjPrivate {
     libxl_evgen_domain_death *deathW;
     unsigned short migrationPort;
     char *lockState;
+    libxl_domain_config *config;
 
     struct libxlDomainJobObj job;
 };
-- 
2.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]