From nobody Mon Feb 9 09:08:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1639404042; cv=none; d=zohomail.com; s=zohoarc; b=mAN9p9jCI+lTPAf5OzvSQlkWOajIyEESNH0gK0D/vKQHSxxzmEQlAUwWjxIYNfIcxDEWJOj71syZ4a5AiFaFtjV1f+ivQdHM2bPY8w+pybuDuBCi1OLjMEwjAvWg+5J5eLCIjIhBxsX/LdVSS1nAfPYMTJzWL3SqUsx+u9yeHE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639404042; 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=FVv/LjLhr2b9PtB2iN5ihDTZC4elAyrP7tniatzCYeA=; b=LIkx0RpRLeNSaDx2tQ6aJ1Xp+jyo2ihjaiaLfROHXBH7MvMA4Zaw25dICvRR4on7Gh0PljDltG+RRj3D8YLv8QLS918ZbP0ac4xoiubaIm1U5NewHwvBRQmAWRJkUjLkI3OqR9l7n+zDrn3SatKoq2ea9t/BtxK2hz7ASNAwPgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1639404042268811.8299556532934; Mon, 13 Dec 2021 06:00:42 -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-104-RF41tKGoOBeeXsTFrXCeJQ-1; Mon, 13 Dec 2021 09:00:33 -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 83CA91926DA1; Mon, 13 Dec 2021 14:00:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BA6B61093; Mon, 13 Dec 2021 14:00:11 +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 A46CC1802E2D; Mon, 13 Dec 2021 14:00:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BDDxpdL002555 for ; Mon, 13 Dec 2021 08:59:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9C78B22DFE; Mon, 13 Dec 2021 13:59:51 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2323C22E05 for ; Mon, 13 Dec 2021 13:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639404041; 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=FVv/LjLhr2b9PtB2iN5ihDTZC4elAyrP7tniatzCYeA=; b=GpHnoeQTbtXuMzOxCxIYGDqgNJK2MGdVCTfnEDCmFEnIwhGdSF+klqjVGjCgCeLLKNW2qd 28/SYe8K8Pn5npFwjohmEGXDLqz8itD8g+QBxVyshrk+0QalaTuxWg9tZSscSJsaxVt9ZS 3Z7YeQWiSc+F+ZHVPTEvMTXy9lrx1KM= X-MC-Unique: RF41tKGoOBeeXsTFrXCeJQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 07/14] bhyve: refactor virBhyveProcessBuildBhyveCmd Date: Mon, 13 Dec 2021 14:59:36 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639404052268100001 Use automatic cleanup for virCommand, steal it on success and remove the error label. Signed-off-by: J=C3=A1n Tomko --- src/bhyve/bhyve_command.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index cf858dfcd6..3368d20a04 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -649,7 +649,7 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *driver,= virDomainDef *def, * -S 31,uart,stdio \ * vm0 */ - virCommand *cmd =3D virCommandNew(BHYVE); + g_autoptr(virCommand) cmd =3D virCommandNew(BHYVE); size_t i; unsigned nusbcontrollers =3D 0; unsigned nisacontrollers =3D 0; @@ -661,14 +661,14 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *drive= r, virDomainDef *def, if (def->cpu->dies !=3D 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Only 1 die per socket is supported")); - goto error; + return NULL; } if (nvcpus !=3D def->cpu->sockets * def->cpu->cores * def->cpu->th= reads) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Invalid CPU topology: total number of vCPUs " "must equal the product of sockets, cores, " "and threads")); - goto error; + return NULL; } =20 if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_CPUTOPOLOGY) !=3D= 0) { @@ -681,7 +681,7 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *driver,= virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Installed bhyve binary does not support " "defining CPU topology")); - goto error; + return NULL; } } else { virCommandAddArgFormat(cmd, "%d", nvcpus); @@ -716,14 +716,14 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *drive= r, virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Installed bhyve binary does not support " "UTC clock")); - goto error; + return NULL; } break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported clock offset '%s'"), virDomainClockOffsetTypeToString(def->clock.offset= )); - goto error; + return NULL; } =20 /* Clarification about -H and -P flags from Peter Grehan: @@ -751,7 +751,7 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *driver,= virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Installed bhyve binary does not support " "UEFI loader")); - goto error; + return NULL; } } =20 @@ -759,26 +759,26 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *drive= r, virDomainDef *def, for (i =3D 0; i < def->ncontrollers; i++) { if (bhyveBuildControllerArgStr(def, def->controllers[i], driver, c= md, &nusbcontrollers, &nisacontrollers)= < 0) - goto error; + return NULL; } for (i =3D 0; i < def->nnets; i++) { if (bhyveBuildNetArgStr(def, def->nets[i], driver, cmd, dryRun) < = 0) - goto error; + return NULL; } for (i =3D 0; i < def->ndisks; i++) { if (bhyveBuildDiskArgStr(def, def->disks[i], cmd) < 0) - goto error; + return NULL; } =20 if (def->ngraphics && def->nvideos) { if (def->ngraphics =3D=3D 1 && def->nvideos =3D=3D 1) { if (bhyveBuildGraphicsArgStr(def, def->graphics[0], def->video= s[0], driver, cmd, dryRun) < 0) - goto error; + return NULL; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Multiple graphics devices are not supported"= )); - goto error; + return NULL; } } =20 @@ -786,16 +786,16 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *drive= r, virDomainDef *def, if (bhyveBuildSoundArgStr(def, def->sounds[i], virDomainDefFindAudioByID(def, def->soun= ds[i]->audioId), driver, cmd) < 0) - goto error; + return NULL; } =20 for (i =3D 0; i < def->nfss; i++) { if (bhyveBuildFSArgStr(def, def->fss[i], cmd) < 0) - goto error; + return NULL; } =20 if (bhyveBuildConsoleArgStr(def, cmd) < 0) - goto error; + return NULL; =20 if (def->namespaceData) { bhyveDomainCmdlineDef *bhyvecmd; @@ -811,11 +811,7 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *driver= , virDomainDef *def, =20 virCommandAddArg(cmd, def->name); =20 - return cmd; - - error: - virCommandFree(cmd); - return NULL; + return g_steal_pointer(&cmd); } =20 virCommand * --=20 2.31.1