qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.9] qga: don't fail if mount doesn't have slave devices
@ 2017-03-30 16:54 Michael Roth
  2017-03-30 17:44 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Roth @ 2017-03-30 16:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

In some cases the slave devices of a virtual block device are tracked
by the parent in the corresponding sysfs node. For instance, if we
have a loop-back mount of the form:

  /dev/loop3p1 on /home/mdroth/mnt type ext4 (rw,relatime,data=ordered)

this will be reflected in sysfs as:

  /sys/devices/virtual/block/loop3/
  ...
  /sys/devices/virtual/block/loop3/slaves
  /sys/devices/virtual/block/loop3/loop3p1

The current code however assumes the mounted virtual block device,
loop3p1 in this case, contains the slaves directory, and reports an
error otherwise. This breaks 'make check' in certain environments.

Fix this by simply skipping attempts to generate disk topology
information in these cases. Since this information is documented
in QAPI as optionally-reported, this should be ok from an API
perspective.

In the future, this can possibly be improved upon by collecting
topology information from the parent in these cases.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qga/commands-posix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 73d93eb..915df9e 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -999,7 +999,9 @@ static void build_guest_fsinfo_for_virtual_device(char const *syspath,
     dirpath = g_strdup_printf("%s/slaves", syspath);
     dir = opendir(dirpath);
     if (!dir) {
-        error_setg_errno(errp, errno, "opendir(\"%s\")", dirpath);
+        if (errno != ENOENT) {
+            error_setg_errno(errp, errno, "opendir(\"%s\")", dirpath);
+        }
         g_free(dirpath);
         return;
     }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.9] qga: don't fail if mount doesn't have slave devices
  2017-03-30 16:54 [Qemu-devel] [PATCH for-2.9] qga: don't fail if mount doesn't have slave devices Michael Roth
@ 2017-03-30 17:44 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2017-03-30 17:44 UTC (permalink / raw)
  To: Michael Roth; +Cc: QEMU Developers

On 30 March 2017 at 17:54, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> In some cases the slave devices of a virtual block device are tracked
> by the parent in the corresponding sysfs node. For instance, if we
> have a loop-back mount of the form:
>
>   /dev/loop3p1 on /home/mdroth/mnt type ext4 (rw,relatime,data=ordered)
>
> this will be reflected in sysfs as:
>
>   /sys/devices/virtual/block/loop3/
>   ...
>   /sys/devices/virtual/block/loop3/slaves
>   /sys/devices/virtual/block/loop3/loop3p1
>
> The current code however assumes the mounted virtual block device,
> loop3p1 in this case, contains the slaves directory, and reports an
> error otherwise. This breaks 'make check' in certain environments.
>
> Fix this by simply skipping attempts to generate disk topology
> information in these cases. Since this information is documented
> in QAPI as optionally-reported, this should be ok from an API
> perspective.
>
> In the future, this can possibly be improved upon by collecting
> topology information from the parent in these cases.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
>  qga/commands-posix.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index 73d93eb..915df9e 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -999,7 +999,9 @@ static void build_guest_fsinfo_for_virtual_device(char const *syspath,
>      dirpath = g_strdup_printf("%s/slaves", syspath);
>      dir = opendir(dirpath);
>      if (!dir) {
> -        error_setg_errno(errp, errno, "opendir(\"%s\")", dirpath);
> +        if (errno != ENOENT) {
> +            error_setg_errno(errp, errno, "opendir(\"%s\")", dirpath);
> +        }
>          g_free(dirpath);
>          return;
>      }
> --
> 2.7.4

Tested-by: Peter Maydell <peter.maydell@linaro.org>

though only confirming that the test now passes on this sparc box.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-30 17:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-30 16:54 [Qemu-devel] [PATCH for-2.9] qga: don't fail if mount doesn't have slave devices Michael Roth
2017-03-30 17:44 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).