@@ -16,69 +16,24 @@ import (
1616 "github.com/Microsoft/hcsshim/pkg/ctrdtaskapi"
1717)
1818
19- type ConfidentialUVMOpt func (ctx context.Context , r * guestresource.LCOWConfidentialOptions ) error
19+ type ConfidentialUVMOpt func (ctx context.Context , r * guestresource.ConfidentialOptions ) error
2020
2121// WithSecurityPolicy sets the desired security policy for the resource.
2222func WithSecurityPolicy (policy string ) ConfidentialUVMOpt {
23- return func (ctx context.Context , r * guestresource.LCOWConfidentialOptions ) error {
23+ return func (ctx context.Context , r * guestresource.ConfidentialOptions ) error {
2424 r .EncodedSecurityPolicy = policy
2525 return nil
2626 }
2727}
2828
2929// WithSecurityPolicyEnforcer sets the desired enforcer type for the resource.
3030func WithSecurityPolicyEnforcer (enforcer string ) ConfidentialUVMOpt {
31- return func (ctx context.Context , r * guestresource.LCOWConfidentialOptions ) error {
31+ return func (ctx context.Context , r * guestresource.ConfidentialOptions ) error {
3232 r .EnforcerType = enforcer
3333 return nil
3434 }
3535}
3636
37- // TODO (Mahati): Move this block out later
38- type WCOWConfidentialUVMOpt func (ctx context.Context , r * guestresource.WCOWConfidentialOptions ) error
39-
40- // WithSecurityPolicy sets the desired security policy for the resource.
41- func WithWCOWSecurityPolicy (policy string ) WCOWConfidentialUVMOpt {
42- return func (ctx context.Context , r * guestresource.WCOWConfidentialOptions ) error {
43- r .EncodedSecurityPolicy = policy
44- return nil
45- }
46- }
47-
48- // WithSecurityPolicyEnforcer sets the desired enforcer type for the resource.
49- func WithWCOWSecurityPolicyEnforcer (enforcer string ) WCOWConfidentialUVMOpt {
50- return func (ctx context.Context , r * guestresource.WCOWConfidentialOptions ) error {
51- r .EnforcerType = enforcer
52- return nil
53- }
54- }
55-
56- func (uvm * UtilityVM ) SetWCOWConfidentialUVMOptions (ctx context.Context , opts ... WCOWConfidentialUVMOpt ) error {
57- if uvm .operatingSystem != "windows" {
58- return errNotSupported
59- }
60- uvm .m .Lock ()
61- defer uvm .m .Unlock ()
62- confOpts := & guestresource.WCOWConfidentialOptions {}
63- for _ , o := range opts {
64- if err := o (ctx , confOpts ); err != nil {
65- return err
66- }
67- }
68- modification := & hcsschema.ModifySettingRequest {
69- RequestType : guestrequest .RequestTypeAdd ,
70- GuestRequest : guestrequest.ModificationRequest {
71- ResourceType : guestresource .ResourceTypeSecurityPolicy ,
72- RequestType : guestrequest .RequestTypeAdd ,
73- Settings : * confOpts ,
74- },
75- }
76- if err := uvm .modify (ctx , modification ); err != nil {
77- return fmt .Errorf ("uvm::Policy: failed to modify utility VM configuration: %w" , err )
78- }
79- return nil
80- }
81-
8237func base64EncodeFileContents (filePath string ) (string , error ) {
8338 if filePath == "" {
8439 return "" , nil
@@ -94,7 +49,7 @@ func base64EncodeFileContents(filePath string) (string, error) {
9449// content before setting it for the resource. This is no-op if the
9550// `referenceName` is empty or the file doesn't exist.
9651func WithUVMReferenceInfo (referenceRoot string , referenceName string ) ConfidentialUVMOpt {
97- return func (ctx context.Context , r * guestresource.LCOWConfidentialOptions ) error {
52+ return func (ctx context.Context , r * guestresource.ConfidentialOptions ) error {
9853 if referenceName == "" {
9954 return nil
10055 }
@@ -112,6 +67,11 @@ func WithUVMReferenceInfo(referenceRoot string, referenceName string) Confidenti
11267 }
11368}
11469
70+ // defaultWCOWOSBootFilesPath returns `%ProgramFiles%\Windows Containers`.
71+ func defaultWCOWOSBootFilesPath () string {
72+ return filepath .Join (os .Getenv ("ProgramFiles" ), "Windows Containers" )
73+ }
74+
11575// SetConfidentialUVMOptions sends information required to run the UVM on
11676// SNP hardware, e.g., security policy and enforcer type, signed UVM reference
11777// information, etc.
@@ -126,7 +86,7 @@ func (uvm *UtilityVM) SetConfidentialUVMOptions(ctx context.Context, opts ...Con
12686 uvm .m .Lock ()
12787 defer uvm .m .Unlock ()
12888
129- confOpts := & guestresource.LCOWConfidentialOptions {}
89+ confOpts := & guestresource.ConfidentialOptions {}
13090 for _ , o := range opts {
13191 if err := o (ctx , confOpts ); err != nil {
13292 return err
@@ -156,7 +116,7 @@ func (uvm *UtilityVM) InjectPolicyFragment(ctx context.Context, fragment *ctrdta
156116 GuestRequest : guestrequest.ModificationRequest {
157117 ResourceType : guestresource .ResourceTypePolicyFragment ,
158118 RequestType : guestrequest .RequestTypeAdd ,
159- Settings : guestresource.LCOWSecurityPolicyFragment {
119+ Settings : guestresource.SecurityPolicyFragment {
160120 Fragment : fragment .Fragment ,
161121 },
162122 },
0 commit comments