void smbios_entry_add(QemuOpts *opts)

{

    Error *local_err = NULL;

    const char *val;



    assert(!smbios_immutable);

    val = qemu_opt_get(opts, "file");

    if (val) {

        struct smbios_structure_header *header;

        struct smbios_table *table;

        int size;



        qemu_opts_validate(opts, qemu_smbios_file_opts, &local_err);

        if (local_err) {

            error_report("%s", error_get_pretty(local_err));

            exit(1);

        }



        size = get_image_size(val);

        if (size == -1 || size < sizeof(struct smbios_structure_header)) {

            error_report("Cannot read SMBIOS file %s", val);

            exit(1);

        }



        if (!smbios_entries) {

            smbios_entries_len = sizeof(uint16_t);

            smbios_entries = g_malloc0(smbios_entries_len);

        }



        smbios_entries = g_realloc(smbios_entries, smbios_entries_len +

                                                      sizeof(*table) + size);

        table = (struct smbios_table *)(smbios_entries + smbios_entries_len);

        table->header.type = SMBIOS_TABLE_ENTRY;

        table->header.length = cpu_to_le16(sizeof(*table) + size);



        if (load_image(val, table->data) != size) {

            error_report("Failed to load SMBIOS file %s", val);

            exit(1);

        }



        header = (struct smbios_structure_header *)(table->data);



        if (test_bit(header->type, have_fields_bitmap)) {

            error_report("can't load type %d struct, fields already specified!",

                         header->type);

            exit(1);

        }

        set_bit(header->type, have_binfile_bitmap);



        if (header->type == 4) {

            smbios_type4_count++;

        }



        smbios_entries_len += sizeof(*table) + size;

        (*(uint16_t *)smbios_entries) =

                cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);

        return;

    }



    val = qemu_opt_get(opts, "type");

    if (val) {

        unsigned long type = strtoul(val, NULL, 0);



        if (type > SMBIOS_MAX_TYPE) {

            error_report("out of range!");

            exit(1);

        }



        if (test_bit(type, have_binfile_bitmap)) {

            error_report("can't add fields, binary file already loaded!");

            exit(1);

        }

        set_bit(type, have_fields_bitmap);



        switch (type) {

        case 0:

            qemu_opts_validate(opts, qemu_smbios_type0_opts, &local_err);

            if (local_err) {

                error_report("%s", error_get_pretty(local_err));

                exit(1);

            }

            save_opt(&type0.vendor, opts, "vendor");

            save_opt(&type0.version, opts, "version");

            save_opt(&type0.date, opts, "date");



            val = qemu_opt_get(opts, "release");

            if (val) {

                if (sscanf(val, "%hhu.%hhu", &type0.major, &type0.minor) != 2) {

                    error_report("Invalid release");

                    exit(1);

                }

                type0.have_major_minor = true;

            }

            return;

        case 1:

            qemu_opts_validate(opts, qemu_smbios_type1_opts, &local_err);

            if (local_err) {

                error_report("%s", error_get_pretty(local_err));

                exit(1);

            }

            save_opt(&type1.manufacturer, opts, "manufacturer");

            save_opt(&type1.product, opts, "product");

            save_opt(&type1.version, opts, "version");

            save_opt(&type1.serial, opts, "serial");

            save_opt(&type1.sku, opts, "sku");

            save_opt(&type1.family, opts, "family");



            val = qemu_opt_get(opts, "uuid");

            if (val) {

                if (qemu_uuid_parse(val, qemu_uuid) != 0) {

                    error_report("Invalid UUID");

                    exit(1);

                }

                qemu_uuid_set = true;

            }

            return;

        default:

            error_report("Don't know how to build fields for SMBIOS type %ld",

                         type);

            exit(1);

        }

    }



    error_report("Must specify type= or file=");

    exit(1);

}

void smbios_entry_add(QemuOpts *opts)

{

    Error *local_err = NULL;

    const char *val;



    assert(!smbios_immutable);

    val = qemu_opt_get(opts, "file");

    if (val) {

        struct smbios_structure_header *header;

        struct smbios_table *table;

        int size;



        qemu_opts_validate(opts, qemu_smbios_file_opts, &local_err);

        if (local_err) {

            error_report("%s", error_get_pretty(local_err));

            exit(1);

        }



        size = get_image_size(val);

        if (size == -1 || size < sizeof(struct smbios_structure_header)) {

            error_report("Cannot read SMBIOS file %s", val);

            exit(1);

        }



        if (!smbios_entries) {

            smbios_entries_len = sizeof(uint16_t);

            smbios_entries = g_malloc0(smbios_entries_len);

        }



        smbios_entries = g_realloc(smbios_entries, smbios_entries_len +

                                                      sizeof(*table) + size);

        table = (struct smbios_table *)(smbios_entries + smbios_entries_len);

        table->header.type = SMBIOS_TABLE_ENTRY;

        table->header.length = cpu_to_le16(sizeof(*table) + size);



        if (load_image(val, table->data) != size) {

            error_report("Failed to load SMBIOS file %s", val);

            exit(1);

        }



        header = (struct smbios_structure_header *)(table->data);



        if (test_bit(header->type, have_fields_bitmap)) {

            error_report("can't load type %d struct, fields already specified!",

                         header->type);

            exit(1);

        }

        set_bit(header->type, have_binfile_bitmap);



        if (header->type == 4) {

            smbios_type4_count++;

        }



        smbios_entries_len += sizeof(*table) + size;

        (*(uint16_t *)smbios_entries) =

                cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);

        return;

    }



    val = qemu_opt_get(opts, "type");

    if (val) {

        unsigned long type = strtoul(val, NULL, 0);



        if (type > SMBIOS_MAX_TYPE) {

            error_report("out of range!");

            exit(1);

        }



        if (test_bit(type, have_binfile_bitmap)) {

            error_report("can't add fields, binary file already loaded!");

            exit(1);

        }

        set_bit(type, have_fields_bitmap);



        switch (type) {

        case 0:

            qemu_opts_validate(opts, qemu_smbios_type0_opts, &local_err);

            if (local_err) {

                error_report("%s", error_get_pretty(local_err));

                exit(1);

            }

            save_opt(&type0.vendor, opts, "vendor");

            save_opt(&type0.version, opts, "version");

            save_opt(&type0.date, opts, "date");



            val = qemu_opt_get(opts, "release");

            if (val) {

                if (sscanf(val, "%hhu.%hhu", &type0.major, &type0.minor) != 2) {

                    error_report("Invalid release");

                    exit(1);

                }

                type0.have_major_minor = true;

            }

            return;

        case 1:

            qemu_opts_validate(opts, qemu_smbios_type1_opts, &local_err);

            if (local_err) {

                error_report("%s", error_get_pretty(local_err));

                exit(1);

            }

            save_opt(&type1.manufacturer, opts, "manufacturer");

            save_opt(&type1.product, opts, "product");

            save_opt(&type1.version, opts, "version");

            save_opt(&type1.serial, opts, "serial");

            save_opt(&type1.sku, opts, "sku");

            save_opt(&type1.family, opts, "family");



            val = qemu_opt_get(opts, "uuid");

            if (val) {

                if (qemu_uuid_parse(val, qemu_uuid) != 0) {

                    error_report("Invalid UUID");

                    exit(1);

                }

                qemu_uuid_set = true;

            }

            return;

        default:

            error_report("Don't know how to build fields for SMBIOS type %ld",

                         type);

            exit(1);

        }

    }



    error_report("Must specify type= or file=");

    exit(1);

}

void FUNC_0(QemuOpts *VAR_0)

{

    Error *local_err = NULL;

    const char *VAR_1;



    assert(!smbios_immutable);

    VAR_1 = qemu_opt_get(VAR_0, "file");

    if (VAR_1) {

        struct smbios_structure_header *VAR_2;

        struct smbios_table *VAR_3;

        int VAR_4;



        qemu_opts_validate(VAR_0, qemu_smbios_file_opts, &local_err);

        if (local_err) {

            error_report("%s", error_get_pretty(local_err));

            exit(1);

        }



        VAR_4 = get_image_size(VAR_1);

        if (VAR_4 == -1 || VAR_4 < sizeof(struct smbios_structure_header)) {

            error_report("Cannot read SMBIOS file %s", VAR_1);

            exit(1);

        }



        if (!smbios_entries) {

            smbios_entries_len = sizeof(uint16_t);

            smbios_entries = g_malloc0(smbios_entries_len);

        }



        smbios_entries = g_realloc(smbios_entries, smbios_entries_len +

                                                      sizeof(*VAR_3) + VAR_4);

        VAR_3 = (struct smbios_table *)(smbios_entries + smbios_entries_len);

        VAR_3->VAR_2.VAR_5 = SMBIOS_TABLE_ENTRY;

        VAR_3->VAR_2.length = cpu_to_le16(sizeof(*VAR_3) + VAR_4);



        if (load_image(VAR_1, VAR_3->data) != VAR_4) {

            error_report("Failed to load SMBIOS file %s", VAR_1);

            exit(1);

        }



        VAR_2 = (struct smbios_structure_header *)(VAR_3->data);



        if (test_bit(VAR_2->VAR_5, have_fields_bitmap)) {

            error_report("can't load VAR_5 %d struct, fields already specified!",

                         VAR_2->VAR_5);

            exit(1);

        }

        set_bit(VAR_2->VAR_5, have_binfile_bitmap);



        if (VAR_2->VAR_5 == 4) {

            smbios_type4_count++;

        }



        smbios_entries_len += sizeof(*VAR_3) + VAR_4;

        (*(uint16_t *)smbios_entries) =

                cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);

        return;

    }



    VAR_1 = qemu_opt_get(VAR_0, "VAR_5");

    if (VAR_1) {

        unsigned long VAR_5 = strtoul(VAR_1, NULL, 0);



        if (VAR_5 > SMBIOS_MAX_TYPE) {

            error_report("out of range!");

            exit(1);

        }



        if (test_bit(VAR_5, have_binfile_bitmap)) {

            error_report("can't add fields, binary file already loaded!");

            exit(1);

        }

        set_bit(VAR_5, have_fields_bitmap);



        switch (VAR_5) {

        case 0:

            qemu_opts_validate(VAR_0, qemu_smbios_type0_opts, &local_err);

            if (local_err) {

                error_report("%s", error_get_pretty(local_err));

                exit(1);

            }

            save_opt(&type0.vendor, VAR_0, "vendor");

            save_opt(&type0.version, VAR_0, "version");

            save_opt(&type0.date, VAR_0, "date");



            VAR_1 = qemu_opt_get(VAR_0, "release");

            if (VAR_1) {

                if (sscanf(VAR_1, "%hhu.%hhu", &type0.major, &type0.minor) != 2) {

                    error_report("Invalid release");

                    exit(1);

                }

                type0.have_major_minor = true;

            }

            return;

        case 1:

            qemu_opts_validate(VAR_0, qemu_smbios_type1_opts, &local_err);

            if (local_err) {

                error_report("%s", error_get_pretty(local_err));

                exit(1);

            }

            save_opt(&type1.manufacturer, VAR_0, "manufacturer");

            save_opt(&type1.product, VAR_0, "product");

            save_opt(&type1.version, VAR_0, "version");

            save_opt(&type1.serial, VAR_0, "serial");

            save_opt(&type1.sku, VAR_0, "sku");

            save_opt(&type1.family, VAR_0, "family");



            VAR_1 = qemu_opt_get(VAR_0, "uuid");

            if (VAR_1) {

                if (qemu_uuid_parse(VAR_1, qemu_uuid) != 0) {

                    error_report("Invalid UUID");

                    exit(1);

                }

                qemu_uuid_set = true;

            }

            return;

        default:

            error_report("Don't know how to build fields for SMBIOS VAR_5 %ld",

                         VAR_5);

            exit(1);

        }

    }



    error_report("Must specify VAR_5= or file=");

    exit(1);

}

void FUNC_0(QemuOpts *VAR_0)
{ Error *local_err = NULL; const char *VAR_1; assert(!smbios_immutable); VAR_1 = qemu_opt_get(VAR_0, "file"); if (VAR_1) { struct smbios_structure_header *VAR_2; struct smbios_table *VAR_3; int VAR_4; qemu_opts_validate(VAR_0, qemu_smbios_file_opts, &local_err); if (local_err) { error_report("%s", error_get_pretty(local_err)); exit(1); } VAR_4 = get_image_size(VAR_1); if (VAR_4 == -1 || VAR_4 < sizeof(struct smbios_structure_header)) { error_report("Cannot read SMBIOS file %s", VAR_1); exit(1); } if (!smbios_entries) { smbios_entries_len = sizeof(uint16_t); smbios_entries = g_malloc0(smbios_entries_len); } smbios_entries = g_realloc(smbios_entries, smbios_entries_len +
sizeof(*VAR_3) + VAR_4); VAR_3 = (struct smbios_table *)(smbios_entries + smbios_entries_len); VAR_3->VAR_2.VAR_5 = SMBIOS_TABLE_ENTRY; VAR_3->VAR_2.length = cpu_to_le16(sizeof(*VAR_3) + VAR_4); if (load_image(VAR_1, VAR_3->data) != VAR_4) { error_report("Failed to load SMBIOS file %s", VAR_1); exit(1); } VAR_2 = (struct smbios_structure_header *)(VAR_3->data); if (test_bit(VAR_2->VAR_5, have_fields_bitmap)) { error_report("can't load VAR_5 %d struct, fields already specified!",
VAR_2->VAR_5); exit(1); } set_bit(VAR_2->VAR_5, have_binfile_bitmap); if (VAR_2->VAR_5 == 4) { smbios_type4_count++; } smbios_entries_len += sizeof(*VAR_3) + VAR_4; (*(uint16_t *)smbios_entries) =
cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1); return; } VAR_1 = qemu_opt_get(VAR_0, "VAR_5"); if (VAR_1) { unsigned long VAR_5 = strtoul(VAR_1, NULL, 0); if (VAR_5 > SMBIOS_MAX_TYPE) { error_report("out of range!"); exit(1); } if (test_bit(VAR_5, have_binfile_bitmap)) { error_report("can't add fields, binary file already loaded!"); exit(1); } set_bit(VAR_5, have_fields_bitmap); switch (VAR_5) { case 0:
qemu_opts_validate(VAR_0, qemu_smbios_type0_opts, &local_err); if (local_err) { error_report("%s", error_get_pretty(local_err)); exit(1); } save_opt(&type0.vendor, VAR_0, "vendor"); save_opt(&type0.version, VAR_0, "version"); save_opt(&type0.date, VAR_0, "date"); VAR_1 = qemu_opt_get(VAR_0, "release"); if (VAR_1) { if (sscanf(VAR_1, "%hhu.%hhu", &type0.major, &type0.minor) != 2) { error_report("Invalid release"); exit(1); } type0.have_major_minor = true; } return; case 1:
qemu_opts_validate(VAR_0, qemu_smbios_type1_opts, &local_err); if (local_err) { error_report("%s", error_get_pretty(local_err)); exit(1); } save_opt(&type1.manufacturer, VAR_0, "manufacturer"); save_opt(&type1.product, VAR_0, "product"); save_opt(&type1.version, VAR_0, "version"); save_opt(&type1.serial, VAR_0, "serial"); save_opt(&type1.sku, VAR_0, "sku"); save_opt(&type1.family, VAR_0, "family"); VAR_1 = qemu_opt_get(VAR_0, "uuid"); if (VAR_1) { if (qemu_uuid_parse(VAR_1, qemu_uuid) != 0) { error_report("Invalid UUID"); exit(1); } qemu_uuid_set = true; } return; default:
error_report("Don't know how to build fields for SMBIOS VAR_5 %ld",
VAR_5); exit(1); } } error_report("Must specify VAR_5= or file="); exit(1); }