From nobody Mon Feb 9 06:50:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1589556515; cv=none; d=zohomail.com; s=zohoarc; b=Yi7XqB6knccQijwOtQ46ERj7Piao2i0Z7bhfMpAEi9Ar0fwL9i4Stik8XFow+bLn6jr+vXRH3SM52qxADE3vR4Mir4v2hy+JxkPEFAq80J9FQXGsCoflVslkMJwnUTqUCIYJXEo/qW+te7qWHVoxfapDgH7q43wiiDDkExTWnQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589556515; 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=1RjWfZ3xJYA4YoArH9M0Nx+g0C2QGJlRKzZhmBlKQlw=; b=Lbo21rpWX71b25H14xLWudlvZKfc0wMKXJUFZg/EhpljhKYP2jiqF6uCP6/enE+5p9btLefqy5adDQCJJXw6s4RxJjd8FhkcAQDB6vi+envQWLvupNkLB9U7WVoxC4OxSlS4yrfJzaLpyhPvKpX6kKpxDxirs7TwVYYGOdOt3Oo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1589556515251611.8380649951632; Fri, 15 May 2020 08:28:35 -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-477-1LTDZWvgPSaZnkK9i3E14g-1; Fri, 15 May 2020 11:28:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B88D107AD62; Fri, 15 May 2020 15:28:26 +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 19038272A3; Fri, 15 May 2020 15:28: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 DEFEA4CAB0; Fri, 15 May 2020 15:28:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04FFSPr2011164 for ; Fri, 15 May 2020 11:28:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 141E15D9F5; Fri, 15 May 2020 15:28:25 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D3EE5D9F1 for ; Fri, 15 May 2020 15:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589556513; 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=1RjWfZ3xJYA4YoArH9M0Nx+g0C2QGJlRKzZhmBlKQlw=; b=hNBzeMdw/dgnxY92WXNGNvLR063Xm71E83VXSeCnsyrxH0TjkJXlN6sff1u8aOcjdhnoxy uGNnyZ5QNgeGo80tfbeP1rV9NTQbCG1aneEAibQfrM7Hs8/gW5F4pBQIv3t1RWa5tO5tHb eeUziOrbe/PL9diHZl0/RsVUXnzBrJA= X-MC-Unique: 1LTDZWvgPSaZnkK9i3E14g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/21] qemuBuildChannelsCommandLine: Extract common formatting of 'chardev' Date: Fri, 15 May 2020 17:27:50 +0200 Message-Id: <6f67f32d8ad87a140873750a5e5639d23cae573c.1589556042.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Both active branches create the same backend chardev. Since there is no other case, extract it before the switch so that we don't have to duplicate it. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_command.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 06568ae585..56b4aae1dd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8521,37 +8521,27 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logMa= nager, for (i =3D 0; i < def->nchannels; i++) { virDomainChrDefPtr channel =3D def->channels[i]; - char *devstr; + g_autofree char *chardevstr =3D NULL; + g_autofree char *netdevstr =3D NULL; - switch ((virDomainChrChannelTargetType) channel->targetType) { - case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: - if (!(devstr =3D qemuBuildChrChardevStr(logManager, secManager, + if (!(chardevstr =3D qemuBuildChrChardevStr(logManager, secManager, cmd, cfg, def, channel->source, channel->info.alias, qemuCaps, cdevflags))) - return -1; - virCommandAddArg(cmd, "-chardev"); - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); + return -1; - if (qemuBuildChrDeviceStr(&devstr, def, channel, qemuCaps) < 0) + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, chardevstr); + + switch ((virDomainChrChannelTargetType) channel->targetType) { + case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: + if (qemuBuildChrDeviceStr(&netdevstr, def, channel, qemuCaps) = < 0) return -1; - virCommandAddArgList(cmd, "-netdev", devstr, NULL); - VIR_FREE(devstr); + virCommandAddArgList(cmd, "-netdev", netdevstr, NULL); break; case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: - if (!(devstr =3D qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, - channel->source, - channel->info.alias, - qemuCaps, cdevflags))) - return -1; - virCommandAddArg(cmd, "-chardev"); - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); - if (qemuBuildChrDeviceCommandLine(cmd, def, channel, qemuCaps)= < 0) return -1; break; --=20 2.26.2