[iwhd] doc: avoid "../iwhd" artifact in generated man page
by Jim Meyering
commit 64aab168216cb2e9776a43f4b4f58e6ad0da4ebb
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Apr 7 19:04:51 2011 +0200
doc: avoid "../iwhd" artifact in generated man page
* man/Makefile.am (iwhd.8): Make help2man run iwhd using its
name, not "../iwhd", so that latter doesn't appear in the
generated man page.
man/Makefile.am | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/man/Makefile.am b/man/Makefile.am
index 8cd0b32..1e40092 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -22,5 +22,6 @@ MAINTAINERCLEANFILES = $(dist_man8_MANS)
iwhd.8: $(top_srcdir)/configure.ac $(top_srcdir)/rest.c
$(AM_V_GEN) \
(echo '[NAME]' && sed 's@/\* *@@; s/-/\\-/; q' $(top_srcdir)/rest.c)|\
- $(HELP2MAN) --no-info -i - -S '$(PACKAGE) $(VERSION)' ../iwhd | \
- sed 's/^\.B info .*/.B info FIXME/' > $@-t && mv $@-t $@
+ PATH=..:$$PATH \
+ $(HELP2MAN) --no-info -i - -S '$(PACKAGE) $(VERSION)' iwhd \
+ > $@-t && mv $@-t $@
13 years
[iwhd] doc: remove from iwhd.8 the reference to texinfo documentation
by Jim Meyering
commit 5bf59b0b9900b7b2657647117a1be0c9ca19db4e
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Apr 7 19:01:10 2011 +0200
doc: remove from iwhd.8 the reference to texinfo documentation
* man/Makefile.am (iwhd.8): Don't refer to texinfo documentation.
man/Makefile.am | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/man/Makefile.am b/man/Makefile.am
index 76e1c2a..8cd0b32 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -22,5 +22,5 @@ MAINTAINERCLEANFILES = $(dist_man8_MANS)
iwhd.8: $(top_srcdir)/configure.ac $(top_srcdir)/rest.c
$(AM_V_GEN) \
(echo '[NAME]' && sed 's@/\* *@@; s/-/\\-/; q' $(top_srcdir)/rest.c)|\
- $(HELP2MAN) -i - -S '$(PACKAGE) $(VERSION)' ../iwhd | \
+ $(HELP2MAN) --no-info -i - -S '$(PACKAGE) $(VERSION)' ../iwhd | \
sed 's/^\.B info .*/.B info FIXME/' > $@-t && mv $@-t $@
13 years
[iwhd] dc-rhev-image: always diagnose OOM
by Jim Meyering
commit 993563078f7c1776557325faab8b39e4afe37bed
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Apr 7 15:30:58 2011 +0200
dc-rhev-image: always diagnose OOM
* dc-rhev-image.c: Include "xalloc.h".
(ensure_path): Use xstrdup, not strdup, so as to exit upon failure.
dc-rhev-image.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index 872ce3b..b9c3479 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -49,6 +49,7 @@
#include "copy-file.h"
#include "progname.h"
#include "dirname.h"
+#include "xalloc.h"
/*
* Note that we almost never prefix with TAG due to compatibility with EC2.
@@ -269,12 +270,8 @@ cfg_veripick(char **cfgval, const char *cfgname, json_t *jcfg,
static void ensure_path(const char *filename)
{
- char *path;
char *s;
-
- path = strdup(filename);
- if (!path)
- return;
+ char *path = xstrdup(filename);
for (s = path; ; s++) {
if (!*s)
break;
13 years
[iwhd] Drop slash from template names.
by Pete Zaitcev
commit 431161d07086b9df973a9bf3de56a88e17c70db4
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Wed Apr 6 23:29:44 2011 -0600
Drop slash from template names.
The 0.92 and HEAD produce an RHEV-M template with a name that starts
with a slash. Looks like another well-meaning change regressing.
dc-rhev-image.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index e944343..36e9940 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -48,6 +48,7 @@
#include "closeout.h"
#include "copy-file.h"
#include "progname.h"
+#include "dirname.h"
/*
* Note that we almost never prefix with TAG due to compatibility with EC2.
@@ -231,6 +232,12 @@ static int path_exists(const char *path)
return access(path, R_OK) == 0;
}
+static const char *image_name(const char *path)
+{
+ const char *b = last_component(path);
+ return *b ? b : "-";
+}
+
static void
cfg_veripick(char **cfgval, const char *cfgname, json_t *jcfg,
const char *cfgtag)
@@ -886,7 +893,6 @@ static void spitovf(struct config *cfg, struct stor_dom *sd,
xmlTextWriterPtr writer;
char uuidbuf[37];
char buf100[100];
- char *s;
char *domdir, *tmpovfdir, *tmpovf, *tmpimgdir, *imgdir, *ovfdir;
int rc;
@@ -980,13 +986,8 @@ static void spitovf(struct config *cfg, struct stor_dom *sd,
rc = xmlTextWriterWriteAttribute(writer,
BAD_CAST "ovf:size", BAD_CAST buf100);
if (rc < 0) goto err_xml;
- /* This is basename(), but we handroll it to make sure, due to BSD. */
- if (!(s = strrchr(cfg->image, '/')) || s[1]==0)
- s = cfg->image;
- else
- s++;
rc = xmlTextWriterWriteAttribute(writer,
- BAD_CAST "ovf:description", BAD_CAST s);
+ BAD_CAST "ovf:description", BAD_CAST image_name(cfg->image));
if (rc < 0) goto err_xml;
rc = xmlTextWriterEndElement(writer); /* close <File> */
if (rc < 0) goto err_xml;
@@ -1070,8 +1071,8 @@ static void spitovf(struct config *cfg, struct stor_dom *sd,
BAD_CAST "ovf:id", BAD_CAST "out");
if (rc < 0) goto err_xml;
- if (!(s = strrchr(cfg->image, '/'))) s = cfg->image;
- rc = xmlTextWriterWriteElement(writer, BAD_CAST "Name", BAD_CAST s);
+ rc = xmlTextWriterWriteElement(writer,
+ BAD_CAST "Name", BAD_CAST image_name(cfg->image));
if (rc < 0) goto err_xml;
uuid_unparse_lower(tpl_uuid, uuidbuf);
13 years
[iwhd] Make directories that we need in export domain.
by Pete Zaitcev
commit d1348eb71f26d7352282d2e84a4f20b09f869f23
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Wed Apr 6 23:32:17 2011 -0600
Make directories that we need in export domain.
We found by trial that RHEV-M creates any directories it needs when they
are needed, but not before. So, a fresh export domain that never hosted
any templates would not have UUID/master, and we need it. The fix is to
create that. Note that we do not create UUID/images, because that is
made when the domain is attached, and one cannot register to an unattached
domain anyhow (because one cannot predict UUID of it).
dc-rhev-image.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index 36e9940..02e6da8 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -267,6 +267,33 @@ cfg_veripick(char **cfgval, const char *cfgname, json_t *jcfg,
*cfgval = tmp;
}
+static void ensure_path(const char *filename)
+{
+ char *path;
+ char *s;
+
+ path = strdup(filename);
+ if (!path)
+ return;
+ for (s = path; ; s++) {
+ if (!*s)
+ break;
+ if (*s == '/')
+ continue;
+ s = strchr(s, '/');
+ if (!s)
+ break;
+ *s = 0;
+ if (mkdir(path, 0770) < 0 && errno != EEXIST) {
+ fprintf(stderr, "ERROR mkdir(%s): %s\n",
+ path, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ *s = '/';
+ }
+ free(path);
+}
+
static size_t api_wcb(void *ptr, size_t bsz, size_t nmemb, void *arg)
{
struct api_buf *bp = arg;
@@ -929,6 +956,12 @@ static void spitovf(struct config *cfg, struct stor_dom *sd,
if (rc < 0)
goto err_alloc;
+ /*
+ * When storage domain is freshly imported, without any VMs,
+ * the RHEV-M may not create the "master/vms/". Pre-create.
+ */
+ ensure_path(ovfdir);
+
now = time(NULL);
gmtime_r(&now, &now_tm);
strftime(now_str, 50, "%Y/%m/%d %H:%M:%S", &now_tm);
13 years
[iwhd] maint: limit scope of backend.c globals
by Jim Meyering
commit bd1c55721b9ccbffeaf535764fb6ff2b0b86ffcb
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Apr 6 13:41:56 2011 +0200
maint: limit scope of backend.c globals
* backend.c (NFSGID): Declare as an enum, rather than via #define.
An enum is easier to reference via debugger.
(hstor, s3_success_pat, s3_failure_pat, regex_ok): Declare static.
backend.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/backend.c b/backend.c
index 7ca4db0..10f6bf9 100644
--- a/backend.c
+++ b/backend.c
@@ -46,9 +46,10 @@
#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
-#define NFSGID 36
+/* FIXME: describe/justify */
+enum { NFSGID = 36 };
-struct hstor_client *hstor;
+static struct hstor_client *hstor;
/***** Generic module stuff, not specific to one back end *****/
@@ -65,9 +66,9 @@ struct hstor_client *hstor;
#define S3_IMAGE_PATTERN "^IMAGE[[:blank:]]+([^[:space:]]+)"
#define S3_ERROR_PATTERN "^ERROR[[:blank:]]+([^[:space:]]+)"
-regex_t s3_success_pat;
-regex_t s3_failure_pat;
-int regex_ok = FALSE;
+static regex_t s3_success_pat;
+static regex_t s3_failure_pat;
+static int regex_ok = FALSE;
void
backend_init (void)
13 years
[iwhd] maint: reduce scope from global to file: client_lock
by Jim Meyering
commit 067ea8abc5a17294b6c9f40b939b4fe916ea8fa5
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Apr 6 13:40:34 2011 +0200
maint: reduce scope from global to file: client_lock
* meta.cpp (client_lock): Declare static.
meta.cpp | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/meta.cpp b/meta.cpp
index aa533c2..e55e5d1 100644
--- a/meta.cpp
+++ b/meta.cpp
@@ -46,7 +46,8 @@ using namespace mongo;
#define SHOW_CONTENTION
-pthread_mutex_t client_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t client_lock = PTHREAD_MUTEX_INITIALIZER;
+
#if defined(SHOW_CONTENTION)
#define CLIENT_LOCK do { \
if (pthread_mutex_trylock(&client_lock) != 0) { \
13 years
[iwhd] maint: eliminate unnecessary global, cfg_file
by Jim Meyering
commit 782aef4955baae328d01f44c8e3a05e776dfdebf
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Apr 6 13:38:34 2011 +0200
maint: eliminate unnecessary global, cfg_file
* rest.c (cfg_file): Move globally-scoped variable into...
(main): ...here.
rest.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/rest.c b/rest.c
index 860ab1c..aa9be64 100644
--- a/rest.c
+++ b/rest.c
@@ -97,7 +97,6 @@ typedef struct {
} rule;
static unsigned short my_port = MY_PORT;
-char *cfg_file = NULL;
static const char *const (reserved_name[]) = {"_default", "_new", "_policy", "_query", NULL};
static const char *const (reserved_attr[]) = {"_attrs", "_bucket", "_date", "_etag", "_key", "_loc", "_size", NULL};
@@ -2288,6 +2287,7 @@ main (int argc, char **argv)
char *stctx = NULL;
char *port_tmp;
bool autostart = false;
+ char *cfg_file = NULL;
set_program_name (argv[0]);
setlocale (LC_ALL, "");
13 years
[iwhd] Match the ERROR tag properly in fs_rhevm_register.
by Pete Zaitcev
commit 9658fec1a097562c58195c968880e8f067fa0d5c
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Wed Apr 6 23:24:16 2011 -0600
Match the ERROR tag properly in fs_rhevm_register.
backend.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/backend.c b/backend.c
index 101f520..c63a0d5 100644
--- a/backend.c
+++ b/backend.c
@@ -1517,7 +1517,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
if (rc == MHD_HTTP_BAD_REQUEST)
rc = MHD_HTTP_OK;
}
- else if (strcmp(buf,"ERROR") == 0) {
+ else if (strncmp(buf,"ERROR",sizeof("ERROR")-1) == 0) {
DPRINTF("found err marker: %s\n",buf+sizeof("ERROR"));
sprintf(ami_id_buf,"failed %.56s",buf+sizeof("ERROR"));
rc = MHD_HTTP_INTERNAL_SERVER_ERROR;
13 years
[iwhd] Mucking around with rc and ret introduced a regression in 0.92: the registration does the right thin
by Pete Zaitcev
commit b56d423864791c3f4b7a30dc07b5e936204b9df2
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Wed Apr 6 23:25:49 2011 -0600
Mucking around with rc and ret introduced a regression in 0.92: the
registration does the right thing, but then reports code 400 to the user.
The trunk code is no better.
The right thing is to reintroduce ret as in 0.92, but do it right.
All we are trying to do is to split a long term accumulator (ret)
and a temporary (rc). Cannot understand why this must be so hard.
backend.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/backend.c b/backend.c
index c63a0d5..7ca4db0 100644
--- a/backend.c
+++ b/backend.c
@@ -1355,7 +1355,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
char *nfs_dir;
const char *conf_name = NULL;
char *conf_text;
- int rc = MHD_HTTP_BAD_REQUEST;
+ int ret = MHD_HTTP_BAD_REQUEST;
const char *argv[12];
unsigned int argc = 0;
pid_t pid;
@@ -1366,6 +1366,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
char *s;
char ami_id_buf[64];
regmatch_t match[2];
+ int rc;
strcpy(ami_id_buf, "none");
@@ -1445,6 +1446,8 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
goto cleanup;
}
+ ret = MHD_HTTP_INTERNAL_SERVER_ERROR;
+
rc = asprintf(&conf_text,
"{\n"
" \"image\" : \"%s/%s\",\n"
@@ -1472,7 +1475,6 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
sprintf(ami_id_buf,"pending %lld",(long long)time(NULL));
DPRINTF("temporary ami-id = \"%s\"\n",ami_id_buf);
(void)meta_set_value(ms->bucket,ms->key,"ami-id",ami_id_buf);
- rc = MHD_HTTP_INTERNAL_SERVER_ERROR;
const char *cmd = "dc-rhev-image";
argv[argc++] = cmd;
@@ -1514,13 +1516,11 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
buf[match[1].rm_eo] = '\0';
DPRINTF("found image UUID: %s\n",buf+match[1].rm_so);
sprintf(ami_id_buf,"OK %.60s",buf+match[1].rm_so);
- if (rc == MHD_HTTP_BAD_REQUEST)
- rc = MHD_HTTP_OK;
+ ret = MHD_HTTP_OK;
}
else if (strncmp(buf,"ERROR",sizeof("ERROR")-1) == 0) {
DPRINTF("found err marker: %s\n",buf+sizeof("ERROR"));
sprintf(ami_id_buf,"failed %.56s",buf+sizeof("ERROR"));
- rc = MHD_HTTP_INTERNAL_SERVER_ERROR;
}
else {
DPRINTF("ignoring line: <%s>\n",buf);
@@ -1555,7 +1555,7 @@ cleanup:
free((char *)conf_name);
(void)meta_set_value(ms->bucket,ms->key,"ami-id",ami_id_buf);
- return rc;
+ return ret;
}
static int
13 years