From patchwork Tue Oct 7 08:00:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 397170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8B83914009E for ; Tue, 7 Oct 2014 19:15:23 +1100 (EST) Received: from localhost ([::1]:57273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbPvV-0008Pq-6j for incoming@patchwork.ozlabs.org; Tue, 07 Oct 2014 04:15:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbPj9-00040s-CB for qemu-devel@nongnu.org; Tue, 07 Oct 2014 04:03:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XbPig-0005Ue-Kl for qemu-devel@nongnu.org; Tue, 07 Oct 2014 04:02:35 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:25315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbPif-0005TA-PQ for qemu-devel@nongnu.org; Tue, 07 Oct 2014 04:02:06 -0400 Received: from 172.24.2.119 (EHLO szxeml412-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CCO01261; Tue, 07 Oct 2014 16:01:27 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml412-hub.china.huawei.com (10.82.67.91) with Microsoft SMTP Server id 14.3.158.1; Tue, 7 Oct 2014 16:01:19 +0800 From: To: Date: Tue, 7 Oct 2014 16:00:34 +0800 Message-ID: <1412668838-8656-31-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 In-Reply-To: <1412668838-8656-1-git-send-email-arei.gonglei@huawei.com> References: <1412668838-8656-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.64 Cc: peter.maydell@linaro.org, weidong.huang@huawei.com, mst@redhat.com, aik@ozlabs.ru, armbru@redhat.com, kraxel@redhat.com, dmitry@daynix.com, akong@redhat.com, agraf@suse.de, Gonglei , lersek@redhat.com, ehabkost@redhat.com, marcel.a@redhat.com, somlo@cmu.edu, luonengjun@huawei.com, peter.huangpeng@huawei.com, alex.williamson@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, rth@twiddle.net, kwolf@redhat.com, peter.crosthwaite@xilinx.com, chenliang88@huawei.com, imammedo@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v11 30/34] nvma: ide: add bootindex to qom property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Gonglei At present, nvma cannot boot. However, it provides already a bootindex property, so change bootindex to qom for nvma device, but not call add_boot_device_path. Signed-off-by: Gonglei --- hw/block/nvme.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index b010c9b..9a95f75 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -24,6 +24,8 @@ #include #include #include +#include "sysemu/sysemu.h" +#include "qapi/visitor.h" #include "nvme.h" @@ -871,11 +873,53 @@ static void nvme_class_init(ObjectClass *oc, void *data) dc->vmsd = &nvme_vmstate; } +static void nvme_get_bootindex(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + NvmeCtrl *s = NVME(obj); + + visit_type_int32(v, &s->conf.bootindex, name, errp); +} + +static void nvme_set_bootindex(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + NvmeCtrl *s = NVME(obj); + int32_t boot_index; + Error *local_err = NULL; + + visit_type_int32(v, &boot_index, name, &local_err); + if (local_err) { + goto out; + } + /* check whether bootindex is present in fw_boot_order list */ + check_boot_index(boot_index, &local_err); + if (local_err) { + goto out; + } + /* change bootindex to a new one */ + s->conf.bootindex = boot_index; + +out: + if (local_err) { + error_propagate(errp, local_err); + } +} + +static void nvme_instance_init(Object *obj) +{ + object_property_add(obj, "bootindex", "int32", + nvme_get_bootindex, + nvme_set_bootindex, NULL, NULL, NULL); + object_property_set_int(obj, -1, "bootindex", NULL); +} + static const TypeInfo nvme_info = { .name = "nvme", .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(NvmeCtrl), .class_init = nvme_class_init, + .instance_init = nvme_instance_init, }; static void nvme_register_types(void)