From nobody Mon Feb 9 18:45:39 2026 Delivered-To: importer@patchew.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=1591369491; cv=none; d=zohomail.com; s=zohoarc; b=KK+pVGZBDE3fJU3jvu1h0xX8xQ77XVtY1O1iTxZzHfmFvmt29ciFWjAk1vWgc0hbfM3yorqBBJewPAAe5EuHrfASrw0INRbCKf9F7nYVJfxdDiJN9HBSHCgsou7keyhSOwl/SNMTDAGOAB1HPRnkl00SjgoCoppL3PsbRiQdgv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591369491; 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=cwucalj6hK2lz24dh0Q3MNFVkxaEqCo7beSnjy5uqM8=; b=dzZMJRAmjS5q7sGJQVn/vHaE5Rn6gJEJk5K0Q0r3cf7QNgssP7VyIh9DBYT0ShkvQTcFVBJmU8Sde5d+/IiUgQgbomCiTXB7hdWO9kuixfgDNRMwsGVR0k6G9WcZELNOvWZwTPgrHMcOpYYRWULeOWZyj+PM3eLNmj7+xxZCBE8= 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 1591369491592105.80353639132886; Fri, 5 Jun 2020 08:04:51 -0700 (PDT) Received: from localhost ([::1]:58998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhDtq-0007QQ-BO for importer@patchew.org; Fri, 05 Jun 2020 11:04:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhDlw-00044C-Kf for qemu-devel@nongnu.org; Fri, 05 Jun 2020 10:56:40 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:35230 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jhDls-0007VV-4V for qemu-devel@nongnu.org; Fri, 05 Jun 2020 10:56:40 -0400 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-277-mfcp4aGCN7u_1PWq54HCzg-1; Fri, 05 Jun 2020 10:56:33 -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 4C1FAEC1A6; Fri, 5 Jun 2020 14:56:32 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-121.ams2.redhat.com [10.36.112.121]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F25A410013C0; Fri, 5 Jun 2020 14:56:28 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CA0FB1138463; Fri, 5 Jun 2020 16:56:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591368995; h=from:from: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; bh=cwucalj6hK2lz24dh0Q3MNFVkxaEqCo7beSnjy5uqM8=; b=UVT/A9msmtkdLbxFt6UxMmpOl/d21T7rSLfgYYZXqs/OQFP+lN7o+7R7f5dlR42vuTAwnL l3vRQHRi+topHRHuxVkZJVWHKhEx8oZ6mwB4EdHqZsDQA6NNL34G1DnmZWx9IcIABlXyrk bD2BkaTIc/0rBzc1K+CZmqgKPALwtAU= X-MC-Unique: mfcp4aGCN7u_1PWq54HCzg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 12/16] qdev: Reject chardev property override Date: Fri, 5 Jun 2020 16:56:21 +0200 Message-Id: <20200605145625.2920920-13-armbru@redhat.com> In-Reply-To: <20200605145625.2920920-1-armbru@redhat.com> References: <20200605145625.2920920-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/05 03:40:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: kwolf@redhat.com, berrange@redhat.com, ehabkost@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) qdev_prop_set_chr() screws up when the property already has a non-null value: it neglects to release the old value. Both the old and the new backend become attached to the same device. Unlike for block devices (see previous commit), this can't be observed from the monitor (I think). Example: -serial null -chardev null,id=3Dchr0 -global isa-serial.chardev=3D= chr0 Special case: attempting to use the same backend both times crashes: $ qemu-system-x86_64 --nodefaults -serial null -global isa-serial.chard= ev=3Dserial0 Unexpected error in qemu_chr_fe_init() at /work/armbru/qemu/chardev/cha= r-fe.c:220: qemu-system-x86_64: Device 'serial0' is in use Aborted (core dumped) Yet another example: -device with multiple chardev=3D... (but not device_add, which silently drops all but the last duplicate property). Perhaps chardev property override could be made to work. Perhaps it should. I can't afford the time to figure this out now. What I can do reject usage that leaves backends in unhealthy states. For what it's worth, we've long done the same for netdev properties. Cc: Marc-Andr=C3=A9 Lureau Cc: Paolo Bonzini Signed-off-by: Markus Armbruster --- hw/core/qdev-properties-system.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index b22255000c..695ebfe8b9 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -244,6 +244,14 @@ static void set_chr(Object *obj, Visitor *v, const cha= r *name, void *opaque, return; } =20 + /* + * TODO Should this really be an error? If no, the old value + * needs to be released before we store the new one. + */ + if (!check_non_null(dev, name, be->chr, str, errp)) { + return; + } + if (!*str) { g_free(str); be->chr =3D NULL; --=20 2.26.2