mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/kraxel/tags/pull-bootindex-20141015-1' into staging
allow changing bootorder via monitor at runtime, by making bootindex a writable qom property. * remotes/kraxel/tags/pull-bootindex-20141015-1: (34 commits) bootindex: change fprintf to error_report bootindex: delete bootindex when device is removed bootindex: move calling add_boot_device_patch to bootindex setter function ide: add calling add_boot_device_patch in bootindex setter function nvma: ide: add bootindex to qom property usb-storage: add bootindex to qom property virtio-blk: alias bootindex property explicitly for virt-blk-pci/ccw/s390 block: remove bootindex property from qdev to qom virtio-blk: add bootindex to qom property ide: add bootindex to qom property scsi: add bootindex to qom property isa-fdc: remove bootindexA/B property from qdev to qom redirect: remove bootindex property from qdev to qom vfio: remove bootindex property from qdev to qom pci-assign: remove bootindex property from qdev to qom host-libusb: remove bootindex property from qdev to qom virtio-net: alias bootindex property explicitly for virt-net-pci/ccw/s390 net: remove bootindex property from qdev to qom usb-net: add bootindex to qom property vmxnet3: add bootindex to qom property ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* 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"
|
||||
#include "qapi/visitor.h"
|
||||
#include "qemu/error-report.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 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 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)
|
||||
{
|
||||
FWBootEntry *node, *i;
|
||||
|
||||
if (bootindex < 0) {
|
||||
del_boot_device_path(dev, suffix);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(dev != NULL || suffix != NULL);
|
||||
|
||||
del_boot_device_path(dev, suffix);
|
||||
|
||||
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) {
|
||||
error_report("Two devices with same boot index %d", 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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
add_boot_device_path(*prop->bootindex, prop->dev, prop->suffix);
|
||||
|
||||
out:
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
}
|
||||
|
||||
static void property_release_bootindex(Object *obj, const char *name,
|
||||
void *opaque)
|
||||
|
||||
{
|
||||
BootIndexProperty *prop = opaque;
|
||||
|
||||
del_boot_device_path(prop->dev, prop->suffix);
|
||||
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);
|
||||
}
|
||||
+13
-5
@@ -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)
|
||||
@@ -2291,8 +2288,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 +2305,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 ={
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
@@ -794,6 +792,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[] = {
|
||||
|
||||
@@ -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:
|
||||
@@ -1850,13 +1848,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 +1889,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)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "sysemu/blockdev.h"
|
||||
#include "hw/block/block.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "qapi/visitor.h"
|
||||
|
||||
/* --------------------------------- */
|
||||
|
||||
@@ -191,6 +192,51 @@ 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;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return ide_dev_initfn(dev, IDE_HD);
|
||||
@@ -300,6 +346,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)
|
||||
|
||||
+11
-2
@@ -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;
|
||||
@@ -4365,13 +4364,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 +4415,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)
|
||||
|
||||
+10
-2
@@ -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);
|
||||
|
||||
@@ -1621,10 +1619,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 +1675,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);
|
||||
}
|
||||
|
||||
+10
-3
@@ -1901,11 +1901,17 @@ 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;
|
||||
}
|
||||
|
||||
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 +2110,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
+12
-2
@@ -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;
|
||||
}
|
||||
|
||||
@@ -752,6 +750,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 +787,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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 */
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
|
||||
+10
-2
@@ -3538,11 +3538,18 @@ 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;
|
||||
}
|
||||
|
||||
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 +3578,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)
|
||||
|
||||
+10
-2
@@ -221,11 +221,18 @@ 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;
|
||||
}
|
||||
|
||||
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 +560,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)
|
||||
|
||||
+3
-2
@@ -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)
|
||||
@@ -1714,6 +1712,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[] = {
|
||||
|
||||
+8
-2
@@ -2172,11 +2172,16 @@ 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;
|
||||
}
|
||||
|
||||
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 +2529,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)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user