From patchwork Wed Oct 15 09:05:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 399833 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 798411400DD for ; Wed, 15 Oct 2014 20:12:14 +1100 (EST) Received: from localhost ([::1]:42936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKcu-0006hG-HW for incoming@patchwork.ozlabs.org; Wed, 15 Oct 2014 05:12:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKXk-0006RY-UP for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeKXb-00070O-Tt for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKXb-0006zx-KZ for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:43 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9F96cNB023308 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 15 Oct 2014 05:06:38 -0400 Received: from nilsson.home.kraxel.org (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9F96cXT012005; Wed, 15 Oct 2014 05:06:38 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id C3E5F8101B; Wed, 15 Oct 2014 11:06:36 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 15 Oct 2014 11:05:58 +0200 Message-Id: <1413363967-2489-26-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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Gonglei , Gerd Hoffmann , Stefan Hajnoczi Subject: [Qemu-devel] [PULL 25/34] 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 Add a qom property with the same name 'bootindex', when we remove it form qdev property, things will continue to work just fine, and we can use qom features which are not supported by qdev property. Signed-off-by: Gonglei Reviewed-by: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- hw/ide/qdev.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index efab95b..7e69020 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -23,6 +23,7 @@ #include "sysemu/blockdev.h" #include "hw/block/block.h" #include "sysemu/sysemu.h" +#include "qapi/visitor.h" /* --------------------------------- */ @@ -191,6 +192,46 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) return 0; } +static void ide_dev_get_bootindex(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + IDEDevice *d = IDE_DEVICE(obj); + + visit_type_int32(v, &d->conf.bootindex, name, errp); +} + +static void ide_dev_set_bootindex(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + IDEDevice *d = IDE_DEVICE(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 */ + d->conf.bootindex = boot_index; + +out: + if (local_err) { + error_propagate(errp, local_err); + } +} + +static void ide_dev_instance_init(Object *obj) +{ + object_property_add(obj, "bootindex", "int32", + ide_dev_get_bootindex, + ide_dev_set_bootindex, NULL, NULL, NULL); +} + static int ide_hd_initfn(IDEDevice *dev) { return ide_dev_initfn(dev, IDE_HD); @@ -300,6 +341,7 @@ static const TypeInfo ide_device_type_info = { .abstract = true, .class_size = sizeof(IDEDeviceClass), .class_init = ide_device_class_init, + .instance_init = ide_dev_instance_init, }; static void ide_register_types(void)