From nobody Mon May 6 19:07:31 2024 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=1615395701; cv=none; d=zohomail.com; s=zohoarc; b=COcxc6c19Xobc/YR9NBdcM/TAtNzkEm0YIkilhfvuG2MBKVGLI68szVNVjU+r4ANqrYURHlsfV050Yow9mD4ftht8CwKC9MkQg9ezyRZ8S2lIKIshmuYbT9a6jy4iN2MFMBYL6a5i8qH1VKlwRZu5KbxXLTZVieHDX8AIP9Fha0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615395701; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=GkcGOwwKAnDbLRFuRrCU9FOw0lZQ74VHA4n00CVeMwE=; b=A5tgpyR+fCAREO0tU+ehwAnoCUNRJ8hpsNE4kMcrbv7QQldTYklrRtN9A4SjFu5RLCIHpuTE0F2tDgtzZFAWfpH+pwkEENfB35skHCINOT/U9+ktSk2+FcQnsL+8jW4I9Fxqcsh7rGukof+yTTxYdy0va21d7+vaS/wQzfOnnas= 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) header.from= 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 1615395701946635.1112217990992; Wed, 10 Mar 2021 09:01:41 -0800 (PST) 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-11-v3X4p6sSPBK9LUQl4W6NSA-1; Wed, 10 Mar 2021 12:01:37 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 260B8881D71; Wed, 10 Mar 2021 17:01:29 +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 B1BA460C5F; Wed, 10 Mar 2021 17:01:28 +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 33E9E1809C86; Wed, 10 Mar 2021 17:01:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12AH1QsA024696 for ; Wed, 10 Mar 2021 12:01:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1F5E45C23E; Wed, 10 Mar 2021 17:01:26 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.194.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43DD75C1A1 for ; Wed, 10 Mar 2021 17:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615395699; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GkcGOwwKAnDbLRFuRrCU9FOw0lZQ74VHA4n00CVeMwE=; b=Axz7P3mXDXHplwTeqJCcJIBjgVkDnHkvNOGzefV2rN/fplxKZlMiJMH7cDeSqYDCziEtPK qnp+JI51xEcUYs/omN7fg72AcSVQcH+2+5IW9fLu1Tvm551imQQPt+NE3yDwq7q9hqgunU PMiHFBTeSv2do86HL8DzQuq5TKaAJF0= X-MC-Unique: v3X4p6sSPBK9LUQl4W6NSA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2] qemu: don't raise error upon interface update without for in coalesce Date: Wed, 10 Mar 2021 18:01:17 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.12 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" With this, incomplete XML without for in coalesce won't raise error as before. It will leave the coalesce parameter empty, thanks to passing it as a parameter and return an integer to indicate error state - previously it returned pointer (or NULL for both error and incomplete XML). I also added a test case to test this functionality in the qemuxml2xmltest. The code went through some refactoring: * change of a condition * addition of a parameter * change of order, that allowed removal of VIR_FREE * removal of redundant labels and variables Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1535930 Signed-off-by: Kristina Hanicova Reviewed-by: Martin Kletzander --- diff to v1: - Added qemuxml2xmlout testcase, per Martin's review src/conf/domain_conf.c | 25 +++++++++-------------- tests/qemuxml2argvdata/net-coalesce.xml | 9 ++++++++ tests/qemuxml2xmloutdata/net-coalesce.xml | 8 +++++++- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b731744f04..798594f520 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7516,11 +7516,11 @@ virDomainNetIPInfoParseXML(const char *source, } =20 =20 -static virNetDevCoalescePtr +static int virDomainNetDefCoalesceParseXML(xmlNodePtr node, - xmlXPathContextPtr ctxt) + xmlXPathContextPtr ctxt, + virNetDevCoalescePtr *coalesce) { - virNetDevCoalescePtr ret =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) unsigned long long tmp =3D 0; g_autofree char *str =3D NULL; @@ -7529,15 +7529,13 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node, =20 str =3D virXPathString("string(./rx/frames/@max)", ctxt); if (!str) - return NULL; - - ret =3D g_new0(virNetDevCoalesce, 1); + return 0; =20 if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) { virReportError(VIR_ERR_XML_DETAIL, _("cannot parse value '%s' for coalesce parameter"), str); - goto error; + return -1; } =20 if (tmp > UINT32_MAX) { @@ -7545,15 +7543,13 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node, _("value '%llu' is too big for coalesce " "parameter, maximum is '%lu'"), tmp, (unsigned long) UINT32_MAX); - goto error; + return -1; } - ret->rx_max_coalesced_frames =3D tmp; =20 - return ret; + *coalesce =3D g_new0(virNetDevCoalesce, 1); + (*coalesce)->rx_max_coalesced_frames =3D tmp; =20 - error: - VIR_FREE(ret); - return NULL; + return 0; } =20 static void @@ -11517,8 +11513,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, =20 node =3D virXPathNode("./coalesce", ctxt); if (node) { - def->coalesce =3D virDomainNetDefCoalesceParseXML(node, ctxt); - if (!def->coalesce) + if (virDomainNetDefCoalesceParseXML(node, ctxt, &def->coalesce) < = 0) goto error; } =20 diff --git a/tests/qemuxml2argvdata/net-coalesce.xml b/tests/qemuxml2argvda= ta/net-coalesce.xml index bdcf786429..6fa3641e7d 100644 --- a/tests/qemuxml2argvdata/net-coalesce.xml +++ b/tests/qemuxml2argvdata/net-coalesce.xml @@ -55,6 +55,15 @@ + + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/net-coalesce.xml b/tests/qemuxml2xmlo= utdata/net-coalesce.xml index 3a37587dde..452ed94de3 100644 --- a/tests/qemuxml2xmloutdata/net-coalesce.xml +++ b/tests/qemuxml2xmloutdata/net-coalesce.xml @@ -56,6 +56,12 @@
+ + + + +
+ @@ -67,7 +73,7 @@ -
+
--=20 2.29.2