[PATCH] customize: Add support for the APK (Alpine Linux) package manager.
by Richard W.M. Jones
---
customize/customize_run.ml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index ed3c818..48475af 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -97,6 +97,11 @@ exec >>%s 2>&1
let guest_install_command packages =
let quoted_args = String.concat " " (List.map quote packages) in
match g#inspect_get_package_management root with
+ | "apk" ->
+ sprintf "
+ apk update
+ apk add %s
+ " quoted_args
| "apt" ->
(* http://unix.stackexchange.com/questions/22820 *)
sprintf "
@@ -124,6 +129,11 @@ exec >>%s 2>&1
and guest_update_command () =
match g#inspect_get_package_management root with
+ | "apk" ->
+ sprintf "
+ apk update
+ apk upgrade
+ "
| "apt" ->
(* http://unix.stackexchange.com/questions/22820 *)
sprintf "
--
2.5.0
8 years, 10 months
[PATCH] p2v: User can click on an interface name to identify the physical interface.
by Richard W.M. Jones
When the user clicks on the second column of the list of network
interfaces, run 'ethtool --identify <if_name> 10', which (on supported
cards) flashes a light on the physical interface for 10 seconds,
allowing it to be identified by the operator.
This has a nasty bit of hidden UI, basically because Gtk makes it near
impossible to put a regular button into a GtkTreeView.
---
p2v/gui.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
p2v/virt-p2v.pod | 4 ++++
2 files changed, 71 insertions(+)
diff --git a/p2v/gui.c b/p2v/gui.c
index 92a7bc4..ed23753 100644
--- a/p2v/gui.c
+++ b/p2v/gui.c
@@ -414,6 +414,7 @@ static void populate_removable (GtkTreeView *removable_list);
static void populate_interfaces (GtkTreeView *interfaces_list);
static void toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data);
static void network_edited_callback (GtkCellRendererToggle *cell, gchar *path_str, gchar *new_text, gpointer data);
+static gboolean maybe_identify_click (GtkWidget *interfaces_list, GdkEventButton *event, gpointer data);
static void set_disks_from_ui (struct config *);
static void set_removable_from_ui (struct config *);
static void set_interfaces_from_ui (struct config *);
@@ -649,6 +650,10 @@ create_conversion_dialog (struct config *config)
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (interfaces_sw),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
interfaces_list = gtk_tree_view_new ();
+ /* See maybe_identify_click below for what we're doing. */
+ g_signal_connect (interfaces_list, "button-press-event",
+ G_CALLBACK (maybe_identify_click), NULL);
+ gtk_widget_set_tooltip_markup (interfaces_list, _("Left click on an interface name to flash the light on the physical interface."));
populate_interfaces (GTK_TREE_VIEW (interfaces_list));
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (interfaces_sw),
interfaces_list);
@@ -1022,6 +1027,68 @@ network_edited_callback (GtkCellRendererToggle *cell, gchar *path_str,
gtk_tree_path_free (path);
}
+/* When the user clicks on the interface name on the list of
+ * interfaces, we want to run 'ethtool --identify', which usually
+ * makes some lights flash on the physical interface. We cannot catch
+ * clicks on the cell itself, so we have to go via a more obscure
+ * route. See http://stackoverflow.com/a/27207433 and
+ * https://en.wikibooks.org/wiki/GTK%2B_By_Example/Tree_View/Events
+ */
+static gboolean
+maybe_identify_click (GtkWidget *interfaces_list, GdkEventButton *event,
+ gpointer data)
+{
+ gboolean ret = FALSE; /* Did we handle this event? */
+
+ /* Single left click only. */
+ if (event->type == GDK_BUTTON_PRESS && event->button == 1) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
+
+ if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (interfaces_list),
+ event->x, event->y,
+ &path, &column, NULL, NULL)) {
+ GList *cols;
+ gint column_index;
+
+ /* Get column index. */
+ cols = gtk_tree_view_get_columns (GTK_TREE_VIEW (interfaces_list));
+ column_index = g_list_index (cols, (gpointer) column);
+ g_list_free (cols);
+
+ if (column_index == INTERFACES_COL_DEVICE) {
+ const gint *indices;
+ gint row_index;
+ const char *if_name;
+ char *cmd;
+
+ /* Get the row index. */
+ indices = gtk_tree_path_get_indices (path);
+ row_index = indices[0];
+
+ /* And the interface name. */
+ if_name = all_interfaces[row_index];
+
+ /* Issue the ethtool command in the background. */
+ if (asprintf (&cmd, "ethtool --identify '%s' 10 &", if_name) == -1) {
+ perror ("asprintf");
+ exit (EXIT_FAILURE);
+ }
+ printf ("%s\n", cmd);
+ ignore_value (system (cmd));
+
+ free (cmd);
+
+ ret = TRUE; /* We handled this event. */
+ }
+
+ gtk_tree_path_free (path);
+ }
+ }
+
+ return ret;
+}
+
static void
set_from_ui_generic (char **all, char ***ret, GtkTreeView *list)
{
diff --git a/p2v/virt-p2v.pod b/p2v/virt-p2v.pod
index 6193ca8..b4598d9 100644
--- a/p2v/virt-p2v.pod
+++ b/p2v/virt-p2v.pod
@@ -232,6 +232,10 @@ should be created in the guest after conversion. You can also connect
these to target hypervisor networks (for further information about
this feature, see L<virt-v2v(1)/NETWORKS AND BRIDGES>).
+On supported hardware, left-clicking on the device name (eg. C<em1>)
+causes a light to start flashing on the physical interface, allowing
+the interface to be identified by the operator.
+
When you are ready to begin the conversion, press the
C<Start conversion> button:
--
2.5.0
8 years, 10 months
[PATCH] daemon: fold xfs_admin stdout to stderr
by Pino Toscano
Apparent newer versions of that report everything on stdout, including
error messages; since we only print something on failure, fold stdout to
stderr so we can see everything on failure.
---
daemon/xfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/xfs.c b/daemon/xfs.c
index abc2736..7f72e6a 100644
--- a/daemon/xfs.c
+++ b/daemon/xfs.c
@@ -537,7 +537,7 @@ do_xfs_admin (const char *device,
ADD_ARG (argv, i, device);
ADD_ARG (argv, i, NULL);
- r = commandv (NULL, &err, argv);
+ r = commandvf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR, argv);
if (r == -1) {
reply_with_error ("%s: %s", device, err);
return -1;
--
2.5.0
8 years, 10 months
[PATCH] xfs_admin: do not set lazycounter in tests not checking that
by Pino Toscano
This flag cannot be disabled (yet) in V5 xfs filesystems; since 2 out
of the current 3 tests of xfs_admin check other results than that flag,
avoid setting it when not needed.
---
generator/actions.ml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index 9ea5736..14902e7 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -10928,12 +10928,12 @@ with zeroes)." };
InitEmpty, Always, TestResultString (
[["part_disk"; "/dev/sda"; "mbr"];
["mkfs"; "xfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"];
- ["xfs_admin"; "/dev/sda1"; ""; ""; ""; ""; "false"; "NOARG"; uuid];
+ ["xfs_admin"; "/dev/sda1"; ""; ""; ""; ""; ""; "NOARG"; uuid];
["vfs_uuid"; "/dev/sda1"]], uuid), [];
InitEmpty, Always, TestResultString (
[["part_disk"; "/dev/sda"; "mbr"];
["mkfs"; "xfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"];
- ["xfs_admin"; "/dev/sda1"; ""; ""; ""; ""; "false"; "LBL-TEST"; "NOARG"];
+ ["xfs_admin"; "/dev/sda1"; ""; ""; ""; ""; ""; "LBL-TEST"; "NOARG"];
["vfs_label"; "/dev/sda1"]], "LBL-TEST"), [];
]);
shortdesc = "change parameters of an XFS filesystem";
--
2.5.0
8 years, 10 months
[PATCH] daemon: improve debugging for "stdout on stderr" flag
by Pino Toscano
When the COMMAND_FLAG_FOLD_STDOUT_ON_STDERR flag is passed to
command*(), indicate that as stdout=e in debugging message.
---
daemon/command.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/daemon/command.c b/daemon/command.c
index 73fce56..2423a4e 100644
--- a/daemon/command.c
+++ b/daemon/command.c
@@ -185,6 +185,7 @@ commandrvf (char **stdoutput, char **stderror, unsigned flags,
int so_fd[2], se_fd[2];
unsigned flag_copy_stdin = flags & COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN;
int flag_copy_fd = (int) (flags & COMMAND_FLAG_FD_MASK);
+ unsigned flag_out_on_err = flags & COMMAND_FLAG_FOLD_STDOUT_ON_STDERR;
pid_t pid;
int r, quit, i;
fd_set rset, rset2;
@@ -196,7 +197,8 @@ commandrvf (char **stdoutput, char **stderror, unsigned flags,
if (verbose) {
printf ("commandrvf: stdout=%s stderr=%s flags=0x%x\n",
- stdoutput ? "y" : "n", stderror ? "y" : "n", flags);
+ stdoutput ? "y" : flag_out_on_err ? "e" : "n",
+ stderror ? "y" : "n", flags);
fputs ("commandrvf: ", stdout);
fputs (argv[0], stdout);
for (i = 1; argv[i] != NULL; ++i) {
@@ -261,7 +263,7 @@ commandrvf (char **stdoutput, char **stderror, unsigned flags,
}
close (so_fd[PIPE_READ]);
close (se_fd[PIPE_READ]);
- if (!(flags & COMMAND_FLAG_FOLD_STDOUT_ON_STDERR)) {
+ if (!flag_out_on_err) {
if (dup2 (so_fd[PIPE_WRITE], STDOUT_FILENO) == -1) {
perror ("dup2/so_fd[PIPE_WRITE]");
_exit (EXIT_FAILURE);
--
2.5.0
8 years, 10 months
[PATCH] btrfs_subvolume_show: fix root/toplevel check w/ btrfs-progs >= 4.4
by Pino Toscano
In trfs-progs 4.4 the error message has been changed, and our check did
not work anymore. Yes, parsing user messages really sucks...
---
daemon/btrfs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 85dbe00..c67af83 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1029,9 +1029,12 @@ do_btrfs_subvolume_show (const char *subvolume)
}
/* If the path is the btrfs root, `btrfs subvolume show' reports:
- * <path> is btrfs root
+ * <path> is btrfs root [in btrfs-progs < 4.4]
+ * <path> is toplevel subvolume
*/
- if (out && strstr (out, "is btrfs root") != NULL) {
+ if (out &&
+ (strstr (out, "is btrfs root") != NULL ||
+ strstr (out, "is toplevel subvolume") != NULL)) {
reply_with_error ("%s is btrfs root", subvolume);
return NULL;
}
--
2.5.0
8 years, 10 months
[PATCH] actions: expand partitions for btrfs_image test
by Pino Toscano
Apparently with newer btrfs-progs (seen with 4.4) 100M are not enough
for a btrfs filesystem; hence double the size of the partitions
created in the test of btrfs_image, so now 200M are enough for btrfs.
---
generator/actions.ml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index 75d3fc5..9ea5736 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12680,8 +12680,8 @@ This enable skinny metadata extent refs." };
tests = [
InitEmpty, Always, TestRun (
[["part_init"; "/dev/sda"; "mbr"];
- ["part_add"; "/dev/sda"; "p"; "64"; "204799"];
- ["part_add"; "/dev/sda"; "p"; "204800"; "409599"];
+ ["part_add"; "/dev/sda"; "p"; "64"; "409599"];
+ ["part_add"; "/dev/sda"; "p"; "409600"; "819199"];
["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
["mkfs_btrfs"; "/dev/sda2"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
["mount"; "/dev/sda1"; "/"];
--
2.5.0
8 years, 10 months
[supermin] [PATCH] ext2: check for needed block size
by Pino Toscano
Check early that there are enough free blocks to store each file,
erroring out with ENOSPC if not; this avoids slightly more obscure
errors later on.
---
src/ext2fs-c.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/ext2fs-c.c b/src/ext2fs-c.c
index f01ca9d..e45980a 100644
--- a/src/ext2fs-c.c
+++ b/src/ext2fs-c.c
@@ -52,6 +52,9 @@
/* fts.h in glibc is broken, forcing us to use the GNUlib alternative. */
#include "fts_.h"
+/* How many blocks of size S are needed for storing N bytes. */
+#define ROUND_UP(N, S) (((N) + (S) - 1) / (S))
+
struct ext2_data
{
ext2_filsys fs;
@@ -629,6 +632,7 @@ ext2_copy_file (struct ext2_data *data, const char *src, const char *dest)
errcode_t err;
struct stat statbuf;
struct statvfs statvfsbuf;
+ size_t blocks;
if (data->debug >= 3)
printf ("supermin: ext2: copy_file %s -> %s\n", src, dest);
@@ -649,6 +653,20 @@ ext2_copy_file (struct ext2_data *data, const char *src, const char *dest)
caml_copy_string (data->fs->device_name));
}
+ /* Check that we have enough free blocks to store the resulting blocks
+ * for this file. The file might need more than that in the filesystem,
+ * but at least this provides a quick check to avoid failing later on.
+ */
+ blocks = ROUND_UP (statbuf.st_size, data->fs->blocksize);
+ if (blocks > ext2fs_free_blocks_count (data->fs->super)) {
+ fprintf (stderr, "supermin: %s: needed %lu blocks (%d each) for "
+ "%lu bytes, available only %llu\n",
+ src, blocks, data->fs->blocksize, statbuf.st_size,
+ ext2fs_free_blocks_count (data->fs->super));
+ unix_error (ENOSPC, (char *) "block size",
+ data->fs->device_name ? caml_copy_string (data->fs->device_name) : Val_none);
+ }
+
/* Sanity check the path. These rules are always true for the paths
* passed to us here from the appliance layer. The assertions just
* verify that the rules haven't changed.
--
2.5.0
8 years, 10 months
[PATCH] test-data: use make functions to get the prepared disk name
by Pino Toscano
Avoid a cat+sed for getting the prepared disk name, using a make
function instead.
---
test-data/phony-guests/Makefile.am | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/test-data/phony-guests/Makefile.am b/test-data/phony-guests/Makefile.am
index 5a56960..9fac2d0 100644
--- a/test-data/phony-guests/Makefile.am
+++ b/test-data/phony-guests/Makefile.am
@@ -70,8 +70,7 @@ CLEANFILES = \
# virt-alignment-scan don't break when they encounter them.
blank-%.img:
rm -f $@ $@-t
- $(top_builddir)/run guestfish \
- -N $@-t="$$(echo $@ | $(SED) -e 's/blank-//' -e 's/.img//')" exit
+ $(top_builddir)/run guestfish -N $@-t="$(patsubst blank-%.img,%,$@)" exit
mv $@-t $@
# Make a (dummy) Fedora image.
--
2.5.0
8 years, 10 months