From nobody Fri Apr 26 20:59:55 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=1633700223; cv=none; d=zohomail.com; s=zohoarc; b=ddOdPxJdVa1U1vK6zTfxRg+p+9WKLjaWWZuejtIlvN1N2pw6XDuoNIPCVSd6Js7ye3wZ6sGEfLajA8rkpf+xqQs9IweG1Cv0mpdshTUPEQU/cVNGufB6ZCc1GcpsPzBXktnMarkr8Ey6tJuIKYMQ6nFp4wAUR4Rlq98AurtK6fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633700223; h=Content-Type:Content-Transfer-Encoding:Cc: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=yGgT9kbiIOOYyoDZ44FpoEHtcO6BD7BXDUwjNChwZ2Q=; b=D5SS6baXD5LmwDLPw4WFXSVitL26hz9NAFWDS5i7tnSi+sVn0ppp7oOqDcO/nYbe4e18NLTwC9QI7ZOyLiMebkYY95cj33ijr3QO1AbL4nycF7p80KSYClRfmIYmp/bg+LBbOqJOvJuWzQaLZySREJRy6fIJxIYvvWPBGxtEDlg= 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) 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 1633700223339187.07381576128876; Fri, 8 Oct 2021 06:37:03 -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-487-Lq9BmhCTM6GL929QXBoJDw-1; Fri, 08 Oct 2021 09:37:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6242B1017989; Fri, 8 Oct 2021 13:35:26 +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 3FD4C5F4EA; Fri, 8 Oct 2021 13:35:26 +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 0B0C31806D01; Fri, 8 Oct 2021 13:35:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 198DZP5q026141 for ; Fri, 8 Oct 2021 09:35:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C6D5196F1; Fri, 8 Oct 2021 13:35:25 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79183196E2; Fri, 8 Oct 2021 13:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633700222; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=yGgT9kbiIOOYyoDZ44FpoEHtcO6BD7BXDUwjNChwZ2Q=; b=GSDweabV1CMUrrw3NRMKmDlSEFqND9VemPjcH6T4WYVdtddf7RCi9nZf3IYVr4ykVEYl/p l42izSmoaLj5PmqOjrAvhqafnKoksT32KzZTSUgVImm16LpwxFSL+UuBPbXoNvGV5njce1 P3JzZ60NAD0mous9q4Zqo5G9Rs18fps= X-MC-Unique: Lq9BmhCTM6GL929QXBoJDw-1 From: Kevin Wolf To: qemu-devel@nongnu.org Subject: [PATCH v2 07/15] qdev: Avoid using string visitor for properties Date: Fri, 8 Oct 2021 15:34:34 +0200 Message-Id: <20211008133442.141332-8-kwolf@redhat.com> In-Reply-To: <20211008133442.141332-1-kwolf@redhat.com> References: <20211008133442.141332-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, damien.hedde@greensocs.com, pkrempa@redhat.com, ehabkost@redhat.com, qemu-block@nongnu.org, mst@redhat.com, libvir-list@redhat.com, jasowang@redhat.com, quintela@redhat.com, armbru@redhat.com, vsementsov@virtuozzo.com, lvivier@redhat.com, its@irrelevant.dk, pbonzini@redhat.com, eblake@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.15 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) X-ZM-MESSAGEID: 1633700224198100002 Content-Type: text/plain; charset="utf-8" The only thing the string visitor adds compared to a keyval visitor is list support. git grep for 'visit_start_list' and 'visit.*List' shows that devices don't make use of this. In a world with a QAPIfied command line interface, the keyval visitor is used to parse the command line. In order to make sure that no devices start using this feature that would make backwards compatibility harder, just switch away from object_property_parse(), which internally uses the string visitor, to a keyval visitor and object_property_set(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- softmmu/qdev-monitor.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 0705f00846..034b999401 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -28,6 +28,8 @@ #include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" +#include "qapi/qmp/qstring.h" +#include "qapi/qobject-input-visitor.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "qemu/help_option.h" @@ -198,16 +200,28 @@ static int set_property(void *opaque, const char *nam= e, const char *value, Error **errp) { Object *obj =3D opaque; + QString *val; + Visitor *v; + int ret; =20 if (strcmp(name, "driver") =3D=3D 0) return 0; if (strcmp(name, "bus") =3D=3D 0) return 0; =20 - if (!object_property_parse(obj, name, value, errp)) { - return -1; + val =3D qstring_from_str(value); + v =3D qobject_input_visitor_new_keyval(QOBJECT(val)); + + if (!object_property_set(obj, name, v, errp)) { + ret =3D -1; + goto out; } - return 0; + + ret =3D 0; +out: + visit_free(v); + qobject_unref(val); + return ret; } =20 static const char *find_typename_by_alias(const char *alias) --=20 2.31.1