From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKXq-0006a8-75 for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:07:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeKXh-00074K-PS for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKXh-000742-HO for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:49 -0400 From: Gerd Hoffmann Date: Wed, 15 Oct 2014 11:06:03 +0200 Message-Id: <1413363967-2489-31-git-send-email-kraxel@redhat.com> In-Reply-To: <1413363967-2489-1-git-send-email-kraxel@redhat.com> References: <1413363967-2489-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 30/34] nvma: ide: add bootindex to qom property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Keith Busch , Kevin Wolf , Gonglei , Gerd Hoffmann , Stefan Hajnoczi 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 Signed-off-by: Gerd Hoffmann --- 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) -- 1.8.3.1