From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124])
	by passt.top (Postfix) with ESMTP id 1EAA45A0271
	for <passt-dev@passt.top>; Fri, 24 Feb 2023 19:49:58 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
	s=mimecast20190719; t=1677264597;
	h=from:from: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;
	bh=l9YrMz4R760l+l25mNO53Z5a/VBhnFzzSsnV6de/TV4=;
	b=aYoBj2av6pOOyEQHa9jcKYPivn4+AGKmtADd4aiJGGlIHcn013milAZwSiym2HzGBegVDc
	IMDEvn5bfRtR98lC7PisrnPJG+azu8Ym+KtJGEPogzOwEut7Ekf45q7/aaCfuGLK6Vngmx
	/Ga3iVovNafi9xe46XyVQ3iNESNuLQc=
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-177-CdrfMo8LO4qUoWXB2P3cDg-1; Fri, 24 Feb 2023 13:49:55 -0500
X-MC-Unique: CdrfMo8LO4qUoWXB2P3cDg-1
Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1F9FA1C05B00
	for <passt-dev@passt.top>; Fri, 24 Feb 2023 18:49:55 +0000 (UTC)
Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.52])
	by smtp.corp.redhat.com (Postfix) with ESMTPS id A4AAB140EBF6
	for <passt-dev@passt.top>; Fri, 24 Feb 2023 18:49:54 +0000 (UTC)
From: Andrea Bolognani <abologna@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH 5/5] qrap: Generate -netdev as JSON
Date: Fri, 24 Feb 2023 19:49:49 +0100
Message-Id: <20230224184949.518615-6-abologna@redhat.com>
In-Reply-To: <20230224184949.518615-1-abologna@redhat.com>
References: <20230224184949.518615-1-abologna@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="US-ASCII"; x-default=true
Message-ID-Hash: WY2EYJW5PPRAGM2HCK5CZACARGMBHXZK
X-Message-ID-Hash: WY2EYJW5PPRAGM2HCK5CZACARGMBHXZK
X-MailFrom: abologna@redhat.com
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
X-Mailman-Version: 3.3.8
Precedence: list
List-Id: Development discussion and patches for passt <passt-dev.passt.top>
Archived-At: <https://archives.passt.top/passt-dev/20230224184949.518615-6-abologna@redhat.com/>
Archived-At: <https://passt.top/hyperkitty/list/passt-dev@passt.top/message/WY2EYJW5PPRAGM2HCK5CZACARGMBHXZK/>
List-Archive: <https://archives.passt.top/passt-dev/>
List-Archive: <https://passt.top/hyperkitty/list/passt-dev@passt.top/>
List-Help: <mailto:passt-dev-request@passt.top?subject=help>
List-Owner: <mailto:passt-dev-owner@passt.top>
List-Post: <mailto:passt-dev@passt.top>
List-Subscribe: <mailto:passt-dev-join@passt.top>
List-Unsubscribe: <mailto:passt-dev-leave@passt.top>

While generating -device as JSON when JSON is in use is
mandatory, because not doing so can often prevent the VM from
starting up, using JSON for -netdev simply makes things a bit
nicer. No reason not to do it, though.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 qrap.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qrap.c b/qrap.c
index 27c12ed..d0e2fb2 100644
--- a/qrap.c
+++ b/qrap.c
@@ -311,7 +311,11 @@ int main(int argc, char **argv)
 	}
 
 	qemu_argv[qemu_argc++] = "-netdev";
-	qemu_argv[qemu_argc++] = "socket,fd=" STR(DEFAULT_FD) ",id=hostnet0";
+	if (!has_json) {
+		qemu_argv[qemu_argc++] = "socket,fd=" STR(DEFAULT_FD) ",id=hostnet0";
+	} else {
+		qemu_argv[qemu_argc++] = "{\"type\":\"socket\",\"fd\":\"" STR(DEFAULT_FD) "\",\"id\":\"hostnet0\"}";
+	}
 	qemu_argv[qemu_argc] = NULL;
 
 valid_args:
-- 
2.39.2