[GH-ISSUE #139] VirtualMachine.IsRunning and VirtualMachine.IsStopped unconditionally rely on fields that VirtualMachine may not have #32

Closed
opened 2026-03-03 15:29:45 +03:00 by kerem · 3 comments
Owner

Originally created by @brandonllocke on GitHub (Mar 30, 2024).
Original GitHub issue: https://github.com/luthermonson/go-proxmox/issues/139

Starting this issue with the full disclosure that I know enough Go and enough Proxmox to be dangerous, but not much more than that.

It seems that the VirtualMachine type is written in such a way that it is not necessarily expected to always get a value for QMPStatus:

QMPStatus      string `json:"qmpstatus,omitempty"`

But the VirtualMachine.IsRunning() and VirtualMachine.IsStopped() functions (and likely others) essentially require QMPStatus to be set to work.

func (v *VirtualMachine) IsRunning() bool {
	return v.Status == StatusVirtualMachineRunning && v.QMPStatus == StatusVirtualMachineRunning
}

As such (for reasons not clear to me), I have VMs on my Proxmox server that are not returning anything for QMPStatus, so IsRunning() always returns false despite the fact that the VMs are running.

Should this be checking for empty values before comparing QMPStatus? If so, I am willing to try to make a PR for that. I Just wanted to make sure I'm not misunderstanding what is happening before I attempt that.

Thanks!

Originally created by @brandonllocke on GitHub (Mar 30, 2024). Original GitHub issue: https://github.com/luthermonson/go-proxmox/issues/139 Starting this issue with the full disclosure that I know enough Go and enough Proxmox to be dangerous, but not much more than that. It seems that the `VirtualMachine` type is written in such a way that it is not necessarily expected to always get a value for QMPStatus: ``` QMPStatus string `json:"qmpstatus,omitempty"` ``` But the `VirtualMachine.IsRunning()` and `VirtualMachine.IsStopped()` functions (and likely others) essentially require QMPStatus to be set to work. ``` func (v *VirtualMachine) IsRunning() bool { return v.Status == StatusVirtualMachineRunning && v.QMPStatus == StatusVirtualMachineRunning } ``` As such (for reasons not clear to me), I have VMs on my Proxmox server that are not returning anything for QMPStatus, so `IsRunning()` always returns `false` despite the fact that the VMs are running. Should this be checking for empty values before comparing QMPStatus? If so, I am willing to try to make a PR for that. I Just wanted to make sure I'm not misunderstanding what is happening before I attempt that. Thanks!
kerem closed this issue 2026-03-03 15:29:45 +03:00
Author
Owner

@justinclift commented on GitHub (Apr 18, 2024):

I have VMs on my Proxmox server that are not returning anything for QMPStatus

It kind of sounds like that might really be the core problem which needs fixing? 😄

<!-- gh-comment-id:2064881420 --> @justinclift commented on GitHub (Apr 18, 2024): > I have VMs on my Proxmox server that are not returning anything for QMPStatus It kind of sounds like that might really be the core problem which needs fixing? :smile:
Author
Owner

@brandonllocke commented on GitHub (Apr 18, 2024):

I can't say much for certain as the documentation on what that value actually means is not very clear, but it does appear QMPStatus is optional, so it being required to determine if a VM is running/stopped/etc. feels like a bug. I'm open to being wrong.

<!-- gh-comment-id:2064926753 --> @brandonllocke commented on GitHub (Apr 18, 2024): I can't say much for certain as the documentation on what that value actually means is not very clear, but it does appear QMPStatus is optional, so it being required to determine if a VM is running/stopped/etc. feels like a bug. I'm open to being wrong.
Author
Owner

@luthermonson commented on GitHub (Apr 19, 2024):

ya so that's leaning towards the client having a bug and we shouldnt check QMPStatus in that func and others

<!-- gh-comment-id:2065564786 --> @luthermonson commented on GitHub (Apr 19, 2024): ya so that's leaning towards the client having a bug and we shouldnt check QMPStatus in that func and others
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-proxmox#32
No description provided.