Repository: sustainable-computing-io/kepler (2025-08-12T10:24:57Z)

Issue:
No VM metrics with Centos/RHEL for Openstack
### Kepler Version

0.10.0 or later (Current/Supported)

### Bug Description

On Openstack for exemple, the virtual machine hypervisor is provided by install qem-kvm:
```
qemu-kvm-core-17:8.2.0-11.el9_4.14.x86_64 : qemu-kvm core components                                                           
Repo        : rhosp-rhel-9.4-appstream
Matched from:                      
Filename    : /usr/libexec/qemu-kvm
```
Then the usage is like: 
`/usr/libexec/qemu-kvm -name guest=instance-0000008b,debug-threads=on -S -object {"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain-25-instance-0000008b/master-key.aes"} -machine pc-q35-rhel9.4.0,usb=off,dump-guest-core=off,hpet=off,acpi=on -accel kvm -cpu Broadwell-IBRS [...] `

So of course, because Kepler is only looking for: 
https://github.com/sustainable-computing-io/kepler/blob/0339f536e97ec74a3813fa784bd5f4d489d75891/internal/resource/vm.go#L15

then it can't work...

### Steps to Reproduce

RHEL/CentOS: yum install qemu-kvm-core

### Expected Behavior

kepler_vm_* metrics are present with the right information of the VM. 

### Environment

Any Centos / RHEL

### Logs and Error Messages

```shell

```

### Additional Context

_No response_


Discussion:

Patch:
diff --git a/internal/resource/vm.go b/internal/resource/vm.go
index bea7fd2248..9a5c49f8f6 100644
--- a/internal/resource/vm.go
+++ b/internal/resource/vm.go
@@ -11,8 +11,8 @@ import (
 )
 
 var (
-	// QEMU/KVM patterns
-	qemuPattern = regexp.MustCompile(`bin/qemu-system-\w+`)
+	// QEMU/KVM patterns - matches both qemu-system-* and qemu-kvm variants
+	qemuPattern = regexp.MustCompile(`(bin/qemu-system-\w+|libexec/qemu-kvm)`)
 
 	// TODO: add patterns for virtual box,  VMware, Xen
 


Test patch:
diff --git a/internal/resource/vm_test.go b/internal/resource/vm_test.go
index 40a4b8c2fc..da3456c8da 100644
--- a/internal/resource/vm_test.go
+++ b/internal/resource/vm_test.go
@@ -72,6 +72,37 @@ func TestVMInfoFromCmdLine(t *testing.T) {
 			hypervisor: KVMHypervisor,
 			vmID:       "12345678-1234-5678-9abc-123456789abc",
 		},
+	}, {
+		name: "QEMU-KVM OpenStack (CentOS/RHEL) - realistic command from issue #2276",
+		cmdline: []string{
+			"/usr/libexec/qemu-kvm",
+			"-name", "guest=instance-0000008b,debug-threads=on",
+			"-S",
+			"-object", `{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain-25-instance-0000008b/master-key.aes"}`,
+			"-machine", "pc-q35-rhel9.4.0,usb=off,dump-guest-core=off,hpet=off,acpi=on",
+			"-accel", "kvm",
+			"-cpu", "Broadwell-IBRS",
+			"-uuid", "df12672f-fedb-4f6f-9d51-0166868835fb",
+		},
+		expected: expect{
+			hypervisor: KVMHypervisor,
+			vmID:       "df12672f-fedb-4f6f-9d51-0166868835fb",
+		},
+	}, {
+		name: "QEMU-KVM OpenStack without UUID (CentOS/RHEL) - uses guest name",
+		cmdline: []string{
+			"/usr/libexec/qemu-kvm",
+			"-name", "guest=instance-0000008b,debug-threads=on",
+			"-S",
+			"-object", `{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain-25-instance-0000008b/master-key.aes"}`,
+			"-machine", "pc-q35-rhel9.4.0,usb=off,dump-guest-core=off,hpet=off,acpi=on",
+			"-accel", "kvm",
+			"-cpu", "Broadwell-IBRS",
+		},
+		expected: expect{
+			hypervisor: KVMHypervisor,
+			vmID:       "instance-0000008b",
+		},
 	}, {
 		name: "Not a VM process",
 		cmdline: []string{