OpenPOWER: Fix for host dump delete

If the dump is not created by host or the request is not
complete the dump id provided by the host will not be
valid. When deleting such dump entries a request for
delete should not be send to the host.

Tests:

Deleting a dump which is not finished when host is running

Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
Change-Id: If7e8b7fad67c215f057152bb64b5232f198fee9e
diff --git a/dump-extensions/openpower-dumps/dump_manager_resource.cpp b/dump-extensions/openpower-dumps/dump_manager_resource.cpp
index 020556c..27bf010 100644
--- a/dump-extensions/openpower-dumps/dump_manager_resource.cpp
+++ b/dump-extensions/openpower-dumps/dump_manager_resource.cpp
@@ -3,6 +3,7 @@
 #include "dump_manager_resource.hpp"
 
 #include "dump_utils.hpp"
+#include "op_dump_consts.hpp"
 #include "resource_dump_entry.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
diff --git a/dump-extensions/openpower-dumps/dump_manager_system.cpp b/dump-extensions/openpower-dumps/dump_manager_system.cpp
index ae9aaa5..e8e8953 100644
--- a/dump-extensions/openpower-dumps/dump_manager_system.cpp
+++ b/dump-extensions/openpower-dumps/dump_manager_system.cpp
@@ -3,6 +3,7 @@
 #include "dump_manager_system.hpp"
 
 #include "dump_utils.hpp"
+#include "op_dump_consts.hpp"
 #include "system_dump_entry.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
diff --git a/dump-extensions/openpower-dumps/op_dump_consts.hpp b/dump-extensions/openpower-dumps/op_dump_consts.hpp
new file mode 100644
index 0000000..4ddd567
--- /dev/null
+++ b/dump-extensions/openpower-dumps/op_dump_consts.hpp
@@ -0,0 +1,3 @@
+#pragma once
+
+constexpr uint32_t INVALID_SOURCE_ID = 0xFFFFFFFF;
diff --git a/dump-extensions/openpower-dumps/resource_dump_entry.cpp b/dump-extensions/openpower-dumps/resource_dump_entry.cpp
index 0954e9a..a1d90a2 100644
--- a/dump-extensions/openpower-dumps/resource_dump_entry.cpp
+++ b/dump-extensions/openpower-dumps/resource_dump_entry.cpp
@@ -2,6 +2,7 @@
 
 #include "dump_utils.hpp"
 #include "host_transport_exts.hpp"
+#include "op_dump_consts.hpp"
 
 #include <phosphor-logging/elog-errors.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
@@ -43,7 +44,7 @@
 
     // Remove resource dump when host is up by using source dump id
     // which is present in resource dump entry dbus object as a property.
-    if (phosphor::dump::isHostRunning())
+    if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID))
     {
         phosphor::dump::host::requestDelete(srcDumpID,
                                             TRANSPORT_DUMP_TYPE_IDENTIFIER);
diff --git a/dump-extensions/openpower-dumps/system_dump_entry.cpp b/dump-extensions/openpower-dumps/system_dump_entry.cpp
index e37304b..3d2e734 100644
--- a/dump-extensions/openpower-dumps/system_dump_entry.cpp
+++ b/dump-extensions/openpower-dumps/system_dump_entry.cpp
@@ -2,6 +2,7 @@
 
 #include "dump_utils.hpp"
 #include "host_transport_exts.hpp"
+#include "op_dump_consts.hpp"
 
 #include <phosphor-logging/elog-errors.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
@@ -33,7 +34,7 @@
 
     // Remove host system dump when host is up by using source dump id
     // which is present in system dump entry dbus object as a property.
-    if (phosphor::dump::isHostRunning())
+    if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID))
     {
         phosphor::dump::host::requestDelete(srcDumpID,
                                             TRANSPORT_DUMP_TYPE_IDENTIFIER);