From 53bf54cdb3df55ce67ae469d13e3e77b03c99b3a Mon Sep 17 00:00:00 2001 From: Dino Korah <691011+codemedic@users.noreply.github.com> Date: Sun, 22 Mar 2026 21:38:32 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20address=20remaining=20cubic=20review=20i?= =?UTF-8?q?ssues=20=E2=80=94=20pgrep=20scope,=20/proc=20portability,=20QEM?= =?UTF-8?q?U=20device=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Scope pgrep fallback to the VM socket path to avoid matching unrelated virtiofsd instances - Replace /proc//comm checks with portable `ps -p ... -o comm=` in both start and stop - Fix QEMU virtiofs capability check: use `-device help` and match quoted device name to avoid false-positives on error output --- quickemu | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/quickemu b/quickemu index 136b7e3..cde805f 100755 --- a/quickemu +++ b/quickemu @@ -1686,8 +1686,8 @@ function start_virtiofsd() { VIRTIOFSD_PID=$(fuser "${VIRTIOFSD_SOCKET}" 2>/dev/null | tr -s ' ' '\n' | grep -m1 '[0-9]') else local candidate - candidate=$(pgrep -f "virtiofsd" 2>/dev/null | head -1) - if grep -q 'virtiofsd' "/proc/${candidate}/comm" 2>/dev/null; then + candidate=$(pgrep -f "virtiofsd.*${VIRTIOFSD_SOCKET}" 2>/dev/null | head -1) + if ps -p "${candidate}" -o comm= 2>/dev/null | grep -q 'virtiofsd'; then VIRTIOFSD_PID="${candidate}" fi fi @@ -1708,8 +1708,8 @@ function stop_virtiofsd() { if [ -n "${pid}" ] && kill -0 "${pid}" 2>/dev/null; then # Guard against PID reuse: only signal the process if it is still - # a virtiofsd instance. /proc//comm holds the executable name. - if grep -q 'virtiofsd' "/proc/${pid}/comm" 2>/dev/null; then + # a virtiofsd instance. + if ps -p "${pid}" -o comm= 2>/dev/null | grep -q 'virtiofsd'; then # Ask virtiofsd to shut down gracefully first; it will close the # vhost-user socket and flush any pending I/O before exiting. kill -TERM "${pid}" 2>/dev/null @@ -2176,7 +2176,7 @@ function vm_boot() { if [ -n "${VIRTIOFSD_SOCKET}" ]; then # Verify QEMU supports vhost-user-fs-pci before using it; older QEMU # builds silently lack the device and would abort VM startup. - if ! "${QEMU}" -device vhost-user-fs-pci,help 2>&1 | grep -q "vhost-user-fs-pci"; then + if ! "${QEMU}" -device help 2>&1 | grep -q '"vhost-user-fs-pci"'; then echo " - WARNING! QEMU does not support vhost-user-fs-pci; falling back to 9p." stop_virtiofsd VIRTIOFSD_SOCKET=""