Change bad VPD dump directory

This commit changes the bad VPD dump directory from /tmp/bad-vpd to
/var/lib/vpd/dumps. This change is done to ensure bad VPD dumps persist
across BMC reboots. The parent directory /var/lib/vpd is created by
vpd-manager during genesis boot/factory reset.

This commit also updates references to the bad VPD dump directory in the
utility API used to dump bad VPD.

Change-Id: Ibdb53e38c1afd15d4324f7bc04dec4d35e70d46a
Signed-off-by: Souvik Roy <souvikroyofficial10@gmail.com>
diff --git a/meson.build b/meson.build
index d949d43..e30cae8 100644
--- a/meson.build
+++ b/meson.build
@@ -42,7 +42,6 @@
 conf_data.set_quoted('BUSNAME', get_option('BUSNAME'))
 conf_data.set_quoted('OBJPATH', get_option('OBJPATH'))
 conf_data.set_quoted('IFACE', get_option('IFACE'))
-conf_data.set_quoted('BAD_VPD_DIR', get_option('BAD_VPD_DIR'))
 conf_data.set_quoted(
     'INVENTORY_JSON_DEFAULT',
     get_option('INVENTORY_JSON_DEFAULT'),
diff --git a/meson.options b/meson.options
index 7a969cc..6c1b3ce 100644
--- a/meson.options
+++ b/meson.options
@@ -24,12 +24,6 @@
     description: 'enable when ECC check used in IPZ parsering, used for Gtest cases.',
 )
 option(
-    'BAD_VPD_DIR',
-    type: 'string',
-    value: '/tmp/bad-vpd/',
-    description: 'Directory which contains the bad vpd file - which needs to be included in bmc dump.',
-)
-option(
     'INVENTORY_JSON_DEFAULT',
     type: 'string',
     value: '/usr/share/vpd/vpd_inventory.json',
diff --git a/vpd-manager/include/constants.hpp b/vpd-manager/include/constants.hpp
index 5195c38..f88944c 100644
--- a/vpd-manager/include/constants.hpp
+++ b/vpd-manager/include/constants.hpp
@@ -181,6 +181,7 @@
 constexpr auto powerVsImagePrefix_MZ = "MZ";
 constexpr auto powerVsImagePrefix_NY = "NY";
 constexpr auto powerVsImagePrefix_NZ = "NZ";
+constexpr auto badVpdDir = "/var/lib/vpd/dumps/";
 
 static constexpr auto BD_YEAR_END = 4;
 static constexpr auto BD_MONTH_END = 7;
diff --git a/vpd-manager/include/utility/vpd_specific_utility.hpp b/vpd-manager/include/utility/vpd_specific_utility.hpp
index a371878..bcdce9d 100644
--- a/vpd-manager/include/utility/vpd_specific_utility.hpp
+++ b/vpd-manager/include/utility/vpd_specific_utility.hpp
@@ -36,7 +36,7 @@
 inline std::string generateBadVPDFileName(
     const std::string& i_vpdFilePath) noexcept
 {
-    std::string l_badVpdFileName{BAD_VPD_DIR};
+    std::string l_badVpdFileName{constants::badVpdDir};
     try
     {
         if (i_vpdFilePath.find("i2c") != std::string::npos)
@@ -71,8 +71,8 @@
 /**
  * @brief API which dumps the broken/bad vpd in a directory.
  * When the vpd is bad, this API places  the bad vpd file inside
- * "/tmp/bad-vpd" in BMC, in order to collect bad VPD data as a part of user
- * initiated BMC dump.
+ * "/var/lib/vpd/dumps" in BMC, in order to collect bad VPD data as a part of
+ * user initiated BMC dump.
  *
  *
  * @param[in] i_vpdFilePath - vpd file path
@@ -86,7 +86,7 @@
     int l_rc{constants::FAILURE};
     try
     {
-        std::filesystem::create_directory(BAD_VPD_DIR);
+        std::filesystem::create_directory(constants::badVpdDir);
         auto l_badVpdPath = generateBadVPDFileName(i_vpdFilePath);
 
         if (l_badVpdPath.empty())
@@ -113,9 +113,11 @@
         std::ofstream l_badVpdFileStream(l_badVpdPath, std::ofstream::binary);
         if (!l_badVpdFileStream.is_open())
         {
-            throw std::runtime_error(
-                "Failed to open bad vpd file path in /tmp/bad-vpd. "
-                "Unable to dump the broken/bad vpd file.");
+            const std::string l_errorMsg{
+                "Failed to open bad vpd file path [" + l_badVpdPath +
+                "]. Unable to dump the broken/bad vpd file."};
+
+            throw std::runtime_error(l_errorMsg);
         }
 
         l_badVpdFileStream.write(