Received: from eggs.gnu.org ([2001:4830:134:3::10]:42002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAtsM-00014A-1I for qemu-devel@nongnu.org; Sat, 26 Jul 2014 00:46:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAtsC-0003dw-HD for qemu-devel@nongnu.org; Sat, 26 Jul 2014 00:46:29 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:45842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAtsB-0003dQ-S2 for qemu-devel@nongnu.org; Sat, 26 Jul 2014 00:46:20 -0400 From: Date: Sat, 26 Jul 2014 12:45:26 +0800 Message-ID: <1406349933-17536-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v3 0/7] modify boot order of guest, and take effect after rebooting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: chenliang88@huawei.com, weidong.huang@huawei.com, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, armbru@redhat.com, kraxel@redhat.com, akong@redhat.com, agraf@suse.de, Gonglei , aliguori@amazon.com, gaowanlong@cn.fujitsu.com, ehabkost@redhat.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, hani@linux.com, stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, kwolf@redhat.com, peter.crosthwaite@xilinx.com, imammedo@redhat.com, afaerber@suse.de From: Gonglei Sometimes, we want to modify boot order of a guest, but no need to shutdown it. We can call dynamic changing bootindex of a guest, which can be assured taking effect just after the guest rebooting. For example, in P2V scene, we boot a guest and then attach a new system disk, for copying some thing. We want to assign the new disk as the booting disk, which means its bootindex=1. Different nics can be assigen different bootindex dynamically also make sense. The patchsets add one qmp interface, and add an fw_cfg_machine_reset() to achieve it. Steps of testing: ./qemu-system-x86_64 -enable-kvm -m 4096 -smp 4 -name redhat6.2 -drive \ file=/home/redhat6.2.img,if=none,id=drive-ide0-0-0 \ -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ -drive file=/home/RH-DVD1.iso,if=none,id=drive-ide0-0-1 \ -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,bootindex=4 \ -vnc 0.0.0.0:10 -netdev type=user,id=net0 \ -device virtio-net-pci,netdev=net0,bootindex=3,id=nic1 \ -netdev type=user,id=net1 -device e1000,netdev=net1,bootindex=2,id=nic2 -monitor stdio QEMU 2.0.93 monitor - type 'help' for more information (qemu) set-bootindex ide0-0-1 1 The bootindex 1 has already been used (qemu) set-bootindex ide0-0-1 5 "/disk@1" (qemu) set-bootindex ide0-0-1 0 (qemu) system_reset (qemu) set-bootindex ide0-0-1 1 The bootindex 1 has already been used (qemu) set-bootindex nic2 0 The bootindex 0 has already been used (qemu) set-bootindex ide0-0-1 -1 (qemu) set-bootindex nic2 0 (qemu) system_reset (qemu) Changes since v1: *rework by Gerd's suggestion: - split modify and del fw_boot_order for single function. - change modify bootindex's realization which simply lookup the device and modify the bootindex. if the new bootindex has already used by another device just throw an error. - change to del_boot_device_path(DeviceState *dev) and simply delete all entries belonging to the device. Changes since v2: *address Gerd's reviewing suggestion: - use the old entry's suffix, if the caller do not pass it in. - call del_boot_device_path() from device_finalize() instead of placing it into each individual device. Thanks Gerd. Gonglei (7): bootindex: add modify_boot_device_path function bootindex: add del_boot_device_path function fw_cfg: add fw_cfg_machine_reset function bootindex: delete bootindex when device is removed qmp: add set-bootindex command qemu-monitor: HMP set-bootindex wrapper spapr: fix possible memory leak hmp-commands.hx | 15 ++++++++++ hmp.c | 13 ++++++++ hmp.h | 1 + hw/core/qdev.c | 2 ++ hw/nvram/fw_cfg.c | 54 +++++++++++++++++++++++++++++----- hw/ppc/spapr.c | 1 + include/hw/nvram/fw_cfg.h | 2 ++ include/sysemu/sysemu.h | 3 ++ qapi-schema.json | 16 ++++++++++ qmp-commands.hx | 24 +++++++++++++++ qmp.c | 17 +++++++++++ vl.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 216 insertions(+), 7 deletions(-) -- 1.7.12.4