summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-03-03 16:58:48 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-03-03 16:58:48 +0000
commit5e8a4627d9f0d313485f186a63dc2250f6fd5c01 (patch)
tree2adfb126d02b7e8ed17d480ada337ed4f107dd35 /src
parent49726b9269490e331e740d55952da87552ca2500 (diff)
downloadlibguestfs-5e8a4627d9f0d313485f186a63dc2250f6fd5c01.tar.gz
libguestfs-5e8a4627d9f0d313485f186a63dc2250f6fd5c01.tar.xz
libguestfs-5e8a4627d9f0d313485f186a63dc2250f6fd5c01.zip
Add a 'fixed' style of appliance.
This is just the 'kernel', 'initrd' and 'root' files, copied from one machine to another, along with a 'README.fixed' file which is also used for identification. This allows the appliance to be copied from one machine to another, making it easier for us to distribute a starter appliance for people who cannot get febootstrap or appliance-building working.
Diffstat (limited to 'src')
-rw-r--r--src/appliance.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/appliance.c b/src/appliance.c
index 50e614fc..a6384c4a 100644
--- a/src/appliance.c
+++ b/src/appliance.c
@@ -49,6 +49,7 @@ static int find_path (guestfs_h *g, int (*pred) (guestfs_h *g, const char *pelem
static int dir_contains_file (const char *dir, const char *file);
static int dir_contains_files (const char *dir, ...);
static int contains_old_style_appliance (guestfs_h *g, const char *path, void *data);
+static int contains_fixed_appliance (guestfs_h *g, const char *path, void *data);
static int contains_supermin_appliance (guestfs_h *g, const char *path, void *data);
static char *calculate_supermin_checksum (guestfs_h *g, const char *supermin_path);
static int check_for_cached_appliance (guestfs_h *g, const char *supermin_path, const char *checksum, uid_t uid, char **kernel, char **initrd, char **appliance);
@@ -61,7 +62,7 @@ static void print_febootstrap_command_line (guestfs_h *g, const char *argv[]);
*
* This function locates or builds the appliance as necessary,
* handling the supermin appliance, caching of supermin-built
- * appliances, or using an old-style appliance.
+ * appliances, or using either a fixed or old-style appliance.
*
* The return value is 0 = good, -1 = error. Returned in '*kernel'
* will be the name of the kernel to use, '*initrd' the name of the
@@ -86,7 +87,10 @@ static void print_febootstrap_command_line (guestfs_h *g, const char *argv[]);
* (4) Try to build the supermin appliance. If this is successful,
* return it.
*
- * (5) Check each element of g->path, looking for an old-style appliance.
+ * (5) Check each element of g->path, looking for a fixed appliance.
+ * If one is found, return it.
+ *
+ * (6) Check each element of g->path, looking for an old-style appliance.
* If one is found, return it.
*
* The supermin appliance cache directory lives in
@@ -163,6 +167,24 @@ guestfs___build_appliance (guestfs_h *g,
/* Step (5). */
char *path;
+ r = find_path (g, contains_fixed_appliance, NULL, &path);
+ if (r == -1)
+ return -1;
+
+ if (r == 1) {
+ size_t len = strlen (path);
+ *kernel = safe_malloc (g, len + 6 /* "kernel" */ + 2);
+ *initrd = safe_malloc (g, len + 6 /* "initrd" */ + 2);
+ *appliance = safe_malloc (g, len + 4 /* "root" */ + 2);
+ sprintf (*kernel, "%s/kernel", path);
+ sprintf (*initrd, "%s/initrd", path);
+ sprintf (*appliance, "%s/root", path);
+
+ free (path);
+ return 0;
+ }
+
+ /* Step (6). */
r = find_path (g, contains_old_style_appliance, NULL, &path);
if (r == -1)
return -1;
@@ -179,7 +201,7 @@ guestfs___build_appliance (guestfs_h *g,
return 0;
}
- error (g, _("cannot find any suitable libguestfs supermin or old-style appliance on LIBGUESTFS_PATH (search path: %s)"),
+ error (g, _("cannot find any suitable libguestfs supermin, fixed or old-style appliance on LIBGUESTFS_PATH (search path: %s)"),
g->path);
return -1;
}
@@ -191,6 +213,14 @@ contains_old_style_appliance (guestfs_h *g, const char *path, void *data)
}
static int
+contains_fixed_appliance (guestfs_h *g, const char *path, void *data)
+{
+ return dir_contains_files (path,
+ "README.fixed",
+ "kernel", "initrd", "root", NULL);
+}
+
+static int
contains_supermin_appliance (guestfs_h *g, const char *path, void *data)
{
return dir_contains_files (path, "supermin.d", NULL);