From nobody Mon Feb 9 20:46:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579796653; cv=none; d=zohomail.com; s=zohoarc; b=ODWvploZr4eYgtRyLEgmgfJLZc1i5KB9yXXCUXNbENQOUNBpdQYIGU16hLNXaEelHHhHWybpBM99HcvvLHZUNNtyLYUtQyVmS8m2A91q32JIsn80cvCLFO6ZqCLZw4VPdw6j+ylDCP4I76VQjjPX5ERUakPctb0fF4soSfx95Dc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579796653; 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=hUG/7q5hSf5ymYtbRPJKidNIIUCm54xUUBFlpg5zKq0=; b=e2F6fLi05IdAu1+GnCplqiA7ty0bRtO8c7W62QPku+QvfgZo7/0KU5UiedPMAXVMdNxrINMay/ju0pXA/6OdCAUFuFPDL8YVJHneYzGmjICSbPkmASgI1muRzp3kxX3TJtAx91YctlnZhA82RU6VSkRHOEYQjmDBVMA6h6tXuGM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579796653790516.9202983617746; Thu, 23 Jan 2020 08:24:13 -0800 (PST) Received: from localhost ([::1]:60322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iufHA-00080z-Gf for importer@patchew.org; Thu, 23 Jan 2020 11:24:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51695) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iucrd-0005NH-Tf for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:49:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iucrc-00049C-Nj for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:49:41 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:40244) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iucrc-000487-Hk for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:49:40 -0500 Received: by mail-wr1-x42e.google.com with SMTP id c14so3133361wrn.7 for ; Thu, 23 Jan 2020 05:49:40 -0800 (PST) Received: from 640k.localdomain.com ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s15sm3073171wrp.4.2020.01.23.05.49.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jan 2020 05:49:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hUG/7q5hSf5ymYtbRPJKidNIIUCm54xUUBFlpg5zKq0=; b=tLqbYJqQtBfyse6rQp3S6/Ma/yd4bd+4qTqBWqo0D81u826aElxbkeXHi6vh7hrw01 0hvLqzNVqE2BR14Y0D2OvLTrFrnY/jlt3BZq251MwiyJMfTll/aFBryoaTN7TAH8yFN/ eft7v8yfhwRZdlqkTETTB4/Ay3msdDucLl8yaGefup37DSTYQmeA+UWaklfQYZR01nas 8qqmRzO60rzaBWMtdcVRpEVipZCWJpMk8iFxeBuBhOKtpOuXY9xscuEYtHEvUGHONFch PlucL6q/mh7XZiH15DQb0xNBy+JkPR73oLqvUBTbfVrrHeV4z6JwJ5TkrN5ttphWI4Lz G61A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=hUG/7q5hSf5ymYtbRPJKidNIIUCm54xUUBFlpg5zKq0=; b=R/oSMGWGTs7AJ6dZhgY1kBXiAAdDiTaKia2Sms1d44i6NkgqW6VVUl83Q4gtU5Jaim e6/GYehDNK9WcDhZgjjjDlInHZkJ5WsQ/PAs6Fts2dudcK9H7PB252BKa2coBOc+gV6/ /16VvBgMX0XsgMVw/qF9fRI6XWvCkig40iRF0jyC2uBb2yHLlkeOGECVlOz8SSsvubKB iYB5Yh54QqG82b7J6Nfeb75WKxE+GwCddeWVFkHbJi64bXsN/rTb0pjErivSSJXxJ80K VGtKKOPTrf+1pCh7vF0Kb8AmAn8fDIoDYv+2lPsKbdekoAgfYQTeYx9NsGWE39rA0jHJ laHQ== X-Gm-Message-State: APjAAAUTOF4943Sdw0B9pRVHPEAAzcaVjTSU4fkg57fzDMs5+NqvBGoi +I3xHTaYvUuXq5WjwCd3hb3HmAdh X-Google-Smtp-Source: APXvYqzLfOi2acp6yMec3AsL88IYDnNi7F7etX7r7FHDZeWzaZHC1thqmyrP08UAtkwpvDKyxNCiEw== X-Received: by 2002:adf:eb48:: with SMTP id u8mr17453068wrn.283.1579787379310; Thu, 23 Jan 2020 05:49:39 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 37/59] object: add object_property_get_defaut() Date: Thu, 23 Jan 2020 14:48:40 +0100 Message-Id: <1579787342-27146-38-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1579787342-27146-1-git-send-email-pbonzini@redhat.com> References: <1579787342-27146-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau The new callback will be used in following "object: add object_property_set_defaut_{bool,str,int,uint}()" and "vl: print default value in object help" patches. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20200110153039.1379601-8-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- include/qom/object.h | 17 +++++++++++++++++ qom/object.c | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index 29f47d3..ca47308 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -367,6 +367,13 @@ typedef void (ObjectPropertyRelease)(Object *obj, */ typedef void (ObjectPropertyInit)(Object *obj, ObjectProperty *prop); =20 +/** + * ObjectPropertyGetDefault: + * + * Get an allocated string representation of the default value. + */ +typedef char *(ObjectPropertyGetDefault)(ObjectProperty *prop); + struct ObjectProperty { gchar *name; @@ -377,6 +384,7 @@ struct ObjectProperty ObjectPropertyResolve *resolve; ObjectPropertyRelease *release; ObjectPropertyInit *init; + ObjectPropertyGetDefault *get_default; void *opaque; }; =20 @@ -1234,6 +1242,15 @@ void object_property_set_int(Object *obj, int64_t va= lue, const char *name, Error **errp); =20 /** + * object_property_get_defaut: + * @prop: the property to get default value + * + * Return an allocated string that represents the default property + * value or NULL. + */ +char *object_property_get_default(ObjectProperty *prop); + +/** * object_property_get_int: * @obj: the object * @name: the name of the property diff --git a/qom/object.c b/qom/object.c index cd7ce81..49c2429 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1438,6 +1438,15 @@ int64_t object_property_get_int(Object *obj, const c= har *name, return retval; } =20 +char *object_property_get_default(ObjectProperty *prop) +{ + if (!prop->get_default) { + return NULL; + } + + return prop->get_default(prop); +} + void object_property_set_uint(Object *obj, uint64_t value, const char *name, Error **errp) { --=20 1.8.3.1