mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00
QAPI patches patches for 2021-01-28
-----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmASY10SHGFybWJydUBy ZWRoYXQuY29tAAoJEDhwtADrkYZT4M4P+gKN64+WaErotLHHsqtiA0aoTwbTFXin OEyR5du0+PjX96qYHHV+ZDn5uxxKI57/SRNooPndjU63sYgAbNApfsu+wUDZC844 qMSlrmyw2+Lw1EIykoLXK49+pEDU0XpVIciL5+zEdtCgjiJRjrOOJ/JRBcKoQNHn UArGNQ8y0D+0i8uXyJjyvQeHdz6KUr9sX1vqwRGMt9axEMDJks0+Si4Zg3z2wlWJ Sc3WsXEhikxK1qkF2/6VsopOgNGB0UUvV6q1GO6ngdqag1Hb6mACzSv9mtIShGjh a2MISBhxF8h4wfO8U5TiS9vBgYR3elA3kRGsn4FOfD3sSilt/SWLPHWXdlO1aL2E TollRPtYBqn2YIYQP1SEp7NIqaWC/QaGkP/mH8Jvv0YlL64RK879lv6KiHKzfvI7 HBD7WGZBwMQqPczuw308tqDTQPKUsPDYoEJAFRywkLry86wL8DBOlkQ0lWUjF06s UQk/i09nhrcNLo0GbmgAOHUVj4m03zLyMW/fYmsQ8xe9/b6GBwJvtm2v5wKwg0HE ixxj4oBIk5YV5Xwt7DKLkT0voPAAgNK13a6ywzbyfsigwaJaO9tLtZ0PMuaT9kgs b/OBdeeIYpFdIT/DlcMWpIFi53VYe0McX8MmprHcMZb1133wk5Z5gk+FAWLMifrw 2ltmoUPoB1dC =djiE -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-01-28' into staging QAPI patches patches for 2021-01-28 # gpg: Signature made Thu 28 Jan 2021 07:10:21 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2021-01-28: qapi: More complex uses of QAPI_LIST_APPEND qapi: Use QAPI_LIST_APPEND in trivial cases qapi: Introduce QAPI_LIST_APPEND qapi: A couple more QAPI_LIST_PREPEND() stragglers net: Clarify early exit condition Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
7e7eb9f852
31 changed files with 267 additions and 551 deletions
|
@ -44,14 +44,11 @@ static ACPIOSTInfo *acpi_cpu_device_status(int idx, AcpiCpuStatus *cdev)
|
|||
|
||||
void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list)
|
||||
{
|
||||
ACPIOSTInfoList ***tail = list;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < cpu_st->dev_count; i++) {
|
||||
ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1);
|
||||
elem->value = acpi_cpu_device_status(i, &cpu_st->devs[i]);
|
||||
elem->next = NULL;
|
||||
**list = elem;
|
||||
*list = &elem->next;
|
||||
QAPI_LIST_APPEND(*tail, acpi_cpu_device_status(i, &cpu_st->devs[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,14 +53,12 @@ static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
|
|||
|
||||
void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list)
|
||||
{
|
||||
ACPIOSTInfoList ***tail = list;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mem_st->dev_count; i++) {
|
||||
ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1);
|
||||
elem->value = acpi_memory_device_status(i, &mem_st->devs[i]);
|
||||
elem->next = NULL;
|
||||
**list = elem;
|
||||
*list = &elem->next;
|
||||
QAPI_LIST_APPEND(*tail,
|
||||
acpi_memory_device_status(i, &mem_st->devs[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ CpuInfoList *qmp_query_cpus(Error **errp)
|
|||
{
|
||||
MachineState *ms = MACHINE(qdev_get_machine());
|
||||
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
||||
CpuInfoList *head = NULL, *cur_item = NULL;
|
||||
CpuInfoList *head = NULL, **tail = &head;
|
||||
CPUState *cpu;
|
||||
|
||||
CPU_FOREACH(cpu) {
|
||||
CpuInfoList *info;
|
||||
CpuInfo *value;
|
||||
#if defined(TARGET_I386)
|
||||
X86CPU *x86_cpu = X86_CPU(cpu);
|
||||
CPUX86State *env = &x86_cpu->env;
|
||||
|
@ -58,53 +58,46 @@ CpuInfoList *qmp_query_cpus(Error **errp)
|
|||
|
||||
cpu_synchronize_state(cpu);
|
||||
|
||||
info = g_malloc0(sizeof(*info));
|
||||
info->value = g_malloc0(sizeof(*info->value));
|
||||
info->value->CPU = cpu->cpu_index;
|
||||
info->value->current = (cpu == first_cpu);
|
||||
info->value->halted = cpu->halted;
|
||||
info->value->qom_path = object_get_canonical_path(OBJECT(cpu));
|
||||
info->value->thread_id = cpu->thread_id;
|
||||
value = g_malloc0(sizeof(*value));
|
||||
value->CPU = cpu->cpu_index;
|
||||
value->current = (cpu == first_cpu);
|
||||
value->halted = cpu->halted;
|
||||
value->qom_path = object_get_canonical_path(OBJECT(cpu));
|
||||
value->thread_id = cpu->thread_id;
|
||||
#if defined(TARGET_I386)
|
||||
info->value->arch = CPU_INFO_ARCH_X86;
|
||||
info->value->u.x86.pc = env->eip + env->segs[R_CS].base;
|
||||
value->arch = CPU_INFO_ARCH_X86;
|
||||
value->u.x86.pc = env->eip + env->segs[R_CS].base;
|
||||
#elif defined(TARGET_PPC)
|
||||
info->value->arch = CPU_INFO_ARCH_PPC;
|
||||
info->value->u.ppc.nip = env->nip;
|
||||
value->arch = CPU_INFO_ARCH_PPC;
|
||||
value->u.ppc.nip = env->nip;
|
||||
#elif defined(TARGET_SPARC)
|
||||
info->value->arch = CPU_INFO_ARCH_SPARC;
|
||||
info->value->u.q_sparc.pc = env->pc;
|
||||
info->value->u.q_sparc.npc = env->npc;
|
||||
value->arch = CPU_INFO_ARCH_SPARC;
|
||||
value->u.q_sparc.pc = env->pc;
|
||||
value->u.q_sparc.npc = env->npc;
|
||||
#elif defined(TARGET_MIPS)
|
||||
info->value->arch = CPU_INFO_ARCH_MIPS;
|
||||
info->value->u.q_mips.PC = env->active_tc.PC;
|
||||
value->arch = CPU_INFO_ARCH_MIPS;
|
||||
value->u.q_mips.PC = env->active_tc.PC;
|
||||
#elif defined(TARGET_TRICORE)
|
||||
info->value->arch = CPU_INFO_ARCH_TRICORE;
|
||||
info->value->u.tricore.PC = env->PC;
|
||||
value->arch = CPU_INFO_ARCH_TRICORE;
|
||||
value->u.tricore.PC = env->PC;
|
||||
#elif defined(TARGET_S390X)
|
||||
info->value->arch = CPU_INFO_ARCH_S390;
|
||||
info->value->u.s390.cpu_state = env->cpu_state;
|
||||
value->arch = CPU_INFO_ARCH_S390;
|
||||
value->u.s390.cpu_state = env->cpu_state;
|
||||
#elif defined(TARGET_RISCV)
|
||||
info->value->arch = CPU_INFO_ARCH_RISCV;
|
||||
info->value->u.riscv.pc = env->pc;
|
||||
value->arch = CPU_INFO_ARCH_RISCV;
|
||||
value->u.riscv.pc = env->pc;
|
||||
#else
|
||||
info->value->arch = CPU_INFO_ARCH_OTHER;
|
||||
value->arch = CPU_INFO_ARCH_OTHER;
|
||||
#endif
|
||||
info->value->has_props = !!mc->cpu_index_to_instance_props;
|
||||
if (info->value->has_props) {
|
||||
value->has_props = !!mc->cpu_index_to_instance_props;
|
||||
if (value->has_props) {
|
||||
CpuInstanceProperties *props;
|
||||
props = g_malloc0(sizeof(*props));
|
||||
*props = mc->cpu_index_to_instance_props(ms, cpu->cpu_index);
|
||||
info->value->props = props;
|
||||
value->props = props;
|
||||
}
|
||||
|
||||
/* XXX: waiting for the qapi to support GSList */
|
||||
if (!cur_item) {
|
||||
head = cur_item = info;
|
||||
} else {
|
||||
cur_item->next = info;
|
||||
cur_item = info;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail, value);
|
||||
}
|
||||
|
||||
return head;
|
||||
|
@ -170,39 +163,33 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
|
|||
{
|
||||
MachineState *ms = MACHINE(qdev_get_machine());
|
||||
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
||||
CpuInfoFastList *head = NULL, *cur_item = NULL;
|
||||
CpuInfoFastList *head = NULL, **tail = &head;
|
||||
SysEmuTarget target = qapi_enum_parse(&SysEmuTarget_lookup, TARGET_NAME,
|
||||
-1, &error_abort);
|
||||
CPUState *cpu;
|
||||
|
||||
CPU_FOREACH(cpu) {
|
||||
CpuInfoFastList *info = g_malloc0(sizeof(*info));
|
||||
info->value = g_malloc0(sizeof(*info->value));
|
||||
CpuInfoFast *value = g_malloc0(sizeof(*value));
|
||||
|
||||
info->value->cpu_index = cpu->cpu_index;
|
||||
info->value->qom_path = object_get_canonical_path(OBJECT(cpu));
|
||||
info->value->thread_id = cpu->thread_id;
|
||||
value->cpu_index = cpu->cpu_index;
|
||||
value->qom_path = object_get_canonical_path(OBJECT(cpu));
|
||||
value->thread_id = cpu->thread_id;
|
||||
|
||||
info->value->has_props = !!mc->cpu_index_to_instance_props;
|
||||
if (info->value->has_props) {
|
||||
value->has_props = !!mc->cpu_index_to_instance_props;
|
||||
if (value->has_props) {
|
||||
CpuInstanceProperties *props;
|
||||
props = g_malloc0(sizeof(*props));
|
||||
*props = mc->cpu_index_to_instance_props(ms, cpu->cpu_index);
|
||||
info->value->props = props;
|
||||
value->props = props;
|
||||
}
|
||||
|
||||
info->value->arch = sysemu_target_to_cpuinfo_arch(target);
|
||||
info->value->target = target;
|
||||
value->arch = sysemu_target_to_cpuinfo_arch(target);
|
||||
value->target = target;
|
||||
if (target == SYS_EMU_TARGET_S390X) {
|
||||
cpustate_to_cpuinfo_s390(&info->value->u.s390x, cpu);
|
||||
cpustate_to_cpuinfo_s390(&value->u.s390x, cpu);
|
||||
}
|
||||
|
||||
if (!cur_item) {
|
||||
head = cur_item = info;
|
||||
} else {
|
||||
cur_item->next = info;
|
||||
cur_item = info;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail, value);
|
||||
}
|
||||
|
||||
return head;
|
||||
|
@ -293,41 +280,31 @@ void qmp_set_numa_node(NumaOptions *cmd, Error **errp)
|
|||
static int query_memdev(Object *obj, void *opaque)
|
||||
{
|
||||
MemdevList **list = opaque;
|
||||
MemdevList *m = NULL;
|
||||
Memdev *m;
|
||||
QObject *host_nodes;
|
||||
Visitor *v;
|
||||
|
||||
if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)) {
|
||||
m = g_malloc0(sizeof(*m));
|
||||
|
||||
m->value = g_malloc0(sizeof(*m->value));
|
||||
m->id = g_strdup(object_get_canonical_path_component(obj));
|
||||
m->has_id = !!m->id;
|
||||
|
||||
m->value->id = g_strdup(object_get_canonical_path_component(obj));
|
||||
m->value->has_id = !!m->value->id;
|
||||
|
||||
m->value->size = object_property_get_uint(obj, "size",
|
||||
&error_abort);
|
||||
m->value->merge = object_property_get_bool(obj, "merge",
|
||||
&error_abort);
|
||||
m->value->dump = object_property_get_bool(obj, "dump",
|
||||
&error_abort);
|
||||
m->value->prealloc = object_property_get_bool(obj,
|
||||
"prealloc",
|
||||
&error_abort);
|
||||
m->value->policy = object_property_get_enum(obj,
|
||||
"policy",
|
||||
"HostMemPolicy",
|
||||
&error_abort);
|
||||
m->size = object_property_get_uint(obj, "size", &error_abort);
|
||||
m->merge = object_property_get_bool(obj, "merge", &error_abort);
|
||||
m->dump = object_property_get_bool(obj, "dump", &error_abort);
|
||||
m->prealloc = object_property_get_bool(obj, "prealloc", &error_abort);
|
||||
m->policy = object_property_get_enum(obj, "policy", "HostMemPolicy",
|
||||
&error_abort);
|
||||
host_nodes = object_property_get_qobject(obj,
|
||||
"host-nodes",
|
||||
&error_abort);
|
||||
v = qobject_input_visitor_new(host_nodes);
|
||||
visit_type_uint16List(v, NULL, &m->value->host_nodes, &error_abort);
|
||||
visit_type_uint16List(v, NULL, &m->host_nodes, &error_abort);
|
||||
visit_free(v);
|
||||
qobject_unref(host_nodes);
|
||||
|
||||
m->next = *list;
|
||||
*list = m;
|
||||
QAPI_LIST_PREPEND(*list, m);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -199,7 +199,7 @@ out:
|
|||
MemoryDeviceInfoList *qmp_memory_device_list(void)
|
||||
{
|
||||
GSList *devices = NULL, *item;
|
||||
MemoryDeviceInfoList *list = NULL, *prev = NULL;
|
||||
MemoryDeviceInfoList *list = NULL, **tail = &list;
|
||||
|
||||
object_child_foreach(qdev_get_machine(), memory_device_build_list,
|
||||
&devices);
|
||||
|
@ -207,19 +207,11 @@ MemoryDeviceInfoList *qmp_memory_device_list(void)
|
|||
for (item = devices; item; item = g_slist_next(item)) {
|
||||
const MemoryDeviceState *md = MEMORY_DEVICE(item->data);
|
||||
const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(item->data);
|
||||
MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1);
|
||||
MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
|
||||
|
||||
mdc->fill_device_info(md, info);
|
||||
|
||||
elem->value = info;
|
||||
elem->next = NULL;
|
||||
if (prev) {
|
||||
prev->next = elem;
|
||||
} else {
|
||||
list = elem;
|
||||
}
|
||||
prev = elem;
|
||||
QAPI_LIST_APPEND(tail, info);
|
||||
}
|
||||
|
||||
g_slist_free(devices);
|
||||
|
|
60
hw/pci/pci.c
60
hw/pci/pci.c
|
@ -1683,41 +1683,34 @@ static PciDeviceInfoList *qmp_query_pci_devices(PCIBus *bus, int bus_num);
|
|||
|
||||
static PciMemoryRegionList *qmp_query_pci_regions(const PCIDevice *dev)
|
||||
{
|
||||
PciMemoryRegionList *head = NULL, *cur_item = NULL;
|
||||
PciMemoryRegionList *head = NULL, **tail = &head;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < PCI_NUM_REGIONS; i++) {
|
||||
const PCIIORegion *r = &dev->io_regions[i];
|
||||
PciMemoryRegionList *region;
|
||||
PciMemoryRegion *region;
|
||||
|
||||
if (!r->size) {
|
||||
continue;
|
||||
}
|
||||
|
||||
region = g_malloc0(sizeof(*region));
|
||||
region->value = g_malloc0(sizeof(*region->value));
|
||||
|
||||
if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
|
||||
region->value->type = g_strdup("io");
|
||||
region->type = g_strdup("io");
|
||||
} else {
|
||||
region->value->type = g_strdup("memory");
|
||||
region->value->has_prefetch = true;
|
||||
region->value->prefetch = !!(r->type & PCI_BASE_ADDRESS_MEM_PREFETCH);
|
||||
region->value->has_mem_type_64 = true;
|
||||
region->value->mem_type_64 = !!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64);
|
||||
region->type = g_strdup("memory");
|
||||
region->has_prefetch = true;
|
||||
region->prefetch = !!(r->type & PCI_BASE_ADDRESS_MEM_PREFETCH);
|
||||
region->has_mem_type_64 = true;
|
||||
region->mem_type_64 = !!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64);
|
||||
}
|
||||
|
||||
region->value->bar = i;
|
||||
region->value->address = r->addr;
|
||||
region->value->size = r->size;
|
||||
region->bar = i;
|
||||
region->address = r->addr;
|
||||
region->size = r->size;
|
||||
|
||||
/* XXX: waiting for the qapi to support GSList */
|
||||
if (!cur_item) {
|
||||
head = cur_item = region;
|
||||
} else {
|
||||
cur_item->next = region;
|
||||
cur_item = region;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail, region);
|
||||
}
|
||||
|
||||
return head;
|
||||
|
@ -1814,23 +1807,14 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus,
|
|||
|
||||
static PciDeviceInfoList *qmp_query_pci_devices(PCIBus *bus, int bus_num)
|
||||
{
|
||||
PciDeviceInfoList *info, *head = NULL, *cur_item = NULL;
|
||||
PciDeviceInfoList *head = NULL, **tail = &head;
|
||||
PCIDevice *dev;
|
||||
int devfn;
|
||||
|
||||
for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
|
||||
dev = bus->devices[devfn];
|
||||
if (dev) {
|
||||
info = g_malloc0(sizeof(*info));
|
||||
info->value = qmp_query_pci_device(dev, bus, bus_num);
|
||||
|
||||
/* XXX: waiting for the qapi to support GSList */
|
||||
if (!cur_item) {
|
||||
head = cur_item = info;
|
||||
} else {
|
||||
cur_item->next = info;
|
||||
cur_item = info;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail, qmp_query_pci_device(dev, bus, bus_num));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1853,21 +1837,13 @@ static PciInfo *qmp_query_pci_bus(PCIBus *bus, int bus_num)
|
|||
|
||||
PciInfoList *qmp_query_pci(Error **errp)
|
||||
{
|
||||
PciInfoList *info, *head = NULL, *cur_item = NULL;
|
||||
PciInfoList *head = NULL, **tail = &head;
|
||||
PCIHostState *host_bridge;
|
||||
|
||||
QLIST_FOREACH(host_bridge, &pci_host_bridges, next) {
|
||||
info = g_malloc0(sizeof(*info));
|
||||
info->value = qmp_query_pci_bus(host_bridge->bus,
|
||||
pci_bus_num(host_bridge->bus));
|
||||
|
||||
/* XXX: waiting for the qapi to support GSList */
|
||||
if (!cur_item) {
|
||||
head = cur_item = info;
|
||||
} else {
|
||||
cur_item->next = info;
|
||||
cur_item = info;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail,
|
||||
qmp_query_pci_bus(host_bridge->bus,
|
||||
pci_bus_num(host_bridge->bus)));
|
||||
}
|
||||
|
||||
return head;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue