[Libguestfs] [PATCH] parted: add more udev_settle calls.
Richard W.M. Jones
rjones at redhat.com
Fri Mar 3 10:24:01 UTC 2017
On Thu, Mar 02, 2017 at 05:44:40PM -0500, Dawid Zamirski wrote:
> add udev_settle calls to print_partition_table and
> sgdisk_info_extract_field because the inspect-os calls
> guestfs_part_get_parttype and guestfs_part_get_gpt_guid for all
> parition devices found and this causes intermittent with opening block
> devices that are certainly present yet RESOLVE_DEVICE macro would fail
> wiht ENOENT.
> ---
> daemon/parted.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/daemon/parted.c b/daemon/parted.c
> index 124d1e9..03e83cb 100644
> --- a/daemon/parted.c
> +++ b/daemon/parted.c
> @@ -320,6 +320,8 @@ print_partition_table (const char *device, bool add_m_option)
> CLEANUP_FREE char *err = NULL;
> int r;
>
> + udev_settle ();
> +
> if (add_m_option)
> r = command (&out, &err, str_parted, "-m", "-s", "--", device,
> "unit", "b",
> @@ -328,6 +330,9 @@ print_partition_table (const char *device, bool add_m_option)
> r = command (&out, &err, str_parted, "-s", "--", device,
> "unit", "b",
> "print", NULL);
> +
> + udev_settle ();
> +
> if (r == -1) {
> int errcode = 0;
>
> @@ -665,6 +670,8 @@ sgdisk_info_extract_field (const char *device, int partnum, const char *field,
> return NULL;
> }
>
> + udev_settle ();
> +
> CLEANUP_FREE char *err = NULL;
> int r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR,
> str_sgdisk, device, "-i", partnum_str, NULL);
> @@ -674,6 +681,8 @@ sgdisk_info_extract_field (const char *device, int partnum, const char *field,
> return NULL;
> }
>
> + udev_settle ();
> +
> CLEANUP_FREE_STRING_LIST char **lines = split_lines (err);
> if (lines == NULL) {
> reply_with_error ("'%s %s -i %i' returned no output",
Looks fine to me - will apply in a moment.
Thanks,
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
More information about the Libguestfs
mailing list