From nobody Mon Feb 9 12:43:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1692867473; cv=none; d=zohomail.com; s=zohoarc; b=ir/YV6qL6oj35sFVvqgK8wzM7j/7AWRgzUTcW/rQNvqWeAKzKZs8/EcxiGWtkwj5Py43tvKa7/ycuRrOADWBfqKAExX6lj6p1cEgYBEi6VRPT9TfaYP7qr7E6nwB+++I8eznw0AqChkLH+LyzSAosLj2fo37lbp3d5p+dakMMZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867473; 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=bPIzlum2CXGD91n/9qRXq/Hr16nJ7TBuFM3Mj8svbbg=; b=nc32RZuahhf9PhIoDskZpL9tkaz9ek7W2aIeBgif72U8LS2COVfHaJcjYdI168vAowDJcH8Ack2FuV0/qmSlrgcfPILh0oy+bhH9RKxWcEL9+uf4FhpFEBfcKint08yiwvK8vZL/1WJfH+f8LdvIp4k+pTF6sTDxYznnU8e0C/w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1692867473894866.0022808440899; Thu, 24 Aug 2023 01:57:53 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-Cefe9lZzNGyGveCP2A_1IA-1; Thu, 24 Aug 2023 04:57:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7FF142808E69; Thu, 24 Aug 2023 08:57:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C80E40D2839; Thu, 24 Aug 2023 08:57:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5118D194658C; Thu, 24 Aug 2023 08:57:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CA9201946589 for ; Thu, 24 Aug 2023 08:57:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AC6901121319; Thu, 24 Aug 2023 08:57:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 543AF1121314 for ; Thu, 24 Aug 2023 08:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867472; 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=bPIzlum2CXGD91n/9qRXq/Hr16nJ7TBuFM3Mj8svbbg=; b=B03uBpmyrTHYJZMcFxwaXQ1fU0pNuSg4C12+5h+mzY+I3RCG+BHYVi7a5d4An7vT0Q9wDT zU0W+qIchmJTa88Xaf0AW7F+qjsKvLcvKAOcvNwQBKVvHoOjjNaplsJbsvdK8M+lIgTsa5 ci4/cbbGbERXpUXoP+0X6Mf6laQqGf4= X-MC-Unique: Cefe9lZzNGyGveCP2A_1IA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/6] nodeDeviceParseMdevctlJSON: Accept empty string Date: Thu, 24 Aug 2023 10:57:36 +0200 Message-ID: <3ad475ebf334fff1aa7eafc344ef32dc5d49ff46.1692867419.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1692867475554100006 Content-Type: text/plain; charset="utf-8"; x-default="true" It is possible for 'mdevctl' to output nothing, an empty string (e.g. when no mediated devices are defined on the host). What is weird is that when passing '--defined' then 'mdevctl' outputs an empty JSON array instead. Nevertheless, we should accept both and threat them the same, i.e. as no mediated devices. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/523 Signed-off-by: Michal Privoznik Reviewed-by: Kristina Hanicova --- src/node_device/node_device_driver.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 2ef9197adc..593bc64e25 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -43,6 +43,7 @@ #include "virutil.h" #include "vircommand.h" #include "virlog.h" +#include "virstring.h" =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 @@ -1176,6 +1177,12 @@ nodeDeviceParseMdevctlJSON(const char *jsonstring, size_t j; virJSONValue *obj; =20 + if (virStringIsEmpty(jsonstring)) { + VIR_DEBUG("mdevctl has no defined mediated devices"); + *devs =3D NULL; + return 0; + } + json_devicelist =3D virJSONValueFromString(jsonstring); =20 if (!json_devicelist || !virJSONValueIsArray(json_devicelist)) { --=20 2.41.0