From nobody Tue Feb 10 04:13:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623774549; cv=none; d=zohomail.com; s=zohoarc; b=Efnl/Zw17TyPecnsCu6KDGRCtdpnUU0v63nNuS70QFhgpCwHEKWX8gztWPdSUNJx4O/YA6LAo2kYXFbsOUM4uEqX3iPqsyHDmGVOP+gjfPBlyTDF36pok19GeZ49blqaiKKihkFnjC9BpEB0O842Jd67eg9/mkEhlp1puL9rhL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623774549; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CNqvf/+zHex+BeTUfKPHsQF30wZWe2oDTRkOonB/ir4=; b=LBUk0HU66oXWwsVuQN5+DCvl9Ep4LFI/DjLVqcbGwDDffZE4fPx981fknK5ULRH7YpWIUOEovfurVzBMR1s4A4SpTElYXXk5IDTwODXCQEpRby7Y9IUTsLaBQuLTTktb8UfX8H01bsxiBX+tpDX+hReudW5AqR3BhAeAet48jAA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 162377454998451.47466120023455; Tue, 15 Jun 2021 09:29:09 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-nL407zrOPE-dg5E8ViGCzA-1; Tue, 15 Jun 2021 12:29:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D253A8015D0; Tue, 15 Jun 2021 16:29:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5B5F18F0A; Tue, 15 Jun 2021 16:29:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7EAAE1809CBB; Tue, 15 Jun 2021 16:29:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15FGSjC6023670 for ; Tue, 15 Jun 2021 12:28:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5468860E3A; Tue, 15 Jun 2021 16:28:45 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-114-10.phx2.redhat.com [10.3.114.10]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2651860C4A for ; Tue, 15 Jun 2021 16:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623774548; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CNqvf/+zHex+BeTUfKPHsQF30wZWe2oDTRkOonB/ir4=; b=bosDohmX4fK5qynNnEfJtXsRZyv3K3lks4me2PQ+ZpLC0dcFFcgcixuATAr5E1R27MmmQv AEi8denVl3cFu2i7O6FZPk8XFb5E8HqehUlQp6QeTWUrH+Bdw27YkZ3jpyp1vtN4Hj6w72 xqBrul/Sjb+mUW9VXWL1NWeRw70RKGc= X-MC-Unique: nL407zrOPE-dg5E8ViGCzA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] nodedev: Handle NULL command variable Date: Tue, 15 Jun 2021 11:28:39 -0500 Message-Id: <20210615162840.269488-3-jjongsma@redhat.com> In-Reply-To: <20210615162840.269488-1-jjongsma@redhat.com> References: <20210615162840.269488-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In commit 68580a51, I removed the checks for NULL cmd variables because virCommandRun() already handles the case where it is called with a NULL cmd. Unfortunately, it handles this case by raising a generic error which is both unhelpful and overwrites our existing error message. So for example, when I attempt to create a mediated device with an invalid parent, I get the following output: virsh # nodedev-create mdev-test.xml error: Failed to create node device from mdev-test.xml error: internal error: invalid use of command API With this patch, I now get a useful error message again: virsh # nodedev-create mdev-test.xml error: Failed to create node device from mdev-test.xml error: internal error: unable to find parent device 'pci_0000_00_03_0' Signed-off-by: Jonathon Jongsma --- src/node_device/node_device_driver.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 0f13cb4849..e6d4e6ccb1 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -799,9 +799,10 @@ virMdevctlCreate(virNodeDeviceDef *def, char **uuid, c= har **errmsg) MDEVCTL_CMD_CR= EATE, uuid, errmsg); + /* an auto-generated uuid is returned via stdout if no uuid is specifi= ed in * the mdevctl args */ - if (virCommandRun(cmd, &status) < 0 || status !=3D 0) + if (!cmd || virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; =20 /* remove newline */ @@ -821,7 +822,7 @@ virMdevctlDefine(virNodeDeviceDef *def, char **uuid, ch= ar **errmsg) =20 /* an auto-generated uuid is returned via stdout if no uuid is specifi= ed in * the mdevctl args */ - if (virCommandRun(cmd, &status) < 0 || status !=3D 0) + if (!cmd || virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; =20 /* remove newline */ @@ -925,7 +926,7 @@ virMdevctlStop(virNodeDeviceDef *def, char **errmsg) =20 cmd =3D nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_STOP, NULL, errms= g); =20 - if (virCommandRun(cmd, &status) < 0 || status !=3D 0) + if (!cmd || virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; =20 return 0; @@ -940,7 +941,7 @@ virMdevctlUndefine(virNodeDeviceDef *def, char **errmsg) =20 cmd =3D nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_UNDEFINE, NULL, e= rrmsg); =20 - if (virCommandRun(cmd, &status) < 0 || status !=3D 0) + if (!cmd || virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; =20 return 0; @@ -955,7 +956,7 @@ virMdevctlStart(virNodeDeviceDef *def, char **errmsg) =20 cmd =3D nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_START, NULL, errm= sg); =20 - if (virCommandRun(cmd, &status) < 0 || status !=3D 0) + if (!cmd || virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; =20 return 0; --=20 2.31.1