Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] vcsim: govc vm.disk.change to vcsim crashes by nil pointer dereference #2904

Closed
Syuparn opened this issue Jul 19, 2022 · 0 comments · Fixed by #2905
Closed

[BUG] vcsim: govc vm.disk.change to vcsim crashes by nil pointer dereference #2904

Syuparn opened this issue Jul 19, 2022 · 0 comments · Fixed by #2905

Comments

@Syuparn
Copy link
Contributor

Syuparn commented Jul 19, 2022

Describe the bug

When govc vm.disk.change is requested to vcsim, govc panics and crashes by nil pointer dereference.

To Reproduce
Steps to reproduce the behavior:

  1. run vcsim without any options
  2. execute command below
# check disk in DC0_H0_VM0
$ govc device.info -vm DC0_H0_VM0 disk-*
Name:           disk-202-0
  Type:         VirtualDisk
  Label:        disk-202-0
  Summary:      10,485,760 KB
  Key:          204
  Controller:   pvscsi-202
  Unit number:  0
  File:         [LocalDS_0] DC0_H0_VM0/disk1.vmdk
# change the disk's size
$ govc vm.disk.change -vm DC0_H0_VM0 -disk.name disk-202-0 -size 10G

Expected behavior

govc raises no errors and vcsim increases the disk's size.

Affected version

  • govc: 0.29.0
  • vcsim: 0.29.0

Screenshots/Debug Output

  • govc panics by nil pointer dereference as below
$ govc vm.disk.change -vm DC0_H0_VM0 -disk.name disk-202-0 -size 10G
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xd7ee28]

goroutine 1 [running]:
github.com/vmware/govmomi/govc/vm/disk.(*change).Run(0xc0001ee150, {0x13ddf80, 0xc000130000}, 0xe?)
        /home/runner/work/govmomi/govmomi/govc/vm/disk/change.go:159 +0x148
github.com/vmware/govmomi/govc/cli.Run({0xc00012e010, 0x7, 0x7})
        /home/runner/work/govmomi/govmomi/govc/cli/command.go:165 +0x32d
main.main()
        /home/runner/work/govmomi/govmomi/govc/main.go:114 +0x4f

Additional context
Add any other context about the problem here.

Panic is raised by this line.

https://github.com/vmware/govmomi/blob/master/govc/vm/disk/change.go#L159

Since vm.disk.change works with vCenter, this is due to vcsim models.

> govc device.info -vm vm1 "disk-*"
Name:           disk-1000-0
  Type:         VirtualDisk
  Label:        Hard disk 1
  Summary:      1,048,576 KB
  Key:          2000
  Controller:   pvscsi-1000
  Unit number:  0
  File:         [datastore1] vm1/vm1.vmdk
> govc vm.disk.change -vm vm1 "-disk.name" disk-1000-0 -size 10G
> govc device.info -vm vm1 "disk-*"
Name:           disk-1000-0
  Type:         VirtualDisk
  Label:        Hard disk 1
  Summary:      10,485,760 KB
  Key:          2000
  Controller:   pvscsi-1000
  Unit number:  0
  File:         [datastore1] vm1/vm1.vmdk
Syuparn added a commit to Syuparn/govmomi that referenced this issue Jul 19, 2022
Closes: vmware#2904
Signed-off-by: syuparn <s.hello.spagetti@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant