Skip to content

Commit

Permalink
govc: Edit disk storage IO
Browse files Browse the repository at this point in the history
Closes: vmware#2806
Signed-off-by: Michael Gasch <mgasch@vmware.com>
  • Loading branch information
Michael Gasch committed Apr 5, 2022
1 parent b76ddb0 commit 642eb49
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions govc/vm/disk/change.go
Expand Up @@ -41,6 +41,9 @@ type change struct {

bytes units.ByteSize
mode string

// SIOC
limit int64
}

func init() {
Expand Down Expand Up @@ -73,6 +76,7 @@ func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) {
f.IntVar(&cmd.key, "disk.key", 0, "Disk unique key")
f.StringVar(&cmd.mode, "mode", "", fmt.Sprintf("Disk mode (%s)", strings.Join(vdmTypes, "|")))
f.StringVar(&cmd.sharing, "sharing", "", fmt.Sprintf("Sharing (%s)", strings.Join(sharing, "|")))
f.Int64Var(&cmd.limit, "disk.io.limit", 0, "Disk storage IO per seconds limit (-1 for unlimited)")
}

func (cmd *change) Process(ctx context.Context) error {
Expand Down Expand Up @@ -152,6 +156,13 @@ func (cmd *change) Run(ctx context.Context, f *flag.FlagSet) error {
editdisk.CapacityInKB = int64(cmd.bytes) / 1024
}

current := editdisk.StorageIOAllocation.Limit
desired := cmd.limit

if desired != 0 && *current != desired {
editdisk.StorageIOAllocation.Limit = types.NewInt64(desired)
}

switch backing := editdisk.Backing.(type) {
case *types.VirtualDiskFlatVer2BackingInfo:
backing.Sharing = cmd.sharing
Expand Down

0 comments on commit 642eb49

Please sign in to comment.