From nobody Sun Feb 8 18:44:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1589556563; cv=none; d=zohomail.com; s=zohoarc; b=cQ/6w94hHF/fUNtfMwzc7iu45hDRvuA6/T8vpgi4UO6SAC52m9SzkIH+eJ4yIb5qXX6L0p26HF/LW0okuOWx/vzgUcnK8dgOf1ujsRhUKk9o/ImkfpURf3zusFHBjsVvcLV0fGspZvlbg1eKgIYrTCDhWuzpZRvbY/3b1H94rsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589556563; 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=73w4syxht8171IKgrY0s5Qc0uOeCk41q0p3AOn+ZPGU=; b=T5JDT9wGm/2rplfbWYzag//1TkL4Dqs58nIkD0KO8WB9L+yJu5r24gu6N8ZbGnG9a4evnryAq6/b0klzggFkaxHSafF6/9jPeHvj3HoDQ2Ozwnh5TjSHFvFsMUxfYNkltHi9IJU7z+QugCDlfuhJz0ZRnpNiRcFf7j7soH9/ZoQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1589556563537949.3912592901265; Fri, 15 May 2020 08:29:23 -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-357-0hLeFZGvMX6fz22FP6g-xw-1; Fri, 15 May 2020 11:29:19 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85EA2107ACCD; Fri, 15 May 2020 15:29:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5EC8E1024837; Fri, 15 May 2020 15:29:14 +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 30AD64EA01; Fri, 15 May 2020 15:29:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04FFTDnA011357 for ; Fri, 15 May 2020 11:29:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 30F0A5D9D7; Fri, 15 May 2020 15:29:13 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C79D5D9C9 for ; Fri, 15 May 2020 15:29:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589556562; 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=73w4syxht8171IKgrY0s5Qc0uOeCk41q0p3AOn+ZPGU=; b=MM7GhsOyBw8x7N18ai4zThqaIGMpe3wqARHAWMROvRfkkwF6e8KcEFJ6GV5xs64UuHdS0z r1AtxJXrj263IL83qCjw/5jkCKnubs2JfBejt7eb2rlHzfXJDV7jJ8S40VjoE2FkSX8ej0 QYVUxnH+WbWOP5hdamfPi04l95gw6RI= X-MC-Unique: 0hLeFZGvMX6fz22FP6g-xw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/21] util: virqemu: Introduce virQEMUBuildNetdevCommandlineFromJSON Date: Fri, 15 May 2020 17:27:59 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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 preparation for converting the generator of -netdev to generate JSON which will be used to do the command line rather than the other way around we need to introduce a convertor which properly configures virQEMUBuildCommandLineJSON for the quirks of -netdev. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/libvirt_private.syms | 1 + src/util/virqemu.c | 22 ++++++++++++++++++++++ src/util/virqemu.h | 3 +++ 3 files changed, 26 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1bd02fd8ee..fd04fcece3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2915,6 +2915,7 @@ virQEMUBuildCommandLineJSON; virQEMUBuildCommandLineJSONArrayBitmap; virQEMUBuildCommandLineJSONArrayNumbered; virQEMUBuildDriveCommandlineFromJSON; +virQEMUBuildNetdevCommandlineFromJSON; virQEMUBuildObjectCommandlineFromJSON; virQEMUBuildQemuImgKeySecretOpts; diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 549f88fcd5..0f8cab29df 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -252,6 +252,28 @@ virQEMUBuildCommandLineJSON(virJSONValuePtr value, } +/** + * virQEMUBuildNetdevCommandlineFromJSON: + * @props: JSON properties describing a netdev + * + * Converts @props into arguments for -netdev including all the quirks and + * differences between the monitor and command line syntax. + */ +char * +virQEMUBuildNetdevCommandlineFromJSON(virJSONValuePtr props) +{ + const char *type =3D virJSONValueObjectGetString(props, "type"); + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + + virBufferAsprintf(&buf, "%s,", type); + + if (virQEMUBuildCommandLineJSON(props, &buf, "type", true, NULL) < 0) + return NULL; + + return virBufferContentAndReset(&buf); +} + + static int virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf, const char *type, diff --git a/src/util/virqemu.h b/src/util/virqemu.h index 67a5711613..22f47851df 100644 --- a/src/util/virqemu.h +++ b/src/util/virqemu.h @@ -49,6 +49,9 @@ int virQEMUBuildCommandLineJSON(virJSONValuePtr value, bool onOff, virQEMUBuildCommandLineJSONArrayFormatFunc= array); +char * +virQEMUBuildNetdevCommandlineFromJSON(virJSONValuePtr props); + int virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf, virJSONValuePtr objprops); --=20 2.26.2