summaryrefslogtreecommitdiffstats
path: root/daemon/guestfsd.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-07-01 17:15:24 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-07-01 17:15:24 +0100
commit99e28249d52ca5495b636e14ae3e4387ee62c8fe (patch)
tree6038b57e180556e9429cd422d075fccd9c4a9ff7 /daemon/guestfsd.c
parent3e2d925717d1dac6b3862e98192c12d1080c2152 (diff)
downloadlibguestfs-99e28249d52ca5495b636e14ae3e4387ee62c8fe.tar.gz
libguestfs-99e28249d52ca5495b636e14ae3e4387ee62c8fe.tar.xz
libguestfs-99e28249d52ca5495b636e14ae3e4387ee62c8fe.zip
Call 'udevadm settle' after operations which add/remove device nodes.
Because udev operates asynchronously, we found errors which were caused by a previous command (eg. sfdisk or pvremove) creating or removing a device, and that change not having happened by the time the next command was run. This patch adds calls to '/sbin/udevadm settle' after any commands which can add or remove device nodes. If udev is not being used or not available, this should have no effect. The command fails and this is silently ignored.
Diffstat (limited to 'daemon/guestfsd.c')
-rw-r--r--daemon/guestfsd.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 0a3e64f5..e5f2cf0b 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -741,3 +741,16 @@ device_name_translation (char *device, const char *func)
device[5] = 's'; /* Restore original device name. */
goto error;
}
+
+/* LVM and other commands aren't synchronous, especially when udev is
+ * involved. eg. You can create or remove some device, but the /dev
+ * device node won't appear until some time later. This means that
+ * you get an error if you run one command followed by another.
+ * Use 'udevadm settle' after certain commands, but don't be too
+ * fussed if it fails.
+ */
+void
+udev_settle (void)
+{
+ command (NULL, NULL, "/sbin/udevadm", "settle", NULL);
+}