From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKXm-0006Te-Kd for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:07:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeKXe-00072K-VE for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKXe-000720-MI for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:46 -0400 From: Gerd Hoffmann Date: Wed, 15 Oct 2014 11:06:04 +0200 Message-Id: <1413363967-2489-32-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 31/34] ide: add calling add_boot_device_patch in bootindex setter function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Gonglei , Gerd Hoffmann , Stefan Hajnoczi From: Gonglei On this way, we can assure the new bootindex take effect during vm rebooting. Meanwhile set the initial value of bootindex to -1. Because ide devcies's unit property maybe do not initialize when set_bootindex function is called, so that we don't know its suffix. So we have to save the call add_boot_device_path() on ide realize/init function. When we want to change bootindex during vm rebooting, we can call it in setter function. Signed-off-by: Gonglei Reviewed-by: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- hw/ide/qdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 7e69020..9814ef0 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -219,6 +219,10 @@ static void ide_dev_set_bootindex(Object *obj, Visitor *v, void *opaque, /* change bootindex to a new one */ d->conf.bootindex = boot_index; + if (d->unit != -1) { + add_boot_device_path(d->conf.bootindex, &d->qdev, + d->unit ? "/disk@1" : "/disk@0"); + } out: if (local_err) { error_propagate(errp, local_err); @@ -230,6 +234,7 @@ 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); + object_property_set_int(obj, -1, "bootindex", NULL); } static int ide_hd_initfn(IDEDevice *dev) -- 1.8.3.1