Revision 01d3c80d

b/qapi-schema.json
2194 2194
# Since: 0.14.0
2195 2195
##
2196 2196
{ 'command': 'closefd', 'data': {'fdname': 'str'} }
2197

  
2198
##
2199
# @MachineInfo:
2200
#
2201
# Information describing a machine.
2202
#
2203
# @name: the name of the machine
2204
#
2205
# @alias: #optional an alias for the machine name
2206
#
2207
# @default: #optional whether the machine is default
2208
#
2209
# Since: 1.2.0
2210
##
2211
{ 'type': 'MachineInfo',
2212
  'data': { 'name': 'str', '*alias': 'str',
2213
            '*is-default': 'bool' } }
2214

  
2215
##
2216
# @query-machines:
2217
#
2218
# Return a list of supported machines
2219
#
2220
# Returns: a list of MachineInfo
2221
#
2222
# Since: 1.2.0
2223
##
2224
{ 'command': 'query-machines', 'returns': ['MachineInfo'] }
b/qmp-commands.hx
2224 2224
        .mhandler.cmd_new = qmp_marshal_input_device_list_properties,
2225 2225
    },
2226 2226

  
2227
    {
2228
        .name       = "query-machines",
2229
        .args_type  = "",
2230
        .mhandler.cmd_new = qmp_marshal_input_query_machines,
2231
    },
2232

  
b/vl.c
1213 1213
    return NULL;
1214 1214
}
1215 1215

  
1216
MachineInfoList *qmp_query_machines(Error **errp)
1217
{
1218
    MachineInfoList *mach_list = NULL;
1219
    QEMUMachine *m;
1220

  
1221
    for (m = first_machine; m; m = m->next) {
1222
        MachineInfoList *entry;
1223
        MachineInfo *info;
1224

  
1225
        info = g_malloc0(sizeof(*info));
1226
        if (m->is_default) {
1227
            info->has_is_default = true;
1228
            info->is_default = true;
1229
        }
1230

  
1231
        if (m->alias) {
1232
            info->has_alias = true;
1233
            info->alias = g_strdup(m->alias);
1234
        }
1235

  
1236
        info->name = g_strdup(m->name);
1237

  
1238
        entry = g_malloc0(sizeof(*entry));
1239
        entry->value = info;
1240
        entry->next = mach_list;
1241
        mach_list = entry;
1242
    }
1243

  
1244
    return mach_list;
1245
}
1246

  
1216 1247
/***********************************************************/
1217 1248
/* main execution loop */
1218 1249

  

Also available in: Unified diff