diff mbox

[3/6] libxl: linux hotplug: clean up get_hotplug_env

Message ID 1465210332-25440-4-git-send-email-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu June 6, 2016, 10:52 a.m. UTC
That get_hotplug_env function is called for both block and nic. Move
some nic specific code out of common code to appropriate place.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl_linux.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Ian Jackson June 14, 2016, 10:20 a.m. UTC | #1
Wei Liu writes ("[PATCH 3/6] libxl: linux hotplug: clean up get_hotplug_env"):
> That get_hotplug_env function is called for both block and nic. Move
> some nic specific code out of common code to appropriate place.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
diff mbox

Patch

diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c
index aed8009..0033a0e 100644
--- a/tools/libxl/libxl_linux.c
+++ b/tools/libxl/libxl_linux.c
@@ -39,12 +39,7 @@  static char **get_hotplug_env(libxl__gc *gc,
     const char *type = libxl__device_kind_to_string(dev->backend_kind);
     char *be_path = libxl__device_backend_path(gc, dev);
     char **env;
-    char *gatewaydev;
     int nr = 0;
-    libxl_nic_type nictype;
-
-    gatewaydev = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/%s", be_path,
-                                                        "gatewaydev"));
 
     const int arraysize = 15;
     GCNEW_ARRAY(env, arraysize);
@@ -56,9 +51,15 @@  static char **get_hotplug_env(libxl__gc *gc,
     env[nr++] = GCSPRINTF("backend/%s/%u/%d", type, dev->domid, dev->devid);
     env[nr++] = "XENBUS_BASE_PATH";
     env[nr++] = "backend";
-    env[nr++] = "netdev";
-    env[nr++] = gatewaydev ? : "";
     if (dev->backend_kind == LIBXL__DEVICE_KIND_VIF) {
+        libxl_nic_type nictype;
+        char *gatewaydev;
+
+        gatewaydev = libxl__xs_read(gc, XBT_NULL,
+                                    GCSPRINTF("%s/%s", be_path, "gatewaydev"));
+        env[nr++] = "netdev";
+        env[nr++] = gatewaydev ? : "";
+
         if (libxl__nic_type(gc, dev, &nictype)) {
             LOG(ERROR, "unable to get nictype");
             return NULL;