All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting
@ 2014-09-05  8:37 arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 01/28] bootdevice: move bootdevice related code to new file bootdevice.c arei.gonglei
                   ` (27 more replies)
  0 siblings, 28 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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.

This patch series do belows works:
 1. add an fw_cfg_machine_reset() assure re-read global fw_boot_order list
   during vm rebooting.
 2. switch the property from qdev to qom, then use the set
    callback to also update the fw_cfg file.

 Note:
 - Do not support change pci option rom's bootindex.
 - Do not handle those devices which don't have use the bootindex property.

changes since v6:
 - move all bootindex/boot-device code to a new file, named bootdevice.c.
 - introduce a getter/setter wrapper for all device.
 - call add_boot_device_path in setter bootindx callback function.
 - call del_boot_device_path in finalize bootindex qom callback function.
 - other bugfixes.

 Thanks for Eduardo's good suggestion! And other guys, thanks too!

changes since v5:
 rework by Gerd and Markus's suggestion(Thanks a lot):
 - Set/update bootindex on reset instead of realize/init.
 - Switch the property from qdev to qom, then use the set
   callback to also update the fw_cfg file.
 - using qom-set instead of 'set-bootindex' qmp interface,
   remove it.

 This is a huge change relative to the previous version. 

Changes since v4:
 - using error_setg() instead of qerror_report() in patch 1/8.
 - call del_boot_device_path() from device_finalize() instead
  of placing it into each individual device in patch 4/8.

Changes since v3:
 - rework del_* and modify_* function, because of virtio devices' specialation.
   For example, virtio-net's id is NULL, and its parent virtio-net-pci's id was assigned.
   Though the global fw_boot_order stored the virtio-net device.
 - call dell_boot_device_path in each individual device avoiding waste resouce.
 - introduce qmp "query-bootindex" command
 - introcude hmp "info bootindex" command
 - Fixes by Eric's reviewing comments, thanks.

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.

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.

For Convenience of testing, my test case based on Andreas's patch series:

 [PATCH qom-next 0/4] qom: HMP commands to replace info qtree
 http://thread.gmane.org/gmane.comp.emulators.qemu/271513
However, there is no direct relation with this bootindex patch series.

This series based on my patch posted yestoday:
 [PATCH] virtio-pci: fix virtio-net child refcount in transports
http://lists.gnu.org/archive/html/qemu-devel/2014-09/msg00805.html

./qemu-system-x86_64 -enable-kvm -m 4096 -smp 4 -name redhat6.2 -drive \
file=/home/win7_32_2U,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/rhel-server-7.0-x86_64-dvd.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 \
-drive file=/mnt/sdb/gonglei/image/virtio-win-1.5.3.vfd,if=none,id=drive-fdc0-0-0,format=raw \
-device isa-fdc,driveA=drive-fdc0-0-0,bootindexA=5,id=floppy1 -qmp unix:/tmp/qmp,server,nowait \
-monitor stdio -netdev type=user,id=net1 -device e1000,netdev=net1,bootindex=2,id=nic \
-boot menu=on -device virtio-scsi-pci,id=scsi0 -drive file=/home/suse11_sp3_32,if=none,\
id=drive-scsi0-0-0-0,format=raw,cache=none,aio=native \
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=8
QEMU 2.1.50 monitor - type 'help' for more information
(qemu) qom-get nic1 bootindex
3 (0x3)
(qemu) qom-set nic1 bootindex 3
The bootindex 3 has already been used
(qemu) qom-set nic1 bootindex 0
(qemu) qom-set floppy1 bootindexA 3
(qemu) system_reset
(qemu) qom-get nic1 bootindex
0 (0x0)
(qemu) qom-get scsi0-0-0-0 bootindex
8 (0x8)
(qemu) qom-set scsi0-0-0-0 bootindex 0
The bootindex 0 has already been used
(qemu) qom-set nic1 bootindex -1
(qemu) qom-set scsi0-0-0-0 bootindex 0
(qemu) qom-get scsi0-0-0-0 bootindex
0 (0x0)
(qemu) 

Gonglei (28):
  bootdevice: move bootdevice related code to new file bootdevice.c
  bootindex: add check bootindex function
  bootindex: add del_boot_device_path function
  fw_cfg: add fw_cfg_machine_reset function
  bootindex: rework add_boot_device_path function
  bootindex: support to set a existent device's bootindex to -1
  bootindex: add a setter/getter functions wrapper for bootindex
    property
  virtio-net: add bootindex to qom property
  e1000: add bootindex to qom property
  eepro100: add bootindex to qom property
  ne2000: add bootindex to qom property
  pcnet: add bootindex to qom property
  rtl8139: add bootindex to qom property
  spapr_lian: add bootindex to qom property
  vmxnet3: add bootindex to qom property
  usb-net: add bootindex to qom property
  net: remove bootindex property from qdev to qom
  host-libusb: remove bootindex property from qdev to qom
  pci-assign: remove bootindex property from qdev to qom
  vfio: remove bootindex property from qdev to qom
  redirect: remove bootindex property from qdev to qom
  isa-fdc: remove bootindexA/B property from qdev to qom
  scsi: add bootindex to qom property
  ide: add bootindex to qom property
  virtio-blk: add bootindex to qom property
  block: remove bootindex property from qdev to qom
  bootindex: move calling add_boot_device_patch to bootindex setter
    function
  bootindex: delete bootindex when device is removed

 Makefile.target           |   2 +-
 bootdevice.c              | 283 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/block/fdc.c            |  20 +++-
 hw/block/virtio-blk.c     |   6 +-
 hw/i386/kvm/pci-assign.c  |  15 ++-
 hw/ide/qdev.c             |  18 ++-
 hw/misc/vfio.c            |  14 ++-
 hw/net/e1000.c            |  13 ++-
 hw/net/eepro100.c         |  14 ++-
 hw/net/lance.c            |  13 +++
 hw/net/ne2000.c           |  15 ++-
 hw/net/pcnet-pci.c        |  13 +++
 hw/net/pcnet.c            |   2 -
 hw/net/pcnet.h            |   1 -
 hw/net/rtl8139.c          |  13 ++-
 hw/net/spapr_llan.c       |  13 ++-
 hw/net/virtio-net.c       |   6 +-
 hw/net/vmxnet3.c          |  11 +-
 hw/nvram/fw_cfg.c         |  55 ++++++++-
 hw/scsi/scsi-disk.c       |  17 ++-
 hw/scsi/scsi-generic.c    |   5 +-
 hw/usb/dev-network.c      |  13 ++-
 hw/usb/host-libusb.c      |  14 ++-
 hw/usb/redirect.c         |  14 ++-
 hw/virtio/virtio-pci.c    |  12 +-
 include/hw/block/block.h  |   1 -
 include/hw/nvram/fw_cfg.h |   2 +
 include/hw/scsi/scsi.h    |   1 +
 include/net/net.h         |   4 +-
 include/sysemu/sysemu.h   |   6 +
 vl.c                      | 118 +------------------
 31 files changed, 562 insertions(+), 172 deletions(-)
 create mode 100644 bootdevice.c

-- 
1.7.12.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 01/28] bootdevice: move bootdevice related code to new file bootdevice.c
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 02/28] bootindex: add check bootindex function arei.gonglei
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 Makefile.target         |   2 +-
 bootdevice.c            | 142 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/sysemu/sysemu.h |   1 +
 vl.c                    | 118 +---------------------------------------
 4 files changed, 145 insertions(+), 118 deletions(-)
 create mode 100644 bootdevice.c

diff --git a/Makefile.target b/Makefile.target
index 1e8d7ab..e9ff1ee 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -127,7 +127,7 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU
 obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
-obj-y += qtest.o
+obj-y += qtest.o bootdevice.o
 obj-y += hw/
 obj-$(CONFIG_FDT) += device_tree.o
 obj-$(CONFIG_KVM) += kvm-all.o
diff --git a/bootdevice.c b/bootdevice.c
new file mode 100644
index 0000000..d5b8789
--- /dev/null
+++ b/bootdevice.c
@@ -0,0 +1,142 @@
+/*
+ * QEMU Boot Device Implement
+ *
+ * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "sysemu/sysemu.h"
+
+typedef struct FWBootEntry FWBootEntry;
+
+struct FWBootEntry {
+    QTAILQ_ENTRY(FWBootEntry) link;
+    int32_t bootindex;
+    DeviceState *dev;
+    char *suffix;
+};
+
+static QTAILQ_HEAD(, FWBootEntry) fw_boot_order =
+    QTAILQ_HEAD_INITIALIZER(fw_boot_order);
+
+void add_boot_device_path(int32_t bootindex, DeviceState *dev,
+                          const char *suffix)
+{
+    FWBootEntry *node, *i;
+
+    if (bootindex < 0) {
+        return;
+    }
+
+    assert(dev != NULL || suffix != NULL);
+
+    node = g_malloc0(sizeof(FWBootEntry));
+    node->bootindex = bootindex;
+    node->suffix = g_strdup(suffix);
+    node->dev = dev;
+
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        if (i->bootindex == bootindex) {
+            fprintf(stderr, "Two devices with same boot index %d\n", bootindex);
+            exit(1);
+        } else if (i->bootindex < bootindex) {
+            continue;
+        }
+        QTAILQ_INSERT_BEFORE(i, node, link);
+        return;
+    }
+    QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
+}
+
+DeviceState *get_boot_device(uint32_t position)
+{
+    uint32_t counter = 0;
+    FWBootEntry *i = NULL;
+    DeviceState *res = NULL;
+
+    if (!QTAILQ_EMPTY(&fw_boot_order)) {
+        QTAILQ_FOREACH(i, &fw_boot_order, link) {
+            if (counter == position) {
+                res = i->dev;
+                break;
+            }
+            counter++;
+        }
+    }
+    return res;
+}
+
+/*
+ * This function returns null terminated string that consist of new line
+ * separated device paths.
+ *
+ * memory pointed by "size" is assigned total length of the array in bytes
+ *
+ */
+char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
+{
+    FWBootEntry *i;
+    size_t total = 0;
+    char *list = NULL;
+
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        char *devpath = NULL, *bootpath;
+        size_t len;
+
+        if (i->dev) {
+            devpath = qdev_get_fw_dev_path(i->dev);
+            assert(devpath);
+        }
+
+        if (i->suffix && !ignore_suffixes && devpath) {
+            size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1;
+
+            bootpath = g_malloc(bootpathlen);
+            snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix);
+            g_free(devpath);
+        } else if (devpath) {
+            bootpath = devpath;
+        } else if (!ignore_suffixes) {
+            assert(i->suffix);
+            bootpath = g_strdup(i->suffix);
+        } else {
+            bootpath = g_strdup("");
+        }
+
+        if (total) {
+            list[total-1] = '\n';
+        }
+        len = strlen(bootpath) + 1;
+        list = g_realloc(list, total + len);
+        memcpy(&list[total], bootpath, len);
+        total += len;
+        g_free(bootpath);
+    }
+
+    *size = total;
+
+    if (boot_strict && *size > 0) {
+        list[total-1] = '\n';
+        list = g_realloc(list, total + 5);
+        memcpy(&list[total], "HALT", 5);
+        *size = total + 5;
+    }
+    return list;
+}
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index d8539fd..8de5100 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -130,6 +130,7 @@ extern int no_shutdown;
 extern int semihosting_enabled;
 extern int old_param;
 extern int boot_menu;
+extern bool boot_strict;
 extern uint8_t *boot_splash_filedata;
 extern size_t boot_splash_filedata_size;
 extern uint8_t qemu_extra_params_fw[2];
diff --git a/vl.c b/vl.c
index a9fd207..9b15e8e 100644
--- a/vl.c
+++ b/vl.c
@@ -178,23 +178,12 @@ int ctrl_grab = 0;
 unsigned int nb_prom_envs = 0;
 const char *prom_envs[MAX_PROM_ENVS];
 int boot_menu;
-static bool boot_strict;
+bool boot_strict;
 uint8_t *boot_splash_filedata;
 size_t boot_splash_filedata_size;
 uint8_t qemu_extra_params_fw[2];
 
 int icount_align_option;
-typedef struct FWBootEntry FWBootEntry;
-
-struct FWBootEntry {
-    QTAILQ_ENTRY(FWBootEntry) link;
-    int32_t bootindex;
-    DeviceState *dev;
-    char *suffix;
-};
-
-static QTAILQ_HEAD(, FWBootEntry) fw_boot_order =
-    QTAILQ_HEAD_INITIALIZER(fw_boot_order);
 
 int nb_numa_nodes;
 int max_numa_nodeid;
@@ -1241,111 +1230,6 @@ static void restore_boot_order(void *opaque)
     g_free(normal_boot_order);
 }
 
-void add_boot_device_path(int32_t bootindex, DeviceState *dev,
-                          const char *suffix)
-{
-    FWBootEntry *node, *i;
-
-    if (bootindex < 0) {
-        return;
-    }
-
-    assert(dev != NULL || suffix != NULL);
-
-    node = g_malloc0(sizeof(FWBootEntry));
-    node->bootindex = bootindex;
-    node->suffix = g_strdup(suffix);
-    node->dev = dev;
-
-    QTAILQ_FOREACH(i, &fw_boot_order, link) {
-        if (i->bootindex == bootindex) {
-            fprintf(stderr, "Two devices with same boot index %d\n", bootindex);
-            exit(1);
-        } else if (i->bootindex < bootindex) {
-            continue;
-        }
-        QTAILQ_INSERT_BEFORE(i, node, link);
-        return;
-    }
-    QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
-}
-
-DeviceState *get_boot_device(uint32_t position)
-{
-    uint32_t counter = 0;
-    FWBootEntry *i = NULL;
-    DeviceState *res = NULL;
-
-    if (!QTAILQ_EMPTY(&fw_boot_order)) {
-        QTAILQ_FOREACH(i, &fw_boot_order, link) {
-            if (counter == position) {
-                res = i->dev;
-                break;
-            }
-            counter++;
-        }
-    }
-    return res;
-}
-
-/*
- * This function returns null terminated string that consist of new line
- * separated device paths.
- *
- * memory pointed by "size" is assigned total length of the array in bytes
- *
- */
-char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
-{
-    FWBootEntry *i;
-    size_t total = 0;
-    char *list = NULL;
-
-    QTAILQ_FOREACH(i, &fw_boot_order, link) {
-        char *devpath = NULL, *bootpath;
-        size_t len;
-
-        if (i->dev) {
-            devpath = qdev_get_fw_dev_path(i->dev);
-            assert(devpath);
-        }
-
-        if (i->suffix && !ignore_suffixes && devpath) {
-            size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1;
-
-            bootpath = g_malloc(bootpathlen);
-            snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix);
-            g_free(devpath);
-        } else if (devpath) {
-            bootpath = devpath;
-        } else if (!ignore_suffixes) {
-            assert(i->suffix);
-            bootpath = g_strdup(i->suffix);
-        } else {
-            bootpath = g_strdup("");
-        }
-
-        if (total) {
-            list[total-1] = '\n';
-        }
-        len = strlen(bootpath) + 1;
-        list = g_realloc(list, total + len);
-        memcpy(&list[total], bootpath, len);
-        total += len;
-        g_free(bootpath);
-    }
-
-    *size = total;
-
-    if (boot_strict && *size > 0) {
-        list[total-1] = '\n';
-        list = g_realloc(list, total + 5);
-        memcpy(&list[total], "HALT", 5);
-        *size = total + 5;
-    }
-    return list;
-}
-
 static QemuOptsList qemu_smp_opts = {
     .name = "smp-opts",
     .implied_opt_name = "cpus",
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 02/28] bootindex: add check bootindex function
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 01/28] bootdevice: move bootdevice related code to new file bootdevice.c arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 03/28] bootindex: add del_boot_device_path function arei.gonglei
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Determine whether a given bootindex exists or not.
If exists, we report an error.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 bootdevice.c            | 15 +++++++++++++++
 include/sysemu/sysemu.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/bootdevice.c b/bootdevice.c
index d5b8789..f5399df 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -36,6 +36,21 @@ struct FWBootEntry {
 static QTAILQ_HEAD(, FWBootEntry) fw_boot_order =
     QTAILQ_HEAD_INITIALIZER(fw_boot_order);
 
+void check_boot_index(int32_t bootindex, Error **errp)
+{
+    FWBootEntry *i;
+
+    if (bootindex >= 0) {
+        QTAILQ_FOREACH(i, &fw_boot_order, link) {
+            if (i->bootindex == bootindex) {
+                error_setg(errp, "The bootindex %d has already been used",
+                           bootindex);
+                return;
+            }
+        }
+    }
+}
+
 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix)
 {
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 8de5100..72463de 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -213,6 +213,7 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
 char *get_boot_devices_list(size_t *size, bool ignore_suffixes);
 
 DeviceState *get_boot_device(uint32_t position);
+void check_boot_index(int32_t bootindex, Error **errp);
 
 QemuOpts *qemu_get_machine_opts(void);
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 03/28] bootindex: add del_boot_device_path function
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 01/28] bootdevice: move bootdevice related code to new file bootdevice.c arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 02/28] bootindex: add check bootindex function arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 04/28] fw_cfg: add fw_cfg_machine_reset function arei.gonglei
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Introduce del_boot_device_path() to clean up fw_cfg content when
hot-unplugging a device that refers to a bootindex.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Chenliang <chenliang88@huawei.com>
---
 bootdevice.c            | 21 +++++++++++++++++++++
 include/sysemu/sysemu.h |  1 +
 2 files changed, 22 insertions(+)

diff --git a/bootdevice.c b/bootdevice.c
index f5399df..89aca7f 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -51,6 +51,27 @@ void check_boot_index(int32_t bootindex, Error **errp)
     }
 }
 
+void del_boot_device_path(DeviceState *dev)
+{
+    FWBootEntry *i;
+
+    assert(dev != NULL);
+
+    /* remove all entries of the assigned device */
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        if (i->dev == NULL) {
+            continue;
+        }
+        if (i->dev == dev) {
+            QTAILQ_REMOVE(&fw_boot_order, i, link);
+            g_free(i->suffix);
+            g_free(i);
+
+            break;
+        }
+    }
+}
+
 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix)
 {
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 72463de..10cd573 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -214,6 +214,7 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes);
 
 DeviceState *get_boot_device(uint32_t position);
 void check_boot_index(int32_t bootindex, Error **errp);
+void del_boot_device_path(DeviceState *dev);
 
 QemuOpts *qemu_get_machine_opts(void);
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 04/28] fw_cfg: add fw_cfg_machine_reset function
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (2 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 03/28] bootindex: add del_boot_device_path function arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path function arei.gonglei
                   ` (23 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

We must assure that the changed bootindex can take effect
when guest is rebooted. So we introduce fw_cfg_machine_reset(),
which change the fw_cfg file's bootindex data using the new
global fw_boot_order list.

Signed-off-by: Chenliang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/nvram/fw_cfg.c         | 55 ++++++++++++++++++++++++++++++++++++++++++++---
 include/hw/nvram/fw_cfg.h |  2 ++
 2 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index b71d251..e7ed27e 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -402,6 +402,26 @@ static void fw_cfg_add_bytes_read_callback(FWCfgState *s, uint16_t key,
     s->entries[arch][key].callback_opaque = callback_opaque;
 }
 
+static void *fw_cfg_modify_bytes_read(FWCfgState *s, uint16_t key,
+                                              void *data, size_t len)
+{
+    void *ptr;
+    int arch = !!(key & FW_CFG_ARCH_LOCAL);
+
+    key &= FW_CFG_ENTRY_MASK;
+
+    assert(key < FW_CFG_MAX_ENTRY && len < UINT32_MAX);
+
+    /* return the old data to the function caller, avoid memory leak */
+    ptr = s->entries[arch][key].data;
+    s->entries[arch][key].data = data;
+    s->entries[arch][key].len = len;
+    s->entries[arch][key].callback_opaque = NULL;
+    s->entries[arch][key].callback = NULL;
+
+    return ptr;
+}
+
 void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len)
 {
     fw_cfg_add_bytes_read_callback(s, key, NULL, NULL, data, len);
@@ -499,13 +519,42 @@ void fw_cfg_add_file(FWCfgState *s,  const char *filename,
     fw_cfg_add_file_callback(s, filename, NULL, NULL, data, len);
 }
 
-static void fw_cfg_machine_ready(struct Notifier *n, void *data)
+void *fw_cfg_modify_file(FWCfgState *s, const char *filename,
+                        void *data, size_t len)
+{
+    int i, index;
+
+    assert(s->files);
+
+    index = be32_to_cpu(s->files->count);
+    assert(index < FW_CFG_FILE_SLOTS);
+
+    for (i = 0; i < index; i++) {
+        if (strcmp(filename, s->files->f[i].name) == 0) {
+            return fw_cfg_modify_bytes_read(s, FW_CFG_FILE_FIRST + i,
+                                     data, len);
+        }
+    }
+    /* add new one */
+    fw_cfg_add_file_callback(s, filename, NULL, NULL, data, len);
+    return NULL;
+}
+
+static void fw_cfg_machine_reset(void *opaque)
 {
+    void *ptr;
     size_t len;
-    FWCfgState *s = container_of(n, FWCfgState, machine_ready);
+    FWCfgState *s = opaque;
     char *bootindex = get_boot_devices_list(&len, false);
 
-    fw_cfg_add_file(s, "bootorder", (uint8_t*)bootindex, len);
+    ptr = fw_cfg_modify_file(s, "bootorder", (uint8_t *)bootindex, len);
+    g_free(ptr);
+}
+
+static void fw_cfg_machine_ready(struct Notifier *n, void *data)
+{
+    FWCfgState *s = container_of(n, FWCfgState, machine_ready);
+    qemu_register_reset(fw_cfg_machine_reset, s);
 }
 
 FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 72b1549..56e1ed7 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -76,6 +76,8 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data,
 void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
                               FWCfgReadCallback callback, void *callback_opaque,
                               void *data, size_t len);
+void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data,
+                         size_t len);
 FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
                         hwaddr crl_addr, hwaddr data_addr);
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path function
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (3 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 04/28] fw_cfg: add fw_cfg_machine_reset function arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05 18:15   ` Eduardo Habkost
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 06/28] bootindex: support to set a existent device's bootindex to -1 arei.gonglei
                   ` (22 subsequent siblings)
  27 siblings, 1 reply; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Add the function of updating bootindex about fw_boot_order list
in add_boot_device_path(). We should delete the old one if a
device has existed in global fw_boot_order list.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 bootdevice.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/bootdevice.c b/bootdevice.c
index 89aca7f..6f430ec 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -72,6 +72,34 @@ void del_boot_device_path(DeviceState *dev)
     }
 }
 
+static void del_original_boot_device(DeviceState *dev, const char *suffix)
+{
+    FWBootEntry *i;
+
+    if (dev == NULL) {
+        return;
+    }
+
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        if (suffix) {
+            if (i->dev == dev && !strcmp(i->suffix, suffix)) {
+                QTAILQ_REMOVE(&fw_boot_order, i, link);
+                g_free(i->suffix);
+                g_free(i);
+
+                break;
+            }
+        } else { /* host-usb and scsi devices do not have a suffix */
+            if (i->dev == dev) {
+                QTAILQ_REMOVE(&fw_boot_order, i, link);
+                g_free(i);
+
+                break;
+            }
+        }
+    }
+}
+
 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix)
 {
@@ -83,6 +111,8 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
 
     assert(dev != NULL || suffix != NULL);
 
+    del_original_boot_device(dev, suffix);
+
     node = g_malloc0(sizeof(FWBootEntry));
     node->bootindex = bootindex;
     node->suffix = g_strdup(suffix);
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 06/28] bootindex: support to set a existent device's bootindex to -1
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (4 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path function arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 07/28] bootindex: add a setter/getter functions wrapper for bootindex property arei.gonglei
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

When set a device's bootindex to -1, we remove it from global
fw_boot_order list.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 bootdevice.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bootdevice.c b/bootdevice.c
index 6f430ec..484d0c9 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -106,6 +106,7 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
     FWBootEntry *node, *i;
 
     if (bootindex < 0) {
+        del_original_boot_device(dev, suffix);
         return;
     }
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 07/28] bootindex: add a setter/getter functions wrapper for bootindex property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (5 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 06/28] bootindex: support to set a existent device's bootindex to -1 arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 08/28] virtio-net: add bootindex to qom property arei.gonglei
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

when we remove bootindex form qdev.property to qom.property,
we can use those functions set/get bootindex property for all
correlative devices.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 bootdevice.c            | 70 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/sysemu/sysemu.h |  3 +++
 2 files changed, 73 insertions(+)

diff --git a/bootdevice.c b/bootdevice.c
index 484d0c9..c669293 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -23,6 +23,7 @@
  */
 
 #include "sysemu/sysemu.h"
+#include "qapi/visitor.h"
 
 typedef struct FWBootEntry FWBootEntry;
 
@@ -207,3 +208,72 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
     }
     return list;
 }
+
+typedef struct {
+    int32_t *bootindex;
+    const char *suffix;
+    DeviceState *dev;
+} BootIndexProperty;
+
+static void device_get_bootindex(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    BootIndexProperty *prop = opaque;
+    visit_type_int32(v, prop->bootindex, name, errp);
+}
+
+static void device_set_bootindex(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    BootIndexProperty *prop = opaque;
+    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 */
+    *prop->bootindex = boot_index;
+
+out:
+    if (local_err) {
+        error_propagate(errp, local_err);
+    }
+}
+
+static void property_release_bootindex(Object *obj, const char *name,
+                                       void *opaque)
+
+{
+    BootIndexProperty *prop = opaque;
+    g_free(prop);
+}
+
+void device_add_bootindex_property(Object *obj, int32_t *bootindex,
+                                   const char *name, const char *suffix,
+                                   DeviceState *dev, Error **errp)
+{
+    Error *local_err = NULL;
+    BootIndexProperty *prop = g_malloc0(sizeof(*prop));
+
+    prop->bootindex = bootindex;
+    prop->suffix = suffix;
+    prop->dev = dev;
+
+    object_property_add(obj, name, "int",
+                        device_get_bootindex,
+                        device_set_bootindex,
+                        property_release_bootindex,
+                        prop, &local_err);
+
+    if (local_err) {
+        error_propagate(errp, local_err);
+        g_free(prop);
+    }
+}
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 10cd573..a636d2e 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -215,6 +215,9 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes);
 DeviceState *get_boot_device(uint32_t position);
 void check_boot_index(int32_t bootindex, Error **errp);
 void del_boot_device_path(DeviceState *dev);
+void device_add_bootindex_property(Object *obj, int32_t *bootindex,
+                                   const char *name, const char *suffix,
+                                   DeviceState *dev, Error **errp);
 
 QemuOpts *qemu_get_machine_opts(void);
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 08/28] virtio-net: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (6 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 07/28] bootindex: add a setter/getter functions wrapper for bootindex property arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05 18:28   ` Eduardo Habkost
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 09/28] e1000: " arei.gonglei
                   ` (19 subsequent siblings)
  27 siblings, 1 reply; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/net/virtio-net.c    |  3 +++
 hw/virtio/virtio-pci.c | 11 ++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 826a2a5..f5f6bf7 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1716,6 +1716,9 @@ static void virtio_net_instance_init(Object *obj)
      * Can be overriden with virtio_net_set_config_size.
      */
     n->config_size = sizeof(struct virtio_net_config);
+    device_add_bootindex_property(obj, &n->nic_conf.bootindex,
+                                  "bootindex", "/ethernet-phy@0",
+                                  DEVICE(n), NULL);
 }
 
 static Property virtio_net_properties[] = {
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 78dcd68..0779d28 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1454,9 +1454,14 @@ static void virtio_net_pci_class_init(ObjectClass *klass, void *data)
 static void virtio_net_pci_instance_init(Object *obj)
 {
     VirtIONetPCI *dev = VIRTIO_NET_PCI(obj);
-    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
-    object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
-    object_unref(OBJECT(&dev->vdev));
+    VirtIONet *n = &dev->vdev;
+
+    object_initialize(n, sizeof(dev->vdev), TYPE_VIRTIO_NET);
+    object_property_add_child(obj, "virtio-backend", OBJECT(n), NULL);
+    object_unref(OBJECT(n));
+    device_add_bootindex_property(obj, &n->nic_conf.bootindex,
+                                  "bootindex", "/ethernet-phy@0",
+                                  DEVICE(n), NULL);
 }
 
 static const TypeInfo virtio_net_pci_info = {
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 09/28] e1000: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (7 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 08/28] virtio-net: add bootindex to qom property arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 10/28] eepro100: " arei.gonglei
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/net/e1000.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 272df00..0edbfa6 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1621,10 +1621,19 @@ static void e1000_class_init(ObjectClass *klass, void *data)
     dc->props = e1000_properties;
 }
 
+static void e1000_instance_init(Object *obj)
+{
+    E1000State *n = E1000(obj);
+    device_add_bootindex_property(obj, &n->conf.bootindex,
+                                  "bootindex", "/ethernet-phy@0",
+                                  DEVICE(n), NULL);
+}
+
 static const TypeInfo e1000_base_info = {
     .name          = TYPE_E1000_BASE,
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(E1000State),
+    .instance_init = e1000_instance_init,
     .class_size    = sizeof(E1000BaseClass),
     .abstract      = true,
 };
@@ -1668,6 +1677,7 @@ static void e1000_register_types(void)
         type_info.parent = TYPE_E1000_BASE;
         type_info.class_data = (void *)info;
         type_info.class_init = e1000_class_init;
+        type_info.instance_init = e1000_instance_init;
 
         type_register(&type_info);
     }
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 10/28] eepro100: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (8 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 09/28] e1000: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 11/28] ne2000: " arei.gonglei
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/net/eepro100.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index 3cd826a..fb9c944 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -1906,6 +1906,14 @@ static int e100_nic_init(PCIDevice *pci_dev)
     return 0;
 }
 
+static void eepro100_instance_init(Object *obj)
+{
+    EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, PCI_DEVICE(obj));
+    device_add_bootindex_property(obj, &s->conf.bootindex,
+                                  "bootindex", "/ethernet-phy@0",
+                                  DEVICE(s), NULL);
+}
+
 static E100PCIDeviceInfo e100_devices[] = {
     {
         .name = "i82550",
@@ -2104,7 +2112,8 @@ static void eepro100_register_types(void)
         type_info.parent = TYPE_PCI_DEVICE;
         type_info.class_init = eepro100_class_init;
         type_info.instance_size = sizeof(EEPRO100State);
-        
+        type_info.instance_init = eepro100_instance_init;
+
         type_register(&type_info);
     }
 }
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 11/28] ne2000: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (9 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 10/28] eepro100: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 12/28] pcnet: " arei.gonglei
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/net/ne2000.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index a62d12d..62b86af 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -752,6 +752,17 @@ static void pci_ne2000_exit(PCIDevice *pci_dev)
     qemu_free_irq(s->irq);
 }
 
+static void ne2000_instance_init(Object *obj)
+{
+    PCIDevice *pci_dev = PCI_DEVICE(obj);
+    PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
+    NE2000State *s = &d->ne2000;
+
+    device_add_bootindex_property(obj, &s->c.bootindex,
+                                  "bootindex", "/ethernet-phy@0",
+                                  &pci_dev->qdev, NULL);
+}
+
 static Property ne2000_properties[] = {
     DEFINE_NIC_PROPERTIES(PCINE2000State, ne2000.c),
     DEFINE_PROP_END_OF_LIST(),
@@ -778,6 +789,7 @@ static const TypeInfo ne2000_info = {
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(PCINE2000State),
     .class_init    = ne2000_class_init,
+    .instance_init = ne2000_instance_init,
 };
 
 static void ne2000_register_types(void)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 12/28] pcnet: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (10 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 11/28] ne2000: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 13/28] rtl8139: " arei.gonglei
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/net/lance.c     | 12 ++++++++++++
 hw/net/pcnet-pci.c | 12 ++++++++++++
 hw/net/pcnet.h     |  1 -
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/hw/net/lance.c b/hw/net/lance.c
index 7811a9e..a1c49f1 100644
--- a/hw/net/lance.c
+++ b/hw/net/lance.c
@@ -42,6 +42,7 @@
 #include "hw/sparc/sun4m.h"
 #include "pcnet.h"
 #include "trace.h"
+#include "sysemu/sysemu.h"
 
 #define TYPE_LANCE "lance"
 #define SYSBUS_PCNET(obj) \
@@ -143,6 +144,16 @@ static void lance_reset(DeviceState *dev)
     pcnet_h_reset(&d->state);
 }
 
+static void lance_instance_init(Object *obj)
+{
+    SysBusPCNetState *d = SYSBUS_PCNET(obj);
+    PCNetState *s = &d->state;
+
+    device_add_bootindex_property(obj, &s->conf.bootindex,
+                                  "bootindex", "/ethernet-phy@0",
+                                  DEVICE(obj), NULL);
+}
+
 static Property lance_properties[] = {
     DEFINE_PROP_PTR("dma", SysBusPCNetState, state.dma_opaque),
     DEFINE_NIC_PROPERTIES(SysBusPCNetState, state.conf),
@@ -169,6 +180,7 @@ static const TypeInfo lance_info = {
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(SysBusPCNetState),
     .class_init    = lance_class_init,
+    .instance_init = lance_instance_init,
 };
 
 static void lance_register_types(void)
diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
index 50ffe91..fb5f5d6 100644
--- a/hw/net/pcnet-pci.c
+++ b/hw/net/pcnet-pci.c
@@ -32,6 +32,7 @@
 #include "hw/loader.h"
 #include "qemu/timer.h"
 #include "sysemu/dma.h"
+#include "sysemu/sysemu.h"
 
 #include "pcnet.h"
 
@@ -344,6 +345,16 @@ static void pci_reset(DeviceState *dev)
     pcnet_h_reset(&d->state);
 }
 
+static void pcnet_instance_init(Object *obj)
+{
+    PCIPCNetState *d = PCI_PCNET(obj);
+    PCNetState *s = &d->state;
+
+    device_add_bootindex_property(obj, &s->conf.bootindex,
+                                  "bootindex", "/ethernet-phy@0",
+                                  DEVICE(obj), NULL);
+}
+
 static Property pcnet_properties[] = {
     DEFINE_NIC_PROPERTIES(PCIPCNetState, state.conf),
     DEFINE_PROP_END_OF_LIST(),
@@ -372,6 +383,7 @@ static const TypeInfo pcnet_info = {
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(PCIPCNetState),
     .class_init    = pcnet_class_init,
+    .instance_init = pcnet_instance_init,
 };
 
 static void pci_pcnet_register_types(void)
diff --git a/hw/net/pcnet.h b/hw/net/pcnet.h
index 9dee6f3..f8e8a6f 100644
--- a/hw/net/pcnet.h
+++ b/hw/net/pcnet.h
@@ -66,5 +66,4 @@ void pcnet_set_link_status(NetClientState *nc);
 void pcnet_common_cleanup(PCNetState *d);
 int pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInfo *info);
 extern const VMStateDescription vmstate_pcnet;
-
 #endif
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 13/28] rtl8139: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (11 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 12/28] pcnet: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 14/28] spapr_lian: " arei.gonglei
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/net/rtl8139.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 6e59f38..138a03a 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -3543,6 +3543,15 @@ static int pci_rtl8139_init(PCIDevice *dev)
     return 0;
 }
 
+static void rtl8139_instance_init(Object *obj)
+{
+    RTL8139State *s = RTL8139(obj);
+
+    device_add_bootindex_property(obj, &s->conf.bootindex,
+                                  "bootindex", "/ethernet-phy@0",
+                                  DEVICE(obj), NULL);
+}
+
 static Property rtl8139_properties[] = {
     DEFINE_NIC_PROPERTIES(RTL8139State, conf),
     DEFINE_PROP_END_OF_LIST(),
@@ -3571,6 +3580,7 @@ static const TypeInfo rtl8139_info = {
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(RTL8139State),
     .class_init    = rtl8139_class_init,
+    .instance_init = rtl8139_instance_init,
 };
 
 static void rtl8139_register_types(void)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 14/28] spapr_lian: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (12 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 13/28] rtl8139: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 15/28] vmxnet3: " arei.gonglei
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/net/spapr_llan.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index 2d47df6..38bbb01 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -219,6 +219,29 @@ static int spapr_vlan_init(VIOsPAPRDevice *sdev)
     return 0;
 }
 
+static void spapr_vlan_get_bootindex(Object *obj, Visitor *v, void *opaque,
+                                     const char *name, Error **errp)
+{
+    VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(obj);
+
+    get_bootindex(&dev->nicconf.bootindex, v, name, errp);
+}
+
+static void spapr_vlan_set_bootindex(Object *obj, Visitor *v, void *opaque,
+                                     const char *name, Error **errp)
+{
+    VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(obj);
+
+    set_bootindex(&dev->nicconf.bootindex, v, name, errp);
+}
+
+static void spapr_vlan_instance_init(Object *obj)
+{
+    object_property_add(obj, "bootindex", "int",
+                        spapr_vlan_get_bootindex,
+                        spapr_vlan_set_bootindex, NULL, NULL, NULL);
+}
+
 void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd)
 {
     DeviceState *dev;
@@ -546,6 +569,7 @@ static const TypeInfo spapr_vlan_info = {
     .parent        = TYPE_VIO_SPAPR_DEVICE,
     .instance_size = sizeof(VIOsPAPRVLANDevice),
     .class_init    = spapr_vlan_class_init,
+    .instance_init = spapr_vlan_instance_init,
 };
 
 static void spapr_vlan_register_types(void)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 15/28] vmxnet3: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (13 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 14/28] spapr_lian: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 16/28] usb-net: " arei.gonglei
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/net/spapr_llan.c | 22 ++++------------------
 hw/net/vmxnet3.c    |  8 ++++++++
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index 38bbb01..c3eb99a 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -219,27 +219,13 @@ static int spapr_vlan_init(VIOsPAPRDevice *sdev)
     return 0;
 }
 
-static void spapr_vlan_get_bootindex(Object *obj, Visitor *v, void *opaque,
-                                     const char *name, Error **errp)
-{
-    VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(obj);
-
-    get_bootindex(&dev->nicconf.bootindex, v, name, errp);
-}
-
-static void spapr_vlan_set_bootindex(Object *obj, Visitor *v, void *opaque,
-                                     const char *name, Error **errp)
+static void spapr_vlan_instance_init(Object *obj)
 {
     VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(obj);
 
-    set_bootindex(&dev->nicconf.bootindex, v, name, errp);
-}
-
-static void spapr_vlan_instance_init(Object *obj)
-{
-    object_property_add(obj, "bootindex", "int",
-                        spapr_vlan_get_bootindex,
-                        spapr_vlan_set_bootindex, NULL, NULL, NULL);
+    device_add_bootindex_property(obj, &dev->nicconf.bootindex,
+                                  "bootindex", "",
+                                  DEVICE(dev), NULL);
 }
 
 void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd)
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index f246fa1..88e9d9c 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2177,6 +2177,13 @@ static int vmxnet3_pci_init(PCIDevice *pci_dev)
     return 0;
 }
 
+static void vmxnet3_instance_init(Object *obj)
+{
+    VMXNET3State *s = VMXNET3(obj);
+    device_add_bootindex_property(obj, &s->conf.bootindex,
+                                  "bootindex", "/ethernet-phy@0",
+                                  DEVICE(obj), NULL);
+}
 
 static void vmxnet3_pci_uninit(PCIDevice *pci_dev)
 {
@@ -2524,6 +2531,7 @@ static const TypeInfo vmxnet3_info = {
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(VMXNET3State),
     .class_init    = vmxnet3_class_init,
+    .instance_init = vmxnet3_instance_init,
 };
 
 static void vmxnet3_register_types(void)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 16/28] usb-net: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (14 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 15/28] vmxnet3: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 17/28] net: remove bootindex property from qdev to qom arei.gonglei
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/usb/dev-network.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 518d536..0dd4df7 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1376,6 +1376,16 @@ static int usb_net_initfn(USBDevice *dev)
     return 0;
 }
 
+static void usb_net_instance_init(Object *obj)
+{
+    USBDevice *dev = USB_DEVICE(obj);
+    USBNetState *s = DO_UPCAST(USBNetState, dev, dev);
+
+    device_add_bootindex_property(obj, &s->conf.bootindex,
+                                  "bootindex", "/ethernet-phy@0",
+                                  &dev->qdev, NULL);
+}
+
 static USBDevice *usb_net_init(USBBus *bus, const char *cmdline)
 {
     Error *local_err = NULL;
@@ -1439,6 +1449,7 @@ static const TypeInfo net_info = {
     .parent        = TYPE_USB_DEVICE,
     .instance_size = sizeof(USBNetState),
     .class_init    = usb_net_class_initfn,
+    .instance_init = usb_net_instance_init,
 };
 
 static void usb_net_register_types(void)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 17/28] net: remove bootindex property from qdev to qom
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (15 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 16/28] usb-net: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 18/28] host-libusb: " arei.gonglei
                   ` (10 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Remove bootindex form qdev property to qom, things will
continue to work just fine, and we can use qom features
which are not supported by qdev property.

Meanwhile set the initial value of bootindex to -1.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/net/e1000.c         | 1 +
 hw/net/eepro100.c      | 1 +
 hw/net/lance.c         | 1 +
 hw/net/ne2000.c        | 1 +
 hw/net/pcnet-pci.c     | 1 +
 hw/net/rtl8139.c       | 1 +
 hw/net/spapr_llan.c    | 1 +
 hw/net/virtio-net.c    | 1 +
 hw/net/vmxnet3.c       | 1 +
 hw/usb/dev-network.c   | 1 +
 hw/virtio/virtio-pci.c | 1 +
 include/net/net.h      | 4 +---
 12 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 0edbfa6..2e5dc41 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1627,6 +1627,7 @@ static void e1000_instance_init(Object *obj)
     device_add_bootindex_property(obj, &n->conf.bootindex,
                                   "bootindex", "/ethernet-phy@0",
                                   DEVICE(n), NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static const TypeInfo e1000_base_info = {
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index fb9c944..cc79f09 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -1912,6 +1912,7 @@ static void eepro100_instance_init(Object *obj)
     device_add_bootindex_property(obj, &s->conf.bootindex,
                                   "bootindex", "/ethernet-phy@0",
                                   DEVICE(s), NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static E100PCIDeviceInfo e100_devices[] = {
diff --git a/hw/net/lance.c b/hw/net/lance.c
index a1c49f1..4972b01 100644
--- a/hw/net/lance.c
+++ b/hw/net/lance.c
@@ -152,6 +152,7 @@ static void lance_instance_init(Object *obj)
     device_add_bootindex_property(obj, &s->conf.bootindex,
                                   "bootindex", "/ethernet-phy@0",
                                   DEVICE(obj), NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static Property lance_properties[] = {
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index 62b86af..6d31555 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -761,6 +761,7 @@ static void ne2000_instance_init(Object *obj)
     device_add_bootindex_property(obj, &s->c.bootindex,
                                   "bootindex", "/ethernet-phy@0",
                                   &pci_dev->qdev, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static Property ne2000_properties[] = {
diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
index fb5f5d6..55f906d 100644
--- a/hw/net/pcnet-pci.c
+++ b/hw/net/pcnet-pci.c
@@ -353,6 +353,7 @@ static void pcnet_instance_init(Object *obj)
     device_add_bootindex_property(obj, &s->conf.bootindex,
                                   "bootindex", "/ethernet-phy@0",
                                   DEVICE(obj), NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static Property pcnet_properties[] = {
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 138a03a..d921ebd 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -3550,6 +3550,7 @@ static void rtl8139_instance_init(Object *obj)
     device_add_bootindex_property(obj, &s->conf.bootindex,
                                   "bootindex", "/ethernet-phy@0",
                                   DEVICE(obj), NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static Property rtl8139_properties[] = {
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index c3eb99a..c8b0978 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -226,6 +226,7 @@ static void spapr_vlan_instance_init(Object *obj)
     device_add_bootindex_property(obj, &dev->nicconf.bootindex,
                                   "bootindex", "",
                                   DEVICE(dev), NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index f5f6bf7..3e6d3fa 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1719,6 +1719,7 @@ static void virtio_net_instance_init(Object *obj)
     device_add_bootindex_property(obj, &n->nic_conf.bootindex,
                                   "bootindex", "/ethernet-phy@0",
                                   DEVICE(n), NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static Property virtio_net_properties[] = {
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 88e9d9c..56b22f3 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2183,6 +2183,7 @@ static void vmxnet3_instance_init(Object *obj)
     device_add_bootindex_property(obj, &s->conf.bootindex,
                                   "bootindex", "/ethernet-phy@0",
                                   DEVICE(obj), NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static void vmxnet3_pci_uninit(PCIDevice *pci_dev)
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 0dd4df7..f110ea7 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1384,6 +1384,7 @@ static void usb_net_instance_init(Object *obj)
     device_add_bootindex_property(obj, &s->conf.bootindex,
                                   "bootindex", "/ethernet-phy@0",
                                   &dev->qdev, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static USBDevice *usb_net_init(USBBus *bus, const char *cmdline)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 0779d28..cb3212f 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1462,6 +1462,7 @@ static void virtio_net_pci_instance_init(Object *obj)
     device_add_bootindex_property(obj, &n->nic_conf.bootindex,
                                   "bootindex", "/ethernet-phy@0",
                                   DEVICE(n), NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static const TypeInfo virtio_net_pci_info = {
diff --git a/include/net/net.h b/include/net/net.h
index ed594f9..e482550 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -36,9 +36,7 @@ typedef struct NICConf {
 #define DEFINE_NIC_PROPERTIES(_state, _conf)                            \
     DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr),                \
     DEFINE_PROP_VLAN("vlan",     _state, _conf.peers),                   \
-    DEFINE_PROP_NETDEV("netdev", _state, _conf.peers),                   \
-    DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1)
-
+    DEFINE_PROP_NETDEV("netdev", _state, _conf.peers)
 
 /* Net clients */
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 18/28] host-libusb: remove bootindex property from qdev to qom
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (16 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 17/28] net: remove bootindex property from qdev to qom arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  9:06   ` Gerd Hoffmann
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 19/28] pci-assign: " arei.gonglei
                   ` (9 subsequent siblings)
  27 siblings, 1 reply; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Remove bootindex form qdev property to qom, things will
continue to work just fine, and we can use qom features
which are not supported by qdev property.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/usb/host-libusb.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index c189147..a2fa70e 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -980,6 +980,17 @@ static int usb_host_initfn(USBDevice *udev)
     return 0;
 }
 
+static void usb_host_instance_init(Object *obj)
+{
+    USBDevice *udev = USB_DEVICE(obj);
+    USBHostDevice *s = USB_HOST_DEVICE(udev);
+
+    device_add_bootindex_property(obj, &s->bootindex,
+                                  "bootindex", NULL,
+                                  &udev->qdev, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
+}
+
 static void usb_host_handle_destroy(USBDevice *udev)
 {
     USBHostDevice *s = USB_HOST_DEVICE(udev);
@@ -1464,7 +1475,6 @@ static Property usb_host_dev_properties[] = {
     DEFINE_PROP_UINT32("productid", USBHostDevice, match.product_id, 0),
     DEFINE_PROP_UINT32("isobufs",  USBHostDevice, iso_urb_count,    4),
     DEFINE_PROP_UINT32("isobsize", USBHostDevice, iso_urb_frames,   32),
-    DEFINE_PROP_INT32("bootindex", USBHostDevice, bootindex,        -1),
     DEFINE_PROP_UINT32("loglevel",  USBHostDevice, loglevel,
                        LIBUSB_LOG_LEVEL_WARNING),
     DEFINE_PROP_BIT("pipeline",    USBHostDevice, options,
@@ -1497,6 +1507,7 @@ static TypeInfo usb_host_dev_info = {
     .parent        = TYPE_USB_DEVICE,
     .instance_size = sizeof(USBHostDevice),
     .class_init    = usb_host_class_initfn,
+    .instance_init = usb_host_instance_init,
 };
 
 static void usb_host_register_types(void)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 19/28] pci-assign: remove bootindex property from qdev to qom
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (17 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 18/28] host-libusb: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 20/28] vfio: " arei.gonglei
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Remove bootindex form qdev property to qom, things will
continue to work just fine, and we can use qom features
which are not supported by qdev property.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/i386/kvm/pci-assign.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index 17c7d6dc..56f387b 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -1850,13 +1850,23 @@ static void assigned_exitfn(struct PCIDevice *pci_dev)
     free_assigned_device(dev);
 }
 
+static void assigned_dev_instance_init(Object *obj)
+{
+    PCIDevice *pci_dev = PCI_DEVICE(obj);
+    AssignedDevice *d = DO_UPCAST(AssignedDevice, dev, PCI_DEVICE(obj));
+
+    device_add_bootindex_property(obj, &d->bootindex,
+                                  "bootindex", NULL,
+                                  &pci_dev->qdev, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
+}
+
 static Property assigned_dev_properties[] = {
     DEFINE_PROP_PCI_HOST_DEVADDR("host", AssignedDevice, host),
     DEFINE_PROP_BIT("prefer_msi", AssignedDevice, features,
                     ASSIGNED_DEVICE_PREFER_MSI_BIT, false),
     DEFINE_PROP_BIT("share_intx", AssignedDevice, features,
                     ASSIGNED_DEVICE_SHARE_INTX_BIT, true),
-    DEFINE_PROP_INT32("bootindex", AssignedDevice, bootindex, -1),
     DEFINE_PROP_STRING("configfd", AssignedDevice, configfd_name),
     DEFINE_PROP_END_OF_LIST(),
 };
@@ -1882,6 +1892,7 @@ static const TypeInfo assign_info = {
     .parent             = TYPE_PCI_DEVICE,
     .instance_size      = sizeof(AssignedDevice),
     .class_init         = assign_class_init,
+    .instance_init      = assigned_dev_instance_init,
 };
 
 static void assign_register_types(void)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 20/28] vfio: remove bootindex property from qdev to qom
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (18 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 19/28] pci-assign: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 21/28] redirect: " arei.gonglei
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Remove bootindex form qdev property to qom, things will
continue to work just fine, and we can use qom features
which are not supported by qdev property.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/misc/vfio.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index 40dcaa6..cdbaedf 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -4365,13 +4365,23 @@ post_reset:
     vfio_pci_post_reset(vdev);
 }
 
+static void vfio_instance_init(Object *obj)
+{
+    PCIDevice *pci_dev = PCI_DEVICE(obj);
+    VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, PCI_DEVICE(obj));
+
+    device_add_bootindex_property(obj, &vdev->bootindex,
+                                  "bootindex", NULL,
+                                  &pci_dev->qdev, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
+}
+
 static Property vfio_pci_dev_properties[] = {
     DEFINE_PROP_PCI_HOST_DEVADDR("host", VFIODevice, host),
     DEFINE_PROP_UINT32("x-intx-mmap-timeout-ms", VFIODevice,
                        intx.mmap_timeout, 1100),
     DEFINE_PROP_BIT("x-vga", VFIODevice, features,
                     VFIO_FEATURE_ENABLE_VGA_BIT, false),
-    DEFINE_PROP_INT32("bootindex", VFIODevice, bootindex, -1),
     /*
      * TODO - support passed fds... is this necessary?
      * DEFINE_PROP_STRING("vfiofd", VFIODevice, vfiofd_name),
@@ -4407,6 +4417,7 @@ static const TypeInfo vfio_pci_dev_info = {
     .parent = TYPE_PCI_DEVICE,
     .instance_size = sizeof(VFIODevice),
     .class_init = vfio_pci_dev_class_init,
+    .instance_init = vfio_instance_init,
 };
 
 static void register_vfio_pci_dev_type(void)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 21/28] redirect: remove bootindex property from qdev to qom
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (19 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 20/28] vfio: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 22/28] isa-fdc: remove bootindexA/B " arei.gonglei
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Remove bootindex form qdev property to qom, things will
continue to work just fine, and we can use qom features
which are not supported by qdev property.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/usb/redirect.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 44522d9..352ba80 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -2468,7 +2468,6 @@ static Property usbredir_properties[] = {
     DEFINE_PROP_CHR("chardev", USBRedirDevice, cs),
     DEFINE_PROP_UINT8("debug", USBRedirDevice, debug, usbredirparser_warning),
     DEFINE_PROP_STRING("filter", USBRedirDevice, filter_str),
-    DEFINE_PROP_INT32("bootindex", USBRedirDevice, bootindex, -1),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2493,11 +2492,23 @@ static void usbredir_class_initfn(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
 }
 
+static void usbredir_instance_init(Object *obj)
+{
+    USBDevice *udev = USB_DEVICE(obj);
+    USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev);
+
+    device_add_bootindex_property(obj, &dev->bootindex,
+                                  "bootindex", NULL,
+                                  &udev->qdev, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
+}
+
 static const TypeInfo usbredir_dev_info = {
     .name          = "usb-redir",
     .parent        = TYPE_USB_DEVICE,
     .instance_size = sizeof(USBRedirDevice),
     .class_init    = usbredir_class_initfn,
+    .instance_init = usbredir_instance_init,
 };
 
 static void usbredir_register_types(void)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 22/28] isa-fdc: remove bootindexA/B property from qdev to qom
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (20 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 21/28] redirect: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 23/28] scsi: add bootindex to qom property arei.gonglei
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Remove bootindexA/B form qdev property to qom, things will
continue to work just fine, and we can use qom features
which are not supported by qdev property.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/block/fdc.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 490d127..51b1f08 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2217,8 +2217,6 @@ static Property isa_fdc_properties[] = {
     DEFINE_PROP_UINT32("dma", FDCtrlISABus, dma, 2),
     DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.drives[0].bs),
     DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].bs),
-    DEFINE_PROP_INT32("bootindexA", FDCtrlISABus, bootindexA, -1),
-    DEFINE_PROP_INT32("bootindexB", FDCtrlISABus, bootindexB, -1),
     DEFINE_PROP_BIT("check_media_rate", FDCtrlISABus, state.check_media_rate,
                     0, true),
     DEFINE_PROP_END_OF_LIST(),
@@ -2236,11 +2234,26 @@ static void isabus_fdc_class_init(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 }
 
+static void isabus_fdc_instance_init(Object *obj)
+{
+    FDCtrlISABus *isa = ISA_FDC(obj);
+
+    device_add_bootindex_property(obj, &isa->bootindexA,
+                                  "bootindexA", "/floppy@0",
+                                  DEVICE(obj), NULL);
+    device_add_bootindex_property(obj, &isa->bootindexB,
+                                  "bootindexB", "/floppy@1",
+                                  DEVICE(obj), NULL);
+    object_property_set_int(obj, -1, "bootindexA", NULL);
+    object_property_set_int(obj, -1, "bootindexB", NULL);
+}
+
 static const TypeInfo isa_fdc_info = {
     .name          = TYPE_ISA_FDC,
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof(FDCtrlISABus),
     .class_init    = isabus_fdc_class_init,
+    .instance_init = isabus_fdc_instance_init,
 };
 
 static const VMStateDescription vmstate_sysbus_fdc ={
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 23/28] scsi: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (21 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 22/28] isa-fdc: remove bootindexA/B " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 24/28] ide: " arei.gonglei
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/scsi/scsi-disk.c    | 14 ++++++++++++++
 hw/scsi/scsi-generic.c |  1 +
 include/hw/scsi/scsi.h |  1 +
 3 files changed, 16 insertions(+)

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index e34a544..205cdb0 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2331,6 +2331,16 @@ static void scsi_disk_realize(SCSIDevice *dev, Error **errp)
     }
 }
 
+void scsi_dev_instance_init(Object *obj)
+{
+    DeviceState *dev = DEVICE(obj);
+    SCSIDevice *s = DO_UPCAST(SCSIDevice, qdev, dev);
+
+    device_add_bootindex_property(obj, &s->conf.bootindex,
+                                  "bootindex", NULL,
+                                  &s->qdev, NULL);
+}
+
 static const SCSIReqOps scsi_disk_emulate_reqops = {
     .size         = sizeof(SCSIDiskReq),
     .free_req     = scsi_free_request,
@@ -2644,6 +2654,7 @@ static const TypeInfo scsi_hd_info = {
     .parent        = TYPE_SCSI_DEVICE,
     .instance_size = sizeof(SCSIDiskState),
     .class_init    = scsi_hd_class_initfn,
+    .instance_init = scsi_dev_instance_init,
 };
 
 static Property scsi_cd_properties[] = {
@@ -2675,6 +2686,7 @@ static const TypeInfo scsi_cd_info = {
     .parent        = TYPE_SCSI_DEVICE,
     .instance_size = sizeof(SCSIDiskState),
     .class_init    = scsi_cd_class_initfn,
+    .instance_init = scsi_dev_instance_init,
 };
 
 #ifdef __linux__
@@ -2705,6 +2717,7 @@ static const TypeInfo scsi_block_info = {
     .parent        = TYPE_SCSI_DEVICE,
     .instance_size = sizeof(SCSIDiskState),
     .class_init    = scsi_block_class_initfn,
+    .instance_init = scsi_dev_instance_init,
 };
 #endif
 
@@ -2743,6 +2756,7 @@ static const TypeInfo scsi_disk_info = {
     .parent        = TYPE_SCSI_DEVICE,
     .instance_size = sizeof(SCSIDiskState),
     .class_init    = scsi_disk_class_initfn,
+    .instance_init = scsi_dev_instance_init,
 };
 
 static void scsi_disk_register_types(void)
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 20587b4..f6100a9 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -513,6 +513,7 @@ static const TypeInfo scsi_generic_info = {
     .parent        = TYPE_SCSI_DEVICE,
     .instance_size = sizeof(SCSIDevice),
     .class_init    = scsi_generic_class_initfn,
+    .instance_init = scsi_dev_instance_init,
 };
 
 static void scsi_generic_register_types(void)
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index 2e3a8f9..99c1c57 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -270,4 +270,5 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int target, int lun);
 /* scsi-generic.c. */
 extern const SCSIReqOps scsi_generic_req_ops;
 
+void scsi_dev_instance_init(Object *obj);
 #endif
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (22 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 23/28] scsi: add bootindex to qom property arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05 18:39   ` Eduardo Habkost
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 25/28] virtio-blk: " arei.gonglei
                   ` (3 subsequent siblings)
  27 siblings, 1 reply; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/ide/qdev.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index efab95b..9e2ed40 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -191,6 +191,17 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
     return 0;
 }
 
+static void ide_dev_instance_init(Object *obj)
+{
+    DeviceState *dev = DEVICE(obj);
+    IDEDevice *d = DO_UPCAST(IDEDevice, qdev, dev);
+
+    device_add_bootindex_property(obj, &d->conf.bootindex,
+                                  "bootindex",
+                                  d->unit ? "/disk@1" : "/disk@0",
+                                  &d->qdev, NULL);
+}
+
 static int ide_hd_initfn(IDEDevice *dev)
 {
     return ide_dev_initfn(dev, IDE_HD);
@@ -238,6 +249,7 @@ static const TypeInfo ide_hd_info = {
     .parent        = TYPE_IDE_DEVICE,
     .instance_size = sizeof(IDEDrive),
     .class_init    = ide_hd_class_init,
+    .instance_init = ide_dev_instance_init,
 };
 
 static Property ide_cd_properties[] = {
@@ -260,6 +272,7 @@ static const TypeInfo ide_cd_info = {
     .parent        = TYPE_IDE_DEVICE,
     .instance_size = sizeof(IDEDrive),
     .class_init    = ide_cd_class_init,
+    .instance_init = ide_dev_instance_init,
 };
 
 static Property ide_drive_properties[] = {
@@ -282,6 +295,7 @@ static const TypeInfo ide_drive_info = {
     .parent        = TYPE_IDE_DEVICE,
     .instance_size = sizeof(IDEDrive),
     .class_init    = ide_drive_class_init,
+    .instance_init = ide_dev_instance_init,
 };
 
 static void ide_device_class_init(ObjectClass *klass, void *data)
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 25/28] virtio-blk: add bootindex to qom property
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (23 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 24/28] ide: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 26/28] block: remove bootindex property from qdev to qom arei.gonglei
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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 <arei.gonglei@huawei.com>
---
 hw/block/virtio-blk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index a7f2827..9d04590 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -805,6 +805,9 @@ static void virtio_blk_instance_init(Object *obj)
                              (Object **)&s->blk.iothread,
                              qdev_prop_allow_set_link_before_realize,
                              OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL);
+    device_add_bootindex_property(obj, &s->conf->bootindex,
+                                  "bootindex", "/disk@0,0",
+                                  DEVICE(obj), NULL);
 }
 
 static Property virtio_blk_properties[] = {
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 26/28] block: remove bootindex property from qdev to qom
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (24 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 25/28] virtio-blk: " arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 27/28] bootindex: move calling add_boot_device_patch to bootindex setter function arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 28/28] bootindex: delete bootindex when device is removed arei.gonglei
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Remove bootindex form qdev property to qom, things will
continue to work just fine, and we can use qom features
which are not supported by qdev property.

Meanwhile set the initial value of bootindex to -1.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/block/virtio-blk.c    | 1 +
 hw/ide/qdev.c            | 1 +
 hw/scsi/scsi-disk.c      | 2 +-
 hw/scsi/scsi-generic.c   | 1 -
 include/hw/block/block.h | 1 -
 5 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 9d04590..4d05114 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -808,6 +808,7 @@ static void virtio_blk_instance_init(Object *obj)
     device_add_bootindex_property(obj, &s->conf->bootindex,
                                   "bootindex", "/disk@0,0",
                                   DEVICE(obj), NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static Property virtio_blk_properties[] = {
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 9e2ed40..8382f24 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -200,6 +200,7 @@ static void ide_dev_instance_init(Object *obj)
                                   "bootindex",
                                   d->unit ? "/disk@1" : "/disk@0",
                                   &d->qdev, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static int ide_hd_initfn(IDEDevice *dev)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 205cdb0..c37a8be 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2339,6 +2339,7 @@ void scsi_dev_instance_init(Object *obj)
     device_add_bootindex_property(obj, &s->conf.bootindex,
                                   "bootindex", NULL,
                                   &s->qdev, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static const SCSIReqOps scsi_disk_emulate_reqops = {
@@ -2692,7 +2693,6 @@ static const TypeInfo scsi_cd_info = {
 #ifdef __linux__
 static Property scsi_block_properties[] = {
     DEFINE_PROP_DRIVE("drive", SCSIDiskState, qdev.conf.bs),
-    DEFINE_PROP_INT32("bootindex", SCSIDiskState, qdev.conf.bootindex, -1),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index f6100a9..a542d1a 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -482,7 +482,6 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun,
 
 static Property scsi_generic_properties[] = {
     DEFINE_PROP_DRIVE("drive", SCSIDevice, conf.bs),
-    DEFINE_PROP_INT32("bootindex", SCSIDevice, conf.bootindex, -1),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/include/hw/block/block.h b/include/hw/block/block.h
index 3a01488..867a226 100644
--- a/include/hw/block/block.h
+++ b/include/hw/block/block.h
@@ -49,7 +49,6 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
                           _conf.physical_block_size, 512),              \
     DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0),  \
     DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0),    \
-    DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1),        \
     DEFINE_PROP_UINT32("discard_granularity", _state, \
                        _conf.discard_granularity, -1)
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 27/28] bootindex: move calling add_boot_device_patch to bootindex setter function
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (25 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 26/28] block: remove bootindex property from qdev to qom arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 28/28] bootindex: delete bootindex when device is removed arei.gonglei
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

On this way, we can assure the new bootindex take effect
during vm rebooting.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 bootdevice.c             | 2 ++
 hw/block/fdc.c           | 3 ---
 hw/block/virtio-blk.c    | 2 --
 hw/i386/kvm/pci-assign.c | 2 --
 hw/ide/qdev.c            | 3 ---
 hw/misc/vfio.c           | 1 -
 hw/net/e1000.c           | 2 --
 hw/net/eepro100.c        | 2 --
 hw/net/ne2000.c          | 2 --
 hw/net/pcnet.c           | 2 --
 hw/net/rtl8139.c         | 2 --
 hw/net/spapr_llan.c      | 2 --
 hw/net/virtio-net.c      | 2 --
 hw/net/vmxnet3.c         | 2 --
 hw/scsi/scsi-disk.c      | 1 -
 hw/scsi/scsi-generic.c   | 3 ---
 hw/usb/dev-network.c     | 1 -
 hw/usb/host-libusb.c     | 1 -
 hw/usb/redirect.c        | 1 -
 19 files changed, 2 insertions(+), 34 deletions(-)

diff --git a/bootdevice.c b/bootdevice.c
index c669293..e95d085 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -241,6 +241,8 @@ static void device_set_bootindex(Object *obj, Visitor *v, void *opaque,
     /* change bootindex to a new one */
     *prop->bootindex = boot_index;
 
+    add_boot_device_path(*prop->bootindex, prop->dev, prop->suffix);
+
 out:
     if (local_err) {
         error_propagate(errp, local_err);
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 51b1f08..970b7c3 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2142,9 +2142,6 @@ static void isabus_fdc_realize(DeviceState *dev, Error **errp)
         error_propagate(errp, err);
         return;
     }
-
-    add_boot_device_path(isa->bootindexA, dev, "/floppy@0");
-    add_boot_device_path(isa->bootindexB, dev, "/floppy@1");
 }
 
 static void sysbus_fdc_initfn(Object *obj)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 4d05114..787955b 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -777,8 +777,6 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
     bdrv_set_guest_block_size(s->bs, s->conf->logical_block_size);
 
     bdrv_iostatus_enable(s->bs);
-
-    add_boot_device_path(s->conf->bootindex, dev, "/disk@0,0");
 }
 
 static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index 56f387b..4159978 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -1825,8 +1825,6 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
     assigned_dev_load_option_rom(dev);
 
-    add_boot_device_path(dev->bootindex, &pci_dev->qdev, NULL);
-
     return 0;
 
 assigned_out:
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 8382f24..daf6992 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -185,9 +185,6 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
         dev->serial = g_strdup(s->drive_serial_str);
     }
 
-    add_boot_device_path(dev->conf.bootindex, &dev->qdev,
-                         dev->unit ? "/disk@1" : "/disk@0");
-
     return 0;
 }
 
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index cdbaedf..d073304 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -4296,7 +4296,6 @@ static int vfio_initfn(PCIDevice *pdev)
         }
     }
 
-    add_boot_device_path(vdev->bootindex, &pdev->qdev, NULL);
     vfio_register_err_notifier(vdev);
 
     return 0;
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 2e5dc41..34dde84 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1569,8 +1569,6 @@ static int pci_e1000_init(PCIDevice *pci_dev)
 
     qemu_format_nic_info_str(qemu_get_queue(d->nic), macaddr);
 
-    add_boot_device_path(d->conf.bootindex, dev, "/ethernet-phy@0");
-
     d->autoneg_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, e1000_autoneg_timer, d);
     d->mit_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, e1000_mit_timer, d);
 
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index cc79f09..9acc8a3 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -1901,8 +1901,6 @@ static int e100_nic_init(PCIDevice *pci_dev)
     s->vmstate->name = qemu_get_queue(s->nic)->model;
     vmstate_register(&pci_dev->qdev, -1, s->vmstate, s);
 
-    add_boot_device_path(s->conf.bootindex, &pci_dev->qdev, "/ethernet-phy@0");
-
     return 0;
 }
 
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index 6d31555..b6d8cb1 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -738,8 +738,6 @@ static int pci_ne2000_init(PCIDevice *pci_dev)
                           object_get_typename(OBJECT(pci_dev)), pci_dev->qdev.id, s);
     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a);
 
-    add_boot_device_path(s->c.bootindex, &pci_dev->qdev, "/ethernet-phy@0");
-
     return 0;
 }
 
diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index 5299d52..d344c15 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -1735,8 +1735,6 @@ int pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInfo *info)
     s->nic = qemu_new_nic(info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s);
     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
 
-    add_boot_device_path(s->conf.bootindex, dev, "/ethernet-phy@0");
-
     /* Initialize the PROM */
 
     /*
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index d921ebd..5300fb8 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -3538,8 +3538,6 @@ static int pci_rtl8139_init(PCIDevice *dev)
     s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, rtl8139_timer, s);
     rtl8139_set_next_tctr_time(s, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
 
-    add_boot_device_path(s->conf.bootindex, d, "/ethernet-phy@0");
-
     return 0;
 }
 
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index c8b0978..052d00d 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -214,8 +214,6 @@ static int spapr_vlan_init(VIOsPAPRDevice *sdev)
                             object_get_typename(OBJECT(sdev)), sdev->qdev.id, dev);
     qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.macaddr.a);
 
-    add_boot_device_path(dev->nicconf.bootindex, DEVICE(dev), "");
-
     return 0;
 }
 
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 3e6d3fa..d529f1f 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1663,8 +1663,6 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
     n->qdev = dev;
     register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION,
                     virtio_net_save, virtio_net_load, n);
-
-    add_boot_device_path(n->nic_conf.bootindex, dev, "/ethernet-phy@0");
 }
 
 static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 56b22f3..a4e7e12 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2172,8 +2172,6 @@ static int vmxnet3_pci_init(PCIDevice *pci_dev)
     register_savevm(dev, "vmxnet3-msix", -1, 1,
                     vmxnet3_msix_save, vmxnet3_msix_load, s);
 
-    add_boot_device_path(s->conf.bootindex, dev, "/ethernet-phy@0");
-
     return 0;
 }
 
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index c37a8be..43e0220 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2285,7 +2285,6 @@ static void scsi_realize(SCSIDevice *dev, Error **errp)
     bdrv_set_guest_block_size(s->qdev.conf.bs, s->qdev.blocksize);
 
     bdrv_iostatus_enable(s->qdev.conf.bs);
-    add_boot_device_path(s->qdev.conf.bootindex, &dev->qdev, NULL);
 }
 
 static void scsi_hd_realize(SCSIDevice *dev, Error **errp)
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index a542d1a..fcd503c 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -431,9 +431,6 @@ static void scsi_generic_realize(SCSIDevice *s, Error **errp)
     /* define device state */
     s->type = scsiid.scsi_type;
     DPRINTF("device type %d\n", s->type);
-    if (s->type == TYPE_DISK || s->type == TYPE_ROM) {
-        add_boot_device_path(s->conf.bootindex, &s->qdev, NULL);
-    }
 
     switch (s->type) {
     case TYPE_TAPE:
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index f110ea7..5870478 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1372,7 +1372,6 @@ static int usb_net_initfn(USBDevice *dev)
              s->conf.macaddr.a[5]);
     usb_desc_set_string(dev, STRING_ETHADDR, s->usbstring_mac);
 
-    add_boot_device_path(s->conf.bootindex, &dev->qdev, "/ethernet@0");
     return 0;
 }
 
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index a2fa70e..50e3b21 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -975,7 +975,6 @@ static int usb_host_initfn(USBDevice *udev)
     qemu_add_exit_notifier(&s->exit);
 
     QTAILQ_INSERT_TAIL(&hostdevs, s, next);
-    add_boot_device_path(s->bootindex, &udev->qdev, NULL);
     usb_host_auto_check(NULL);
     return 0;
 }
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 352ba80..de93a59 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1397,7 +1397,6 @@ static int usbredir_initfn(USBDevice *udev)
                           usbredir_chardev_read, usbredir_chardev_event, dev);
 
     qemu_add_vm_change_state_handler(usbredir_vm_state_change, dev);
-    add_boot_device_path(dev->bootindex, &udev->qdev, NULL);
     return 0;
 }
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [Qemu-devel] [PATCH v7 28/28] bootindex: delete bootindex when device is removed
  2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
                   ` (26 preceding siblings ...)
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 27/28] bootindex: move calling add_boot_device_patch to bootindex setter function arei.gonglei
@ 2014-09-05  8:37 ` arei.gonglei
  27 siblings, 0 replies; 41+ messages in thread
From: arei.gonglei @ 2014-09-05  8:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: chenliang88, weidong.huang, mst, aik, hutao, armbru, kraxel,
	akong, agraf, Gonglei, aliguori, ehabkost, luonengjun,
	peter.huangpeng, hani, stefanha, pbonzini, lcapitulino, kwolf,
	peter.crosthwaite, imammedo, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Device should be removed from global boot list when
it is hot-unplugged.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 bootdevice.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bootdevice.c b/bootdevice.c
index e95d085..1255c06 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -254,6 +254,8 @@ static void property_release_bootindex(Object *obj, const char *name,
 
 {
     BootIndexProperty *prop = opaque;
+
+    del_boot_device_path(prop->dev);
     g_free(prop);
 }
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 18/28] host-libusb: remove bootindex property from qdev to qom
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 18/28] host-libusb: " arei.gonglei
@ 2014-09-05  9:06   ` Gerd Hoffmann
  2014-09-05  9:12     ` Gonglei (Arei)
  0 siblings, 1 reply; 41+ messages in thread
From: Gerd Hoffmann @ 2014-09-05  9:06 UTC (permalink / raw)
  To: arei.gonglei
  Cc: chenliang88, weidong.huang, mst, aik, hutao, qemu-devel, armbru,
	akong, agraf, aliguori, ehabkost, luonengjun, peter.huangpeng,
	hani, stefanha, pbonzini, lcapitulino, kwolf, peter.crosthwaite,
	imammedo, afaerber

> +static void usb_host_instance_init(Object *obj)
> +{
> +    USBDevice *udev = USB_DEVICE(obj);
> +    USBHostDevice *s = USB_HOST_DEVICE(udev);
> +
> +    device_add_bootindex_property(obj, &s->bootindex,
> +                                  "bootindex", NULL,
> +                                  &udev->qdev, NULL);
> +    object_property_set_int(obj, -1, "bootindex", NULL);

I think the object_property_set_int() call can be moved to
device_add_bootindex_property, so there is no need to duplicate the call
to init bootindex with -1 in all devices.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 18/28] host-libusb: remove bootindex property from qdev to qom
  2014-09-05  9:06   ` Gerd Hoffmann
@ 2014-09-05  9:12     ` Gonglei (Arei)
  0 siblings, 0 replies; 41+ messages in thread
From: Gonglei (Arei) @ 2014-09-05  9:12 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: chenliang (T), Huangweidong (C),
	mst, aik, hutao, qemu-devel, armbru, akong, agraf, aliguori,
	ehabkost, Luonengjun, Huangpeng (Peter),
	hani, stefanha, pbonzini, lcapitulino, kwolf, peter.crosthwaite,
	imammedo, afaerber

Hi,

> From: Gerd Hoffmann [mailto:kraxel@redhat.com]
> Sent: Friday, September 05, 2014 5:06 PM
> Subject: Re: [PATCH v7 18/28] host-libusb: remove bootindex property from
> qdev to qom
> 
> > +static void usb_host_instance_init(Object *obj)
> > +{
> > +    USBDevice *udev = USB_DEVICE(obj);
> > +    USBHostDevice *s = USB_HOST_DEVICE(udev);
> > +
> > +    device_add_bootindex_property(obj, &s->bootindex,
> > +                                  "bootindex", NULL,
> > +                                  &udev->qdev, NULL);
> > +    object_property_set_int(obj, -1, "bootindex", NULL);
> 
> I think the object_property_set_int() call can be moved to
> device_add_bootindex_property, so there is no need to duplicate the call
> to init bootindex with -1 in all devices.
> 
Good idea. Thanks! Will fix this.

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path function
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path function arei.gonglei
@ 2014-09-05 18:15   ` Eduardo Habkost
  2014-09-08 11:54     ` Gonglei
  0 siblings, 1 reply; 41+ messages in thread
From: Eduardo Habkost @ 2014-09-05 18:15 UTC (permalink / raw)
  To: arei.gonglei
  Cc: chenliang88, weidong.huang, mst, aik, hutao, qemu-devel, armbru,
	kraxel, akong, agraf, aliguori, luonengjun, peter.huangpeng,
	hani, stefanha, pbonzini, lcapitulino, kwolf, peter.crosthwaite,
	imammedo, afaerber

On Fri, Sep 05, 2014 at 04:37:13PM +0800, arei.gonglei@huawei.com wrote:
[...]
> +static void del_original_boot_device(DeviceState *dev, const char *suffix)
> +{
> +    FWBootEntry *i;
> +
> +    if (dev == NULL) {
> +        return;
> +    }
> +
> +    QTAILQ_FOREACH(i, &fw_boot_order, link) {
> +        if (suffix) {
> +            if (i->dev == dev && !strcmp(i->suffix, suffix)) {
> +                QTAILQ_REMOVE(&fw_boot_order, i, link);
> +                g_free(i->suffix);
> +                g_free(i);
> +
> +                break;
> +            }
> +        } else { /* host-usb and scsi devices do not have a suffix */
> +            if (i->dev == dev) {
> +                QTAILQ_REMOVE(&fw_boot_order, i, link);
> +                g_free(i);
> +
> +                break;
> +            }
> +        }

g_free() and g_strcmp0() accept NULL as arguments, so you can replace
those 16 lines with:

    if (i->dev == dev && !g_strcmp0(i->suffix, suffix))) {
        QTAILQ_REMOVE(&fw_boot_order, i, link);
        g_free(i->suffix);
        g_free(i);
        break;
    }

-- 
Eduardo

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 08/28] virtio-net: add bootindex to qom property
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 08/28] virtio-net: add bootindex to qom property arei.gonglei
@ 2014-09-05 18:28   ` Eduardo Habkost
  2014-09-08 12:07     ` Gonglei
  0 siblings, 1 reply; 41+ messages in thread
From: Eduardo Habkost @ 2014-09-05 18:28 UTC (permalink / raw)
  To: arei.gonglei
  Cc: chenliang88, weidong.huang, mst, aik, hutao, qemu-devel, armbru,
	kraxel, akong, agraf, aliguori, luonengjun, peter.huangpeng,
	hani, stefanha, pbonzini, lcapitulino, kwolf, peter.crosthwaite,
	imammedo, afaerber

On Fri, Sep 05, 2014 at 04:37:16PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> 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 <arei.gonglei@huawei.com>
> ---
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index 78dcd68..0779d28 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1454,9 +1454,14 @@ static void virtio_net_pci_class_init(ObjectClass *klass, void *data)
>  static void virtio_net_pci_instance_init(Object *obj)
>  {
>      VirtIONetPCI *dev = VIRTIO_NET_PCI(obj);
> -    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
> -    object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
> -    object_unref(OBJECT(&dev->vdev));
> +    VirtIONet *n = &dev->vdev;
> +
> +    object_initialize(n, sizeof(dev->vdev), TYPE_VIRTIO_NET);
> +    object_property_add_child(obj, "virtio-backend", OBJECT(n), NULL);
> +    object_unref(OBJECT(n));
> +    device_add_bootindex_property(obj, &n->nic_conf.bootindex,
> +                                  "bootindex", "/ethernet-phy@0",
> +                                  DEVICE(n), NULL);

Is anybody able to explain what would be the user-visible effects of
simply using dev as the parameter to device_add_bootindex_property() and
add_boot_device_path(), instead of dev->vdev? Don't they have exactly
the same fw dev path?

-- 
Eduardo

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom property
  2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 24/28] ide: " arei.gonglei
@ 2014-09-05 18:39   ` Eduardo Habkost
  2014-09-08 12:07     ` Gonglei
  0 siblings, 1 reply; 41+ messages in thread
From: Eduardo Habkost @ 2014-09-05 18:39 UTC (permalink / raw)
  To: arei.gonglei
  Cc: chenliang88, weidong.huang, mst, aik, hutao, qemu-devel, armbru,
	kraxel, akong, agraf, aliguori, luonengjun, peter.huangpeng,
	hani, stefanha, pbonzini, lcapitulino, kwolf, peter.crosthwaite,
	imammedo, afaerber

On Fri, Sep 05, 2014 at 04:37:32PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> 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 <arei.gonglei@huawei.com>
> ---
>  hw/ide/qdev.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
> index efab95b..9e2ed40 100644
> --- a/hw/ide/qdev.c
> +++ b/hw/ide/qdev.c
> @@ -191,6 +191,17 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
>      return 0;
>  }
>  
> +static void ide_dev_instance_init(Object *obj)
> +{
> +    DeviceState *dev = DEVICE(obj);
> +    IDEDevice *d = DO_UPCAST(IDEDevice, qdev, dev);
> +
> +    device_add_bootindex_property(obj, &d->conf.bootindex,
> +                                  "bootindex",
> +                                  d->unit ? "/disk@1" : "/disk@0",
> +                                  &d->qdev, NULL);
> +}
> +
>  static int ide_hd_initfn(IDEDevice *dev)
>  {
>      return ide_dev_initfn(dev, IDE_HD);
> @@ -238,6 +249,7 @@ static const TypeInfo ide_hd_info = {
>      .parent        = TYPE_IDE_DEVICE,
>      .instance_size = sizeof(IDEDrive),
>      .class_init    = ide_hd_class_init,
> +    .instance_init = ide_dev_instance_init,
>  };
>  
>  static Property ide_cd_properties[] = {
> @@ -260,6 +272,7 @@ static const TypeInfo ide_cd_info = {
>      .parent        = TYPE_IDE_DEVICE,
>      .instance_size = sizeof(IDEDrive),
>      .class_init    = ide_cd_class_init,
> +    .instance_init = ide_dev_instance_init,
>  };
>  
>  static Property ide_drive_properties[] = {
> @@ -282,6 +295,7 @@ static const TypeInfo ide_drive_info = {
>      .parent        = TYPE_IDE_DEVICE,
>      .instance_size = sizeof(IDEDrive),
>      .class_init    = ide_drive_class_init,
> +    .instance_init = ide_dev_instance_init,
>  };

If all TYPE_IDE_DEVICE subclasses have the same instance_init, why not
just set ide_device_type_info.instance_init = ide_dev_instance_init?

-- 
Eduardo

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path function
  2014-09-05 18:15   ` Eduardo Habkost
@ 2014-09-08 11:54     ` Gonglei
  0 siblings, 0 replies; 41+ messages in thread
From: Gonglei @ 2014-09-08 11:54 UTC (permalink / raw)
  To: 'Eduardo Habkost', arei.gonglei
  Cc: kwolf, chenliang88, peter.crosthwaite, weidong.huang, stefanha,
	mst, aik, hutao, luonengjun, qemu-devel, armbru, agraf, hani,
	kraxel, aliguori, imammedo, lcapitulino, pbonzini,
	peter.huangpeng, akong, afaerber

> Subject: Re: [Qemu-devel] [PATCH v7 05/28] bootindex: rework
> add_boot_device_path function
> 
> On Fri, Sep 05, 2014 at 04:37:13PM +0800, arei.gonglei@huawei.com wrote:
> [...]
> > +static void del_original_boot_device(DeviceState *dev, const char *suffix)
> > +{
> > +    FWBootEntry *i;
> > +
> > +    if (dev == NULL) {
> > +        return;
> > +    }
> > +
> > +    QTAILQ_FOREACH(i, &fw_boot_order, link) {
> > +        if (suffix) {
> > +            if (i->dev == dev && !strcmp(i->suffix, suffix)) {
> > +                QTAILQ_REMOVE(&fw_boot_order, i, link);
> > +                g_free(i->suffix);
> > +                g_free(i);
> > +
> > +                break;
> > +            }
> > +        } else { /* host-usb and scsi devices do not have a suffix */
> > +            if (i->dev == dev) {
> > +                QTAILQ_REMOVE(&fw_boot_order, i, link);
> > +                g_free(i);
> > +
> > +                break;
> > +            }
> > +        }
> 
> g_free() and g_strcmp0() accept NULL as arguments, so you can replace
> those 16 lines with:
> 
>     if (i->dev == dev && !g_strcmp0(i->suffix, suffix))) {
>         QTAILQ_REMOVE(&fw_boot_order, i, link);
>         g_free(i->suffix);
>         g_free(i);
>         break;
>     }
> 
OK. Thanks for your point!

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom property
  2014-09-05 18:39   ` Eduardo Habkost
@ 2014-09-08 12:07     ` Gonglei
  2014-09-09  7:51       ` Gonglei (Arei)
  0 siblings, 1 reply; 41+ messages in thread
From: Gonglei @ 2014-09-08 12:07 UTC (permalink / raw)
  To: 'Eduardo Habkost', arei.gonglei
  Cc: kwolf, chenliang88, peter.crosthwaite, weidong.huang, stefanha,
	mst, aik, hutao, luonengjun, qemu-devel, armbru, agraf, hani,
	kraxel, aliguori, imammedo, lcapitulino, pbonzini,
	peter.huangpeng, akong, afaerber

> Subject: Re: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom property
> 
> On Fri, Sep 05, 2014 at 04:37:32PM +0800, arei.gonglei@huawei.com wrote:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > 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 <arei.gonglei@huawei.com>
> > ---
> >  hw/ide/qdev.c | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> >
> > diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
> > index efab95b..9e2ed40 100644
> > --- a/hw/ide/qdev.c
> > +++ b/hw/ide/qdev.c
> > @@ -191,6 +191,17 @@ static int ide_dev_initfn(IDEDevice *dev,
> IDEDriveKind kind)
> >      return 0;
> >  }
> >
> > +static void ide_dev_instance_init(Object *obj)
> > +{
> > +    DeviceState *dev = DEVICE(obj);
> > +    IDEDevice *d = DO_UPCAST(IDEDevice, qdev, dev);
> > +
> > +    device_add_bootindex_property(obj, &d->conf.bootindex,
> > +                                  "bootindex",
> > +                                  d->unit ? "/disk@1" : "/disk@0",
> > +                                  &d->qdev, NULL);
> > +}
> > +
> >  static int ide_hd_initfn(IDEDevice *dev)
> >  {
> >      return ide_dev_initfn(dev, IDE_HD);
> > @@ -238,6 +249,7 @@ static const TypeInfo ide_hd_info = {
> >      .parent        = TYPE_IDE_DEVICE,
> >      .instance_size = sizeof(IDEDrive),
> >      .class_init    = ide_hd_class_init,
> > +    .instance_init = ide_dev_instance_init,
> >  };
> >
> >  static Property ide_cd_properties[] = {
> > @@ -260,6 +272,7 @@ static const TypeInfo ide_cd_info = {
> >      .parent        = TYPE_IDE_DEVICE,
> >      .instance_size = sizeof(IDEDrive),
> >      .class_init    = ide_cd_class_init,
> > +    .instance_init = ide_dev_instance_init,
> >  };
> >
> >  static Property ide_drive_properties[] = {
> > @@ -282,6 +295,7 @@ static const TypeInfo ide_drive_info = {
> >      .parent        = TYPE_IDE_DEVICE,
> >      .instance_size = sizeof(IDEDrive),
> >      .class_init    = ide_drive_class_init,
> > +    .instance_init = ide_dev_instance_init,
> >  };
> 
> If all TYPE_IDE_DEVICE subclasses have the same instance_init, why not
> just set ide_device_type_info.instance_init = ide_dev_instance_init?
> 
OK. TBH I have not noticed this way, sorry. 

Great thanks for your help and reviewing, Eduardo. :)

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 08/28] virtio-net: add bootindex to qom property
  2014-09-05 18:28   ` Eduardo Habkost
@ 2014-09-08 12:07     ` Gonglei
  2014-09-09  8:03       ` Gonglei (Arei)
  0 siblings, 1 reply; 41+ messages in thread
From: Gonglei @ 2014-09-08 12:07 UTC (permalink / raw)
  To: 'Eduardo Habkost', arei.gonglei
  Cc: kwolf, chenliang88, peter.crosthwaite, weidong.huang, stefanha,
	mst, aik, hutao, luonengjun, qemu-devel, armbru, agraf, hani,
	kraxel, aliguori, imammedo, lcapitulino, pbonzini,
	peter.huangpeng, akong, afaerber

> Subject: Re: [Qemu-devel] [PATCH v7 08/28] virtio-net: add bootindex to qom
> property
> 
> On Fri, Sep 05, 2014 at 04:37:16PM +0800, arei.gonglei@huawei.com wrote:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > 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 <arei.gonglei@huawei.com>
> > ---
> > diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> > index 78dcd68..0779d28 100644
> > --- a/hw/virtio/virtio-pci.c
> > +++ b/hw/virtio/virtio-pci.c
> > @@ -1454,9 +1454,14 @@ static void virtio_net_pci_class_init(ObjectClass
> *klass, void *data)
> >  static void virtio_net_pci_instance_init(Object *obj)
> >  {
> >      VirtIONetPCI *dev = VIRTIO_NET_PCI(obj);
> > -    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
> > -    object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev),
> NULL);
> > -    object_unref(OBJECT(&dev->vdev));
> > +    VirtIONet *n = &dev->vdev;
> > +
> > +    object_initialize(n, sizeof(dev->vdev), TYPE_VIRTIO_NET);
> > +    object_property_add_child(obj, "virtio-backend", OBJECT(n), NULL);
> > +    object_unref(OBJECT(n));
> > +    device_add_bootindex_property(obj, &n->nic_conf.bootindex,
> > +                                  "bootindex", "/ethernet-phy@0",
> > +                                  DEVICE(n), NULL);
> 
> Is anybody able to explain what would be the user-visible effects of
> simply using dev as the parameter to device_add_bootindex_property() and
> add_boot_device_path(), instead of dev->vdev? 

AFAICT, using dev instead of dev->vdev will cause that one virtio-net device
have two bootindex entries in the global fw_boot_order list. 

> Don't they have exactly the same fw dev path?
> 
No, they have the same fw dev path.

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom property
  2014-09-08 12:07     ` Gonglei
@ 2014-09-09  7:51       ` Gonglei (Arei)
  2014-09-09 16:18         ` Eduardo Habkost
  0 siblings, 1 reply; 41+ messages in thread
From: Gonglei (Arei) @ 2014-09-09  7:51 UTC (permalink / raw)
  To: Gonglei, 'Eduardo Habkost'
  Cc: kwolf, chenliang (T), peter.crosthwaite, Huangweidong (C),
	stefanha, mst, aik, hutao, Luonengjun, qemu-devel, armbru, agraf,
	hani, kraxel, aliguori, imammedo, lcapitulino, pbonzini,
	Huangpeng (Peter),
	akong, afaerber

Hi,

> Subject: RE: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom property
> 
> > Subject: Re: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom
> property
> >
> > On Fri, Sep 05, 2014 at 04:37:32PM +0800, arei.gonglei@huawei.com wrote:
> > > From: Gonglei <arei.gonglei@huawei.com>
> > >
> > > 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 <arei.gonglei@huawei.com>
> > > ---
> > >  hw/ide/qdev.c | 14 ++++++++++++++
> > >  1 file changed, 14 insertions(+)
> > >
> > > diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
> > > index efab95b..9e2ed40 100644
> > > --- a/hw/ide/qdev.c
> > > +++ b/hw/ide/qdev.c
> > > @@ -191,6 +191,17 @@ static int ide_dev_initfn(IDEDevice *dev,
> > IDEDriveKind kind)
> > >      return 0;
> > >  }
> > >
> > > +static void ide_dev_instance_init(Object *obj)
> > > +{
> > > +    DeviceState *dev = DEVICE(obj);
> > > +    IDEDevice *d = DO_UPCAST(IDEDevice, qdev, dev);
> > > +
> > > +    device_add_bootindex_property(obj, &d->conf.bootindex,
> > > +                                  "bootindex",
> > > +                                  d->unit ? "/disk@1" :
> "/disk@0",
> > > +                                  &d->qdev, NULL);
> > > +}
> > > +
Oops, I found a thorny issue that the d->unit parameter had not been initialized
in ide_dev_instance_init(). d->unit maybe is a random value, which will against
the original purpose in this situation. 

What's your opinion, Eduardo? Thanks!

Best regards,
-Gonglei


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 08/28] virtio-net: add bootindex to qom property
  2014-09-08 12:07     ` Gonglei
@ 2014-09-09  8:03       ` Gonglei (Arei)
  0 siblings, 0 replies; 41+ messages in thread
From: Gonglei (Arei) @ 2014-09-09  8:03 UTC (permalink / raw)
  To: Gonglei, 'Eduardo Habkost'
  Cc: kwolf, chenliang (T), peter.crosthwaite, Huangweidong (C),
	stefanha, mst, aik, hutao, Luonengjun, qemu-devel, armbru, agraf,
	hani, kraxel, aliguori, imammedo, lcapitulino, pbonzini,
	Huangpeng (Peter),
	akong, afaerber

Hi,

> > Subject: Re: [Qemu-devel] [PATCH v7 08/28] virtio-net: add bootindex to qom
> > property
> >
> > On Fri, Sep 05, 2014 at 04:37:16PM +0800, arei.gonglei@huawei.com wrote:
> > > From: Gonglei <arei.gonglei@huawei.com>
> > >
> > > 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 <arei.gonglei@huawei.com>
> > > ---
> > > diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> > > index 78dcd68..0779d28 100644
> > > --- a/hw/virtio/virtio-pci.c
> > > +++ b/hw/virtio/virtio-pci.c
> > > @@ -1454,9 +1454,14 @@ static void
> virtio_net_pci_class_init(ObjectClass
> > *klass, void *data)
> > >  static void virtio_net_pci_instance_init(Object *obj)
> > >  {
> > >      VirtIONetPCI *dev = VIRTIO_NET_PCI(obj);
> > > -    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
> > > -    object_property_add_child(obj, "virtio-backend",
> OBJECT(&dev->vdev),
> > NULL);
> > > -    object_unref(OBJECT(&dev->vdev));
> > > +    VirtIONet *n = &dev->vdev;
> > > +
> > > +    object_initialize(n, sizeof(dev->vdev), TYPE_VIRTIO_NET);
> > > +    object_property_add_child(obj, "virtio-backend", OBJECT(n), NULL);
> > > +    object_unref(OBJECT(n));
> > > +    device_add_bootindex_property(obj, &n->nic_conf.bootindex,
> > > +                                  "bootindex",
> "/ethernet-phy@0",
> > > +                                  DEVICE(n), NULL);
> >
> > Is anybody able to explain what would be the user-visible effects of
> > simply using dev as the parameter to device_add_bootindex_property() and
> > add_boot_device_path(), instead of dev->vdev?
> 
> AFAICT, using dev instead of dev->vdev will cause that one virtio-net device
> have two bootindex entries in the global fw_boot_order list.
> 
> > Don't they have exactly the same fw dev path?
> >
> No, they have the same fw dev path.
> 
After my patch series:
 [PATCH v2 0/9] virtio: fix virtio child recount in transports

This would not be a question in my next version, I will drop it. :)

Best regards,
-Gonglei


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom property
  2014-09-09  7:51       ` Gonglei (Arei)
@ 2014-09-09 16:18         ` Eduardo Habkost
  2014-09-10  1:21           ` Gonglei (Arei)
  0 siblings, 1 reply; 41+ messages in thread
From: Eduardo Habkost @ 2014-09-09 16:18 UTC (permalink / raw)
  To: Gonglei (Arei)
  Cc: chenliang (T), Huangweidong (C),
	mst, aik, hutao, qemu-devel, agraf, kraxel, akong, Gonglei,
	armbru, aliguori, Luonengjun, Huangpeng (Peter),
	hani, stefanha, pbonzini, lcapitulino, kwolf, peter.crosthwaite,
	imammedo, afaerber

On Tue, Sep 09, 2014 at 07:51:49AM +0000, Gonglei (Arei) wrote:
> Hi,
> 
> > Subject: RE: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom property
> > 
> > > Subject: Re: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom
> > property
> > >
> > > On Fri, Sep 05, 2014 at 04:37:32PM +0800, arei.gonglei@huawei.com wrote:
> > > > From: Gonglei <arei.gonglei@huawei.com>
> > > >
> > > > 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 <arei.gonglei@huawei.com>
> > > > ---
> > > >  hw/ide/qdev.c | 14 ++++++++++++++
> > > >  1 file changed, 14 insertions(+)
> > > >
> > > > diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
> > > > index efab95b..9e2ed40 100644
> > > > --- a/hw/ide/qdev.c
> > > > +++ b/hw/ide/qdev.c
> > > > @@ -191,6 +191,17 @@ static int ide_dev_initfn(IDEDevice *dev,
> > > IDEDriveKind kind)
> > > >      return 0;
> > > >  }
> > > >
> > > > +static void ide_dev_instance_init(Object *obj)
> > > > +{
> > > > +    DeviceState *dev = DEVICE(obj);
> > > > +    IDEDevice *d = DO_UPCAST(IDEDevice, qdev, dev);
> > > > +
> > > > +    device_add_bootindex_property(obj, &d->conf.bootindex,
> > > > +                                  "bootindex",
> > > > +                                  d->unit ? "/disk@1" :
> > "/disk@0",
> > > > +                                  &d->qdev, NULL);
> > > > +}
> > > > +
> Oops, I found a thorny issue that the d->unit parameter had not been initialized
> in ide_dev_instance_init(). d->unit maybe is a random value, which will against
> the original purpose in this situation. 
> 
> What's your opinion, Eduardo? Thanks!

It looks like you can call add_boot_device_path() only on realize, on
IDE. If IDE is the only case, we could just change IDE to not use
device_add_bootindex_property(), having its own getter/setter and a call
to add_boot_device_path() on realize().

Or, to keep the code generic, we could just make get_boot_devices_list()
query the device for the suffix, instead of requiring the suffix to be
set before device_add_bootindex_property() is called. With something
like:

typedef struct BootDeviceInfo {
    int bootindex;
    const char *suffix;
} BootDeviceInfo;

struct FWBootEntry {
    QTAILQ_ENTRY(FWBootEntry) link;
    DeviceState *dev;
    BootDeviceInfo *bootdev;
};

void add_boot_device_path(DeviceState *dev, BootDeviceInfo *info);
void del_boot_device_path(BootDeviceInfo *info);
void device_add_bootindex_property(Object *obj, const char *property,
                                   DeviceState *dev, BootDeviceInfo *info,
                                   Error **errp);

This way, the suffix can be set between device_add_bootindex_property()
and get_boot_devices_list() if necessary:

static void somedevice_instance_init(Object *obj)
{
    SomeDevice *somedev = SOME_DEVICE(obj);
    device_add_bootindex_property(obj, DEVICE(obj), &somedev->bootinfo, &error_abort);
}

static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
{
    [...]
    dev->bootinfo.suffix = dev->unit ? "/disk@1" : "/disk@0";
}

-- 
Eduardo

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom property
  2014-09-09 16:18         ` Eduardo Habkost
@ 2014-09-10  1:21           ` Gonglei (Arei)
  0 siblings, 0 replies; 41+ messages in thread
From: Gonglei (Arei) @ 2014-09-10  1:21 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: chenliang (T), Huangweidong (C),
	mst, aik, hutao, qemu-devel, agraf, kraxel, akong, Gonglei,
	armbru, aliguori, Luonengjun, Huangpeng (Peter),
	hani, stefanha, pbonzini, lcapitulino, kwolf, peter.crosthwaite,
	imammedo, afaerber

Hi,

> From: Eduardo Habkost [mailto:ehabkost@redhat.com]
> > > > Subject: Re: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom
> > > property
> > > >
> > > > On Fri, Sep 05, 2014 at 04:37:32PM +0800, arei.gonglei@huawei.com
> wrote:
> > > > > From: Gonglei <arei.gonglei@huawei.com>
> > > > >
> > > > > 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 <arei.gonglei@huawei.com>
> > > > > ---
> > > > >  hw/ide/qdev.c | 14 ++++++++++++++
> > > > >  1 file changed, 14 insertions(+)
> > > > >
> > > > > diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
> > > > > index efab95b..9e2ed40 100644
> > > > > --- a/hw/ide/qdev.c
> > > > > +++ b/hw/ide/qdev.c
> > > > > @@ -191,6 +191,17 @@ static int ide_dev_initfn(IDEDevice *dev,
> > > > IDEDriveKind kind)
> > > > >      return 0;
> > > > >  }
> > > > >
> > > > > +static void ide_dev_instance_init(Object *obj)
> > > > > +{
> > > > > +    DeviceState *dev = DEVICE(obj);
> > > > > +    IDEDevice *d = DO_UPCAST(IDEDevice, qdev, dev);
> > > > > +
> > > > > +    device_add_bootindex_property(obj, &d->conf.bootindex,
> > > > > +                                  "bootindex",
> > > > > +                                  d->unit ? "/disk@1" :
> > > "/disk@0",
> > > > > +                                  &d->qdev, NULL);
> > > > > +}
> > > > > +
> > Oops, I found a thorny issue that the d->unit parameter had not been
> initialized
> > in ide_dev_instance_init(). d->unit maybe is a random value, which will
> against
> > the original purpose in this situation.
> >
> > What's your opinion, Eduardo? Thanks!
> 
> It looks like you can call add_boot_device_path() only on realize, on
> IDE. If IDE is the only case, we could just change IDE to not use
> device_add_bootindex_property(), having its own getter/setter and a call
> to add_boot_device_path() on realize().
> 
> Or, to keep the code generic, we could just make get_boot_devices_list()
> query the device for the suffix, instead of requiring the suffix to be
> set before device_add_bootindex_property() is called. With something
> like:
> 
> typedef struct BootDeviceInfo {
>     int bootindex;
>     const char *suffix;
> } BootDeviceInfo;
> 
> struct FWBootEntry {
>     QTAILQ_ENTRY(FWBootEntry) link;
>     DeviceState *dev;
>     BootDeviceInfo *bootdev;
> };
> 
> void add_boot_device_path(DeviceState *dev, BootDeviceInfo *info);
> void del_boot_device_path(BootDeviceInfo *info);
> void device_add_bootindex_property(Object *obj, const char *property,
>                                    DeviceState *dev, BootDeviceInfo
> *info,
>                                    Error **errp);
> 
> This way, the suffix can be set between device_add_bootindex_property()
> and get_boot_devices_list() if necessary:
> 
> static void somedevice_instance_init(Object *obj)
> {
>     SomeDevice *somedev = SOME_DEVICE(obj);
>     device_add_bootindex_property(obj, DEVICE(obj), &somedev->bootinfo,
> &error_abort);
> }
> 
> static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
> {
>     [...]
>     dev->bootinfo.suffix = dev->unit ? "/disk@1" : "/disk@0";
> }
> 
Thank you so much!

I agree more with #1, because only IDE device has this special case.
This is not worth add a property to DeviceState struct for a special
device IMO. 

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2014-09-10  1:27 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-05  8:37 [Qemu-devel] [PATCH v7 00/28] modify boot order of guest, and take effect after rebooting arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 01/28] bootdevice: move bootdevice related code to new file bootdevice.c arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 02/28] bootindex: add check bootindex function arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 03/28] bootindex: add del_boot_device_path function arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 04/28] fw_cfg: add fw_cfg_machine_reset function arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 05/28] bootindex: rework add_boot_device_path function arei.gonglei
2014-09-05 18:15   ` Eduardo Habkost
2014-09-08 11:54     ` Gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 06/28] bootindex: support to set a existent device's bootindex to -1 arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 07/28] bootindex: add a setter/getter functions wrapper for bootindex property arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 08/28] virtio-net: add bootindex to qom property arei.gonglei
2014-09-05 18:28   ` Eduardo Habkost
2014-09-08 12:07     ` Gonglei
2014-09-09  8:03       ` Gonglei (Arei)
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 09/28] e1000: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 10/28] eepro100: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 11/28] ne2000: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 12/28] pcnet: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 13/28] rtl8139: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 14/28] spapr_lian: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 15/28] vmxnet3: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 16/28] usb-net: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 17/28] net: remove bootindex property from qdev to qom arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 18/28] host-libusb: " arei.gonglei
2014-09-05  9:06   ` Gerd Hoffmann
2014-09-05  9:12     ` Gonglei (Arei)
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 19/28] pci-assign: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 20/28] vfio: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 21/28] redirect: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 22/28] isa-fdc: remove bootindexA/B " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 23/28] scsi: add bootindex to qom property arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 24/28] ide: " arei.gonglei
2014-09-05 18:39   ` Eduardo Habkost
2014-09-08 12:07     ` Gonglei
2014-09-09  7:51       ` Gonglei (Arei)
2014-09-09 16:18         ` Eduardo Habkost
2014-09-10  1:21           ` Gonglei (Arei)
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 25/28] virtio-blk: " arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 26/28] block: remove bootindex property from qdev to qom arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 27/28] bootindex: move calling add_boot_device_patch to bootindex setter function arei.gonglei
2014-09-05  8:37 ` [Qemu-devel] [PATCH v7 28/28] bootindex: delete bootindex when device is removed arei.gonglei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.