1 /*
2  * virsysinfo.h: get SMBIOS/sysinfo information from the host
3  *
4  * Copyright (C) 2010-2011 Red Hat, Inc.
5  * Copyright (C) 2010 Daniel Veillard
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library.  If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 #pragma once
23 
24 #include "internal.h"
25 #include "virbuffer.h"
26 #include "virenum.h"
27 
28 typedef enum {
29     VIR_SYSINFO_SMBIOS,
30     VIR_SYSINFO_FWCFG,
31 
32     VIR_SYSINFO_LAST
33 } virSysinfoType;
34 
35 typedef struct _virSysinfoProcessorDef virSysinfoProcessorDef;
36 struct _virSysinfoProcessorDef {
37     char *processor_socket_destination;
38     char *processor_type;
39     char *processor_family;
40     char *processor_manufacturer;
41     char *processor_signature;
42     char *processor_version;
43     char *processor_external_clock;
44     char *processor_max_speed;
45     char *processor_status;
46     char *processor_serial_number;
47     char *processor_part_number;
48 };
49 
50 typedef struct _virSysinfoMemoryDef virSysinfoMemoryDef;
51 struct _virSysinfoMemoryDef {
52     char *memory_size;
53     char *memory_form_factor;
54     char *memory_locator;
55     char *memory_bank_locator;
56     char *memory_type;
57     char *memory_type_detail;
58     char *memory_speed;
59     char *memory_manufacturer;
60     char *memory_serial_number;
61     char *memory_part_number;
62 };
63 
64 typedef struct _virSysinfoBIOSDef virSysinfoBIOSDef;
65 struct _virSysinfoBIOSDef {
66     char *vendor;
67     char *version;
68     char *date;
69     char *release;
70 };
71 
72 typedef struct _virSysinfoSystemDef virSysinfoSystemDef;
73 struct _virSysinfoSystemDef {
74     char *manufacturer;
75     char *product;
76     char *version;
77     char *serial;
78     char *uuid;
79     char *sku;
80     char *family;
81 };
82 
83 typedef struct _virSysinfoBaseBoardDef virSysinfoBaseBoardDef;
84 struct _virSysinfoBaseBoardDef {
85     char *manufacturer;
86     char *product;
87     char *version;
88     char *serial;
89     char *asset;
90     char *location;
91     /* XXX board type */
92 };
93 
94 typedef struct _virSysinfoChassisDef virSysinfoChassisDef;
95 struct _virSysinfoChassisDef {
96     char *manufacturer;
97     char *version;
98     char *serial;
99     char *asset;
100     char *sku;
101 };
102 
103 typedef struct _virSysinfoOEMStringsDef virSysinfoOEMStringsDef;
104 struct _virSysinfoOEMStringsDef {
105     size_t nvalues;
106     char **values;
107 };
108 
109 typedef struct _virSysinfoFWCfgDef virSysinfoFWCfgDef;
110 struct _virSysinfoFWCfgDef {
111     char *name;
112     char *value;
113     char *file;
114 };
115 
116 typedef struct _virSysinfoDef virSysinfoDef;
117 struct _virSysinfoDef {
118     virSysinfoType type;
119 
120     /* The following members are valid for type == VIR_SYSINFO_SMBIOS */
121     virSysinfoBIOSDef *bios;
122     virSysinfoSystemDef *system;
123 
124     size_t nbaseBoard;
125     virSysinfoBaseBoardDef *baseBoard;
126 
127     virSysinfoChassisDef *chassis;
128 
129     size_t nprocessor;
130     virSysinfoProcessorDef *processor;
131 
132     size_t nmemory;
133     virSysinfoMemoryDef *memory;
134 
135     virSysinfoOEMStringsDef *oemStrings;
136 
137     /* The following members are valid for type == VIR_SYSINFO_FWCFG */
138     size_t nfw_cfgs;
139     virSysinfoFWCfgDef *fw_cfgs;
140 };
141 
142 virSysinfoDef *virSysinfoRead(void);
143 
144 void virSysinfoBIOSDefFree(virSysinfoBIOSDef *def);
145 void virSysinfoSystemDefFree(virSysinfoSystemDef *def);
146 void virSysinfoBaseBoardDefClear(virSysinfoBaseBoardDef *def);
147 void virSysinfoChassisDefFree(virSysinfoChassisDef *def);
148 void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDef *def);
149 void virSysinfoDefFree(virSysinfoDef *def);
150 
151 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSysinfoDef, virSysinfoDefFree);
152 
153 int virSysinfoFormat(virBuffer *buf, virSysinfoDef *def)
154     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
155 
156 bool virSysinfoIsEqual(virSysinfoDef *src,
157                        virSysinfoDef *dst);
158 
159 VIR_ENUM_DECL(virSysinfo);
160