...

Source file src/github.com/Microsoft/hcsshim/internal/uvm/hvsocket.go

Documentation: github.com/Microsoft/hcsshim/internal/uvm

     1  //go:build windows
     2  
     3  package uvm
     4  
     5  import (
     6  	"context"
     7  	"fmt"
     8  
     9  	"github.com/Microsoft/hcsshim/internal/hcs/resourcepaths"
    10  	hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
    11  	"github.com/Microsoft/hcsshim/internal/protocol/guestrequest"
    12  )
    13  
    14  // UpdateHvSocketService calls HCS to update/create the hvsocket service for
    15  // the UVM. Takes in a service ID and the hvsocket service configuration. If there is no
    16  // entry for the service ID already it will be created. The same call on HvSockets side
    17  // handles the Create/Update/Delete cases based on what is passed in. Here is the logic
    18  // for the call.
    19  //
    20  // 1. If the service ID does not currently exist in the service table, it will be created
    21  // with whatever descriptors and state was specified (disabled or not).
    22  // 2. If the service already exists and empty descriptors and Disabled is passed in for the
    23  // service config, the service will be removed.
    24  // 3. Otherwise any combination that is not Disabled && Empty descriptors will just update the
    25  // service.
    26  //
    27  // If the request is crafted with Disabled = True and empty descriptors, then this function
    28  // will behave identically to a call to RemoveHvSocketService. Prefer RemoveHvSocketService for this
    29  // behavior as the relevant fields are set on HCS' side.
    30  func (uvm *UtilityVM) UpdateHvSocketService(ctx context.Context, sid string, doc *hcsschema.HvSocketServiceConfig) error {
    31  	request := &hcsschema.ModifySettingRequest{
    32  		RequestType:  guestrequest.RequestTypeUpdate,
    33  		ResourcePath: fmt.Sprintf(resourcepaths.HvSocketConfigResourceFormat, sid),
    34  		Settings:     doc,
    35  	}
    36  	return uvm.modify(ctx, request)
    37  }
    38  
    39  // RemoveHvSocketService will remove an hvsocket service entry if it exists.
    40  func (uvm *UtilityVM) RemoveHvSocketService(ctx context.Context, sid string) error {
    41  	request := &hcsschema.ModifySettingRequest{
    42  		RequestType:  guestrequest.RequestTypeRemove,
    43  		ResourcePath: fmt.Sprintf(resourcepaths.HvSocketConfigResourceFormat, sid),
    44  	}
    45  	return uvm.modify(ctx, request)
    46  }
    47  

View as plain text