示例#1
0
void visit_type_PciDeviceInfo(Visitor *m, PciDeviceInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "PciDeviceInfo", name, sizeof(PciDeviceInfo), errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->bus : NULL, "bus", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->slot : NULL, "slot", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->function : NULL, "function", errp);
    visit_start_struct(m, NULL, "", "class_info", 0, errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->class_info.has_desc : NULL, "desc", errp);
    if ((*obj)->class_info.has_desc) {
        visit_type_str(m, (obj && *obj) ? &(*obj)->class_info.desc : NULL, "desc", errp);
    }
    visit_end_optional(m, errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->class_info.class : NULL, "class", errp);
    visit_end_struct(m, errp);
    visit_start_struct(m, NULL, "", "id", 0, errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->id.device : NULL, "device", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->id.vendor : NULL, "vendor", errp);
    visit_end_struct(m, errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_irq : NULL, "irq", errp);
    if ((*obj)->has_irq) {
        visit_type_int(m, (obj && *obj) ? &(*obj)->irq : NULL, "irq", errp);
    }
    visit_end_optional(m, errp);
    visit_type_str(m, (obj && *obj) ? &(*obj)->qdev_id : NULL, "qdev_id", errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_pci_bridge : NULL, "pci_bridge", errp);
    if ((*obj)->has_pci_bridge) {
        visit_type_PciBridgeInfo(m, (obj && *obj) ? &(*obj)->pci_bridge : NULL, "pci_bridge", errp);
    }
    visit_end_optional(m, errp);
    visit_type_PciMemoryRegionList(m, (obj && *obj) ? &(*obj)->regions : NULL, "regions", errp);
    visit_end_struct(m, errp);
}
示例#2
0
static void balloon_stats_get_all(Object *obj, struct Visitor *v,
                                  void *opaque, const char *name, Error **errp)
{
    Error *err = NULL;
    VirtIOBalloon *s = opaque;
    int i;

    visit_start_struct(v, NULL, "guest-stats", name, 0, &err);
    if (err) {
        goto out;
    }
    visit_type_int(v, &s->stats_last_update, "last-update", &err);
    if (err) {
        goto out_end;
    }

    visit_start_struct(v, NULL, NULL, "stats", 0, &err);
    if (err) {
        goto out_end;
    }
    for (i = 0; !err && i < VIRTIO_BALLOON_S_NR; i++) {
        visit_type_int64(v, (int64_t *) &s->stats[i], balloon_stat_names[i],
                         &err);
    }
    error_propagate(errp, err);
    err = NULL;
    visit_end_struct(v, &err);

out_end:
    error_propagate(errp, err);
    err = NULL;
    visit_end_struct(v, &err);
out:
    error_propagate(errp, err);
}
示例#3
0
void visit_type_VersionInfo(Visitor *m, VersionInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "VersionInfo", name, sizeof(VersionInfo), errp);
    visit_start_struct(m, NULL, "", "qemu", 0, errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->qemu.major : NULL, "major", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->qemu.minor : NULL, "minor", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->qemu.micro : NULL, "micro", errp);
    visit_end_struct(m, errp);
    visit_type_str(m, (obj && *obj) ? &(*obj)->package : NULL, "package", errp);
    visit_end_struct(m, errp);
}
static void visit_type_TestStruct(Visitor *v, TestStruct **obj,
                                  const char *name, Error **errp)
{
    Error *err = NULL;

    visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct),
                       &err);
    if (err) {
        goto out;
    }
    visit_type_int(v, &(*obj)->integer, "integer", &err);
    if (err) {
        goto out_end;
    }
    visit_type_bool(v, &(*obj)->boolean, "boolean", &err);
    if (err) {
        goto out_end;
    }
    visit_type_str(v, &(*obj)->string, "string", &err);

out_end:
    error_propagate(errp, err);
    err = NULL;
    visit_end_struct(v, &err);
out:
    error_propagate(errp, err);
}
示例#5
0
void visit_type_KvmInfo(Visitor *m, KvmInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "KvmInfo", name, sizeof(KvmInfo), errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->enabled : NULL, "enabled", errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->present : NULL, "present", errp);
    visit_end_struct(m, errp);
}
示例#6
0
void visit_type_PciMemoryRange(Visitor *m, PciMemoryRange ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "PciMemoryRange", name, sizeof(PciMemoryRange), errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->base : NULL, "base", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->limit : NULL, "limit", errp);
    visit_end_struct(m, errp);
}
示例#7
0
void visit_type_VncInfo(Visitor *m, VncInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "VncInfo", name, sizeof(VncInfo), errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->enabled : NULL, "enabled", errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_host : NULL, "host", errp);
    if ((*obj)->has_host) {
        visit_type_str(m, (obj && *obj) ? &(*obj)->host : NULL, "host", errp);
    }
    visit_end_optional(m, errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_family : NULL, "family", errp);
    if ((*obj)->has_family) {
        visit_type_str(m, (obj && *obj) ? &(*obj)->family : NULL, "family", errp);
    }
    visit_end_optional(m, errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_service : NULL, "service", errp);
    if ((*obj)->has_service) {
        visit_type_str(m, (obj && *obj) ? &(*obj)->service : NULL, "service", errp);
    }
    visit_end_optional(m, errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_auth : NULL, "auth", errp);
    if ((*obj)->has_auth) {
        visit_type_str(m, (obj && *obj) ? &(*obj)->auth : NULL, "auth", errp);
    }
    visit_end_optional(m, errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_clients : NULL, "clients", errp);
    if ((*obj)->has_clients) {
        visit_type_VncClientInfoList(m, (obj && *obj) ? &(*obj)->clients : NULL, "clients", errp);
    }
    visit_end_optional(m, errp);
    visit_end_struct(m, errp);
}
示例#8
0
void visit_type_ChardevInfo(Visitor *m, ChardevInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "ChardevInfo", name, sizeof(ChardevInfo), errp);
    visit_type_str(m, (obj && *obj) ? &(*obj)->label : NULL, "label", errp);
    visit_type_str(m, (obj && *obj) ? &(*obj)->filename : NULL, "filename", errp);
    visit_end_struct(m, errp);
}
示例#9
0
static void visit_type_TestStruct(Visitor *v, TestStruct **obj, const char *name, Error **errp)
{
    visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct), errp);
    visit_type_int(v, &(*obj)->x, "x", errp);
    visit_type_int(v, &(*obj)->y, "y", errp);
    visit_end_struct(v, errp);
}
示例#10
0
static void test_visitor_in_null(TestInputVisitorData *data,
                                 const void *unused)
{
    Visitor *v;
    Error *err = NULL;
    char *tmp;

    /*
     * FIXME: Since QAPI doesn't know the 'null' type yet, we can't
     * test visit_type_null() by reading into a QAPI struct then
     * checking that it was populated correctly.  The best we can do
     * for now is ensure that we consumed null from the input, proven
     * by the fact that we can't re-read the key; and that we detect
     * when input is not null.
     */

    v = visitor_input_test_init(data, "{ 'a': null, 'b': '' }");
    visit_start_struct(v, NULL, NULL, 0, &error_abort);
    visit_type_null(v, "a", &error_abort);
    visit_type_str(v, "a", &tmp, &err);
    g_assert(!tmp);
    error_free_or_abort(&err);
    visit_type_null(v, "b", &err);
    error_free_or_abort(&err);
    visit_check_struct(v, &error_abort);
    visit_end_struct(v, NULL);
}
示例#11
0
void visit_type_PciInfo(Visitor *m, PciInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "PciInfo", name, sizeof(PciInfo), errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->bus : NULL, "bus", errp);
    visit_type_PciDeviceInfoList(m, (obj && *obj) ? &(*obj)->devices : NULL, "devices", errp);
    visit_end_struct(m, errp);
}
示例#12
0
void visit_type_CpuInfo(Visitor *m, CpuInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "CpuInfo", name, sizeof(CpuInfo), errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->CPU : NULL, "CPU", errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->current : NULL, "current", errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->halted : NULL, "halted", errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_pc : NULL, "pc", errp);
    if ((*obj)->has_pc) {
        visit_type_int(m, (obj && *obj) ? &(*obj)->pc : NULL, "pc", errp);
    }
    visit_end_optional(m, errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_nip : NULL, "nip", errp);
    if ((*obj)->has_nip) {
        visit_type_int(m, (obj && *obj) ? &(*obj)->nip : NULL, "nip", errp);
    }
    visit_end_optional(m, errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_npc : NULL, "npc", errp);
    if ((*obj)->has_npc) {
        visit_type_int(m, (obj && *obj) ? &(*obj)->npc : NULL, "npc", errp);
    }
    visit_end_optional(m, errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_PC : NULL, "PC", errp);
    if ((*obj)->has_PC) {
        visit_type_int(m, (obj && *obj) ? &(*obj)->PC : NULL, "PC", errp);
    }
    visit_end_optional(m, errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->thread_id : NULL, "thread_id", errp);
    visit_end_struct(m, errp);
}
示例#13
0
void visit_type_MigrationStats(Visitor *m, MigrationStats ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "MigrationStats", name, sizeof(MigrationStats), errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->transferred : NULL, "transferred", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->remaining : NULL, "remaining", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->total : NULL, "total", errp);
    visit_end_struct(m, errp);
}
示例#14
0
void visit_type_StatusInfo(Visitor *m, StatusInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "StatusInfo", name, sizeof(StatusInfo), errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->running : NULL, "running", errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->singlestep : NULL, "singlestep", errp);
    visit_type_RunState(m, (obj && *obj) ? &(*obj)->status : NULL, "status", errp);
    visit_end_struct(m, errp);
}
示例#15
0
void visit_type_PciBridgeInfo(Visitor *m, PciBridgeInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "PciBridgeInfo", name, sizeof(PciBridgeInfo), errp);
    visit_start_struct(m, NULL, "", "bus", 0, errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->bus.number : NULL, "number", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->bus.secondary : NULL, "secondary", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->bus.subordinate : NULL, "subordinate", errp);
    visit_type_PciMemoryRange(m, (obj && *obj) ? &(*obj)->bus.io_range : NULL, "io_range", errp);
    visit_type_PciMemoryRange(m, (obj && *obj) ? &(*obj)->bus.memory_range : NULL, "memory_range", errp);
    visit_type_PciMemoryRange(m, (obj && *obj) ? &(*obj)->bus.prefetchable_range : NULL, "prefetchable_range", errp);
    visit_end_struct(m, errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_devices : NULL, "devices", errp);
    if ((*obj)->has_devices) {
        visit_type_PciDeviceInfoList(m, (obj && *obj) ? &(*obj)->devices : NULL, "devices", errp);
    }
    visit_end_optional(m, errp);
    visit_end_struct(m, errp);
}
示例#16
0
void visit_type_MouseInfo(Visitor *m, MouseInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "MouseInfo", name, sizeof(MouseInfo), errp);
    visit_type_str(m, (obj && *obj) ? &(*obj)->name : NULL, "name", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->index : NULL, "index", errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->current : NULL, "current", errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->absolute : NULL, "absolute", errp);
    visit_end_struct(m, errp);
}
示例#17
0
void visit_type_NameInfo(Visitor *m, NameInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "NameInfo", name, sizeof(NameInfo), errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_name : NULL, "name", errp);
    if ((*obj)->has_name) {
        visit_type_str(m, (obj && *obj) ? &(*obj)->name : NULL, "name", errp);
    }
    visit_end_optional(m, errp);
    visit_end_struct(m, errp);
}
static void visit_type_TestStruct(Visitor *v, TestStruct **obj,
                                  const char *name, Error **errp)
{
    visit_start_struct(v, (void **)obj, NULL, name, sizeof(TestStruct), errp);

    visit_type_int(v, &(*obj)->integer, "integer", errp);
    visit_type_bool(v, &(*obj)->boolean, "boolean", errp);
    visit_type_str(v, &(*obj)->string, "string", errp);

    visit_end_struct(v, errp);
}
示例#19
0
void visit_type_SpiceChannel(Visitor *m, SpiceChannel ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "SpiceChannel", name, sizeof(SpiceChannel), errp);
    visit_type_str(m, (obj && *obj) ? &(*obj)->host : NULL, "host", errp);
    visit_type_str(m, (obj && *obj) ? &(*obj)->family : NULL, "family", errp);
    visit_type_str(m, (obj && *obj) ? &(*obj)->port : NULL, "port", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->connection_id : NULL, "connection-id", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->channel_type : NULL, "channel-type", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->channel_id : NULL, "channel-id", errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->tls : NULL, "tls", errp);
    visit_end_struct(m, errp);
}
示例#20
0
static void prop_get_fdt(Object *obj, Visitor *v, void *opaque,
                        const char *name, Error **errp)
{
    sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj);
    int fdt_offset_next, fdt_offset, fdt_depth;
    void *fdt;

    if (!drc->fdt) {
        return;
    }

    fdt = drc->fdt;
    fdt_offset = drc->fdt_start_offset;
    fdt_depth = 0;

    do {
        const char *name = NULL;
        const struct fdt_property *prop = NULL;
        int prop_len = 0, name_len = 0;
        uint32_t tag;

        tag = fdt_next_tag(fdt, fdt_offset, &fdt_offset_next);
        switch (tag) {
        case FDT_BEGIN_NODE:
            fdt_depth++;
            name = fdt_get_name(fdt, fdt_offset, &name_len);
            visit_start_struct(v, NULL, NULL, name, 0, NULL);
            break;
        case FDT_END_NODE:
            /* shouldn't ever see an FDT_END_NODE before FDT_BEGIN_NODE */
            g_assert(fdt_depth > 0);
            visit_end_struct(v, NULL);
            fdt_depth--;
            break;
        case FDT_PROP: {
            int i;
            prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len);
            name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
            visit_start_list(v, name, NULL);
            for (i = 0; i < prop_len; i++) {
                visit_type_uint8(v, (uint8_t *)&prop->data[i], NULL, NULL);

            }
            visit_end_list(v, NULL);
            break;
        }
        default:
            error_setg(&error_abort, "device FDT in unexpected state: %d", tag);
        }
        fdt_offset = fdt_offset_next;
    } while (fdt_depth != 0);
}
示例#21
0
static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
{
    Error *err = NULL;
    VirtIOBalloon *s = opaque;
    int i;

    visit_start_struct(v, name, NULL, 0, &err);
    if (err) {
        goto out;
    }
    visit_type_int(v, "last-update", &s->stats_last_update, &err);
    if (err) {
        goto out_end;
    }

    visit_start_struct(v, "stats", NULL, 0, &err);
    if (err) {
        goto out_end;
    }
    for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) {
        visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], &err);
        if (err) {
            goto out_nested;
        }
    }
    visit_check_struct(v, &err);
out_nested:
    visit_end_struct(v, NULL);

    if (!err) {
        visit_check_struct(v, &err);
    }
out_end:
    visit_end_struct(v, NULL);
out:
    error_propagate(errp, err);
}
示例#22
0
static void balloon_stats_get_all(Object *obj, struct Visitor *v,
                                  void *opaque, const char *name, Error **errp)
{
    VirtIOBalloon *s = opaque;
    int i;

    if (!s->stats_last_update) {
        error_setg(errp, "guest hasn't updated any stats yet");
        return;
    }

    visit_start_struct(v, NULL, "guest-stats", name, 0, errp);
    visit_type_int(v, &s->stats_last_update, "last-update", errp);

    visit_start_struct(v, NULL, NULL, "stats", 0, errp);
    for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) {
        visit_type_int64(v, (int64_t *) &s->stats[i], balloon_stat_names[i],
                         errp);
    }
    visit_end_struct(v, errp);

    visit_end_struct(v, errp);
}
示例#23
0
void visit_type_BlockDeviceInfo(Visitor *m, BlockDeviceInfo ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "BlockDeviceInfo", name, sizeof(BlockDeviceInfo), errp);
    visit_type_str(m, (obj && *obj) ? &(*obj)->file : NULL, "file", errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->ro : NULL, "ro", errp);
    visit_type_str(m, (obj && *obj) ? &(*obj)->drv : NULL, "drv", errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_backing_file : NULL, "backing_file", errp);
    if ((*obj)->has_backing_file) {
        visit_type_str(m, (obj && *obj) ? &(*obj)->backing_file : NULL, "backing_file", errp);
    }
    visit_end_optional(m, errp);
    visit_type_bool(m, (obj && *obj) ? &(*obj)->encrypted : NULL, "encrypted", errp);
    visit_end_struct(m, errp);
}
示例#24
0
void visit_type_BlockDeviceStats(Visitor *m, BlockDeviceStats ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "BlockDeviceStats", name, sizeof(BlockDeviceStats), errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->rd_bytes : NULL, "rd_bytes", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->wr_bytes : NULL, "wr_bytes", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->rd_operations : NULL, "rd_operations", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->wr_operations : NULL, "wr_operations", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->flush_operations : NULL, "flush_operations", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->flush_total_time_ns : NULL, "flush_total_time_ns", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->wr_total_time_ns : NULL, "wr_total_time_ns", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->rd_total_time_ns : NULL, "rd_total_time_ns", errp);
    visit_type_int(m, (obj && *obj) ? &(*obj)->wr_highest_offset : NULL, "wr_highest_offset", errp);
    visit_end_struct(m, errp);
}
示例#25
0
static void rtc_get_date(DeviceState *dev, Visitor *v, void *opaque,
                         const char *name, Error **errp)
{
    ISADevice *isa = ISA_DEVICE(dev);
    RTCState *s = DO_UPCAST(RTCState, dev, isa);

    visit_start_struct(v, NULL, "struct tm", name, 0, errp);
    visit_type_int32(v, &s->current_tm.tm_year, "tm_year", errp);
    visit_type_int32(v, &s->current_tm.tm_mon, "tm_mon", errp);
    visit_type_int32(v, &s->current_tm.tm_mday, "tm_mday", errp);
    visit_type_int32(v, &s->current_tm.tm_hour, "tm_hour", errp);
    visit_type_int32(v, &s->current_tm.tm_min, "tm_min", errp);
    visit_type_int32(v, &s->current_tm.tm_sec, "tm_sec", errp);
    visit_end_struct(v, errp);
}
示例#26
0
Object *user_creatable_add(const QDict *qdict,
                           Visitor *v, Error **errp)
{
    char *type = NULL;
    char *id = NULL;
    Object *obj = NULL;
    Error *local_err = NULL;
    QDict *pdict;

    pdict = qdict_clone_shallow(qdict);

    visit_start_struct(v, NULL, NULL, 0, &local_err);
    if (local_err) {
        goto out;
    }

    qdict_del(pdict, "qom-type");
    visit_type_str(v, "qom-type", &type, &local_err);
    if (local_err) {
        goto out_visit;
    }

    qdict_del(pdict, "id");
    visit_type_str(v, "id", &id, &local_err);
    if (local_err) {
        goto out_visit;
    }
    visit_check_struct(v, &local_err);
    if (local_err) {
        goto out_visit;
    }

    obj = user_creatable_add_type(type, id, pdict, v, &local_err);

out_visit:
    visit_end_struct(v, NULL);

out:
    QDECREF(pdict);
    g_free(id);
    g_free(type);
    if (local_err) {
        error_propagate(errp, local_err);
        object_unref(obj);
        return NULL;
    }
    return obj;
}
示例#27
0
void visit_type_BlockStats(Visitor *m, BlockStats ** obj, const char *name, Error **errp)
{
    visit_start_struct(m, (void **)obj, "BlockStats", name, sizeof(BlockStats), errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_device : NULL, "device", errp);
    if ((*obj)->has_device) {
        visit_type_str(m, (obj && *obj) ? &(*obj)->device : NULL, "device", errp);
    }
    visit_end_optional(m, errp);
    visit_type_BlockDeviceStats(m, (obj && *obj) ? &(*obj)->stats : NULL, "stats", errp);
    visit_start_optional(m, (obj && *obj) ? &(*obj)->has_parent : NULL, "parent", errp);
    if ((*obj)->has_parent) {
        visit_type_BlockStats(m, (obj && *obj) ? &(*obj)->parent : NULL, "parent", errp);
    }
    visit_end_optional(m, errp);
    visit_end_struct(m, errp);
}
示例#28
0
void visit_type_GuestAgentInfo(Visitor *m, GuestAgentInfo ** obj, const char *name, Error **errp)
{
    if (!error_is_set(errp)) {
        Error *err = NULL;
        visit_start_struct(m, (void **)obj, "GuestAgentInfo", name, sizeof(GuestAgentInfo), &err);
        if (!err) {
            if (!obj || *obj) {
                visit_type_GuestAgentInfo_fields(m, obj, &err);
                error_propagate(errp, err);
                err = NULL;
            }
            /* Always call end_struct if start_struct succeeded.  */
            visit_end_struct(m, &err);
        }
        error_propagate(errp, err);
    }
}
示例#29
0
static void rtc_get_date(Object *obj, Visitor *v, void *opaque,
                         const char *name, Error **errp)
{
    RTCState *s = MC146818_RTC(obj);
    struct tm current_tm;

    rtc_update_time(s);
    rtc_get_time(s, &current_tm);
    visit_start_struct(v, NULL, "struct tm", name, 0, errp);
    visit_type_int32(v, &current_tm.tm_year, "tm_year", errp);
    visit_type_int32(v, &current_tm.tm_mon, "tm_mon", errp);
    visit_type_int32(v, &current_tm.tm_mday, "tm_mday", errp);
    visit_type_int32(v, &current_tm.tm_hour, "tm_hour", errp);
    visit_type_int32(v, &current_tm.tm_min, "tm_min", errp);
    visit_type_int32(v, &current_tm.tm_sec, "tm_sec", errp);
    visit_end_struct(v, errp);
}
示例#30
0
static QCryptoBlockCreateOptions *
block_crypto_create_opts_init(QCryptoBlockFormat format,
                              QemuOpts *opts,
                              Error **errp)
{
    OptsVisitor *ov;
    QCryptoBlockCreateOptions *ret = NULL;
    Error *local_err = NULL;

    ret = g_new0(QCryptoBlockCreateOptions, 1);
    ret->format = format;

    ov = opts_visitor_new(opts);

    visit_start_struct(opts_get_visitor(ov),
                       NULL, NULL, 0, &local_err);
    if (local_err) {
        goto out;
    }

    switch (format) {
    case Q_CRYPTO_BLOCK_FORMAT_LUKS:
        visit_type_QCryptoBlockCreateOptionsLUKS_members(
            opts_get_visitor(ov), &ret->u.luks, &local_err);
        break;

    default:
        error_setg(&local_err, "Unsupported block format %d", format);
        break;
    }
    if (!local_err) {
        visit_check_struct(opts_get_visitor(ov), &local_err);
    }

    visit_end_struct(opts_get_visitor(ov));

 out:
    if (local_err) {
        error_propagate(errp, local_err);
        qapi_free_QCryptoBlockCreateOptions(ret);
        ret = NULL;
    }
    opts_visitor_cleanup(ov);
    return ret;
}