});
}
+VsmStatus Client::vsm_get_zone_rootpath(const char* id, VsmString* rootpath) noexcept
+{
+ assert(id);
+ assert(rootpath);
+
+ return coverException([&] {
+ api::ZoneInfoOut info;
+ mHostClient.callGetZoneInfo({ id }, info);
+ *rootpath = ::strdup(info.rootPath.c_str());
+ });
+}
+
VsmStatus Client::vsm_lookup_zone_by_pid(int pid, VsmString* id) noexcept
{
assert(id);
VsmStatus vsm_get_active_zone_id(VsmString* id) noexcept;
/**
+ * @see ::vsm_get_zone_rootpath
+ */
+ VsmStatus vsm_get_zone_rootpath(const char* id, VsmString* rootpath) noexcept;
+
+ /**
* @see ::vsm_lookup_zone_by_pid
*/
VsmStatus vsm_lookup_zone_by_pid(int pid, VsmString* id) noexcept;
return getClient(client).vsm_get_active_zone_id(id);
}
+API VsmStatus vsm_get_zone_rootpath(VsmClient client, const char* id, VsmString* rootpath)
+{
+ return getClient(client).vsm_get_zone_rootpath(id, rootpath);
+}
+
API VsmStatus vsm_lookup_zone_by_pid(VsmClient client, int pid, VsmString* id)
{
return getClient(client).vsm_lookup_zone_by_pid(pid, id);
VsmStatus vsm_get_active_zone_id(VsmClient client, VsmString* id);
/**
+ * Get zone rootfs path.
+ *
+ * @param[in] client vasum-server's client
+ * @param[in] id zone name
+ * @param[out] rootpath zone rootfs path
+ * @return status of this function call
+ * @remark Use @p vsm_string_free() to free memory occupied by @p rootpath.
+ */
+VsmStatus vsm_get_zone_rootpath(VsmClient client, const char* id, VsmString* rootpath);
+
+/**
* Get zone name of process with given pid.
*
* @param[in] client vasum-server's client
vsm_client_free(client);
}
+BOOST_AUTO_TEST_CASE(GetZoneRootPath)
+{
+ const std::string zoneId = "zone1";
+
+ VsmClient client = vsm_client_create();
+ VsmStatus status = vsm_connect(client);
+ BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
+ VsmString rootpath;
+ status = vsm_get_zone_rootpath(client, zoneId.c_str(), &rootpath);
+ BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
+
+ BOOST_CHECK_EQUAL(rootpath, "/tmp/ut-zones/" + zoneId + "/rootfs");
+
+ vsm_string_free(rootpath);
+ vsm_client_free(client);
+}
+
BOOST_AUTO_TEST_CASE(LookupZoneById)
{
const std::string activeZoneId = "zone1";