This is the mail archive of the
cluster-cvs@sourceware.org
mailing list for the cluster.
cluster: RHEL5 - [fence] fence_xvmd: Add KVM support; misc cleanups.
- From: Lon Hohberger <lon at fedoraproject dot org>
- To: cluster-cvs-relay at redhat dot com
- Date: Thu, 9 Apr 2009 20:41:26 +0000 (UTC)
- Subject: cluster: RHEL5 - [fence] fence_xvmd: Add KVM support; misc cleanups.
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=a72a13f8acd9747fc63299ffd265e3176fb95b52
Commit: a72a13f8acd9747fc63299ffd265e3176fb95b52
Parent: d5dba53a3bc5c20629b449bee5e3b0be4c71b538
Author: Lon Hohberger <lhh@redhat.com>
AuthorDate: Thu Jun 26 11:56:35 2008 -0400
Committer: Lon Hohberger <lhh@redhat.com>
CommitterDate: Thu Apr 9 15:55:15 2009 -0400
[fence] fence_xvmd: Add KVM support; misc cleanups.
* fence_xvmd -h now displays appropriate cluster.conf
related help information.
---
fence/agents/xvm/fence_xvm.c | 8 ++++++++
fence/agents/xvm/fence_xvmd.c | 13 +++++++++----
fence/agents/xvm/options.c | 34 ++++++++++++++++++++++++----------
fence/agents/xvm/options.h | 1 +
fence/agents/xvm/xvm.h | 6 ++++++
5 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/fence/agents/xvm/fence_xvm.c b/fence/agents/xvm/fence_xvm.c
index 898a55f..d1ffb12 100644
--- a/fence/agents/xvm/fence_xvm.c
+++ b/fence/agents/xvm/fence_xvm.c
@@ -328,6 +328,14 @@ main(int argc, char **argv)
if (args.flags & F_HELP) {
args_usage(argv[0], my_options, 0);
+
+ printf("With no command line argument, arguments are "
+ "read from standard input.\n");
+ printf("Arguments read from standard input take "
+ "the form of:\n\n");
+ printf(" arg1=value1\n");
+ printf(" arg2=value2\n\n");
+
args_usage(argv[0], my_options, 1);
exit(0);
}
diff --git a/fence/agents/xvm/fence_xvmd.c b/fence/agents/xvm/fence_xvmd.c
index 1c22039..1ca9e53 100644
--- a/fence/agents/xvm/fence_xvmd.c
+++ b/fence/agents/xvm/fence_xvmd.c
@@ -598,7 +598,7 @@ xvmd_loop(cman_handle_t ch, void *h, int fd, fence_xvm_args_t *args,
virt_list_t *vl = NULL;
virt_state_t *dom = NULL;
- vp = virConnectOpen(NULL);
+ vp = virConnectOpen(args->uri);
if (!vp)
perror("virConnectOpen");
@@ -655,7 +655,7 @@ xvmd_loop(cman_handle_t ch, void *h, int fd, fence_xvm_args_t *args,
continue;
/* Request and/or timeout: open connection */
- vp = virConnectOpen(NULL);
+ vp = virConnectOpen(args->uri);
if (!vp) {
printf("NOTICE: virConnectOpen(): %s; cannot fence!\n",
strerror(errno));
@@ -770,7 +770,7 @@ main(int argc, char **argv)
int mc_sock;
char key[MAX_KEY_LEN];
int key_len = 0, x;
- char *my_options = "dfi:a:p:I:C:c:k:u?hLXV";
+ char *my_options = "dfi:a:p:I:C:U:c:k:u?hLXV";
cman_handle_t ch = NULL;
void *h = NULL;
@@ -788,12 +788,17 @@ main(int argc, char **argv)
}
if (args.flags & F_ERR) {
- args_usage(argv[0], my_options, 0);
return 1;
}
if (args.flags & F_HELP) {
args_usage(argv[0], my_options, 0);
+
+ printf("Arguments may be specified as part of the\n");
+ printf("fence_xvmd tag in cluster.conf in the form of:\n");
+ printf(" <fence_xvmd argname=\"value\" ... />\n\n");
+
+ args_usage(argv[0], my_options, 1);
return 0;
}
diff --git a/fence/agents/xvm/options.c b/fence/agents/xvm/options.c
index 1508206..2c1b5be 100644
--- a/fence/agents/xvm/options.c
+++ b/fence/agents/xvm/options.c
@@ -91,6 +91,8 @@ assign_family(fence_xvm_args_t *args, struct arg_info *arg,
static inline void
assign_address(fence_xvm_args_t *args, struct arg_info *arg, char *value)
{
+ if (args->addr)
+ free(args->addr);
args->addr = strdup(value);
}
@@ -163,6 +165,8 @@ assign_key(fence_xvm_args_t *args, struct arg_info *arg, char *value)
{
struct stat st;
+ if (args->key_file)
+ free(args->key_file);
args->key_file = strdup(value);
if (stat(value, &st) == -1) {
@@ -268,6 +272,18 @@ assign_nocluster(fence_xvm_args_t *args, struct arg_info *arg, char *value)
}
+static inline void
+assign_uri(fence_xvm_args_t *args, struct arg_info *arg, char *value)
+{
+ if (args->uri)
+ free(args->uri);
+
+ /* XXX NO validation yet */
+ args->uri = strdup(value);
+}
+
+
+
/** ALL valid command line and stdin arguments for this fencing agent */
static struct arg_info _arg_info[] = {
{ '\xff', NULL, "agent",
@@ -279,7 +295,7 @@ static struct arg_info _arg_info[] = {
NULL },
{ 'd', "-d", "debug",
- "Enable debugging mode",
+ "Specify (CCS) / increment (command line) debug level",
assign_debug },
{ 'f', "-f", NULL,
@@ -349,6 +365,10 @@ static struct arg_info _arg_info[] = {
{ 'L', "-L", NULL,
"Local mode only (no cluster; implies -X)",
assign_nocluster },
+
+ { 'U', "-U", "uri",
+ "URI for Hypervisor (default: " DEFAULT_HYPERVISOR_URI ")",
+ assign_uri },
{ 'V', "-V", NULL,
"Display version and exit",
@@ -401,7 +421,8 @@ args_init(fence_xvm_args_t *args)
{
args->addr = NULL;
args->domain = NULL;
- args->key_file = DEFAULT_KEY_FILE;
+ args->key_file = strdup(DEFAULT_KEY_FILE);
+ args->uri = strdup(DEFAULT_HYPERVISOR_URI);
args->op = FENCE_REBOOT;
args->hash = DEFAULT_HASH;
args->auth = DEFAULT_AUTH;
@@ -460,14 +481,7 @@ args_usage(char *progname, char *optstr, int print_stdin)
int x;
struct arg_info *arg;
- if (print_stdin) {
- printf("With no command line argument, arguments are "
- "read from standard input.\n");
- printf("Arguments read from standard input take "
- "the form of:\n\n");
- printf(" arg1=value1\n");
- printf(" arg2=value2\n\n");
- } else {
+ if (!print_stdin) {
if (progname) {
printf("usage: %s [args]\n", progname);
} else {
diff --git a/fence/agents/xvm/options.h b/fence/agents/xvm/options.h
index 96b0d07..7687acc 100644
--- a/fence/agents/xvm/options.h
+++ b/fence/agents/xvm/options.h
@@ -36,6 +36,7 @@ typedef struct {
char *addr;
char *domain;
char *key_file;
+ char *uri;
fence_cmd_t op;
fence_hash_t hash;
fence_auth_type_t auth;
diff --git a/fence/agents/xvm/xvm.h b/fence/agents/xvm/xvm.h
index b035d24..4bc267a 100644
--- a/fence/agents/xvm/xvm.h
+++ b/fence/agents/xvm/xvm.h
@@ -56,6 +56,12 @@ typedef enum {
/* FENCE_ON = 0x3 Turn the VM on */
} fence_cmd_t;
+#define DEFAULT_TTL 4
+
+#ifndef DEFAULT_HYPERVISOR_URI
+#define DEFAULT_HYPERVISOR_URI "xen:///"
+#endif
+
#define MAX_HASH_LENGTH SHA512_LENGTH
#define MAX_KEY_LEN 4096