diff --git a/appliance/init b/appliance/init index 3816dfd83..d44000720 100755 --- a/appliance/init +++ b/appliance/init @@ -131,7 +131,6 @@ mdadm -As --auto=yes --run # Scan for LVM. modprobe dm_mod ||: -lvmetad ||: lvm vgchange -aay --sysinit diff --git a/daemon/daemon.h b/daemon/daemon.h index 771698156..9fb047239 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -189,6 +189,7 @@ extern int lv_canonical (const char *device, char **ret); /*-- in lvm-filter.c --*/ extern void copy_lvm (void); +extern void start_lvmetad (void); /*-- in zero.c --*/ extern void wipe_device_before_mkfs (const char *device); diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index bd3f7de7c..b343d7e4d 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -274,8 +274,10 @@ main (int argc, char *argv[]) /* Make a private copy of /etc/lvm so we can change the config (see * daemon/lvm-filter.c). */ - if (!test_mode) + if (!test_mode) { copy_lvm (); + start_lvmetad (); + } /* Connect to virtio-serial channel. */ if (!channel) diff --git a/daemon/lvm-filter.c b/daemon/lvm-filter.c index 8629aab34..d53d64b32 100644 --- a/daemon/lvm-filter.c +++ b/daemon/lvm-filter.c @@ -39,6 +39,7 @@ GUESTFSD_EXT_CMD(str_lvm, lvm); GUESTFSD_EXT_CMD(str_cp, cp); GUESTFSD_EXT_CMD(str_rm, rm); +GUESTFSD_EXT_CMD(str_lvmetad, lvmetad); /* This runs during daemon start up and creates a complete copy of * /etc/lvm so that we can modify it as we desire. We set @@ -101,6 +102,23 @@ copy_lvm (void) atexit (rm_lvm_system_dir); } +/* Try to run lvmetad, without failing if it couldn't. */ +void +start_lvmetad (void) +{ + char cmd[64]; + int r; + + snprintf (cmd, sizeof cmd, "%s", str_lvmetad); + if (verbose) + printf ("%s\n", cmd); + r = system (cmd); + if (r == -1) + perror ("system/lvmetad"); + else if (!WIFEXITED (r) || WEXITSTATUS (r) != 0) + fprintf (stderr, "warning: lvmetad command failed\n"); +} + static void rm_lvm_system_dir (void) { @@ -247,7 +265,7 @@ rescan (void) unlink (lvm_cache); CLEANUP_FREE char *err = NULL; - int r = command (NULL, &err, str_lvm, "vgscan", NULL); + int r = command (NULL, &err, str_lvm, "vgscan", "--cache", NULL); if (r == -1) { reply_with_error ("vgscan: %s", err); return -1; diff --git a/daemon/lvm.c b/daemon/lvm.c index d4909adfb..e21f7c1d7 100644 --- a/daemon/lvm.c +++ b/daemon/lvm.c @@ -794,7 +794,7 @@ do_vgscan (void) int r; r = command (NULL, &err, - str_lvm, "vgscan", NULL); + str_lvm, "vgscan", "--cache", NULL); if (r == -1) { reply_with_error ("%s", err); return -1;