dbus-sdr: Look for ObjectManagers on /xyz/openbmc_project/vr

There are event-only voltage regular control sensors using the code
merged in https://gerrit.openbmc.org/q/hashtag:dbus-sdr-vr-sensors
that install ObjectManagers at /xyz/openbmc_project/vr.

In commit 9a9ac0bcfc2df48873ca0f9725eb5255f7191d84, dbus-sdr was updated
to only look for ObjectManagers located at and under
/xyz/openbmc_project/sensors. This broke the VR daemon as the VR
controls now do not appear in `ipmitool sdr elist event`.

The reason is, before the above commit, dbus-sdr looked for
ObjectManagers located at and under the root path, which involved
both /xyz/openbmc_project/sensors and /xyz/openbmc_project/vr. After the
move, /vr got left out.

This change adds /vr back, so dbus-sdr looks for ObjectManagers on both
paths.

Tested: `ipmitool sdr elist event` makes the VR daemon's event-only IPMI
sensors show up again.

Signed-off-By: Sui Chen <suichen@google.com>
Change-Id: Icab98137a0115e1c5a482cc97598f7dd66d26bfc
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index ecb8fc2..6b3dc8c 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -308,20 +308,40 @@
     if (std::chrono::duration_cast<std::chrono::seconds>(now - lastUpdate)
             .count() > updatePeriod)
     {
-        ObjectValueTree managedObjects;
-        boost::system::error_code ec =
-            getManagedObjects(ctx, sensorConnection.c_str(),
-                              "/xyz/openbmc_project/sensors", managedObjects);
-        if (ec)
-        {
-            phosphor::logging::log<phosphor::logging::level::ERR>(
-                "GetMangagedObjects for getSensorMap failed",
-                phosphor::logging::entry("ERROR=%s", ec.message().c_str()));
+        bool found = false;
 
+        // Object managers for different kinds of OpenBMC DBus interfaces.
+        // Documented in the phosphor-dbus-interfaces repository.
+        const char* paths[] = {
+            "/xyz/openbmc_project/sensors",
+            "/xyz/openbmc_project/vr",
+        };
+        constexpr size_t num_paths = sizeof(paths) / sizeof(paths[0]);
+        ObjectValueTree allManagedObjects;
+
+        for (size_t i = 0; i < num_paths; i++)
+        {
+            ObjectValueTree managedObjects;
+            boost::system::error_code ec = getManagedObjects(
+                ctx, sensorConnection.c_str(), paths[i], managedObjects);
+            if (ec)
+            {
+                phosphor::logging::log<phosphor::logging::level::ERR>(
+                    "GetMangagedObjects for getSensorMap failed",
+                    phosphor::logging::entry("ERROR=%s", ec.message().c_str()));
+
+                continue;
+            }
+            allManagedObjects.merge(managedObjects);
+            found = true;
+        }
+
+        if (!found)
+        {
             return false;
         }
 
-        SensorCache[sensorConnection] = managedObjects;
+        SensorCache[sensorConnection] = allManagedObjects;
         // Update time after finish building the map which allow the
         // data to be cached for updatePeriod plus the build time.
         updateTimeMap[sensorConnection] = std::chrono::steady_clock::now();