From nobody Fri May 3 15:48:30 2024 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com 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 1626280886848921.2877288130346; Wed, 14 Jul 2021 09:41:26 -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-602-bM73hamxPYeBqugV76nv7g-1; Wed, 14 Jul 2021 12:41:24 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AAE31804140; Wed, 14 Jul 2021 16:41:18 +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 EB9C760936; Wed, 14 Jul 2021 16:41:17 +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 E332E1809C99; Wed, 14 Jul 2021 16:41:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16EGfDIk020196 for ; Wed, 14 Jul 2021 12:41:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E5291011017; Wed, 14 Jul 2021 16:41:13 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A8911014617 for ; Wed, 14 Jul 2021 16:41:10 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E740858F14 for ; Wed, 14 Jul 2021 16:41:10 +0000 (UTC) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-26-4Jz7Owu_P0CznddLJnJ_bQ-1; Wed, 14 Jul 2021 12:41:06 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16EGZZvM118186; Wed, 14 Jul 2021 12:41:05 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 39ssmrafxm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Jul 2021 12:41:05 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16EGacQH010707; Wed, 14 Jul 2021 16:41:03 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 39q2th9vhn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Jul 2021 16:41:03 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16EGexke14483784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jul 2021 16:40:59 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 86252AE053; Wed, 14 Jul 2021 16:40:59 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 60A73AE058; Wed, 14 Jul 2021 16:40:59 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.86.110]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 14 Jul 2021 16:40:59 +0000 (GMT) X-MC-Unique: bM73hamxPYeBqugV76nv7g-1 X-MC-Unique: 4Jz7Owu_P0CznddLJnJ_bQ-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH v2] nodedev: fix internal error when no defined mdevs exist Date: Wed, 14 Jul 2021 18:40:57 +0200 Message-Id: <20210714164057.8644-1-fiuczy@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: phAr_atFmlWD7lN0mrtkpVxFlqRmkvFs X-Proofpoint-GUID: phAr_atFmlWD7lN0mrtkpVxFlqRmkvFs X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-14_10:2021-07-14, 2021-07-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 priorityscore=1501 impostorscore=0 adultscore=0 mlxlogscore=886 bulkscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107140099 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: jjongsma@redhat.com, shalini@linux.ibm.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.13 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-ZM-MESSAGEID: 1626280889244100001 Content-Type: text/plain; charset="utf-8" Commit e9b534905f4 introduced an error when parsing an empty list returned from mdevctl. This occurs e.g. if nodedev-undefine is used to undefine the last defined mdev which cuases the following error messages libvirtd[33143]: internal error: Unexpected format for mdevctl response libvirtd[33143]: internal error: failed to query mdevs from mdevctl: libvirtd[33143]: mdevctl failed to updated mediated devices Signed-off-by: Boris Fiuczynski Reviewed-by: Martin Kletzander Reviewed-by: Shalini Chellathurai Saroja --- src/node_device/node_device_driver.c | 5 +++++ tests/nodedevmdevctldata/mdevctl-list-empty.json | 1 + tests/nodedevmdevctldata/mdevctl-list-empty.out.xml | 0 tests/nodedevmdevctltest.c | 1 + 4 files changed, 7 insertions(+) create mode 100644 tests/nodedevmdevctldata/mdevctl-list-empty.json create mode 100644 tests/nodedevmdevctldata/mdevctl-list-empty.out.xml diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index b4dd57e5f4..b16b05f9b2 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -1120,6 +1120,11 @@ nodeDeviceParseMdevctlJSON(const char *jsonstring, goto error; } =20 + if (virJSONValueArraySize(json_devicelist) =3D=3D 0) { + *devs =3D outdevs; + return 0; + } + /* mdevctl list --dumpjson produces an output that is an array that * contains only a single object which contains a property for each pa= rent * device */ diff --git a/tests/nodedevmdevctldata/mdevctl-list-empty.json b/tests/noded= evmdevctldata/mdevctl-list-empty.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/tests/nodedevmdevctldata/mdevctl-list-empty.json @@ -0,0 +1 @@ +[] diff --git a/tests/nodedevmdevctldata/mdevctl-list-empty.out.xml b/tests/no= dedevmdevctldata/mdevctl-list-empty.out.xml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 8ba1d2da70..e246de4d87 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -360,6 +360,7 @@ mymain(void) =20 DO_TEST_LIST_DEFINED(); =20 + DO_TEST_PARSE_JSON("mdevctl-list-empty"); DO_TEST_PARSE_JSON("mdevctl-list-multiple"); =20 DO_TEST_DEFINE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); --=20 2.31.1