master
h 72 lines 2.22 KB
Raw
1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 IWSLCVolume.h
8
9 Abstract:
10
11 Abstract interface implemented by all WSLC-managed volume drivers
12 (currently WSLCVhdVolumeImpl and WSLCGuestVolumeImpl). WSLCSession
13 stores volumes through this interface so it can hold a single map
14 regardless of the concrete driver type.
15
16 --*/
17
18 #pragma once
19
20 #include "wslc.h"
21 #include <map>
22 #include <string>
23 #include <utility>
24
25 namespace wsl::windows::service::wslc {
26
27 class IWSLCVolume
28 {
29 public:
30 virtual ~IWSLCVolume() = default;
31
32 // The docker volume name.
33 virtual const std::string& Name() const noexcept = 0;
34
35 // The WSLC volume driver, e.g. "vhd" or "guest". This is the driver
36 // stored in the WSLC volume metadata label, not the underlying docker
37 // driver (which may be "local" for guest volumes).
38 virtual const char* Driver() const noexcept = 0;
39
40 // The user-specified labels on this volume (excludes the WSLC metadata label).
41 virtual const std::map<std::string, std::string>& Labels() const noexcept = 0;
42
43 // The path at which the volume is mounted inside the utility VM.
44 virtual const std::string& Mountpoint() const noexcept = 0;
45
46 // The status of the volume as {Code, Message}: S_OK with an empty message when the volume
47 // opened successfully and is usable, otherwise a failure HRESULT and a human-readable reason
48 // (e.g. the backing VHD is missing).
49 virtual std::pair<HRESULT, std::string> Status() const
50 {
51 return {S_OK, {}};
52 }
53
54 // Remove the volume from docker and release any host-side resources
55 // (e.g. detach/delete the VHD for VHD volumes). Throws on failure.
56 virtual void Delete() = 0;
57
58 // Called when Docker has already destroyed the volume (e.g. container delete with -v).
59 // Releases any host-side resources without contacting Docker. Default is a no-op.
60 virtual void OnDeleted()
61 {
62 }
63
64 // Returns a JSON string for the COM-facing InspectVolume result.
65 virtual std::string Inspect() const = 0;
66
67 // Returns the WSLCVolumeInformation struct for the COM-facing
68 // ListVolumes / CreateVolume results.
69 virtual WSLCVolumeInformation GetVolumeInformation() const = 0;
70 };
71
72 } // namespace wsl::windows::service::wslc