diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2011-01-26 16:05:09 +0000 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2011-01-26 16:05:09 +0000 |
commit | 7e65d6104a0f93ca56c357c75a81763626e8dc83 (patch) | |
tree | 3a4519e6233adfde080c70065e32f655a1d1a6be | |
parent | a6998c944c4bbfc13804f20958953cdcd686f762 (diff) | |
download | xen-7e65d6104a0f93ca56c357c75a81763626e8dc83.tar.gz xen-7e65d6104a0f93ca56c357c75a81763626e8dc83.tar.bz2 xen-7e65d6104a0f93ca56c357c75a81763626e8dc83.zip |
xl: avoid creating domains with duplicate names
Do not create the domain if another domain with the same name is already
running.
This is another error-checking function at rather too high a level:
this should be moved into libxl_domain_rename in 4.2.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
-rw-r--r-- | tools/libxl/xl_cmdimpl.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 5826755ee6..76c64084d9 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -583,6 +583,7 @@ static void parse_config_data(const char *configfile_filename_report, XLU_ConfigList *vbds, *nics, *pcis, *cvfbs, *net2s, *cpuids; int pci_power_mgmt = 0; int pci_msitranslate = 1; + uint32_t domid_e; int e; libxl_domain_create_info *c_info = &d_config->c_info; @@ -612,6 +613,15 @@ static void parse_config_data(const char *configfile_filename_report, if (xlu_cfg_replace_string (config, "name", &c_info->name)) c_info->name = strdup("test"); + e = libxl_name_to_domid(&ctx, c_info->name, &domid_e); + if (!e) { + fprintf(stderr, "A domain with name \"%s\" already exists.\n", c_info->name); + exit(1); + } + if (e != ERROR_INVAL) { + fprintf(stderr, "Unexpected error checking for existing domain" + " (error=%d)", e); + } if (!xlu_cfg_get_string (config, "uuid", &buf) ) { if ( libxl_uuid_from_string(&c_info->uuid, buf) ) { |