Dawid Zamirski
2017-Mar-02 22:44 UTC
[Libguestfs] [PATCH] parted: add more udev_settle calls.
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", -- 2.9.3
Dawid Zamirski
2017-Mar-02 22:46 UTC
[Libguestfs] [PATCH] parted: add more udev_settle calls.
On Thu, 2017-03-02 at 17:44 -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",Just FYI, this patch is to resolve this: https://paste.fedoraproject.org/paste/LIltC71IXO8JwHlvN~ckwl5M1UNdIGYhy RLivL9gydE=
Richard W.M. Jones
2017-Mar-03 10:24 UTC
[Libguestfs] [PATCH] parted: add more udev_settle calls.
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
Apparently Analagous Threads
- [PATCH 20/27] daemon: Reimplement ‘part_list’ API in OCaml.
- [PATCH] daemon: parted: Always use -s option even with -m.
- [PATCH 1/2] parted: introduce enum for whether parted has option -m
- Re: [PATCH] New API: part_get_part_type for showing partition type
- Re: [PATCH] New API: part_get_part_type for showing partition type