From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E090CA9EC3 for ; Thu, 31 Oct 2019 11:11:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD8662087F for ; Thu, 31 Oct 2019 11:11:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YSyQ9Ofc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD8662087F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQ8Mb-0007Gf-UJ for qemu-devel@archiver.kernel.org; Thu, 31 Oct 2019 07:11:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45863) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQ8DK-0006hC-Es for qemu-devel@nongnu.org; Thu, 31 Oct 2019 07:02:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQ8DI-0005GJ-2y for qemu-devel@nongnu.org; Thu, 31 Oct 2019 07:02:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:20145 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iQ8DH-0005Ex-VO for qemu-devel@nongnu.org; Thu, 31 Oct 2019 07:02:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572519719; 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=mNLLd2HIRByWcXLj/ZuynJr2+WKUeU0HeIJX7BIfftY=; b=YSyQ9OfcYkhAKhsiceDoHYOncnBQP/5LsN4ikEtVpUeIPZReYlHGR98jFyBwzc7qAVAise iSc+/wM7tF7BvebKAr82ScOweJaAt0U4Uj/leIWNExC/wznCIOS/xOAMNsFuSnzfNYtWTx 0ZEqHwqkzuvlcHX5pAaLkuSam/S0qDQ= 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-24-wF7lnmueMDqgTJRmJPABnA-1; Thu, 31 Oct 2019 07:01:55 -0400 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 0FB0D800686; Thu, 31 Oct 2019 11:01:54 +0000 (UTC) Received: from probe.redhat.com (ovpn-121-17.rdu2.redhat.com [10.10.121.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B74A6106A; Thu, 31 Oct 2019 11:00:50 +0000 (UTC) From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 4/9] bootdevice: Add interface to gather LCHS Date: Thu, 31 Oct 2019 06:58:59 -0400 Message-Id: <20191031105904.12194-5-jsnow@redhat.com> In-Reply-To: <20191031105904.12194-1-jsnow@redhat.com> References: <20191031105904.12194-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: wF7lnmueMDqgTJRmJPABnA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 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: Kevin Wolf , Fam Zheng , Thomas Huth , qemu-block@nongnu.org, "Michael S. Tsirkin" , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Arbel Moshe , Laszlo Ersek , "Gonglei \(Arei\)" , Sam Eiderman , Gerd Hoffmann , Stefan Hajnoczi , Laurent Vivier , Paolo Bonzini , Sam Eiderman , Max Reitz , John Snow , Karl Heubaum Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Sam Eiderman Add an interface to provide direct logical CHS values for boot devices. We will use this interface in the next commits. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: John Snow --- include/sysemu/sysemu.h | 3 +++ bootdevice.c | 55 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 44f18eb739..5bc5c79cbc 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -103,6 +103,9 @@ void device_add_bootindex_property(Object *obj, int32_t= *bootindex, DeviceState *dev, Error **errp); void restore_boot_order(void *opaque); void validate_bootdevices(const char *devices, Error **errp); +void add_boot_device_lchs(DeviceState *dev, const char *suffix, + uint32_t lcyls, uint32_t lheads, uint32_t lsecs)= ; +void del_boot_device_lchs(DeviceState *dev, const char *suffix); =20 /* handler to set the boot_device order for a specific type of MachineClas= s */ typedef void QEMUBootSetHandler(void *opaque, const char *boot_order, diff --git a/bootdevice.c b/bootdevice.c index 1d225202f9..bc5e1c2de4 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -343,3 +343,58 @@ void device_add_bootindex_property(Object *obj, int32_= t *bootindex, /* initialize devices' bootindex property to -1 */ object_property_set_int(obj, -1, name, NULL); } + +typedef struct FWLCHSEntry FWLCHSEntry; + +struct FWLCHSEntry { + QTAILQ_ENTRY(FWLCHSEntry) link; + DeviceState *dev; + char *suffix; + uint32_t lcyls; + uint32_t lheads; + uint32_t lsecs; +}; + +static QTAILQ_HEAD(, FWLCHSEntry) fw_lchs =3D + QTAILQ_HEAD_INITIALIZER(fw_lchs); + +void add_boot_device_lchs(DeviceState *dev, const char *suffix, + uint32_t lcyls, uint32_t lheads, uint32_t lsecs) +{ + FWLCHSEntry *node; + + if (!lcyls && !lheads && !lsecs) { + return; + } + + assert(dev !=3D NULL || suffix !=3D NULL); + + node =3D g_malloc0(sizeof(FWLCHSEntry)); + node->suffix =3D g_strdup(suffix); + node->dev =3D dev; + node->lcyls =3D lcyls; + node->lheads =3D lheads; + node->lsecs =3D lsecs; + + QTAILQ_INSERT_TAIL(&fw_lchs, node, link); +} + +void del_boot_device_lchs(DeviceState *dev, const char *suffix) +{ + FWLCHSEntry *i; + + if (dev =3D=3D NULL) { + return; + } + + QTAILQ_FOREACH(i, &fw_lchs, link) { + if ((!suffix || !g_strcmp0(i->suffix, suffix)) && + i->dev =3D=3D dev) { + QTAILQ_REMOVE(&fw_lchs, i, link); + g_free(i->suffix); + g_free(i); + + break; + } + } +} --=20 2.21.0