Skip to content

feat(kubevirt): add tool for QEMU guest agent access#811

Open
codingben wants to merge 2 commits into
containers:mainfrom
codingben:add-guest-info
Open

feat(kubevirt): add tool for QEMU guest agent access#811
codingben wants to merge 2 commits into
containers:mainfrom
codingben:add-guest-info

Conversation

@codingben
Copy link
Copy Markdown
Contributor

@codingben codingben commented Feb 25, 2026

Implements vm_guest_info tool to retrieve information from inside running VMs via QEMU guest agent without requiring SSH credentials.

Assisted-By: Claude noreply@anthropic.com

@codingben
Copy link
Copy Markdown
Contributor Author

/cc @lyarwood @ksimon1 @manusa @Cali0707

Comment thread evals/tasks/kubevirt/audit-vm-users/task.yaml Outdated
Copy link
Copy Markdown
Contributor

@lyarwood lyarwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets start with the evals, the use cases here are far too high level and model dependant for now. Can you simplify these and break them out into their own commits before any tooling is introduced.

Comment thread evals/tasks/kubevirt/audit-vm-users/task.yaml Outdated
Comment thread evals/tasks/kubevirt/audit-vm-users/task.yaml Outdated
Comment thread evals/tasks/kubevirt/diagnose-vm-network/task.yaml Outdated
@codingben
Copy link
Copy Markdown
Contributor Author

@ksimon1 I'll address it. @lyarwood Does it looks better now?

Comment thread pkg/toolsets/kubevirt/vm/guestagent/tool.go Outdated
Comment thread pkg/toolsets/kubevirt/vm/guestagent/tool.go Outdated
Comment thread pkg/toolsets/kubevirt/vm/guestagent/tool.go Outdated
Comment thread pkg/toolsets/kubevirt/vm/guestagent/tool.go Outdated
Comment thread pkg/toolsets/kubevirt/vm/guestagent/tool.go Outdated
Comment thread pkg/mcp/kubevirt_test.go
@codingben codingben requested review from awels and ksimon1 April 12, 2026 15:29
@codingben codingben force-pushed the add-guest-info branch 2 times, most recently from 10eb79b to 07aa5a4 Compare April 13, 2026 12:34
Comment thread evals/tasks/kubevirt/vm-guest-info/task.yaml Outdated
Comment thread evals/tasks/kubevirt/vm-guest-info/task.yaml Outdated
Comment thread evals/tasks/kubevirt/vm-guest-info/task.yaml Outdated
Comment thread evals/tasks/kubevirt/get-vm-filesystems/task.yaml Outdated
Comment thread pkg/toolsets/kubevirt/vm/guestagent/tool.go Outdated
Comment thread pkg/toolsets/kubevirt/vm/guestagent/tool.go Outdated
Comment thread pkg/toolsets/kubevirt/vm/guestagent/tool.go Outdated
Comment thread pkg/toolsets/kubevirt/vm/guestagent/tool.go Outdated
Comment thread pkg/toolsets/kubevirt/vm/guestagent/tool_test.go Outdated
@lyarwood lyarwood mentioned this pull request Apr 15, 2026
@Cali0707
Copy link
Copy Markdown
Collaborator

/run-mcpchecker kubevirt

func getGuestOSInfo(ctx context.Context, dynamicClient dynamic.Interface, namespace, name string) (map[string]any, error) {
result, err := dynamicClient.Resource(vmiSubresourcesGVR).
Namespace(namespace).
Get(ctx, name+"/guestosinfo", metav1.GetOptions{})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The subresources.kubevirt.io API group is blocked by the AccessControlRoundTripper because it is not discoverable via standard REST mapper (see #1061 for the same issue with pause/unpause). This path hack (name+"/guestosinfo") also relies on the dynamic client not URL-encoding the slash. Has this been tested against a real KubeVirt cluster?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see and will take a deeper look. I haven't tested it against a real cluster yet.

Comment thread evals/tasks/kubevirt/get-vm-filesystems/task.yaml Outdated
@codingben
Copy link
Copy Markdown
Contributor Author

/run-mcpchecker kubevirt

Did it work? I don't see results from this job.

@lyarwood
Copy link
Copy Markdown
Contributor

/run-mcpchecker kubevirt

Did it work? I don't see results from this job.

See https://github.com/containers/kubernetes-mcp-server/actions/runs/24468624290/job/71502564513

@codingben codingben force-pushed the add-guest-info branch 5 times, most recently from 7287232 to f37c6f1 Compare April 16, 2026 14:06
Comment thread pkg/kubevirt/guestagent.go Outdated
Comment thread pkg/kubevirt/guestagent.go Outdated
Comment thread pkg/kubevirt/guestagent.go Outdated
Comment thread pkg/kubevirt/guestagent_test.go
Comment on lines +64 to +73
- script:
inline: |-
#!/usr/bin/env bash
set -e
if ! kubectl get vm test-vm -n vm-test-os-info &>/dev/null; then
echo "ERROR: VirtualMachine 'test-vm' not found"
exit 1
fi
echo "Verification passed: VM exists"
exit 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We spoke about this briefly a few days ago but the verify step here only checks that the VM exists, not that the agent actually retrieved OS info from the guest agent. The same issue applies to the other eval tasks (get-vm-filesystems, get-vm-ip-address, list-vm-users).

You could add an llmJudge verify step to check the agent's response semantically. mcpchecker supports contains and exact fields on llmJudge, for example:

verify:
  - script:
      inline: |-
        # existing VM existence check
  - llmJudge:
      contains: "Fedora"

This would verify the agent's response mentions the expected OS name. Similar patterns for the other tasks:

  • get-vm-filesystems: contains: "/"
  • get-vm-ip-address: contains: "10."
  • list-vm-users: contains: "admin"

Note: llmJudge does a semantic comparison via a judge LLM, not a literal substring match, so it's fairly flexible. However it does not support custom evaluation criteria or rubrics - only contains and exact reference matching.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I've added it, can you please review here this revision?

@codingben codingben force-pushed the add-guest-info branch 3 times, most recently from 5fdfeb0 to c307c36 Compare April 19, 2026 09:08
@codingben
Copy link
Copy Markdown
Contributor Author

Can we retrigger the Ubuntu 24.04-arm job? I'm not sure what caused the failure there.

@Cali0707
Copy link
Copy Markdown
Collaborator

@codingben soemtimes we have flakes on those, I imagine this is a similar case - rerunning it now anyways

@codingben
Copy link
Copy Markdown
Contributor Author

@codingben soemtimes we have flakes on those, I imagine this is a similar case - rerunning it now anyways

I see that the CI passed now. Can you please run MCP checker on this PR?

@manusa
Copy link
Copy Markdown
Member

manusa commented Apr 29, 2026

/run-mcpchecker kubevirt

@github-actions
Copy link
Copy Markdown
Contributor

mcpchecker MCP Evaluation Results

Commit: c307c36
Summary: 7/17 tasks passed (41.2%)

Metric Result
Tasks Passed 7/17
Assertions Passed 42/42
Overall ⚠️ Workflow failed

View full results

@codingben
Copy link
Copy Markdown
Contributor Author

Hey, how we can proceed here? Can we merge it?

@lyarwood
Copy link
Copy Markdown
Contributor

lyarwood commented May 7, 2026

Hey, how we can proceed here? Can we merge it?

Can you rebase this branch on main to pick up #1054, that should fix the passing rate and allow us to move forward here.

Add five simple evaluation tasks that test basic vm_guest_info functionality:
- get-vm-filesystems: Get filesystem information from inside a VM
- get-vm-ip-address: Get IP address from inside the guest OS
- get-vm-os-info: Get OS name and version from a VM
- list-vm-users: List currently logged-in users in a VM
- vm-guest-info: General test for retrieving guest agent information

These evals focus on testing the basic building blocks rather than
high-level use cases, making them more reliable and model-independent.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Ben Oukhanov <boukhanov@redhat.com>
@codingben
Copy link
Copy Markdown
Contributor Author

@lyarwood Thank you! Just rebased it. Can you please run the MCP checker again?

Add new vm_guest_info tool that enables querying information from inside
VirtualMachines using the QEMU guest agent, without requiring SSH access
or credentials.

The tool supports querying:
- os: Operating system information (name, version, kernel, hostname)
- filesystem: Mounted filesystems and disk usage
- network: Network interfaces and IP addresses
- users: Currently logged-in users and sessions

This provides a secure way to gather runtime information from VMs for
monitoring, troubleshooting, and compliance purposes.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Ben Oukhanov <boukhanov@redhat.com>
@lyarwood
Copy link
Copy Markdown
Contributor

lyarwood commented May 7, 2026

@manusa would you mind running /run-mcpchecker kubevirt again?

@Cali0707
Copy link
Copy Markdown
Collaborator

Cali0707 commented May 7, 2026

/run-mcpchecker kubevirt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants