Skip to content

Commit

Permalink
qga: don't fail if mount doesn't have slave devices
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Peter Maydell <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
Tested-by: Peter Maydell <[email protected]>
  • Loading branch information
mdroth committed Mar 30, 2017
1 parent df90463 commit 8251a72
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion qga/commands-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8251a72

Please sign in to comment.