From nobody Mon Feb 9 12:26:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1671440705; cv=none; d=zohomail.com; s=zohoarc; b=m690piY7V+xoXRYtccm8r7Y6YtoEifljsZRaO4q4cg1F8KOZ6ENGv0NzmkihLIxbnK+yfZWtDz/8KaKviItmUJh0zneNXA92mKyGgY8kkyoDS+ZZARUSrdUDxNNa6DxAKN38CaSlcAGPMEI2ZFa+vqxhNjhw3dS2UdFnKOWEXy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671440705; 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=b9HpRvEbikjd5pcbgsHfWLa6kdi8mYUY+ZXt7P6DN2c=; b=Lb7Ckjjr8Xgrs1qb0n/NRAdfkeTN0fpPTM9vWAGypxcDS4MsvRZlvI1lV0R1zagNeEDyo/k2OsibU+3opL+9+9CEgZIgvhvn60Fogqh3bDCTrux6WOZ5QPnb8y+6DsKSmkQ4Ep3pg+gOKbXQM4w9m7l0xjj0XyJmrrymTaXAdl0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1671440705033792.6786569036295; Mon, 19 Dec 2022 01:05:05 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [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-201-HDnoEU35PuKCZ4O21SEY0A-1; Mon, 19 Dec 2022 04:04:10 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4000A280607C; Mon, 19 Dec 2022 09:04:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64E75C16020; Mon, 19 Dec 2022 09:04:06 +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 4C4BF19465B7; Mon, 19 Dec 2022 09:04:05 +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 5B319194658D for ; Mon, 19 Dec 2022 09:04:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 504D81121315; Mon, 19 Dec 2022 09:04:04 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEFC81121314 for ; Mon, 19 Dec 2022 09:04:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671440704; 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=b9HpRvEbikjd5pcbgsHfWLa6kdi8mYUY+ZXt7P6DN2c=; b=QpdFsbp67wiRdcmFnd+Vv7NkOujfUm8qPcA4zAbYjJkGKWTF09SxQ9X2a9UHDGQtebcUni 9rt+PN7WBj9wkcVztQp12xkqZItefxg3aElUlYcwrawzp7OHQrQHoZoUj4jcvXcmTjD3w2 izmfWW5o/coGBnCT4gzvabD/0+uAJAM= X-MC-Unique: HDnoEU35PuKCZ4O21SEY0A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] virqemu: Don't strip the requested key from nested objects Date: Mon, 19 Dec 2022 10:04:00 +0100 Message-Id: <0429ee4abaf4b11ed693f97b95d1beaec69d55aa.1671440529.git.pkrempa@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.8 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: 1671440706883100001 Content-Type: text/plain; charset="utf-8" Skipping of a specific key is needed only for the top level object to specially handle the object type. We must not pass it to any recursed printing of nested objects as skipping keys there might be surprising and also is unhandlable later when formatting the commandline. Until now this did not pose a problem but was discovered when adding a new netdev backend which has a nested config object which also has the 'type' key which was being skipped. Modern usage will prefer JSON directly but fix the commandline generator to prevent surprises. Signed-off-by: Peter Krempa --- src/util/virqemu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 9dc0eab386..15602e30db 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -163,8 +163,7 @@ virQEMUBuildCommandLineJSONIterate(const char *key, if (data->prefix) key =3D tmpkey =3D g_strdup_printf("%s.%s", data->prefix, key); - return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf, - data->skipKey, + return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf, NULL, data->arrayFunc, false); } @@ -222,14 +221,14 @@ virQEMUBuildCommandLineJSONRecurse(const char *key, return -1; } - if (arrayFunc(key, value, buf, skipKey) < 0) { + if (arrayFunc(key, value, buf, NULL) < 0) { /* fallback, treat the array as a non-bitmap, adding the key * for each member */ for (i =3D 0; i < virJSONValueArraySize(value); i++) { elem =3D virJSONValueArrayGet((virJSONValue *)value, i); /* recurse to avoid duplicating code */ - if (virQEMUBuildCommandLineJSONRecurse(key, elem, buf, ski= pKey, + if (virQEMUBuildCommandLineJSONRecurse(key, elem, buf, NUL= L, arrayFunc, true) < = 0) return -1; } @@ -257,7 +256,8 @@ virQEMUBuildCommandLineJSONRecurse(const char *key, * virQEMUBuildCommandLineJSON: * @value: json object containing the value * @buf: otuput buffer - * @skipKey: name of key that will be handled separately by caller + * @skipKey: name of key inside the top level object that will be handled + * separately by caller * @arrayFunc: array formatter function to allow for different syntax * * Formats JSON value object into command line parameters suitable for use= with --=20 2.38.1