From 0e30b2fa8676667fc2a0cdfdd179c6ff84047150 Mon Sep 17 00:00:00 2001 From: Lon Hohberger Date: Tue, 1 Sep 2009 15:31:24 -0400 Subject: [PATCH] Move VM naming scheme to top level of config Signed-off-by: Lon Hohberger --- server/libvirt.c | 19 ++++++++++--------- server/mcast.c | 9 ++++++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/server/libvirt.c b/server/libvirt.c index ac4c756..a26b47d 100644 --- a/server/libvirt.c +++ b/server/libvirt.c @@ -352,19 +352,20 @@ libvirt_init(backend_context_t *c, config_object_t *config) printf("Using %s\n", uri); } - if (sc_get(config, "backends/libvirt/@use_uuid", - value, sizeof(value)) == 0) { - use_uuid = atoi(value); - if (use_uuid == 0) { - if (!strcasecmp(value, "true") || - !strcasecmp(value, "yes")) { - use_uuid = 1; - } - } else if (use_uuid < 0) { + /* Naming scheme is a top-level configuration option */ + if ((sc_get(config, "@name_mode", value, sizeof(value)-1) == 0)) { + + dbg_printf(1, "Got %s for name_mode\n", value); + if (!strcasecmp(value, "uuid")) { + use_uuid = 1; + } else if (!strcasecmp(value, "name")) { use_uuid = 0; + } else { + dbg_printf(1, "Unsupported name_mode: %s\n", value); } } + /* We don't need to store the URI; we only use it once */ vp = virConnectOpen(uri); if (!vp) { free(info); diff --git a/server/mcast.c b/server/mcast.c index 8d41352..73b7a45 100644 --- a/server/mcast.c +++ b/server/mcast.c @@ -353,9 +353,12 @@ mcast_config(config_object_t *config, mcast_options *args) } } - args->flags = 0; - if (sc_get(config, "listeners/multicast/@name_mode", - value, sizeof(value)-1) == 0) { + if (sc_get(config, "@name_mode", value, sizeof(value)-1) == 0) { + /* + * This is just an optimization. If an administrator + * configured something at the top level, we can use it + * to explicitly ignore UUID vs. name + */ dbg_printf(1, "Got %s for name_mode\n", value); if (!strcasecmp(value, "uuid")) { args->flags |= RF_UUID;