Richard W.M. Jones
2015-Oct-05 12:50 UTC
[Libguestfs] [PATCH] Remove multiple hacks that only apply to RHEL 5.
We don't support RHEL 5 upstream (see the 'oldlinux' branch for a version that works with RHEL 5). Therefore remove a bunch of hacks that were only needed on RHEL 5. --- appliance/packagelist.in | 2 - common-rules.mk | 8 - daemon/parted.c | 455 +++++++++++----------------------------- daemon/swap.c | 18 +- generator/actions.ml | 4 +- generator/ruby.ml | 14 -- run.in | 13 +- src/inspect-apps.c | 13 -- tests/regressions/rhbz975797.sh | 5 +- tests/xml/fake-libvirt-xml.c | 9 - 10 files changed, 129 insertions(+), 412 deletions(-) diff --git a/appliance/packagelist.in b/appliance/packagelist.in index fee6fa0..aa5e07e 100644 --- a/appliance/packagelist.in +++ b/appliance/packagelist.in @@ -28,8 +28,6 @@ ifelse(REDHAT,1, cryptsetup cryptsetup-luks dnl old name used before Fedora 17 dhclient - dnl e4fsprogs only exists on RHEL 5, will be ignored everywhere else. - e4fsprogs genisoimage gfs-utils gfs2-utils diff --git a/common-rules.mk b/common-rules.mk index 312107e..e6b40d1 100644 --- a/common-rules.mk +++ b/common-rules.mk @@ -19,11 +19,3 @@ # cf. 'subdir-rules.mk' -include $(top_builddir)/localenv - -# Old RHEL 5 autoconf defines these, but RHEL 5 automake doesn't -# create variables for them. So define them here if they're not -# defined already. -builddir ?= @builddir@ -abs_builddir ?= @abs_builddir@ -srcdir ?= @srcdir@ -abs_srcdir ?= @abs_srcdir@ diff --git a/daemon/parted.c b/daemon/parted.c index fab3423..df6b7e7 100644 --- a/daemon/parted.c +++ b/daemon/parted.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> +#include <stdbool.h> #include <stdint.h> #include <inttypes.h> #include <string.h> @@ -33,13 +34,6 @@ GUESTFSD_EXT_CMD(str_parted, parted); GUESTFSD_EXT_CMD(str_sfdisk, sfdisk); GUESTFSD_EXT_CMD(str_sgdisk, sgdisk); -enum parted_has_m_opt { - PARTED_INVALID = -1, - /* parted do not support -m option */ - PARTED_OPT_NO_M = 0, - PARTED_OPT_HAS_M = 1, -}; - /* Notes: * * Parted 1.9 sends error messages to stdout, hence use of the @@ -319,43 +313,14 @@ get_table_field (const char *line, int n) return q; } -/* RHEL 5 parted doesn't have the -m (machine readable) option so we - * must do a lot more work to parse the output in - * print_partition_table below. Test for this option the first time - * this function is called. - */ -static enum parted_has_m_opt -test_parted_m_opt (void) -{ - static enum parted_has_m_opt result = PARTED_INVALID; - - if (result >= 0) - return result; - - CLEANUP_FREE char *err = NULL; - int r = commandr (NULL, &err, str_parted, "-s", "-m", "/dev/null", NULL); - if (r == -1) { - /* Test failed, eg. missing or completely unusable parted binary. */ - reply_with_error ("could not run 'parted' command"); - return -1; - } - - if (err && strstr (err, "invalid option -- m")) - result = PARTED_OPT_NO_M; - else - result = PARTED_OPT_HAS_M; - return result; -} - static char * -print_partition_table (const char *device, - enum parted_has_m_opt parted_has_m_opt) +print_partition_table (const char *device, bool add_m_option) { char *out; CLEANUP_FREE char *err = NULL; int r; - if (PARTED_OPT_HAS_M == parted_has_m_opt) + if (add_m_option) r = command (&out, &err, str_parted, "-m", "-s", "--", device, "unit", "b", "print", NULL); @@ -364,15 +329,13 @@ print_partition_table (const char *device, "unit", "b", "print", NULL); if (r == -1) { - /* Hack for parted 1.x which sends errors to stdout. */ - const char *msg = *err ? err : out; int errcode = 0; /* Translate "unrecognised disk label" into an errno code. */ - if (msg && strstr (msg, "unrecognised disk label") != NULL) + if (err && strstr (err, "unrecognised disk label") != NULL) errcode = EINVAL; - reply_with_error_errno (errcode, "parted print: %s: %s", device, msg); + reply_with_error_errno (errcode, "parted print: %s: %s", device, err); free (out); return NULL; } @@ -383,93 +346,46 @@ print_partition_table (const char *device, char * do_part_get_parttype (const char *device) { - enum parted_has_m_opt parted_has_m_opt = test_parted_m_opt (); - if (parted_has_m_opt == PARTED_INVALID) - return NULL; - - CLEANUP_FREE char *out = print_partition_table (device, parted_has_m_opt); + CLEANUP_FREE char *out = print_partition_table (device, true); if (!out) return NULL; - if (PARTED_OPT_HAS_M == parted_has_m_opt) { - /* New-style parsing using the "machine-readable" format from - * 'parted -m'. - */ - CLEANUP_FREE_STRING_LIST char **lines = split_lines (out); - - if (!lines) - return NULL; - - if (lines[0] == NULL || STRNEQ (lines[0], "BYT;")) { - reply_with_error ("unknown signature, expected \"BYT;\" as first line of the output: %s", - lines[0] ? lines[0] : "(signature was null)"); - return NULL; - } - - if (lines[1] == NULL) { - reply_with_error ("parted didn't return a line describing the device"); - return NULL; - } - - /* lines[1] is something like: - * "/dev/sda:1953525168s:scsi:512:512:msdos:ATA Hitachi HDT72101;" - */ - char *r = get_table_field (lines[1], 5); - if (r == NULL) { - return NULL; - } - - /* If "loop" return an error (RHBZ#634246). */ - if (STREQ (r, "loop")) { - free (r); - reply_with_error ("not a partitioned device"); - return NULL; - } - - return r; + CLEANUP_FREE_STRING_LIST char **lines = split_lines (out); + if (!lines) + return NULL; + + if (lines[0] == NULL || STRNEQ (lines[0], "BYT;")) { + reply_with_error ("unknown signature, expected \"BYT;\" as first line of the output: %s", + lines[0] ? lines[0] : "(signature was null)"); + return NULL; } - else { - /* Old-style. Look for "\nPartition Table: <str>\n". */ - char *p = strstr (out, "\nPartition Table: "); - if (!p) { - reply_with_error ("parted didn't return Partition Table line"); - return NULL; - } - p += 18; - char *q = strchr (p, '\n'); - if (!q) { - reply_with_error ("parted Partition Table has no end of line char"); - return NULL; - } - - *q = '\0'; - - p = strdup (p); - if (!p) { - reply_with_perror ("strdup"); - return NULL; - } - - /* If "loop" return an error (RHBZ#634246). */ - if (STREQ (p, "loop")) { - free (p); - reply_with_error ("not a partitioned device"); - return NULL; - } + if (lines[1] == NULL) { + reply_with_error ("parted didn't return a line describing the device"); + return NULL; + } - return p; /* caller frees */ + /* lines[1] is something like: + * "/dev/sda:1953525168s:scsi:512:512:msdos:ATA Hitachi HDT72101;" + */ + char *r = get_table_field (lines[1], 5); + if (r == NULL) + return NULL; + + /* If "loop" return an error (RHBZ#634246). */ + if (STREQ (r, "loop")) { + free (r); + reply_with_error ("not a partitioned device"); + return NULL; } + + return r; } guestfs_int_partition_list * do_part_list (const char *device) { - enum parted_has_m_opt parted_has_m_opt = test_parted_m_opt (); - if (parted_has_m_opt == PARTED_INVALID) - return NULL; - - CLEANUP_FREE char *out = print_partition_table (device, parted_has_m_opt); + CLEANUP_FREE char *out = print_partition_table (device, true); if (!out) return NULL; @@ -480,97 +396,36 @@ do_part_list (const char *device) guestfs_int_partition_list *r; - if (PARTED_OPT_HAS_M == parted_has_m_opt) { - /* New-style parsing using the "machine-readable" format from - * 'parted -m'. - * - * lines[0] is "BYT;", lines[1] is the device line which we ignore, - * lines[2..] are the partitions themselves. Count how many. - */ - size_t nr_rows = 0, row; - for (row = 2; lines[row] != NULL; ++row) - ++nr_rows; - - r = malloc (sizeof *r); - if (r == NULL) { - reply_with_perror ("malloc"); - return NULL; - } - r->guestfs_int_partition_list_len = nr_rows; - r->guestfs_int_partition_list_val - malloc (nr_rows * sizeof (guestfs_int_partition)); - if (r->guestfs_int_partition_list_val == NULL) { - reply_with_perror ("malloc"); - goto error2; - } - - /* Now parse the lines. */ - size_t i; - for (i = 0, row = 2; lines[row] != NULL; ++i, ++row) { - if (sscanf (lines[row], "%d:%" SCNi64 "B:%" SCNi64 "B:%" SCNi64 "B", - &r->guestfs_int_partition_list_val[i].part_num, - &r->guestfs_int_partition_list_val[i].part_start, - &r->guestfs_int_partition_list_val[i].part_end, - &r->guestfs_int_partition_list_val[i].part_size) != 4) { - reply_with_error ("could not parse row from output of parted print command: %s", lines[row]); - goto error3; - } - } + /* lines[0] is "BYT;", lines[1] is the device line which we ignore, + * lines[2..] are the partitions themselves. Count how many. + */ + size_t nr_rows = 0, row; + for (row = 2; lines[row] != NULL; ++row) + ++nr_rows; + + r = malloc (sizeof *r); + if (r == NULL) { + reply_with_perror ("malloc"); + return NULL; + } + r->guestfs_int_partition_list_len = nr_rows; + r->guestfs_int_partition_list_val + malloc (nr_rows * sizeof (guestfs_int_partition)); + if (r->guestfs_int_partition_list_val == NULL) { + reply_with_perror ("malloc"); + goto error2; } - else { - /* Old-style. Start at the line following "^Number", up to the - * next blank line. - */ - size_t start = 0, end = 0, row; - - for (row = 0; lines[row] != NULL; ++row) - if (STRPREFIX (lines[row], "Number")) { - start = row+1; - break; - } - - if (start == 0) { - reply_with_error ("parted output has no \"Number\" line"); - return NULL; - } - - for (row = start; lines[row] != NULL; ++row) - if (STREQ (lines[row], "")) { - end = row; - break; - } - - if (end == 0) { - reply_with_error ("parted output has no blank after end of table"); - return NULL; - } - - size_t nr_rows = end - start; - - r = malloc (sizeof *r); - if (r == NULL) { - reply_with_perror ("malloc"); - return NULL; - } - r->guestfs_int_partition_list_len = nr_rows; - r->guestfs_int_partition_list_val - malloc (nr_rows * sizeof (guestfs_int_partition)); - if (r->guestfs_int_partition_list_val == NULL) { - reply_with_perror ("malloc"); - goto error2; - } - /* Now parse the lines. */ - size_t i; - for (i = 0, row = start; row < end; ++i, ++row) { - if (sscanf (lines[row], " %d %" SCNi64 "B %" SCNi64 "B %" SCNi64 "B", - &r->guestfs_int_partition_list_val[i].part_num, - &r->guestfs_int_partition_list_val[i].part_start, - &r->guestfs_int_partition_list_val[i].part_end, - &r->guestfs_int_partition_list_val[i].part_size) != 4) { - reply_with_error ("could not parse row from output of parted print command: %s", lines[row]); - goto error3; - } + /* Now parse the lines. */ + size_t i; + for (i = 0, row = 2; lines[row] != NULL; ++i, ++row) { + if (sscanf (lines[row], "%d:%" SCNi64 "B:%" SCNi64 "B:%" SCNi64 "B", + &r->guestfs_int_partition_list_val[i].part_num, + &r->guestfs_int_partition_list_val[i].part_start, + &r->guestfs_int_partition_list_val[i].part_end, + &r->guestfs_int_partition_list_val[i].part_size) != 4) { + reply_with_error ("could not parse row from output of parted print command: %s", lines[row]); + goto error3; } } @@ -591,11 +446,7 @@ do_part_get_bootable (const char *device, int partnum) return -1; } - enum parted_has_m_opt parted_has_m_opt = test_parted_m_opt (); - if (parted_has_m_opt == PARTED_INVALID) - return -1; - - CLEANUP_FREE char *out = print_partition_table (device, parted_has_m_opt); + CLEANUP_FREE char *out = print_partition_table (device, true); if (!out) return -1; @@ -604,95 +455,41 @@ do_part_get_bootable (const char *device, int partnum) if (!lines) return -1; - if (PARTED_OPT_HAS_M == parted_has_m_opt) { - /* New-style parsing using the "machine-readable" format from - * 'parted -m'. - * - * Partitions may not be in any order, so we have to look for - * the matching partition number (RHBZ#602997). - */ - if (lines[0] == NULL || STRNEQ (lines[0], "BYT;")) { - reply_with_error ("unknown signature, expected \"BYT;\" as first line of the output: %s", - lines[0] ? lines[0] : "(signature was null)"); - return -1; - } - - if (lines[1] == NULL) { - reply_with_error ("parted didn't return a line describing the device"); - return -1; - } - - size_t row; - int pnum; - for (row = 2; lines[row] != NULL; ++row) { - if (sscanf (lines[row], "%d:", &pnum) != 1) { - reply_with_error ("could not parse row from output of parted print command: %s", lines[row]); - return -1; - } - if (pnum == partnum) - break; - } - - if (lines[row] == NULL) { - reply_with_error ("partition number %d not found", partnum); - return -1; - } - - CLEANUP_FREE char *boot = get_table_field (lines[row], 6); - if (boot == NULL) - return -1; - - return strstr (boot, "boot") != NULL; + /* Partitions may not be in any order, so we have to look for + * the matching partition number (RHBZ#602997). + */ + if (lines[0] == NULL || STRNEQ (lines[0], "BYT;")) { + reply_with_error ("unknown signature, expected \"BYT;\" as first line of the output: %s", + lines[0] ? lines[0] : "(signature was null)"); + return -1; } - else { - /* Old-style: First look for the line matching "^Number". */ - size_t start = 0, header, row; - - for (row = 0; lines[row] != NULL; ++row) - if (STRPREFIX (lines[row], "Number")) { - start = row+1; - header = row; - break; - } - if (start == 0) { - reply_with_error ("parted output has no \"Number\" line"); - return -1; - } + if (lines[1] == NULL) { + reply_with_error ("parted didn't return a line describing the device"); + return -1; + } - /* Now we have to look at the column number of the "Flags" field. - * This is because parted's output has no way to represent a - * missing field except as whitespace, so we cannot just count - * fields from the left. eg. The "File system" field is often - * missing in the output. - */ - char *p = strstr (lines[header], "Flags"); - if (!p) { - reply_with_error ("parted output has no \"Flags\" field"); + size_t row; + int pnum; + for (row = 2; lines[row] != NULL; ++row) { + if (sscanf (lines[row], "%d:", &pnum) != 1) { + reply_with_error ("could not parse row from output of parted print command: %s", lines[row]); return -1; } - size_t col = p - lines[header]; + if (pnum == partnum) + break; + } - /* Partitions may not be in any order, so we have to look for - * the matching partition number (RHBZ#602997). - */ - int pnum; - for (row = start; lines[row] != NULL; ++row) { - if (sscanf (lines[row], " %d", &pnum) != 1) { - reply_with_error ("could not parse row from output of parted print command: %s", lines[row]); - return -1; - } - if (pnum == partnum) - break; - } + if (lines[row] == NULL) { + reply_with_error ("partition number %d not found", partnum); + return -1; + } - if (lines[row] == NULL) { - reply_with_error ("partition number %d not found", partnum); - return -1; - } + CLEANUP_FREE char *boot = get_table_field (lines[row], 6); + if (boot == NULL) + return -1; - return STRPREFIX (&lines[row][col], "boot"); - } + return strstr (boot, "boot") != NULL; } /* Test if sfdisk is recent enough to have --part-type, to be used instead @@ -979,63 +776,51 @@ do_part_get_name (const char *device, int partnum) return NULL; if (STREQ (parttype, "gpt")) { - enum parted_has_m_opt parted_has_m_opt = test_parted_m_opt (); - if (parted_has_m_opt == PARTED_INVALID) - return NULL; - - CLEANUP_FREE char *out = print_partition_table (device, parted_has_m_opt); + CLEANUP_FREE char *out = print_partition_table (device, true); if (!out) return NULL; - if (PARTED_OPT_HAS_M == parted_has_m_opt) { - /* New-style parsing using the "machine-readable" format from - * 'parted -m'. - */ - CLEANUP_FREE_STRING_LIST char **lines = split_lines (out); + CLEANUP_FREE_STRING_LIST char **lines = split_lines (out); - if (!lines) - return NULL; - - if (lines[0] == NULL || STRNEQ (lines[0], "BYT;")) { - reply_with_error ("unknown signature, expected \"BYT;\" as first line of the output: %s", - lines[0] ? lines[0] : "(signature was null)"); - return NULL; - } + if (!lines) + return NULL; - if (lines[1] == NULL) { - reply_with_error ("parted didn't return a line describing the device"); - return NULL; - } + if (lines[0] == NULL || STRNEQ (lines[0], "BYT;")) { + reply_with_error ("unknown signature, expected \"BYT;\" as first line of the output: %s", + lines[0] ? lines[0] : "(signature was null)"); + return NULL; + } - size_t row; - int pnum; - for (row = 2; lines[row] != NULL; ++row) { - if (sscanf (lines[row], "%d:", &pnum) != 1) { - reply_with_error ("could not parse row from output of parted print command: %s", lines[row]); - return NULL; - } - if (pnum == partnum) - break; - } + if (lines[1] == NULL) { + reply_with_error ("parted didn't return a line describing the device"); + return NULL; + } - if (lines[row] == NULL) { - reply_with_error ("partition number %d not found", partnum); + size_t row; + int pnum; + for (row = 2; lines[row] != NULL; ++row) { + if (sscanf (lines[row], "%d:", &pnum) != 1) { + reply_with_error ("could not parse row from output of parted print command: %s", lines[row]); return NULL; } + if (pnum == partnum) + break; + } - char *name = get_table_field (lines[row], 5); - if (name == NULL) - reply_with_error ("cannot get the name field from '%s'", lines[row]); - - return name; + if (lines[row] == NULL) { + reply_with_error ("partition number %d not found", partnum); + return NULL; } + + char *name = get_table_field (lines[row], 5); + if (name == NULL) + reply_with_error ("cannot get the name field from '%s'", lines[row]); + + return name; } else { reply_with_error ("part-get-name can only be used on GUID Partition Tables"); return NULL; } - - reply_with_error ("cannot get the partition name from '%s' layouts", parttype); - return NULL; } char * @@ -1052,7 +837,7 @@ do_part_get_mbr_part_type (const char *device, int partnum) * partition type info. * Use traditional style. */ - CLEANUP_FREE char *out = print_partition_table (device, PARTED_OPT_NO_M); + CLEANUP_FREE char *out = print_partition_table (device, false); if (!out) return NULL; diff --git a/daemon/swap.c b/daemon/swap.c index 26fe30d..9d7839e 100644 --- a/daemon/swap.c +++ b/daemon/swap.c @@ -38,26 +38,10 @@ GUESTFSD_EXT_CMD(str_swaplabel, swaplabel); /* Confirmed this is true for Linux swap partitions from the Linux sources. */ #define SWAP_LABEL_MAX 16 -/* Convenient place to test for the later version of e2fsprogs - * and util-linux which supports -U parameters to specify UUIDs. - * (Not supported in RHEL 5). - */ int optgroup_linuxfsuuid_available (void) { - CLEANUP_FREE char *err = NULL; - int av; - - /* Upstream util-linux have been gradually changing '--help' to go - * from stderr to stdout, and changing the return code from 1 to 0. - * Thus we need to fold stdout and stderr together, and ignore the - * return code. - */ - ignore_value (commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR, - str_mkswap, "--help", NULL)); - - av = strstr (err, "-U") != NULL; - return av; + return 1; } /* Takes optional arguments, consult optargs_bitmask. */ diff --git a/generator/actions.ml b/generator/actions.ml index 12d5e5a..2f29f7a 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -6169,11 +6169,11 @@ the command C<mount -o loop file mountpoint>." }; InitEmpty, Always, TestRun ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkswap"; "/dev/sda1"; "hello"; "NOARG"]]), []; - InitEmpty, IfAvailable "linuxfsuuid", TestResultString ( + InitEmpty, Always, TestResultString ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkswap"; "/dev/sda1"; "NOARG"; uuid]; ["vfs_uuid"; "/dev/sda1"]], uuid), []; - InitEmpty, IfAvailable "linuxfsuuid", TestResultString ( + InitEmpty, Always, TestResultString ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkswap"; "/dev/sda1"; "hello"; uuid]; ["vfs_label"; "/dev/sda1"]], "hello"), [] diff --git a/generator/ruby.ml b/generator/ruby.ml index 87bb34a..cb187b0 100644 --- a/generator/ruby.ml +++ b/generator/ruby.ml @@ -84,20 +84,6 @@ let rec generate_ruby_c () #define RSTRING_PTR(r) (RSTRING((r))->ptr) #endif -/* For RHEL 5 (Ruby 1.8.5) */ -#ifndef HAVE_RB_HASH_LOOKUP -VALUE -rb_hash_lookup (VALUE hash, VALUE key) -{ - volatile VALUE val; - - if (!st_lookup (RHASH(hash)->tbl, key, &val)) - return Qnil; - - return val; -} -#endif /* !HAVE_RB_HASH_LOOKUP */ - static VALUE m_guestfs; /* guestfs module */ static VALUE c_guestfs; /* guestfs_h handle */ static VALUE e_Error; /* used for all errors */ diff --git a/run.in b/run.in index 42f8cc8..46dbaf0 100755 --- a/run.in +++ b/run.in @@ -238,14 +238,11 @@ fi timeout_period=4h timeout_kill=30s -# Do we have Padraig's timeout utility (from coreutils)? -if timeout --help >/dev/null 2>&1; then - # Must use the --foreground option (RHBZ#1025269). - if timeout --foreground 2 sleep 0 >/dev/null 2>&1; then - # Does this version of timeout have the -k option? (Not on RHEL 6) - if timeout -k 10s 10s true >/dev/null 2>&1; then - timeout="timeout --foreground -k $timeout_kill $timeout_period" - fi +# Must use the --foreground option (RHBZ#1025269). +if timeout --foreground 2 sleep 0 >/dev/null 2>&1; then + # Does this version of timeout have the -k option? (Not on RHEL 6) + if timeout -k 10s 10s true >/dev/null 2>&1; then + timeout="timeout --foreground -k $timeout_kill $timeout_period" fi fi diff --git a/src/inspect-apps.c b/src/inspect-apps.c index a7da1dc..b54cf07 100644 --- a/src/inspect-apps.c +++ b/src/inspect-apps.c @@ -30,12 +30,6 @@ #include <sys/endian.h> #endif -/* be32toh is usually a macro defined in <endian.h>, but it might be - * a function in some system so check both, and if neither is defined - * then define be32toh for RHEL 5. - */ -#if !defined(HAVE_BE32TOH) && !defined(be32toh) - #if defined __APPLE__ && defined __MACH__ /* Define/include necessary items on MacOS X */ #include <machine/endian.h> @@ -46,13 +40,6 @@ #define __bswap_32 OSSwapConstInt32 #endif /* __APPLE__ */ -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define be32toh(x) __bswap_32 (x) -#else -#define be32toh(x) (x) -#endif -#endif - #include "guestfs.h" #include "guestfs-internal.h" #include "guestfs-internal-actions.h" diff --git a/tests/regressions/rhbz975797.sh b/tests/regressions/rhbz975797.sh index 938c1c5..3c536a9 100755 --- a/tests/regressions/rhbz975797.sh +++ b/tests/regressions/rhbz975797.sh @@ -51,10 +51,7 @@ fi rm -f rhbz975797-*.img -# The timeout utility was not available in RHEL 5. -if timeout --help >/dev/null 2>&1; then - timeout="timeout 600" -fi +timeout="timeout 600" # Use real disk images here since the code for adding /dev/null may # take shortcuts. diff --git a/tests/xml/fake-libvirt-xml.c b/tests/xml/fake-libvirt-xml.c index b7ab7a8..a34b700 100644 --- a/tests/xml/fake-libvirt-xml.c +++ b/tests/xml/fake-libvirt-xml.c @@ -25,15 +25,6 @@ #include <sys/types.h> #include <sys/stat.h> -/* We're not using gnulib here so that we don't have to link to gnulib - * rpl_* libraries (not possible since this is an LD_PRELOAD lib). - * However that does mean we have to define O_CLOEXEC explicitly for - * RHEL 5. - */ -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - /* Old <libvirt.h> had a slightly different definition of * virDomainGetXMLDesc (using 'int' for flags instead of 'unsigned * int'). To avoid an error trying to redefine it with a different -- 2.5.0
Pino Toscano
2015-Oct-05 13:09 UTC
Re: [Libguestfs] [PATCH] Remove multiple hacks that only apply to RHEL 5.
On Monday 05 October 2015 13:50:06 Richard W.M. Jones wrote:> We don't support RHEL 5 upstream (see the 'oldlinux' branch for a > version that works with RHEL 5). Therefore remove a bunch of hacks > that were only needed on RHEL 5. > ---Mostly LGTM, just two notes:> diff --git a/daemon/swap.c b/daemon/swap.c > index 26fe30d..9d7839e 100644 > --- a/daemon/swap.c > +++ b/daemon/swap.c > @@ -38,26 +38,10 @@ GUESTFSD_EXT_CMD(str_swaplabel, swaplabel); > /* Confirmed this is true for Linux swap partitions from the Linux sources. */ > #define SWAP_LABEL_MAX 16 > > -/* Convenient place to test for the later version of e2fsprogs > - * and util-linux which supports -U parameters to specify UUIDs. > - * (Not supported in RHEL 5). > - */ > int > optgroup_linuxfsuuid_available (void) > { > - CLEANUP_FREE char *err = NULL; > - int av; > - > - /* Upstream util-linux have been gradually changing '--help' to go > - * from stderr to stdout, and changing the return code from 1 to 0. > - * Thus we need to fold stdout and stderr together, and ignore the > - * return code. > - */ > - ignore_value (commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR, > - str_mkswap, "--help", NULL)); > - > - av = strstr (err, "-U") != NULL; > - return av; > + return 1; > }If the "linuxfsuuid" is now always available, then it could be retired: - remove its dependency in actions (there are 5) - adding it to the optgroups_retired list in generator/optgroups.ml> diff --git a/generator/ruby.ml b/generator/ruby.ml > index 87bb34a..cb187b0 100644 > --- a/generator/ruby.ml > +++ b/generator/ruby.ml > @@ -84,20 +84,6 @@ let rec generate_ruby_c () > #define RSTRING_PTR(r) (RSTRING((r))->ptr) > #endif > > -/* For RHEL 5 (Ruby 1.8.5) */ > -#ifndef HAVE_RB_HASH_LOOKUP > -VALUE > -rb_hash_lookup (VALUE hash, VALUE key) > -{ > - volatile VALUE val; > - > - if (!st_lookup (RHASH(hash)->tbl, key, &val)) > - return Qnil; > - > - return val; > -} > -#endif /* !HAVE_RB_HASH_LOOKUP */The have_func("rb_hash_lookup") in ruby/ext/guestfs/extconf.rb.in could be removed then. Thanks, -- Pino Toscano
Richard W.M. Jones
2015-Oct-05 13:32 UTC
Re: [Libguestfs] [PATCH] Remove multiple hacks that only apply to RHEL 5.
On Mon, Oct 05, 2015 at 03:09:01PM +0200, Pino Toscano wrote:> On Monday 05 October 2015 13:50:06 Richard W.M. Jones wrote: > > We don't support RHEL 5 upstream (see the 'oldlinux' branch for a > > version that works with RHEL 5). Therefore remove a bunch of hacks > > that were only needed on RHEL 5. > > --- > > Mostly LGTM, just two notes: > > > diff --git a/daemon/swap.c b/daemon/swap.c > > index 26fe30d..9d7839e 100644 > > --- a/daemon/swap.c > > +++ b/daemon/swap.c > > @@ -38,26 +38,10 @@ GUESTFSD_EXT_CMD(str_swaplabel, swaplabel); > > /* Confirmed this is true for Linux swap partitions from the Linux sources. */ > > #define SWAP_LABEL_MAX 16 > > > > -/* Convenient place to test for the later version of e2fsprogs > > - * and util-linux which supports -U parameters to specify UUIDs. > > - * (Not supported in RHEL 5). > > - */ > > int > > optgroup_linuxfsuuid_available (void) > > { > > - CLEANUP_FREE char *err = NULL; > > - int av; > > - > > - /* Upstream util-linux have been gradually changing '--help' to go > > - * from stderr to stdout, and changing the return code from 1 to 0. > > - * Thus we need to fold stdout and stderr together, and ignore the > > - * return code. > > - */ > > - ignore_value (commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR, > > - str_mkswap, "--help", NULL)); > > - > > - av = strstr (err, "-U") != NULL; > > - return av; > > + return 1; > > } > > If the "linuxfsuuid" is now always available, then it could be retired: > - remove its dependency in actions (there are 5) > - adding it to the optgroups_retired list in generator/optgroups.mlI think I want to keep my options open on this one. Maybe we'll want the option back again, if we decide to test for the 'mkswap' utility. It depends on whether we will ever support a non-Linux appliance. Years ago, this looked likely -- we even had a Windows-based appliance, or rough plans for one. Nowadays I can't really see that ever happening.> > diff --git a/generator/ruby.ml b/generator/ruby.ml > > index 87bb34a..cb187b0 100644 > > --- a/generator/ruby.ml > > +++ b/generator/ruby.ml > > @@ -84,20 +84,6 @@ let rec generate_ruby_c () > > #define RSTRING_PTR(r) (RSTRING((r))->ptr) > > #endif > > > > -/* For RHEL 5 (Ruby 1.8.5) */ > > -#ifndef HAVE_RB_HASH_LOOKUP > > -VALUE > > -rb_hash_lookup (VALUE hash, VALUE key) > > -{ > > - volatile VALUE val; > > - > > - if (!st_lookup (RHASH(hash)->tbl, key, &val)) > > - return Qnil; > > - > > - return val; > > -} > > -#endif /* !HAVE_RB_HASH_LOOKUP */ > > The > have_func("rb_hash_lookup") > in ruby/ext/guestfs/extconf.rb.in could be removed then.Ah, removed it too, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Possibly Parallel Threads
- Re: [PATCH] part-list: add support for show partition type
- [PATCH] part-list: add support for show partition type
- [PATCH 1/2] parted: introduce enum for whether parted has option -m
- [PATCH 20/27] daemon: Reimplement ‘part_list’ API in OCaml.
- [PATCH] daemon: parted: Always use -s option even with -m.