From nobody Sun Feb 8 17:22:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1637253271; cv=none; d=zohomail.com; s=zohoarc; b=ZEl1ADAzrIj7C4+O7I7/kZKUD58KmB1lsj5sh/QtCgCKPVOwI8lZarAPIs9wIP9/PlPV3QyUDvj9+ltreOW/7VqiYWwhBii/oLZ0Lup4gLqxgDStgweW5AXtxuHmpIiB49YgsmGHn2Gff78DFtBjjBRzaW0lHjn8I09/bfYDUss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637253271; h=Content-Type:Content-Transfer-Encoding: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=JC8mteV2iyq2XMfeTJy8ZtCl7qNpolCJMSlLLwO6ZSQ=; b=L3xspkQMai1kD+Rt32/KP8/ELV0F0jbpAKcwuowN6/6MbwbzL56xcghfUU+FSCTW+GQtw/LoGVF1fQGxpxanuVYoZt5ze9wq0vTBkBFPwKfZUwLKKgxJcGlgpNDB7hjoH75JEgt1MHaZ/C865Nk+qR4CFJ+n0zpih9ZkwsVlI9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1637253271284665.8418271152776; Thu, 18 Nov 2021 08:34:31 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-175-Prcc8bbpPA2jh4GwvR7KCQ-1; Thu, 18 Nov 2021 11:34:28 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 481A11922966; Thu, 18 Nov 2021 16:34:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5080360BF1; Thu, 18 Nov 2021 16:34:23 +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 1C9BE4EA3F; Thu, 18 Nov 2021 16:34:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AIGY7XR028173 for ; Thu, 18 Nov 2021 11:34:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8E6F3608BA; Thu, 18 Nov 2021 16:34:07 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id D894A6FEED for ; Thu, 18 Nov 2021 16:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637253270; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JC8mteV2iyq2XMfeTJy8ZtCl7qNpolCJMSlLLwO6ZSQ=; b=KoT9BBlm/s6iiRe4nBDaxzWKQHUIQX7fPfudE9rwt6v7SDGXI0rw4v/U1BygdaVSwZQOiI 3QCy+k5y8Kx7qvQZ7MV3AoqD9057n45UYU3LDOo4aGASRXuBQyjkc2jaAQQPPkc3G4rL2L fvQ1rjUgPpZRAZFtYi1jI5OOoMmD2dQ= X-MC-Unique: Prcc8bbpPA2jh4GwvR7KCQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/16] qemuDomainAttachChrDeviceAssignAddr: Simplify return value handling Date: Thu, 18 Nov 2021 17:33:37 +0100 Message-Id: <22a3906fa23a81db64f43fd295c7cfc596f0d2cb.1637253107.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@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.12 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: 1637253271938100004 Content-Type: text/plain; charset="utf-8" Rather than returning a different error code if the device address needs to be released pass in the 'need_release' flag via a pointer. Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d44523fe7e..5e44210aff 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2125,13 +2125,12 @@ qemuDomainChrRemove(virDomainDef *vmdef, return ret; } -/* Returns 1 if the address will need to be released later, - * -1 on error - * 0 otherwise - */ + + static int qemuDomainAttachChrDeviceAssignAddr(virDomainObj *vm, - virDomainChrDef *chr) + virDomainChrDef *chr, + bool *need_release) { virDomainDef *def =3D vm->def; qemuDomainObjPrivate *priv =3D vm->privateData; @@ -2147,13 +2146,16 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainObj *v= m, chr->targetType =3D=3D VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PC= I) { if (qemuDomainEnsurePCIAddress(vm, &dev) < 0) return -1; - return 1; + *need_release =3D true; + return 0; } else if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && chr->targetType =3D=3D VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_US= B) { if (virDomainUSBAddressEnsure(priv->usbaddrs, &chr->info) < 0) return -1; - return 1; + + *need_release =3D true; + return 0; } else if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && chr->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_V= IRTIO) { @@ -2176,7 +2178,7 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, virDomainObj *vm, virDomainChrDef *chr) { - int ret =3D -1, rc; + int ret =3D -1; qemuDomainObjPrivate *priv =3D vm->privateData; virErrorPtr orig_err; virDomainDef *vmdef =3D vm->def; @@ -2203,10 +2205,8 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0) goto cleanup; - if ((rc =3D qemuDomainAttachChrDeviceAssignAddr(vm, chr)) < 0) + if (qemuDomainAttachChrDeviceAssignAddr(vm, chr, &need_release) < 0) goto cleanup; - if (rc =3D=3D 1) - need_release =3D true; if (qemuDomainNamespaceSetupChardev(vm, chr, &teardowndevice) < 0) goto cleanup; --=20 2.31.1