From: Wei Liu Date: Mon, 6 Jun 2016 10:52:09 +0000 (+0100) Subject: libxl: linux hotplug: clean up get_hotplug_env X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~957 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5e6e8546cf975b12c36b96c1b495bbfd2f0657f5;p=xen.git 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. Signed-off-by: Wei Liu Acked-by: Ian Jackson --- diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c index aed8009b39..0033a0e4e3 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;