From nobody Mon Feb 9 20:10:14 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=1575904308; cv=none; d=zohomail.com; s=zohoarc; b=H115WNati/CVFTuhuWbFaNsCOgTKiLB3UdRTqfXeqUXsrLMgPskuViIARMWRD8mWtFOt8H29SFpJCt9aoFJ4FIaJCFV8RvZ5aTW8bUQp1aKcWxe1RHT+SkUJxz0lGWjaOy36Jl9Elm2GIdP81Ws7yS8c0NjKfi68oML89g0hL/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904308; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Ft7K9jTEk6HhMYPt6hQBBzpDQMmZcbUpSDG664CJFNU=; b=e3rwTUo662dHoUfU4cgP85Xz63fW5GvNIzIICkvtLC5PlKYk0GhcZfgag8lKl9eivjtUdEub6Hw1dPOWZ9YCYDQSBd24nbJRI0F4MS9N0Sucxa22wJFxQWyAfIK8d0dbIfxp/9tL16rBOOYdnWJPLR7u/A+aHw+RJuhbufsf68w= 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 15759043080771007.2423196256344; Mon, 9 Dec 2019 07:11:48 -0800 (PST) Received: from localhost ([::1]:41288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKhO-0005Ug-Gx for importer@patchew.org; Mon, 09 Dec 2019 10:11:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47265) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKY2-0003ZB-GX for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXx-0001OO-3x for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:06 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:35402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXw-0001Nt-Sy for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:01 -0500 Received: by mail-wm1-x342.google.com with SMTP id c20so13811563wmb.0 for ; Mon, 09 Dec 2019 07:02:00 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:58 -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; bh=Ft7K9jTEk6HhMYPt6hQBBzpDQMmZcbUpSDG664CJFNU=; b=Vm2s9QvEcWz3gO44MeWeq47IPkeOVYMKi20q2MB/rwXIeL5xYBy1D3j6hkxz5w8InU MA+7fvyItnGwsw6aAvomdAe1uEmTo+ZbGfierBImcs09dhBWhAq+gaWi15AvKYMwf/6R UHEkz6TvMNr9N8nQXX2jq6JUgxbJUd19Iy6lltXnoSFeQ+kqbf5rcDuoWroyUq2KboAL DGX5Nmv5fae1QNcVcszcS8h4GmohHvF347TCjGcNk7tjM6Hwv9sL0FwFD3gqGAcb7Mfb mmlM0DUqU2/3EZtpQ73/WlksHspv6bkl/GzA198wulsZJ13yX4gOLlYTAZZ71LVd3rLm AD8A== 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; bh=Ft7K9jTEk6HhMYPt6hQBBzpDQMmZcbUpSDG664CJFNU=; b=XpeYXUWDyiHcF7KvjDSLsz/uIWCbqHHiTu/JO0Q1l4ET3p65aJAQN8qxM0YiO5EvHs ZTdv8YQ0i21hAaUrPZ6LVlZ6UY71LvTNiJq5EB04e00caLD9wUiM6wRAEb6R+I1rwbIi gCqoy3snGCfMNRKiYgPmX0Q0K4GFi4ytkX5cOlM1tT0VjvFY+hWrEkJ8w5fVVLOvGrxJ zbjVde3nRfRpyGR/VPEAnOfj/SDPaZPReTerYcoHtENVVJ2Nk5FO407Wr5RLfQOGGldK PYs8mh1mEenwk8jeG/NpqQNfadcrDZ73gJ17HFFg2ht7YSk6MFP5kAkDCKgPpman29Xf xnCQ== X-Gm-Message-State: APjAAAVzfYBD8vq0m9gcyfOoKViicKfUXRF32R+dMRw9tHdO+hNeyops dNSog43OwKLwJs1eHmy7X2w7qLZ9 X-Google-Smtp-Source: APXvYqy7OFL5C+heQGi721sNwZ3M5HBb8w6yHIXPjw0rmWNKwoiK1KU9Fzb6RicvHKveOdyGsGVIww== X-Received: by 2002:a7b:c0d8:: with SMTP id s24mr26650801wmh.30.1575903719051; Mon, 09 Dec 2019 07:01:59 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 10/18] qom: introduce object_register_sugar_prop Date: Mon, 9 Dec 2019 16:01:37 +0100 Message-Id: <1575903705-12925-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Similar to the existing "-rtc driftfix" option, we will convert some legacy "-machine" command line options to global properties on accelerators. Because accelerators are not devices, we cannot use qdev_prop_register_glob= al. Instead, provide a slot in the generic object_compat_props arrays for command line syntactic sugar. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/qom/object.h | 1 + qom/object.c | 23 +++++++++++++++++++++-- vl.c | 10 +++------- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 128d00c..230b18f 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -679,6 +679,7 @@ void object_apply_global_props(Object *obj, const GPtrA= rray *props, Error **errp); void object_set_machine_compat_props(GPtrArray *compat_props); void object_set_accelerator_compat_props(GPtrArray *compat_props); +void object_register_sugar_prop(const char *driver, const char *prop, cons= t char *value); void object_apply_compat_props(Object *obj); =20 /** diff --git a/qom/object.c b/qom/object.c index d51b57f..bfb4413 100644 --- a/qom/object.c +++ b/qom/object.c @@ -414,10 +414,29 @@ void object_apply_global_props(Object *obj, const GPt= rArray *props, Error **errp * Global property defaults * Slot 0: accelerator's global property defaults * Slot 1: machine's global property defaults + * Slot 2: global properties from legacy command line option * Each is a GPtrArray of of GlobalProperty. * Applied in order, later entries override earlier ones. */ -static GPtrArray *object_compat_props[2]; +static GPtrArray *object_compat_props[3]; + +/* + * Retrieve @GPtrArray for global property defined with options + * other than "-global". These are generally used for syntactic + * sugar and legacy command line options. + */ +void object_register_sugar_prop(const char *driver, const char *prop, cons= t char *value) +{ + GlobalProperty *g; + if (!object_compat_props[2]) { + object_compat_props[2] =3D g_ptr_array_new(); + } + g =3D g_new(GlobalProperty, 1); + g->driver =3D g_strdup(driver); + g->property =3D g_strdup(prop); + g->value =3D g_strdup(value); + g_ptr_array_add(object_compat_props[2], g); +} =20 /* * Set machine's global property defaults to @compat_props. @@ -445,7 +464,7 @@ void object_apply_compat_props(Object *obj) =20 for (i =3D 0; i < ARRAY_SIZE(object_compat_props); i++) { object_apply_global_props(obj, object_compat_props[i], - &error_abort); + i =3D=3D 2 ? &error_fatal : &error_abort= ); } } =20 diff --git a/vl.c b/vl.c index 58aad4f..d6c77bc 100644 --- a/vl.c +++ b/vl.c @@ -897,13 +897,9 @@ static void configure_rtc(QemuOpts *opts) value =3D qemu_opt_get(opts, "driftfix"); if (value) { if (!strcmp(value, "slew")) { - static GlobalProperty slew_lost_ticks =3D { - .driver =3D "mc146818rtc", - .property =3D "lost_tick_policy", - .value =3D "slew", - }; - - qdev_prop_register_global(&slew_lost_ticks); + object_register_sugar_prop("mc146818rtc", + "lost_tick_policy", + "slew"); } else if (!strcmp(value, "none")) { /* discard is default */ } else { --=20 1.8.3.1