qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor
@ 2014-10-15  9:05 Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 01/34] bootdevice: move bootdevice related code to new file bootdevice.c Gerd Hoffmann
                   ` (34 more replies)
  0 siblings, 35 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

It's finally sorted, here comes the pull request for the bootindex patch
series which turns bootindex into a writable qom property and thereby
allows changing the bootorder at runtime via monitor.

please pull,
  Gerd

The following changes since commit b1d28ec6a7dbdaadda39d29322f0de694aeb0b74:

  Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20141010' into staging (2014-10-10 14:55:29 +0100)

are available in the git repository at:


  git://git.kraxel.org/qemu tags/pull-bootindex-20141015-1

for you to fetch changes up to 54086fe5d2c562a3173126d9991bd064faf1e884:

  bootindex: change fprintf to error_report (2014-10-15 10:46:01 +0200)

----------------------------------------------------------------
allow changing bootorder via monitor at runtime,
by making bootindex a writable qom property.

----------------------------------------------------------------
Gonglei (34):
      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
      virtio-net: alias bootindex property explicitly for virt-net-pci/ccw/s390
      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
      virtio-blk: alias bootindex property explicitly for virt-blk-pci/ccw/s390
      usb-storage: add bootindex to qom property
      nvma: ide: add bootindex to qom property
      ide: add calling add_boot_device_patch in bootindex setter function
      bootindex: move calling add_boot_device_patch to bootindex setter function
      bootindex: delete bootindex when device is removed
      bootindex: change fprintf to error_report

 Makefile.target            |   2 +-
 bootdevice.c               | 258 +++++++++++++++++++++++++++++++++++++++++++++
 hw/block/fdc.c             |  18 +++-
 hw/block/nvme.c            |  44 ++++++++
 hw/block/virtio-blk.c      |   5 +-
 hw/i386/kvm/pci-assign.c   |  14 ++-
 hw/ide/qdev.c              |  47 +++++++++
 hw/misc/vfio.c             |  13 ++-
 hw/net/e1000.c             |  12 ++-
 hw/net/eepro100.c          |  13 ++-
 hw/net/lance.c             |  12 +++
 hw/net/ne2000-isa.c        |  44 ++++++++
 hw/net/ne2000.c            |  14 ++-
 hw/net/pcnet-pci.c         |  12 +++
 hw/net/pcnet.c             |   2 -
 hw/net/pcnet.h             |   1 -
 hw/net/rtl8139.c           |  12 ++-
 hw/net/spapr_llan.c        |  12 ++-
 hw/net/virtio-net.c        |   5 +-
 hw/net/vmxnet3.c           |  10 +-
 hw/nvram/fw_cfg.c          |  55 +++++++++-
 hw/s390x/s390-virtio-bus.c |   4 +
 hw/s390x/virtio-ccw.c      |   4 +
 hw/scsi/scsi-bus.c         |  14 ++-
 hw/scsi/scsi-disk.c        |   2 -
 hw/scsi/scsi-generic.c     |   4 -
 hw/usb/dev-network.c       |  11 +-
 hw/usb/dev-storage.c       |  52 +++++++++
 hw/usb/host-libusb.c       |  13 ++-
 hw/usb/redirect.c          |  13 ++-
 hw/virtio/virtio-pci.c     |   4 +
 include/hw/block/block.h   |   1 -
 include/hw/nvram/fw_cfg.h  |   2 +
 include/net/net.h          |   3 +-
 include/sysemu/sysemu.h    |   6 ++
 vl.c                       | 118 +--------------------
 36 files changed, 690 insertions(+), 166 deletions(-)
 create mode 100644 bootdevice.c

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

* [Qemu-devel] [PULL 01/34] bootdevice: move bootdevice related code to new file bootdevice.c
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 02/34] bootindex: add check bootindex function Gerd Hoffmann
                   ` (33 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann, Anthony Liguori

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

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.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 964d634..aee73e1 100644
--- a/vl.c
+++ b/vl.c
@@ -180,23 +180,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;
@@ -1246,111 +1235,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.8.3.1

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

* [Qemu-devel] [PULL 02/34] bootindex: add check bootindex function
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 01/34] bootdevice: move bootdevice related code to new file bootdevice.c Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 03/34] bootindex: add del_boot_device_path function Gerd Hoffmann
                   ` (32 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.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.8.3.1

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

* [Qemu-devel] [PULL 03/34] bootindex: add del_boot_device_path function
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 01/34] bootdevice: move bootdevice related code to new file bootdevice.c Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 02/34] bootindex: add check bootindex function Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-16 10:04   ` Peter Maydell
  2014-10-15  9:05 ` [Qemu-devel] [PULL 04/34] fw_cfg: add fw_cfg_machine_reset function Gerd Hoffmann
                   ` (31 subsequent siblings)
  34 siblings, 1 reply; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Chenliang, Gonglei, Gerd Hoffmann

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 or update a
existent devcie's bootindex.

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

diff --git a/bootdevice.c b/bootdevice.c
index f5399df..7167fbc 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -51,6 +51,26 @@ void check_boot_index(int32_t bootindex, Error **errp)
     }
 }
 
+void del_boot_device_path(DeviceState *dev, const char *suffix)
+{
+    FWBootEntry *i;
+
+    if (dev == NULL) {
+        return;
+    }
+
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        if ((!suffix || !g_strcmp0(i->suffix, suffix)) &&
+             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..b3489be 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, const char *suffix);
 
 QemuOpts *qemu_get_machine_opts(void);
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 04/34] fw_cfg: add fw_cfg_machine_reset function
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 03/34] bootindex: add del_boot_device_path function Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 05/34] bootindex: rework add_boot_device_path function Gerd Hoffmann
                   ` (30 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Chenliang, Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.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.8.3.1

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

* [Qemu-devel] [PULL 05/34] bootindex: rework add_boot_device_path function
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 04/34] fw_cfg: add fw_cfg_machine_reset function Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 06/34] bootindex: support to set a existent device's bootindex to -1 Gerd Hoffmann
                   ` (29 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 bootdevice.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bootdevice.c b/bootdevice.c
index 7167fbc..aac0ffb 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -82,6 +82,8 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
 
     assert(dev != NULL || suffix != NULL);
 
+    del_boot_device_path(dev, suffix);
+
     node = g_malloc0(sizeof(FWBootEntry));
     node->bootindex = bootindex;
     node->suffix = g_strdup(suffix);
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 06/34] bootindex: support to set a existent device's bootindex to -1
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 05/34] bootindex: rework add_boot_device_path function Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 07/34] bootindex: add a setter/getter functions wrapper for bootindex property Gerd Hoffmann
                   ` (28 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 bootdevice.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bootdevice.c b/bootdevice.c
index aac0ffb..a38479a 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -77,6 +77,7 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
     FWBootEntry *node, *i;
 
     if (bootindex < 0) {
+        del_boot_device_path(dev, suffix);
         return;
     }
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 07/34] bootindex: add a setter/getter functions wrapper for bootindex property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 06/34] bootindex: support to set a existent device's bootindex to -1 Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 08/34] virtio-net: add bootindex to qom property Gerd Hoffmann
                   ` (27 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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. Meanwhile set the initial value of
bootindex to -1.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 bootdevice.c            | 73 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/sysemu/sysemu.h |  3 ++
 2 files changed, 76 insertions(+)

diff --git a/bootdevice.c b/bootdevice.c
index a38479a..69cffd8 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -23,6 +23,7 @@
  */
 
 #include "sysemu/sysemu.h"
+#include "qapi/visitor.h"
 
 typedef struct FWBootEntry FWBootEntry;
 
@@ -178,3 +179,75 @@ 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, "int32",
+                        device_get_bootindex,
+                        device_set_bootindex,
+                        property_release_bootindex,
+                        prop, &local_err);
+
+    if (local_err) {
+        error_propagate(errp, local_err);
+        g_free(prop);
+        return;
+    }
+    /* initialize devices' bootindex property to -1 */
+    object_property_set_int(obj, -1, name, NULL);
+}
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index b3489be..0037a69 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, const char *suffix);
+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.8.3.1

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

* [Qemu-devel] [PULL 08/34] virtio-net: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (6 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 07/34] bootindex: add a setter/getter functions wrapper for bootindex property Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 09/34] e1000: " Gerd Hoffmann
                   ` (26 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann, Anthony Liguori, Michael S. Tsirkin

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/net/virtio-net.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 2040eac..f5ead97 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1714,6 +1714,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[] = {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 09/34] e1000: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (7 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 08/34] virtio-net: add bootindex to qom property Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 10/34] eepro100: " Gerd Hoffmann
                   ` (25 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.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.8.3.1

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

* [Qemu-devel] [PULL 10/34] eepro100: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (8 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 09/34] e1000: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 11/34] ne2000: " Gerd Hoffmann
                   ` (24 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.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.8.3.1

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

* [Qemu-devel] [PULL 11/34] ne2000: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (9 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 10/34] eepro100: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 12/34] pcnet: " Gerd Hoffmann
                   ` (23 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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.

At present, isa_ne2000 device does not support to boot
os, so we register two seprate qom getter/setter functions.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/net/ne2000-isa.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 hw/net/ne2000.c     | 12 ++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c
index 6eb1dac..82e2ba1 100644
--- a/hw/net/ne2000-isa.c
+++ b/hw/net/ne2000-isa.c
@@ -28,6 +28,7 @@
 #include "net/net.h"
 #include "ne2000.h"
 #include "exec/address-spaces.h"
+#include "qapi/visitor.h"
 
 #define TYPE_ISA_NE2000 "ne2k_isa"
 #define ISA_NE2000(obj) OBJECT_CHECK(ISANE2000State, (obj), TYPE_ISA_NE2000)
@@ -101,11 +102,54 @@ static void isa_ne2000_class_initfn(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 }
 
+static void isa_ne2000_get_bootindex(Object *obj, Visitor *v, void *opaque,
+                                     const char *name, Error **errp)
+{
+    ISANE2000State *isa = ISA_NE2000(obj);
+    NE2000State *s = &isa->ne2000;
+
+    visit_type_int32(v, &s->c.bootindex, name, errp);
+}
+
+static void isa_ne2000_set_bootindex(Object *obj, Visitor *v, void *opaque,
+                                     const char *name, Error **errp)
+{
+    ISANE2000State *isa = ISA_NE2000(obj);
+    NE2000State *s = &isa->ne2000;
+    int32_t boot_index;
+    Error *local_err = NULL;
+
+    visit_type_int32(v, &boot_index, name, &local_err);
+    if (local_err) {
+        goto out;
+    }
+    /* check whether bootindex is present in fw_boot_order list  */
+    check_boot_index(boot_index, &local_err);
+    if (local_err) {
+        goto out;
+    }
+    /* change bootindex to a new one */
+    s->c.bootindex = boot_index;
+
+out:
+    if (local_err) {
+        error_propagate(errp, local_err);
+    }
+}
+
+static void isa_ne2000_instance_init(Object *obj)
+{
+    object_property_add(obj, "bootindex", "int32",
+                        isa_ne2000_get_bootindex,
+                        isa_ne2000_set_bootindex, NULL, NULL, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
+}
 static const TypeInfo ne2000_isa_info = {
     .name          = TYPE_ISA_NE2000,
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof(ISANE2000State),
     .class_init    = isa_ne2000_class_initfn,
+    .instance_init = isa_ne2000_instance_init,
 };
 
 static void ne2000_isa_register_types(void)
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.8.3.1

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

* [Qemu-devel] [PULL 12/34] pcnet: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (10 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 11/34] ne2000: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 13/34] rtl8139: " Gerd Hoffmann
                   ` (22 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.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.8.3.1

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

* [Qemu-devel] [PULL 13/34] rtl8139: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (11 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 12/34] pcnet: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 14/34] spapr_lian: " Gerd Hoffmann
                   ` (21 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.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.8.3.1

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

* [Qemu-devel] [PULL 14/34] spapr_lian: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (12 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 13/34] rtl8139: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 15/34] vmxnet3: " Gerd Hoffmann
                   ` (20 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, open list:sPAPR, Gerd Hoffmann, Alexander Graf

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/net/spapr_llan.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index 23c47d3..0ff159b 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -226,6 +226,15 @@ static int spapr_vlan_init(VIOsPAPRDevice *sdev)
     return 0;
 }
 
+static void spapr_vlan_instance_init(Object *obj)
+{
+    VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(obj);
+
+    device_add_bootindex_property(obj, &dev->nicconf.bootindex,
+                                  "bootindex", "",
+                                  DEVICE(dev), NULL);
+}
+
 void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd)
 {
     DeviceState *dev;
@@ -553,6 +562,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.8.3.1

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

* [Qemu-devel] [PULL 15/34] vmxnet3: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (13 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 14/34] spapr_lian: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 16/34] usb-net: " Gerd Hoffmann
                   ` (19 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dmitry Fleytman, Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/net/vmxnet3.c | 8 ++++++++
 1 file changed, 8 insertions(+)

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.8.3.1

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

* [Qemu-devel] [PULL 16/34] usb-net: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (14 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 15/34] vmxnet3: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 17/34] net: remove bootindex property from qdev to qom Gerd Hoffmann
                   ` (18 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.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 23e3c45..f341b33 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1375,6 +1375,16 @@ static void usb_net_realize(USBDevice *dev, Error **errrp)
     add_boot_device_path(s->conf.bootindex, &dev->qdev, "/ethernet@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;
@@ -1438,6 +1448,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.8.3.1

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

* [Qemu-devel] [PULL 17/34] net: remove bootindex property from qdev to qom
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (15 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 16/34] usb-net: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 18/34] virtio-net: alias bootindex property explicitly for virt-net-pci/ccw/s390 Gerd Hoffmann
                   ` (17 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/net/net.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/net/net.h b/include/net/net.h
index ed594f9..008d610 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -36,8 +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.8.3.1

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

* [Qemu-devel] [PULL 18/34] virtio-net: alias bootindex property explicitly for virt-net-pci/ccw/s390
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (16 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 17/34] net: remove bootindex property from qdev to qom Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 19/34] host-libusb: remove bootindex property from qdev to qom Gerd Hoffmann
                   ` (16 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Alexander Graf, Christian Borntraeger,
	Gonglei, Gerd Hoffmann, Anthony Liguori, Cornelia Huck,
	Richard Henderson

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

Since the "bootindex" property is a QOM property and not a qdev property
now, we must alias it explicitly for virtio-net-pci, as well as CCW and
s390-virtio.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/s390x/s390-virtio-bus.c | 2 ++
 hw/s390x/virtio-ccw.c      | 2 ++
 hw/virtio/virtio-pci.c     | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index f451ca1..168acfd 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -162,6 +162,8 @@ static void s390_virtio_net_instance_init(Object *obj)
 
     virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
                                 TYPE_VIRTIO_NET);
+    object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
+                              "bootindex", &error_abort);
 }
 
 static int s390_virtio_blk_init(VirtIOS390Device *s390_dev)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 18ba29f..6b99fc9 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -795,6 +795,8 @@ static void virtio_ccw_net_instance_init(Object *obj)
 
     virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
                                 TYPE_VIRTIO_NET);
+    object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
+                              "bootindex", &error_abort);
 }
 
 static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 390f824..20f1ef2 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1466,6 +1466,8 @@ static void virtio_net_pci_instance_init(Object *obj)
 
     virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
                                 TYPE_VIRTIO_NET);
+    object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
+                              "bootindex", &error_abort);
 }
 
 static const TypeInfo virtio_net_pci_info = {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 19/34] host-libusb: remove bootindex property from qdev to qom
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (17 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 18/34] virtio-net: alias bootindex property explicitly for virt-net-pci/ccw/s390 Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 20/34] pci-assign: " Gerd Hoffmann
                   ` (15 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/host-libusb.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 45b74e5..906e429 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -982,6 +982,16 @@ static void usb_host_realize(USBDevice *udev, Error **errp)
     usb_host_auto_check(NULL);
 }
 
+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);
+}
+
 static void usb_host_handle_destroy(USBDevice *udev)
 {
     USBHostDevice *s = USB_HOST_DEVICE(udev);
@@ -1465,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,
@@ -1498,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.8.3.1

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

* [Qemu-devel] [PULL 20/34] pci-assign: remove bootindex property from qdev to qom
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (18 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 19/34] host-libusb: remove bootindex property from qdev to qom Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 21/34] vfio: " Gerd Hoffmann
                   ` (14 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann, Anthony Liguori, Michael S. Tsirkin

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/i386/kvm/pci-assign.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index 13b9de0..1e976c8 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -1850,13 +1850,22 @@ 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);
+}
+
 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 +1891,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.8.3.1

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

* [Qemu-devel] [PULL 21/34] vfio: remove bootindex property from qdev to qom
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (19 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 20/34] pci-assign: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 22/34] redirect: " Gerd Hoffmann
                   ` (13 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Williamson, Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/misc/vfio.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index d66f3d2..b37f41c 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -4365,13 +4365,22 @@ 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);
+}
+
 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 +4416,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.8.3.1

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

* [Qemu-devel] [PULL 22/34] redirect: remove bootindex property from qdev to qom
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (20 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 21/34] vfio: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 23/34] isa-fdc: remove bootindexA/B " Gerd Hoffmann
                   ` (12 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/redirect.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index e2c9896..95f1aa2 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -2471,7 +2471,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(),
 };
 
@@ -2496,11 +2495,22 @@ 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);
+}
+
 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.8.3.1

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

* [Qemu-devel] [PULL 23/34] isa-fdc: remove bootindexA/B property from qdev to qom
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (21 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 22/34] redirect: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 24/34] scsi: add bootindex to qom property Gerd Hoffmann
                   ` (11 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Gonglei, Gerd Hoffmann, Stefan Hajnoczi

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/block/fdc.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 6c86a6b..9f9484c 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2291,8 +2291,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(),
@@ -2310,11 +2308,24 @@ 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);
+}
+
 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.8.3.1

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

* [Qemu-devel] [PULL 24/34] scsi: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (22 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 23/34] isa-fdc: remove bootindexA/B " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 25/34] ide: " Gerd Hoffmann
                   ` (10 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/scsi/scsi-bus.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 0f3e039..59e8f90 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -2016,6 +2016,16 @@ static void scsi_device_class_init(ObjectClass *klass, void *data)
     k->props     = scsi_props;
 }
 
+static 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 TypeInfo scsi_device_type_info = {
     .name = TYPE_SCSI_DEVICE,
     .parent = TYPE_DEVICE,
@@ -2023,6 +2033,7 @@ static const TypeInfo scsi_device_type_info = {
     .abstract = true,
     .class_size = sizeof(SCSIDeviceClass),
     .class_init = scsi_device_class_init,
+    .instance_init = scsi_dev_instance_init,
 };
 
 static void scsi_register_types(void)
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 25/34] ide: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (23 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 24/34] scsi: add bootindex to qom property Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:05 ` [Qemu-devel] [PULL 26/34] virtio-blk: " Gerd Hoffmann
                   ` (9 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Gonglei, Gerd Hoffmann, Stefan Hajnoczi

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/ide/qdev.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index efab95b..7e69020 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -23,6 +23,7 @@
 #include "sysemu/blockdev.h"
 #include "hw/block/block.h"
 #include "sysemu/sysemu.h"
+#include "qapi/visitor.h"
 
 /* --------------------------------- */
 
@@ -191,6 +192,46 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
     return 0;
 }
 
+static void ide_dev_get_bootindex(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    IDEDevice *d = IDE_DEVICE(obj);
+
+    visit_type_int32(v, &d->conf.bootindex, name, errp);
+}
+
+static void ide_dev_set_bootindex(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    IDEDevice *d = IDE_DEVICE(obj);
+    int32_t boot_index;
+    Error *local_err = NULL;
+
+    visit_type_int32(v, &boot_index, name, &local_err);
+    if (local_err) {
+        goto out;
+    }
+    /* check whether bootindex is present in fw_boot_order list  */
+    check_boot_index(boot_index, &local_err);
+    if (local_err) {
+        goto out;
+    }
+    /* change bootindex to a new one */
+    d->conf.bootindex = boot_index;
+
+out:
+    if (local_err) {
+        error_propagate(errp, local_err);
+    }
+}
+
+static void ide_dev_instance_init(Object *obj)
+{
+    object_property_add(obj, "bootindex", "int32",
+                        ide_dev_get_bootindex,
+                        ide_dev_set_bootindex, NULL, NULL, NULL);
+}
+
 static int ide_hd_initfn(IDEDevice *dev)
 {
     return ide_dev_initfn(dev, IDE_HD);
@@ -300,6 +341,7 @@ static const TypeInfo ide_device_type_info = {
     .abstract = true,
     .class_size = sizeof(IDEDeviceClass),
     .class_init = ide_device_class_init,
+    .instance_init = ide_dev_instance_init,
 };
 
 static void ide_register_types(void)
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 26/34] virtio-blk: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (24 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 25/34] ide: " Gerd Hoffmann
@ 2014-10-15  9:05 ` Gerd Hoffmann
  2014-10-15  9:06 ` [Qemu-devel] [PULL 27/34] block: remove bootindex property from qdev to qom Gerd Hoffmann
                   ` (8 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Anthony Liguori, Michael S. Tsirkin, Gonglei,
	Gerd Hoffmann, Stefan Hajnoczi

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.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 45e0c8f..fd1ad3a 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -794,6 +794,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->blk.conf.bootindex,
+                                  "bootindex", "/disk@0,0",
+                                  DEVICE(obj), NULL);
 }
 
 static Property virtio_blk_properties[] = {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 27/34] block: remove bootindex property from qdev to qom
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (25 preceding siblings ...)
  2014-10-15  9:05 ` [Qemu-devel] [PULL 26/34] virtio-blk: " Gerd Hoffmann
@ 2014-10-15  9:06 ` Gerd Hoffmann
  2014-10-15  9:06 ` [Qemu-devel] [PULL 28/34] virtio-blk: alias bootindex property explicitly for virt-blk-pci/ccw/s390 Gerd Hoffmann
                   ` (7 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/scsi/scsi-bus.c       | 3 ++-
 hw/scsi/scsi-disk.c      | 1 -
 hw/scsi/scsi-generic.c   | 1 -
 include/hw/block/block.h | 1 -
 4 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 59e8f90..e7b1cf6 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -231,7 +231,8 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
     dev = qdev_create(&bus->qbus, driver);
     qdev_prop_set_uint32(dev, "scsi-id", unit);
     if (bootindex >= 0) {
-        qdev_prop_set_int32(dev, "bootindex", bootindex);
+        object_property_set_int(OBJECT(dev), bootindex, "bootindex",
+                                &error_abort);
     }
     if (object_property_find(OBJECT(dev), "removable", NULL)) {
         qdev_prop_set_bit(dev, "removable", removable);
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 7a7938a..9cd3445 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2662,7 +2662,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 01bca08..03b980c 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -463,7 +463,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.8.3.1

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

* [Qemu-devel] [PULL 28/34] virtio-blk: alias bootindex property explicitly for virt-blk-pci/ccw/s390
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (26 preceding siblings ...)
  2014-10-15  9:06 ` [Qemu-devel] [PULL 27/34] block: remove bootindex property from qdev to qom Gerd Hoffmann
@ 2014-10-15  9:06 ` Gerd Hoffmann
  2014-10-15  9:06 ` [Qemu-devel] [PULL 29/34] usb-storage: add bootindex to qom property Gerd Hoffmann
                   ` (6 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Alexander Graf, Christian Borntraeger,
	Gonglei, Gerd Hoffmann, Anthony Liguori, Cornelia Huck,
	Richard Henderson

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

Since the "bootindex" property is a QOM property and not a qdev property
now, we must alias it explicitly for virtio-blk-pci, as well as CCW and
s390-virtio.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/s390x/s390-virtio-bus.c | 2 ++
 hw/s390x/virtio-ccw.c      | 2 ++
 hw/virtio/virtio-pci.c     | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 168acfd..fabde37 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -185,6 +185,8 @@ static void s390_virtio_blk_instance_init(Object *obj)
                                 TYPE_VIRTIO_BLK);
     object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev),"iothread",
                               &error_abort);
+    object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
+                              "bootindex", &error_abort);
 }
 
 static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 6b99fc9..6bb8708 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -819,6 +819,8 @@ static void virtio_ccw_blk_instance_init(Object *obj)
                                 TYPE_VIRTIO_BLK);
     object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev),"iothread",
                               &error_abort);
+    object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
+                              "bootindex", &error_abort);
 }
 
 static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 20f1ef2..3f219ae 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1115,6 +1115,8 @@ static void virtio_blk_pci_instance_init(Object *obj)
                                 TYPE_VIRTIO_BLK);
     object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev),"iothread",
                               &error_abort);
+    object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
+                              "bootindex", &error_abort);
 }
 
 static const TypeInfo virtio_blk_pci_info = {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 29/34] usb-storage: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (27 preceding siblings ...)
  2014-10-15  9:06 ` [Qemu-devel] [PULL 28/34] virtio-blk: alias bootindex property explicitly for virt-blk-pci/ccw/s390 Gerd Hoffmann
@ 2014-10-15  9:06 ` Gerd Hoffmann
  2014-10-15  9:06 ` [Qemu-devel] [PULL 30/34] nvma: ide: " Gerd Hoffmann
                   ` (5 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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.

Because usb-storage rely on scsi-disk which is created
in usb_msg_realize_storage(), so we should store the SCSIDevice
pointer in MSDState struct. Only in this way, we can change
the global boot_order_list when we want to change the bootindex
during vm rebooting by calling object_property_set_int(Object(SCSIDevice),).

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/dev-storage.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index bd7cc53..7406fdd 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -17,6 +17,7 @@
 #include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/blockdev.h"
+#include "qapi/visitor.h"
 
 //#define DEBUG_MSD
 
@@ -59,6 +60,7 @@ typedef struct {
     /* usb-storage only */
     BlockConf conf;
     uint32_t removable;
+    SCSIDevice *scsi_dev;
 } MSDState;
 
 struct usb_msd_cbw {
@@ -634,6 +636,7 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp)
     }
     s->bus.qbus.allow_hotplug = 0;
     usb_msd_handle_reset(dev);
+    s->scsi_dev = scsi_dev;
 
     if (bdrv_key_required(bs)) {
         if (cur_mon) {
@@ -767,6 +770,54 @@ static void usb_msd_class_initfn_storage(ObjectClass *klass, void *data)
     usb_msd_class_initfn_common(klass);
 }
 
+static void usb_msd_get_bootindex(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    USBDevice *dev = USB_DEVICE(obj);
+    MSDState *s = DO_UPCAST(MSDState, dev, dev);
+
+    visit_type_int32(v, &s->conf.bootindex, name, errp);
+}
+
+static void usb_msd_set_bootindex(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    USBDevice *dev = USB_DEVICE(obj);
+    MSDState *s = DO_UPCAST(MSDState, dev, dev);
+    int32_t boot_index;
+    Error *local_err = NULL;
+
+    visit_type_int32(v, &boot_index, name, &local_err);
+    if (local_err) {
+        goto out;
+    }
+    /* check whether bootindex is present in fw_boot_order list  */
+    check_boot_index(boot_index, &local_err);
+    if (local_err) {
+        goto out;
+    }
+    /* change bootindex to a new one */
+    s->conf.bootindex = boot_index;
+
+    if (s->scsi_dev) {
+        object_property_set_int(OBJECT(s->scsi_dev), boot_index, "bootindex",
+                                &error_abort);
+    }
+
+out:
+    if (local_err) {
+        error_propagate(errp, local_err);
+    }
+}
+
+static void usb_msd_instance_init(Object *obj)
+{
+    object_property_add(obj, "bootindex", "int32",
+                        usb_msd_get_bootindex,
+                        usb_msd_set_bootindex, NULL, NULL, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
+}
+
 static void usb_msd_class_initfn_bot(ObjectClass *klass, void *data)
 {
     USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
@@ -780,6 +831,7 @@ static const TypeInfo msd_info = {
     .parent        = TYPE_USB_DEVICE,
     .instance_size = sizeof(MSDState),
     .class_init    = usb_msd_class_initfn_storage,
+    .instance_init = usb_msd_instance_init,
 };
 
 static const TypeInfo bot_info = {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 30/34] nvma: ide: add bootindex to qom property
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (28 preceding siblings ...)
  2014-10-15  9:06 ` [Qemu-devel] [PULL 29/34] usb-storage: add bootindex to qom property Gerd Hoffmann
@ 2014-10-15  9:06 ` Gerd Hoffmann
  2014-10-15  9:06 ` [Qemu-devel] [PULL 31/34] ide: add calling add_boot_device_patch in bootindex setter function Gerd Hoffmann
                   ` (4 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Keith Busch, Kevin Wolf, Gonglei, Gerd Hoffmann, Stefan Hajnoczi

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

At present, nvma cannot boot. However, it provides already
a bootindex property, so change bootindex to qom for nvma
device, but not call add_boot_device_path.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/block/nvme.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index b010c9b..9a95f75 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -24,6 +24,8 @@
 #include <hw/hw.h>
 #include <hw/pci/msix.h>
 #include <hw/pci/pci.h>
+#include "sysemu/sysemu.h"
+#include "qapi/visitor.h"
 
 #include "nvme.h"
 
@@ -871,11 +873,53 @@ static void nvme_class_init(ObjectClass *oc, void *data)
     dc->vmsd = &nvme_vmstate;
 }
 
+static void nvme_get_bootindex(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    NvmeCtrl *s = NVME(obj);
+
+    visit_type_int32(v, &s->conf.bootindex, name, errp);
+}
+
+static void nvme_set_bootindex(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    NvmeCtrl *s = NVME(obj);
+    int32_t boot_index;
+    Error *local_err = NULL;
+
+    visit_type_int32(v, &boot_index, name, &local_err);
+    if (local_err) {
+        goto out;
+    }
+    /* check whether bootindex is present in fw_boot_order list  */
+    check_boot_index(boot_index, &local_err);
+    if (local_err) {
+        goto out;
+    }
+    /* change bootindex to a new one */
+    s->conf.bootindex = boot_index;
+
+out:
+    if (local_err) {
+        error_propagate(errp, local_err);
+    }
+}
+
+static void nvme_instance_init(Object *obj)
+{
+    object_property_add(obj, "bootindex", "int32",
+                        nvme_get_bootindex,
+                        nvme_set_bootindex, NULL, NULL, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
+}
+
 static const TypeInfo nvme_info = {
     .name          = "nvme",
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(NvmeCtrl),
     .class_init    = nvme_class_init,
+    .instance_init = nvme_instance_init,
 };
 
 static void nvme_register_types(void)
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 31/34] ide: add calling add_boot_device_patch in bootindex setter function
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (29 preceding siblings ...)
  2014-10-15  9:06 ` [Qemu-devel] [PULL 30/34] nvma: ide: " Gerd Hoffmann
@ 2014-10-15  9:06 ` Gerd Hoffmann
  2014-10-15  9:06 ` [Qemu-devel] [PULL 32/34] bootindex: move calling add_boot_device_patch to " Gerd Hoffmann
                   ` (3 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Gonglei, Gerd Hoffmann, Stefan Hajnoczi

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

On this way, we can assure the new bootindex take effect
during vm rebooting. Meanwhile set the initial value of
bootindex to -1.

Because ide devcies's unit property maybe
do not initialize when set_bootindex function is called,
so that we don't know its suffix. So we have to save the
call add_boot_device_path() on ide realize/init function.
When we want to change bootindex during vm rebooting, we
can call it in setter function.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/ide/qdev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 7e69020..9814ef0 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -219,6 +219,10 @@ static void ide_dev_set_bootindex(Object *obj, Visitor *v, void *opaque,
     /* change bootindex to a new one */
     d->conf.bootindex = boot_index;
 
+    if (d->unit != -1) {
+        add_boot_device_path(d->conf.bootindex, &d->qdev,
+                             d->unit ? "/disk@1" : "/disk@0");
+    }
 out:
     if (local_err) {
         error_propagate(errp, local_err);
@@ -230,6 +234,7 @@ static void ide_dev_instance_init(Object *obj)
     object_property_add(obj, "bootindex", "int32",
                         ide_dev_get_bootindex,
                         ide_dev_set_bootindex, NULL, NULL, NULL);
+    object_property_set_int(obj, -1, "bootindex", NULL);
 }
 
 static int ide_hd_initfn(IDEDevice *dev)
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 32/34] bootindex: move calling add_boot_device_patch to bootindex setter function
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (30 preceding siblings ...)
  2014-10-15  9:06 ` [Qemu-devel] [PULL 31/34] ide: add calling add_boot_device_patch in bootindex setter function Gerd Hoffmann
@ 2014-10-15  9:06 ` Gerd Hoffmann
  2014-10-15  9:06 ` [Qemu-devel] [PULL 33/34] bootindex: delete bootindex when device is removed Gerd Hoffmann
                   ` (2 subsequent siblings)
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Anthony Liguori, Michael S. Tsirkin, Alexander Graf,
	Alex Williamson, Gonglei, open list:sPAPR, Gerd Hoffmann,
	Stefan Hajnoczi, Dmitry Fleytman, Paolo Bonzini

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 bootdevice.c             | 2 ++
 hw/block/fdc.c           | 3 ---
 hw/block/virtio-blk.c    | 2 --
 hw/i386/kvm/pci-assign.c | 2 --
 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     | 2 --
 hw/usb/host-libusb.c     | 1 -
 hw/usb/redirect.c        | 1 -
 18 files changed, 2 insertions(+), 32 deletions(-)

diff --git a/bootdevice.c b/bootdevice.c
index 69cffd8..79c2327 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -212,6 +212,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 9f9484c..34c1d8f 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2216,9 +2216,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 fd1ad3a..1fa9770 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -768,8 +768,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 1e976c8..bb206da 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/misc/vfio.c b/hw/misc/vfio.c
index b37f41c..b5e7981 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 0edbfa6..e33a4da 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 fb9c944..4877bfd 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 62b86af..3ab2d03 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 138a03a..8b8a1b1 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 0ff159b..2c8b038 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -221,8 +221,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 f5ead97..9b88775 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1661,8 +1661,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 88e9d9c..8eea589 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 9cd3445..ae9e08d 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2269,7 +2269,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 03b980c..84a1d5b 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -413,9 +413,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 f341b33..5b95d5c 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1371,8 +1371,6 @@ static void usb_net_realize(USBDevice *dev, Error **errrp)
              s->conf.macaddr.a[4],
              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");
 }
 
 static void usb_net_instance_init(Object *obj)
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 906e429..d2d161b 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -978,7 +978,6 @@ static void usb_host_realize(USBDevice *udev, Error **errp)
     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);
 }
 
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 95f1aa2..9fbd59e 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -1401,7 +1401,6 @@ static void usbredir_realize(USBDevice *udev, Error **errp)
                           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);
 }
 
 static void usbredir_cleanup_device_queues(USBRedirDevice *dev)
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 33/34] bootindex: delete bootindex when device is removed
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (31 preceding siblings ...)
  2014-10-15  9:06 ` [Qemu-devel] [PULL 32/34] bootindex: move calling add_boot_device_patch to " Gerd Hoffmann
@ 2014-10-15  9:06 ` Gerd Hoffmann
  2014-10-15  9:06 ` [Qemu-devel] [PULL 34/34] bootindex: change fprintf to error_report Gerd Hoffmann
  2014-10-16  8:25 ` [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Peter Maydell
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 bootdevice.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bootdevice.c b/bootdevice.c
index 79c2327..56b1952 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -225,6 +225,8 @@ static void property_release_bootindex(Object *obj, const char *name,
 
 {
     BootIndexProperty *prop = opaque;
+
+    del_boot_device_path(prop->dev, prop->suffix);
     g_free(prop);
 }
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 34/34] bootindex: change fprintf to error_report
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (32 preceding siblings ...)
  2014-10-15  9:06 ` [Qemu-devel] [PULL 33/34] bootindex: delete bootindex when device is removed Gerd Hoffmann
@ 2014-10-15  9:06 ` Gerd Hoffmann
  2014-10-16  8:25 ` [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Peter Maydell
  34 siblings, 0 replies; 38+ messages in thread
From: Gerd Hoffmann @ 2014-10-15  9:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gonglei, Gerd Hoffmann

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

The function may be called by qmp command, we should
report error message to the caller.

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

diff --git a/bootdevice.c b/bootdevice.c
index 56b1952..b29970c 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -24,6 +24,7 @@
 
 #include "sysemu/sysemu.h"
 #include "qapi/visitor.h"
+#include "qemu/error-report.h"
 
 typedef struct FWBootEntry FWBootEntry;
 
@@ -93,7 +94,7 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
 
     QTAILQ_FOREACH(i, &fw_boot_order, link) {
         if (i->bootindex == bootindex) {
-            fprintf(stderr, "Two devices with same boot index %d\n", bootindex);
+            error_report("Two devices with same boot index %d", bootindex);
             exit(1);
         } else if (i->bootindex < bootindex) {
             continue;
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor
  2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
                   ` (33 preceding siblings ...)
  2014-10-15  9:06 ` [Qemu-devel] [PULL 34/34] bootindex: change fprintf to error_report Gerd Hoffmann
@ 2014-10-16  8:25 ` Peter Maydell
  34 siblings, 0 replies; 38+ messages in thread
From: Peter Maydell @ 2014-10-16  8:25 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 15 October 2014 11:05, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> It's finally sorted, here comes the pull request for the bootindex patch
> series which turns bootindex into a writable qom property and thereby
> allows changing the bootorder at runtime via monitor.
>
> please pull,
>   Gerd
>
> The following changes since commit b1d28ec6a7dbdaadda39d29322f0de694aeb0b74:
>
>   Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20141010' into staging (2014-10-10 14:55:29 +0100)
>
> are available in the git repository at:
>
>
>   git://git.kraxel.org/qemu tags/pull-bootindex-20141015-1
>
> for you to fetch changes up to 54086fe5d2c562a3173126d9991bd064faf1e884:
>
>   bootindex: change fprintf to error_report (2014-10-15 10:46:01 +0200)
>
> ----------------------------------------------------------------
> allow changing bootorder via monitor at runtime,
> by making bootindex a writable qom property.
>
> ----------------------------------------------------------------

Applied, thanks.

-- PMM

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

* Re: [Qemu-devel] [PULL 03/34] bootindex: add del_boot_device_path function
  2014-10-15  9:05 ` [Qemu-devel] [PULL 03/34] bootindex: add del_boot_device_path function Gerd Hoffmann
@ 2014-10-16 10:04   ` Peter Maydell
  2014-10-16 10:11     ` Gonglei
  0 siblings, 1 reply; 38+ messages in thread
From: Peter Maydell @ 2014-10-16 10:04 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Chenliang, Gonglei, QEMU Developers

On 15 October 2014 11:05, Gerd Hoffmann <kraxel@redhat.com> wrote:
> 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 or update a
> existent devcie's bootindex.

> +void del_boot_device_path(DeviceState *dev, const char *suffix)
> +{
> +    FWBootEntry *i;
> +
> +    if (dev == NULL) {
> +        return;
> +    }
> +
> +    QTAILQ_FOREACH(i, &fw_boot_order, link) {
> +        if ((!suffix || !g_strcmp0(i->suffix, suffix)) &&

I've just noticed that this won't build with our minimum
required glib version: g_strcmp0 wasn't introduced
until glib 2.16.

It should be fairly easy to provide a back-compat implementation
in our glib-compat.h header, or you could just rephrase this
to work with the usual strcmp, since you're already doing a
manual NULL check on one of the arguments.

thanks
-- PMM

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

* Re: [Qemu-devel] [PULL 03/34] bootindex: add del_boot_device_path function
  2014-10-16 10:04   ` Peter Maydell
@ 2014-10-16 10:11     ` Gonglei
  0 siblings, 0 replies; 38+ messages in thread
From: Gonglei @ 2014-10-16 10:11 UTC (permalink / raw)
  To: Peter Maydell; +Cc: chenliang (T), Gerd Hoffmann, QEMU Developers

On 2014/10/16 18:04, Peter Maydell wrote:

> On 15 October 2014 11:05, Gerd Hoffmann <kraxel@redhat.com> wrote:
>> 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 or update a
>> existent devcie's bootindex.
> 
>> +void del_boot_device_path(DeviceState *dev, const char *suffix)
>> +{
>> +    FWBootEntry *i;
>> +
>> +    if (dev == NULL) {
>> +        return;
>> +    }
>> +
>> +    QTAILQ_FOREACH(i, &fw_boot_order, link) {
>> +        if ((!suffix || !g_strcmp0(i->suffix, suffix)) &&
> 
> I've just noticed that this won't build with our minimum
> required glib version: g_strcmp0 wasn't introduced
> until glib 2.16.
> 
> It should be fairly easy to provide a back-compat implementation
> in our glib-compat.h header, or you could just rephrase this
> to work with the usual strcmp, since you're already doing a
> manual NULL check on one of the arguments.
> 

OK, thanks for your point, Peter.
I'll post a patch to fix this problem :)

Best regards,
-Gonglei

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

end of thread, other threads:[~2014-10-16 10:11 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-15  9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 01/34] bootdevice: move bootdevice related code to new file bootdevice.c Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 02/34] bootindex: add check bootindex function Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 03/34] bootindex: add del_boot_device_path function Gerd Hoffmann
2014-10-16 10:04   ` Peter Maydell
2014-10-16 10:11     ` Gonglei
2014-10-15  9:05 ` [Qemu-devel] [PULL 04/34] fw_cfg: add fw_cfg_machine_reset function Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 05/34] bootindex: rework add_boot_device_path function Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 06/34] bootindex: support to set a existent device's bootindex to -1 Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 07/34] bootindex: add a setter/getter functions wrapper for bootindex property Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 08/34] virtio-net: add bootindex to qom property Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 09/34] e1000: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 10/34] eepro100: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 11/34] ne2000: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 12/34] pcnet: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 13/34] rtl8139: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 14/34] spapr_lian: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 15/34] vmxnet3: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 16/34] usb-net: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 17/34] net: remove bootindex property from qdev to qom Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 18/34] virtio-net: alias bootindex property explicitly for virt-net-pci/ccw/s390 Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 19/34] host-libusb: remove bootindex property from qdev to qom Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 20/34] pci-assign: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 21/34] vfio: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 22/34] redirect: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 23/34] isa-fdc: remove bootindexA/B " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 24/34] scsi: add bootindex to qom property Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 25/34] ide: " Gerd Hoffmann
2014-10-15  9:05 ` [Qemu-devel] [PULL 26/34] virtio-blk: " Gerd Hoffmann
2014-10-15  9:06 ` [Qemu-devel] [PULL 27/34] block: remove bootindex property from qdev to qom Gerd Hoffmann
2014-10-15  9:06 ` [Qemu-devel] [PULL 28/34] virtio-blk: alias bootindex property explicitly for virt-blk-pci/ccw/s390 Gerd Hoffmann
2014-10-15  9:06 ` [Qemu-devel] [PULL 29/34] usb-storage: add bootindex to qom property Gerd Hoffmann
2014-10-15  9:06 ` [Qemu-devel] [PULL 30/34] nvma: ide: " Gerd Hoffmann
2014-10-15  9:06 ` [Qemu-devel] [PULL 31/34] ide: add calling add_boot_device_patch in bootindex setter function Gerd Hoffmann
2014-10-15  9:06 ` [Qemu-devel] [PULL 32/34] bootindex: move calling add_boot_device_patch to " Gerd Hoffmann
2014-10-15  9:06 ` [Qemu-devel] [PULL 33/34] bootindex: delete bootindex when device is removed Gerd Hoffmann
2014-10-15  9:06 ` [Qemu-devel] [PULL 34/34] bootindex: change fprintf to error_report Gerd Hoffmann
2014-10-16  8:25 ` [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).