diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/examples/xl.conf | 3 | ||||
| -rw-r--r-- | tools/libxl/libxl.c | 13 | ||||
| -rw-r--r-- | tools/libxl/xl.c | 4 | ||||
| -rw-r--r-- | tools/libxl/xl.h | 1 | ||||
| -rw-r--r-- | tools/libxl/xl_cmdimpl.c | 5 | 
5 files changed, 26 insertions, 0 deletions
| diff --git a/tools/examples/xl.conf b/tools/examples/xl.conf index 09a3d46615..6a520bf24b 100644 --- a/tools/examples/xl.conf +++ b/tools/examples/xl.conf @@ -6,3 +6,6 @@  # full path of the lockfile used by xl during domain creation  #lockfile="/var/lock/xl" + +# default vif script  +#vifscript="vif-bridge" diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 09cf3d948c..1f7a529dbc 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -31,6 +31,8 @@  #include <inttypes.h>  #include <assert.h> +#include <arpa/inet.h> +  #include "libxl.h"  #include "libxl_utils.h"  #include "libxl_internal.h" @@ -1173,6 +1175,7 @@ int libxl_device_nic_init(libxl_device_nic *nic_info, int devnum)      nic_info->mac[5] = r[2];      nic_info->ifname = NULL;      nic_info->bridge = strdup("xenbr0"); +    nic_info->ip.s_addr = 0UL;      if ( asprintf(&nic_info->script, "%s/vif-bridge",                 libxl_xen_script_dir_path()) < 0 )          return ERROR_FAIL; @@ -1232,6 +1235,16 @@ int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic)      flexarray_append(back, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x",                                                   nic->mac[0], nic->mac[1], nic->mac[2],                                                   nic->mac[3], nic->mac[4], nic->mac[5])); +    if (nic->ip.s_addr != 0UL) { +        char dst[INET_ADDRSTRLEN]; +        const char *addr = inet_ntop(AF_INET, &nic->ip.s_addr, &dst[0], INET_ADDRSTRLEN); +        if (addr) { +            flexarray_append(back, "ip"); +            flexarray_append(back, libxl__strdup(&gc, addr)); +        } else { +            LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "Unable to format IP address"); +        } +    }      flexarray_append(back, "bridge");      flexarray_append(back, libxl__strdup(&gc, nic->bridge));      flexarray_append(back, "handle"); diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c index 2ad117f56d..9e3023c629 100644 --- a/tools/libxl/xl.c +++ b/tools/libxl/xl.c @@ -35,6 +35,7 @@  xentoollog_logger_stdiostream *logger;  int autoballoon = 1;  char *lockfile; +char *default_vifscript = NULL;  static xentoollog_level minmsglevel = XTL_PROGRESS; @@ -72,6 +73,9 @@ static void parse_global_config(const char *configfile,          }      } +    if (!xlu_cfg_get_string (config, "vifscript", &buf)) +        default_vifscript = strdup(buf); +      xlu_cfg_destroy(config);  } diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h index bb3aca23ed..653be2e982 100644 --- a/tools/libxl/xl.h +++ b/tools/libxl/xl.h @@ -101,5 +101,6 @@ extern xentoollog_logger_stdiostream *logger;  /* global options */  extern int autoballoon;  extern char *lockfile; +extern char *default_vifscript;  #endif /* XL_H */ diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 3bbd239382..9822e99401 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -798,6 +798,11 @@ static void parse_config_data(const char *configfile_filename_report,              nic = d_config->vifs + d_config->num_vifs;              CHK_ERRNO( libxl_device_nic_init(nic, d_config->num_vifs) ); +            if (default_vifscript) { +                free(nic->script); +                nic->script = strdup(default_vifscript); +            } +              p = strtok(buf2, ",");              if (!p)                  goto skip; | 
