From nobody Mon Sep 16 19:26:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1566894937; cv=none; d=zoho.com; s=zohoarc; b=Sm5vT2+CQ+Z2MjUuWgvIiCLb32DXtF1jLwyWljcHvqbhQYsYCraMm6fGraPGWuDlkpvPQBtIfeOd5AEheRQJ01gcpjfO383U+g4Y2qgqKvTSqvOzji+0Xdrc4wSXggVwkJaf6fLvGOh7mJIwAVRok5jptcNoDZi4+XcVhdrXR90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566894937; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=8eLgMvSwORUZUmDlsIJbtbpzEk6fBmFl/QdEmSm+N6s=; b=RcOkFcAIGj6BGXdncuCfLnF9FQRUft0LS3RBiP/vPjdA4o7VmStleuIgM95RMh3BX/csDjkMmYZ4mCLAdkTwVQ5i9x/h+rf7WTCW4ild+K7m+t8qsLYqwF90kUwXyVPnr1o9yRtb+TTLxpZVP+STLfuDKTkx9kLoFBnk6HmXccs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566894937372280.8924412265312; Tue, 27 Aug 2019 01:35:37 -0700 (PDT) Received: from localhost ([::1]:48166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2Wwy-0006sC-Cv for importer@patchew.org; Tue, 27 Aug 2019 04:35:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36820) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <35-hkXQYKCj4xfrjnilttlqj.htrvjrz-ij0jqstslsz.twl@flex--sameid.bounces.google.com>) id 1i2Wmw-0005AP-4f for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <35-hkXQYKCj4xfrjnilttlqj.htrvjrz-ij0jqstslsz.twl@flex--sameid.bounces.google.com>) id 1i2Wmu-0007zl-KX for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:14 -0400 Received: from mail-qt1-x84a.google.com ([2607:f8b0:4864:20::84a]:32794) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <35-hkXQYKCj4xfrjnilttlqj.htrvjrz-ij0jqstslsz.twl@flex--sameid.bounces.google.com>) id 1i2Wmu-0007yO-Do for qemu-devel@nongnu.org; Tue, 27 Aug 2019 04:25:12 -0400 Received: by mail-qt1-x84a.google.com with SMTP id z4so7765747qts.0 for ; Tue, 27 Aug 2019 01:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=8eLgMvSwORUZUmDlsIJbtbpzEk6fBmFl/QdEmSm+N6s=; b=CbKJAPw1MT/IBrPU8qQ6swEAaAYIdWjHRJRpRIcxJ3pOz34LIGk3RvyLDuz6Cizf7l HQwvZQOkaHTWmbmyY2frSZdUI43cLDiE7Xzr4xOviAgKRJaZtAlmEXtEPLNPhSsOxt4T 9d3q5+f7C2OyQ1BgCWrYQ8vFPX+ykhbt+osW/cCWKcI92i+4GT3bBGM+P/e9GJa/sNSt GgkBcoZg09Eoj4OxKtL42Clv/swGGz+hV3qvlNuCEuTr6jd0sIWyX0nWoP9yi28yMHPm dpTAdmOqu6dhiMqo56uP2lNHJp2i2xXig93spewf6Kv0i/aVct2kDh/RH+ugG5/EnZZ7 wv5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8eLgMvSwORUZUmDlsIJbtbpzEk6fBmFl/QdEmSm+N6s=; b=Yf5q6gRfOUkwNWzJ+F57y5PTd6QRN8mkHTW9+W31VJWFYt/EXGyqmw2Qb6bFICv8X9 Q79wRIegYpCRO2CSgh0I59g+ElYdNqGNE8+wJP9rPCLcyyIbO/bvEtWtK2fJ0xuq3Y4R 3Wm/DBuWrk7Cf1FLsacAcfHIK7Mi3nkWJ98XRssp2cIVcZb6q5Fpueof0WkpbKUFWFIV FP6a9aJDisiYvD4u4xYfxmBOdfNQ5gbca8OfR8jtnYkY7OzlAMEZ2ULRbWBYowLm6mm7 8mmDV9qZ2Lcnbw3sGZZHxfK6AXT4/NDDwO57KGbG/OYPATu/r5N9LiRnvz7u5iWQHRS/ /sBw== X-Gm-Message-State: APjAAAXz0f2U+1nWyJLMAK8BhGFZchS5stNz6sbjrVr+7Vy0hbxXdx4k eV4FIxapxjAzmJpUt39PnOY51p6MzfVwSMuX4xGJlyc/gA/I8r0Y7C1FT+OREx/0TwI8tJ1q4j8 8I06FhE3T8qR/zRxE1Jd845Iy0F9+Z5yWlPOMDNJZRqJAoPwbG3vqLLQbvdN5 X-Google-Smtp-Source: APXvYqzR2Bu5tguLmNI2OJs0vJYQdBPkgBFglYW047s6xn9s/pmimcdYPkN3v+UNZqcUaKuhGP9+ar6pLMg= X-Received: by 2002:a05:620a:16d6:: with SMTP id a22mr20275853qkn.414.1566894311112; Tue, 27 Aug 2019 01:25:11 -0700 (PDT) Date: Tue, 27 Aug 2019 11:24:25 +0300 In-Reply-To: <20190827082427.64280-1-sameid@google.com> Message-Id: <20190827082427.64280-7-sameid@google.com> Mime-Version: 1.0 References: <20190827082427.64280-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::84a Subject: [Qemu-devel] [PATCH v6 6/8] bootdevice: Refactor get_boot_devices_list 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: , From: Sam Eiderman via Qemu-devel Reply-To: Sam Eiderman Cc: kwolf@redhat.com, qemu-block@nongnu.org, Arbel Moshe , seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.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 Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Move device name construction to a separate function. We will reuse this function in the following commit to pass logical CHS parameters through fw_cfg much like we currently pass bootindex. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman --- bootdevice.c | 61 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index bc5e1c2de4..2b12fb85a4 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -202,6 +202,39 @@ DeviceState *get_boot_device(uint32_t position) return res; } =20 +static char *get_boot_device_path(DeviceState *dev, bool ignore_suffixes, + char *suffix) +{ + char *devpath =3D NULL, *s =3D NULL, *d, *bootpath; + + if (dev) { + devpath =3D qdev_get_fw_dev_path(dev); + assert(devpath); + } + + if (!ignore_suffixes) { + if (dev) { + d =3D qdev_get_own_fw_dev_path_from_handler(dev->parent_bus, d= ev); + if (d) { + assert(!suffix); + s =3D d; + } else { + s =3D g_strdup(suffix); + } + } else { + s =3D g_strdup(suffix); + } + } + + bootpath =3D g_strdup_printf("%s%s", + devpath ? devpath : "", + s ? s : ""); + g_free(devpath); + g_free(s); + + return bootpath; +} + /* * This function returns null terminated string that consist of new line * separated device paths. @@ -218,36 +251,10 @@ char *get_boot_devices_list(size_t *size) bool ignore_suffixes =3D mc->ignore_boot_device_suffixes; =20 QTAILQ_FOREACH(i, &fw_boot_order, link) { - char *devpath =3D NULL, *suffix =3D NULL; char *bootpath; - char *d; size_t len; =20 - if (i->dev) { - devpath =3D qdev_get_fw_dev_path(i->dev); - assert(devpath); - } - - if (!ignore_suffixes) { - if (i->dev) { - d =3D qdev_get_own_fw_dev_path_from_handler(i->dev->parent= _bus, - i->dev); - if (d) { - assert(!i->suffix); - suffix =3D d; - } else { - suffix =3D g_strdup(i->suffix); - } - } else { - suffix =3D g_strdup(i->suffix); - } - } - - bootpath =3D g_strdup_printf("%s%s", - devpath ? devpath : "", - suffix ? suffix : ""); - g_free(devpath); - g_free(suffix); + bootpath =3D get_boot_device_path(i->dev, ignore_suffixes, i->suff= ix); =20 if (total) { list[total-1] =3D '\n'; --=20 2.23.0.187.g17f5b7556c-goog