Skip to content

fix(vm-manager): guard qemu location lookup output#2682

Open
ljm42 wants to merge 1 commit into
masterfrom
fix/qemu-null-shell-output
Open

fix(vm-manager): guard qemu location lookup output#2682
ljm42 wants to merge 1 commit into
masterfrom
fix/qemu-null-shell-output

Conversation

@ljm42

@ljm42 ljm42 commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

VM launch path translation now treats missing getfattr output as an empty location so PHP 8.4 does not log deprecation noise while preserving the existing fallback behavior.

Why This Exists

The VM manager qemu.php hook asks shfs for a system.LOCATION value before replacing /mnt/user/... paths with their backing disk or pool path. When that attribute lookup returns no output, shell_exec() can return null; passing that directly into trim() emits a PHP 8.4 deprecation warning during VM startup.

Resolution

Coalesce the shell_exec() result to an empty string before trimming it. This keeps the existing empty($realdisk) fallback path intact when no location is available.

Reviewer Considerations

  • Confirm that preserving the original /mnt/user/... argument is still the right fallback when no system.LOCATION value is returned.
  • The command and xattr name are unchanged; only the handling of no-output results changes.

Behavior Changes

VM startup should no longer emit a PHP deprecation warning when the location lookup produces no output. Path translation behavior is otherwise unchanged.

Implementation Summary

  • Guard the qemu.php shell_exec() result with ?? '' before trim().

Verification

  • git diff --check
  • Dev-container PHP syntax lint: php -l emhttp/plugins/dynamix.vm.manager/scripts/qemu.php
  • Target PHP 8.4 expression check: trim(null ?? "") === "" returned true.

Risk

Low; the change only normalizes a no-output command result to the empty string path the existing logic already treats as no replacement.

OS-480

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

detect_user_share() now converts a null getfattr result to an empty string before trimming, so unreadable system.LOCATION values are handled as missing metadata.

Changes

VM share detection failure handling

Layer / File(s) Summary
Null getfattr fallback
emhttp/plugins/dynamix.vm.manager/scripts/qemu.php
detect_user_share() coalesces a null getfattr result to an empty string before trimming, changing unreadable system.LOCATION handling.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

I sniffed the disk and hopped along 🐰
When getfattr blinked out, I sang a small song
No nulls to nibble, no trim-time fright
Just empty grass and a gentler byte ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main fix: guarding the VM manager's qemu location lookup output.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/qemu-null-shell-output

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2026.06.24.2338
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2682/webgui-pr-2682.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates
  • Post-merge behavior: This preview stays available after merge until preview storage expires or it is manually cleaned up

📝 Modified Files:

Click to expand file list
emhttp/plugins/dynamix.vm.manager/scripts/qemu.php

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2682, or run:

plugin remove webgui-pr-2682

🤖 This comment is automatically generated and will be updated with each new push to this PR.

@ljm42 ljm42 marked this pull request as ready for review June 24, 2026 23:45
@unraid-bot unraid-bot added the 7.3.2 Approved for release 7.3.2 (auto-managed by notification-worker) label Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.3.2 Approved for release 7.3.2 (auto-managed by notification-worker)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants