This same set of functions is used by the qemu, xen, and lxc drivers' connectSysInfo function. --- src/util/virsysinfo.c | 72 ++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index f58122f9..1fa9bef 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -1,7 +1,7 @@ /* * virsysinfo.c: get SMBIOS/sysinfo information from the host * - * Copyright (C) 2010-2013 Red Hat, Inc. + * Copyright (C) 2010-2014 Red Hat, Inc. * Copyright (C) 2010 Daniel Veillard * * This library is free software; you can redistribute it and/or @@ -880,16 +880,18 @@ virSysinfoBIOSFormat(virBufferPtr buf, virSysinfoDefPtr def) !def->bios_date && !def->bios_release) return; - virBufferAddLit(buf, " <bios>\n"); - virBufferEscapeString(buf, " <entry name='vendor'>%s</entry>\n", + virBufferAddLit(buf, "<bios>\n"); + virBufferAdjustIndent(buf, 2); + virBufferEscapeString(buf, "<entry name='vendor'>%s</entry>\n", def->bios_vendor); - virBufferEscapeString(buf, " <entry name='version'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='version'>%s</entry>\n", def->bios_version); - virBufferEscapeString(buf, " <entry name='date'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='date'>%s</entry>\n", def->bios_date); - virBufferEscapeString(buf, " <entry name='release'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='release'>%s</entry>\n", def->bios_release); - virBufferAddLit(buf, " </bios>\n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "</bios>\n"); } static void @@ -900,22 +902,24 @@ virSysinfoSystemFormat(virBufferPtr buf, virSysinfoDefPtr def) !def->system_uuid && !def->system_sku && !def->system_family) return; - virBufferAddLit(buf, " <system>\n"); - virBufferEscapeString(buf, " <entry name='manufacturer'>%s</entry>\n", + virBufferAddLit(buf, "<system>\n"); + virBufferAdjustIndent(buf, 2); + virBufferEscapeString(buf, "<entry name='manufacturer'>%s</entry>\n", def->system_manufacturer); - virBufferEscapeString(buf, " <entry name='product'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='product'>%s</entry>\n", def->system_product); - virBufferEscapeString(buf, " <entry name='version'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='version'>%s</entry>\n", def->system_version); - virBufferEscapeString(buf, " <entry name='serial'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='serial'>%s</entry>\n", def->system_serial); - virBufferEscapeString(buf, " <entry name='uuid'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='uuid'>%s</entry>\n", def->system_uuid); - virBufferEscapeString(buf, " <entry name='sku'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='sku'>%s</entry>\n", def->system_sku); - virBufferEscapeString(buf, " <entry name='family'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='family'>%s</entry>\n", def->system_family); - virBufferAddLit(buf, " </system>\n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "</system>\n"); } static void @@ -940,8 +944,8 @@ virSysinfoProcessorFormat(virBufferPtr buf, virSysinfoDefPtr def) !processor->processor_part_number) continue; - virBufferAddLit(buf, " <processor>\n"); - virBufferAdjustIndent(buf, 4); + virBufferAddLit(buf, "<processor>\n"); + virBufferAdjustIndent(buf, 2); virBufferEscapeString(buf, "<entry name='socket_destination'>%s</entry>\n", processor->processor_socket_destination); @@ -965,8 +969,8 @@ virSysinfoProcessorFormat(virBufferPtr buf, virSysinfoDefPtr def) processor->processor_serial_number); virBufferEscapeString(buf, "<entry name='part_number'>%s</entry>\n", processor->processor_part_number); - virBufferAdjustIndent(buf, -4); - virBufferAddLit(buf, " </processor>\n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "</processor>\n"); } } @@ -991,34 +995,36 @@ virSysinfoMemoryFormat(virBufferPtr buf, virSysinfoDefPtr def) !memory->memory_part_number) continue; - virBufferAddLit(buf, " <memory_device>\n"); - virBufferEscapeString(buf, " <entry name='size'>%s</entry>\n", + virBufferAddLit(buf, "<memory_device>\n"); + virBufferAdjustIndent(buf, 2); + virBufferEscapeString(buf, "<entry name='size'>%s</entry>\n", memory->memory_size); virBufferEscapeString(buf, - " <entry name='form_factor'>%s</entry>\n", + "<entry name='form_factor'>%s</entry>\n", memory->memory_form_factor); - virBufferEscapeString(buf, " <entry name='locator'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='locator'>%s</entry>\n", memory->memory_locator); virBufferEscapeString(buf, - " <entry name='bank_locator'>%s</entry>\n", + "<entry name='bank_locator'>%s</entry>\n", memory->memory_bank_locator); - virBufferEscapeString(buf, " <entry name='type'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='type'>%s</entry>\n", memory->memory_type); virBufferEscapeString(buf, - " <entry name='type_detail'>%s</entry>\n", + "<entry name='type_detail'>%s</entry>\n", memory->memory_type_detail); - virBufferEscapeString(buf, " <entry name='speed'>%s</entry>\n", + virBufferEscapeString(buf, "<entry name='speed'>%s</entry>\n", memory->memory_speed); virBufferEscapeString(buf, - " <entry name='manufacturer'>%s</entry>\n", + "<entry name='manufacturer'>%s</entry>\n", memory->memory_manufacturer); virBufferEscapeString(buf, - " <entry name='serial_number'>%s</entry>\n", + "<entry name='serial_number'>%s</entry>\n", memory->memory_serial_number); virBufferEscapeString(buf, - " <entry name='part_number'>%s</entry>\n", + "<entry name='part_number'>%s</entry>\n", memory->memory_part_number); - virBufferAddLit(buf, " </memory_device>\n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "</memory_device>\n"); } } @@ -1043,12 +1049,14 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def) } virBufferAsprintf(buf, "<sysinfo type='%s'>\n", type); + virBufferAdjustIndent(buf, 2); virSysinfoBIOSFormat(buf, def); virSysinfoSystemFormat(buf, def); virSysinfoProcessorFormat(buf, def); virSysinfoMemoryFormat(buf, def); + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</sysinfo>\n"); if (virBufferError(buf)) { -- 1.8.5.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list