static int virSysinfoParseSystem(const char *base, virSysinfoSystemDefPtr *sysdef) { int ret = -1; virSysinfoSystemDefPtr def; if (VIR_ALLOC(def) < 0) return ret; if (!virSysinfoParseLine(base, "Manufacturer", &def->manufacturer)) goto cleanup; if (!virSysinfoParseLine(base, "Type", &def->family)) goto cleanup; if (!virSysinfoParseLine(base, "Sequence Code", &def->serial)) goto cleanup; if (!def->manufacturer && !def->product && !def->version && !def->serial && !def->uuid && !def->sku && !def->family) { virSysinfoSystemDefFree(def); def = NULL; } *sysdef = def; def = NULL; ret = 0; cleanup: virSysinfoSystemDefFree(def); return ret; }
static int virSysinfoParseSystem(const char *base, virSysinfoDefPtr ret) { if (virSysinfoParseLine(base, "Manufacturer", &ret->system_manufacturer) && virSysinfoParseLine(base, "Type", &ret->system_family) && virSysinfoParseLine(base, "Sequence Code", &ret->system_serial)) return 0; else return -1; }
static int virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret) { char *tmp_base; char *manufacturer = NULL; char *procline = NULL; int result = -1; virSysinfoProcessorDefPtr processor; if (!(tmp_base=virSysinfoParseLine(base, "vendor_id", &manufacturer))) goto cleanup; /* Find processor N: line and gather the processor manufacturer, version, serial number, and family */ while ((tmp_base = strstr(tmp_base, "processor ")) && (tmp_base = virSysinfoParseLine(tmp_base, "processor ", &procline))) { if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) { virReportOOMError(); goto cleanup; } processor = &ret->processor[ret->nprocessor - 1]; processor->processor_manufacturer = strdup(manufacturer); if (!virSysinfoParseDelimited(procline, "version", &processor->processor_version, '=', ',') || !virSysinfoParseDelimited(procline, "identification", &processor->processor_serial_number, '=', ',') || !virSysinfoParseDelimited(procline, "machine", &processor->processor_family, '=', '\n')) goto cleanup; } result = 0; cleanup: VIR_FREE(manufacturer); VIR_FREE(procline); return result; }