NVMeDevice: Integrate subsystem startup

Currently the associated NVMeSubsystem instance is stopped via
NVMeDevice::stop() to maintain encapsulation. To mirror stop(),
and given the subsystem also needs to be started in both the
basic management command and MI paths, integrate the call to
NVMeSubsystem::start() into NVMeDevice::start().

Note that NVMeDevice::start() is only invoked after instantiation of its
object, in the same manner as NVMeSubsystem, and so is only
ever invoked once. MCTP endpoint recovery calls back through the
private NVMeDevice::setup() method, which is separate to
(but invoked from) NVMeDevice::start().

Change-Id: Ie29782de1e0dd2581c59a9fdddca3942d52b2e77
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/src/NVMeDevice.cpp b/src/NVMeDevice.cpp
index ce2d24d..516a982 100644
--- a/src/NVMeDevice.cpp
+++ b/src/NVMeDevice.cpp
@@ -4,6 +4,8 @@
 
 void NVMeDevice::start()
 {
+    subsys->start();
+
     if (intf.getProtocol() == NVMeIntf::Protocol::NVMeMI)
     {
         setup();
diff --git a/src/NVMeSensorMain.cpp b/src/NVMeSensorMain.cpp
index 2357573..c770c7b 100644
--- a/src/NVMeSensorMain.cpp
+++ b/src/NVMeSensorMain.cpp
@@ -285,10 +285,14 @@
                 auto nvmeSubsys = NVMeSubsystem::create(
                     io, objectServer, dbusConnection, nvmeObjectPath,
                     *sensorName, configData, nvmeIntf, enableFeatureLockdown);
-                nvmeSubsys->start();
                 auto nvmeDev = NVMeDevice::create(std::move(nvmeIntf),
                                                   nvmeSubsys);
-                nvmeDevices.try_emplace(nvmeObjectPath, nvmeDev);
+                auto [entry, added] = nvmeDevices.try_emplace(nvmeObjectPath,
+                                                              nvmeDev);
+                if (added)
+                {
+                    entry->second->start();
+                }
             }
             catch (std::exception& ex)
             {
@@ -358,10 +362,12 @@
 
                 auto nvmeDev = NVMeDevice::create(
                     io, mctpDev, std::move(nvmeIntf), nvmeSubsys);
-                auto [entry, _] = nvmeDevices.try_emplace(nvmeObjectPath,
-                                                          nvmeDev);
-                nvmeSubsys->start();
-                entry->second->start();
+                auto [entry, added] = nvmeDevices.try_emplace(nvmeObjectPath,
+                                                              nvmeDev);
+                if (added)
+                {
+                    entry->second->start();
+                }
             }
             catch (std::exception& ex)
             {