From db0ba9202af0b7a14b977df795c747c72dcf327a Mon Sep 17 00:00:00 2001 From: Mayank Bhatt Date: Mon, 16 Oct 2023 15:20:07 -0700 Subject: [PATCH] vcsim: Handle prepare guest operations when svm is nil The existing code would panic due to not checking for svm being nil and then immediately accessing a field to check power state. --- simulator/container_virtual_machine.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simulator/container_virtual_machine.go b/simulator/container_virtual_machine.go index a2b91fd86..a44ad8b97 100644 --- a/simulator/container_virtual_machine.go +++ b/simulator/container_virtual_machine.go @@ -131,7 +131,7 @@ func (svm *simVM) syncNetworkConfigToVMGuestProperties() error { } func (svm *simVM) prepareGuestOperation(auth types.BaseGuestAuthentication) types.BaseMethodFault { - if svm != nil && (svm.c == nil || svm.c.id == "") { + if svm == nil || svm.c == nil || svm.c.id == "" { return new(types.GuestOperationsUnavailable) }