blob: 2889877680fb19b0742a261f4d61cb6583b5f98a [file] [log] [blame]
Michael Rothc17d9902011-07-19 14:50:42 -05001#
2# QAPI command marshaller generator
3#
4# Copyright IBM, Corp. 2011
Eric Blaked708cdb2015-05-04 09:05:19 -06005# Copyright (C) 2014-2015 Red Hat, Inc.
Michael Rothc17d9902011-07-19 14:50:42 -05006#
7# Authors:
8# Anthony Liguori <aliguori@us.ibm.com>
9# Michael Roth <mdroth@linux.vnet.ibm.com>
Markus Armbruster297a3642014-05-07 09:53:54 +020010# Markus Armbruster <armbru@redhat.com>
Michael Rothc17d9902011-07-19 14:50:42 -050011#
Markus Armbruster678e48a2014-03-01 08:40:34 +010012# This work is licensed under the terms of the GNU GPL, version 2.
13# See the COPYING file in the top-level directory.
Michael Rothc17d9902011-07-19 14:50:42 -050014
15from ordereddict import OrderedDict
16from qapi import *
Markus Armbruster297a3642014-05-07 09:53:54 +020017import re
Michael Rothc17d9902011-07-19 14:50:42 -050018import os
Michael Rothc17d9902011-07-19 14:50:42 -050019import errno
20
Michael Rothc17d9902011-07-19 14:50:42 -050021def generate_command_decl(name, args, ret_type):
22 arglist=""
Eric Blake6b5abc72015-05-04 09:05:33 -060023 for argname, argtype, optional in parse_args(args):
Amos Kong0d14eeb2014-06-10 19:25:52 +080024 argtype = c_type(argtype, is_param=True)
Michael Rothc17d9902011-07-19 14:50:42 -050025 if optional:
Eric Blake18df5152015-05-14 06:50:48 -060026 arglist += "bool has_%s, " % c_name(argname)
27 arglist += "%s %s, " % (argtype, c_name(argname))
Michael Rothc17d9902011-07-19 14:50:42 -050028 return mcgen('''
29%(ret_type)s qmp_%(name)s(%(args)sError **errp);
30''',
Eric Blake18df5152015-05-14 06:50:48 -060031 ret_type=c_type(ret_type), name=c_name(name),
32 args=arglist).strip()
Michael Rothc17d9902011-07-19 14:50:42 -050033
Markus Armbruster297a3642014-05-07 09:53:54 +020034def gen_err_check(errvar):
35 if errvar:
36 return mcgen('''
37if (local_err) {
38 goto out;
39}
40''')
41 return ''
42
Michael Rothc17d9902011-07-19 14:50:42 -050043def gen_sync_call(name, args, ret_type, indent=0):
44 ret = ""
45 arglist=""
46 retval=""
47 if ret_type:
48 retval = "retval = "
Eric Blake6b5abc72015-05-04 09:05:33 -060049 for argname, argtype, optional in parse_args(args):
Michael Rothc17d9902011-07-19 14:50:42 -050050 if optional:
Eric Blake18df5152015-05-14 06:50:48 -060051 arglist += "has_%s, " % c_name(argname)
52 arglist += "%s, " % (c_name(argname))
Michael Rothc17d9902011-07-19 14:50:42 -050053 push_indent(indent)
54 ret = mcgen('''
Markus Armbruster297a3642014-05-07 09:53:54 +020055%(retval)sqmp_%(name)s(%(args)s&local_err);
Michael Rothc17d9902011-07-19 14:50:42 -050056
57''',
Eric Blake18df5152015-05-14 06:50:48 -060058 name=c_name(name), args=arglist, retval=retval).rstrip()
Michael Rothc17d9902011-07-19 14:50:42 -050059 if ret_type:
Markus Armbruster297a3642014-05-07 09:53:54 +020060 ret += "\n" + gen_err_check('local_err')
Michael Rothc17d9902011-07-19 14:50:42 -050061 ret += "\n" + mcgen(''''
Markus Armbruster297a3642014-05-07 09:53:54 +020062%(marshal_output_call)s
Michael Rothc17d9902011-07-19 14:50:42 -050063''',
64 marshal_output_call=gen_marshal_output_call(name, ret_type)).rstrip()
65 pop_indent(indent)
66 return ret.rstrip()
67
68
69def gen_marshal_output_call(name, ret_type):
70 if not ret_type:
71 return ""
Eric Blake18df5152015-05-14 06:50:48 -060072 return "qmp_marshal_output_%s(retval, ret, &local_err);" % c_name(name)
Michael Rothc17d9902011-07-19 14:50:42 -050073
Markus Armbrusterf9bee752014-05-07 09:53:44 +020074def gen_visitor_input_containers_decl(args, obj):
Michael Rothc17d9902011-07-19 14:50:42 -050075 ret = ""
76
77 push_indent()
78 if len(args) > 0:
79 ret += mcgen('''
Markus Armbrusterf9bee752014-05-07 09:53:44 +020080QmpInputVisitor *mi = qmp_input_visitor_new_strict(%(obj)s);
Michael Rothc17d9902011-07-19 14:50:42 -050081QapiDeallocVisitor *md;
82Visitor *v;
Markus Armbrusterf9bee752014-05-07 09:53:44 +020083''',
84 obj=obj)
Michael Rothc17d9902011-07-19 14:50:42 -050085 pop_indent()
86
87 return ret.rstrip()
88
89def gen_visitor_input_vars_decl(args):
90 ret = ""
91 push_indent()
Eric Blake6b5abc72015-05-04 09:05:33 -060092 for argname, argtype, optional in parse_args(args):
Michael Rothc17d9902011-07-19 14:50:42 -050093 if optional:
94 ret += mcgen('''
95bool has_%(argname)s = false;
96''',
Eric Blake18df5152015-05-14 06:50:48 -060097 argname=c_name(argname))
Amos Kong05dfb262014-06-10 19:25:53 +080098 if is_c_ptr(argtype):
Michael Rothc17d9902011-07-19 14:50:42 -050099 ret += mcgen('''
100%(argtype)s %(argname)s = NULL;
101''',
Eric Blake18df5152015-05-14 06:50:48 -0600102 argname=c_name(argname), argtype=c_type(argtype))
Michael Rothc17d9902011-07-19 14:50:42 -0500103 else:
104 ret += mcgen('''
Michael Rothfc13d932014-05-20 12:20:39 -0500105%(argtype)s %(argname)s = {0};
Michael Rothc17d9902011-07-19 14:50:42 -0500106''',
Eric Blake18df5152015-05-14 06:50:48 -0600107 argname=c_name(argname), argtype=c_type(argtype))
Michael Rothc17d9902011-07-19 14:50:42 -0500108
109 pop_indent()
110 return ret.rstrip()
111
Markus Armbrusterf9bee752014-05-07 09:53:44 +0200112def gen_visitor_input_block(args, dealloc=False):
Michael Rothc17d9902011-07-19 14:50:42 -0500113 ret = ""
Markus Armbruster297a3642014-05-07 09:53:54 +0200114 errparg = '&local_err'
115 errarg = 'local_err'
Luiz Capitulino8f91ad82013-07-11 14:26:56 -0400116
Michael Rothc17d9902011-07-19 14:50:42 -0500117 if len(args) == 0:
118 return ret
119
120 push_indent()
121
122 if dealloc:
Luiz Capitulino8f91ad82013-07-11 14:26:56 -0400123 errparg = 'NULL'
Markus Armbruster297a3642014-05-07 09:53:54 +0200124 errarg = None;
Michael Rothc17d9902011-07-19 14:50:42 -0500125 ret += mcgen('''
Markus Armbrusterf9bee752014-05-07 09:53:44 +0200126qmp_input_visitor_cleanup(mi);
Michael Rothc17d9902011-07-19 14:50:42 -0500127md = qapi_dealloc_visitor_new();
128v = qapi_dealloc_get_visitor(md);
129''')
130 else:
131 ret += mcgen('''
Michael Rothc17d9902011-07-19 14:50:42 -0500132v = qmp_input_get_visitor(mi);
Markus Armbrusterf9bee752014-05-07 09:53:44 +0200133''')
Michael Rothc17d9902011-07-19 14:50:42 -0500134
Eric Blake6b5abc72015-05-04 09:05:33 -0600135 for argname, argtype, optional in parse_args(args):
Michael Rothc17d9902011-07-19 14:50:42 -0500136 if optional:
137 ret += mcgen('''
Markus Armbrustere2cd0f42014-05-07 09:53:46 +0200138visit_optional(v, &has_%(c_name)s, "%(name)s", %(errp)s);
Michael Rothc17d9902011-07-19 14:50:42 -0500139''',
Eric Blake18df5152015-05-14 06:50:48 -0600140 c_name=c_name(argname), name=argname, errp=errparg)
Markus Armbruster297a3642014-05-07 09:53:54 +0200141 ret += gen_err_check(errarg)
142 ret += mcgen('''
143if (has_%(c_name)s) {
144''',
Eric Blake18df5152015-05-14 06:50:48 -0600145 c_name=c_name(argname))
Michael Rothc17d9902011-07-19 14:50:42 -0500146 push_indent()
147 ret += mcgen('''
Eric Blakee3c4c3d2015-05-14 06:51:01 -0600148visit_type_%(visitor)s(v, &%(c_name)s, "%(name)s", %(errp)s);
Michael Rothc17d9902011-07-19 14:50:42 -0500149''',
Eric Blake18df5152015-05-14 06:50:48 -0600150 c_name=c_name(argname), name=argname, argtype=argtype,
Eric Blakee3c4c3d2015-05-14 06:51:01 -0600151 visitor=type_name(argtype), errp=errparg)
Markus Armbruster297a3642014-05-07 09:53:54 +0200152 ret += gen_err_check(errarg)
Michael Rothc17d9902011-07-19 14:50:42 -0500153 if optional:
154 pop_indent()
155 ret += mcgen('''
156}
Markus Armbrustere2cd0f42014-05-07 09:53:46 +0200157''')
Michael Rothc17d9902011-07-19 14:50:42 -0500158
159 if dealloc:
160 ret += mcgen('''
161qapi_dealloc_visitor_cleanup(md);
162''')
Michael Rothc17d9902011-07-19 14:50:42 -0500163 pop_indent()
164 return ret.rstrip()
165
Anthony Liguori776574d2011-09-02 12:34:46 -0500166def gen_marshal_output(name, args, ret_type, middle_mode):
Michael Rothc17d9902011-07-19 14:50:42 -0500167 if not ret_type:
168 return ""
Anthony Liguori776574d2011-09-02 12:34:46 -0500169
Michael Rothc17d9902011-07-19 14:50:42 -0500170 ret = mcgen('''
171static void qmp_marshal_output_%(c_name)s(%(c_ret_type)s ret_in, QObject **ret_out, Error **errp)
172{
Markus Armbruster297a3642014-05-07 09:53:54 +0200173 Error *local_err = NULL;
Michael Rothc17d9902011-07-19 14:50:42 -0500174 QmpOutputVisitor *mo = qmp_output_visitor_new();
Markus Armbrusterf9bee752014-05-07 09:53:44 +0200175 QapiDeallocVisitor *md;
Michael Rothc17d9902011-07-19 14:50:42 -0500176 Visitor *v;
177
178 v = qmp_output_get_visitor(mo);
Eric Blakee3c4c3d2015-05-14 06:51:01 -0600179 visit_type_%(visitor)s(v, &ret_in, "unused", &local_err);
Markus Armbruster297a3642014-05-07 09:53:54 +0200180 if (local_err) {
181 goto out;
Michael Rothc17d9902011-07-19 14:50:42 -0500182 }
Markus Armbruster297a3642014-05-07 09:53:54 +0200183 *ret_out = qmp_output_get_qobject(mo);
184
185out:
186 error_propagate(errp, local_err);
Michael Rothc17d9902011-07-19 14:50:42 -0500187 qmp_output_visitor_cleanup(mo);
Markus Armbrusterf9bee752014-05-07 09:53:44 +0200188 md = qapi_dealloc_visitor_new();
Michael Rothc17d9902011-07-19 14:50:42 -0500189 v = qapi_dealloc_get_visitor(md);
Eric Blakee3c4c3d2015-05-14 06:51:01 -0600190 visit_type_%(visitor)s(v, &ret_in, "unused", NULL);
Michael Rothc17d9902011-07-19 14:50:42 -0500191 qapi_dealloc_visitor_cleanup(md);
192}
193''',
Eric Blake18df5152015-05-14 06:50:48 -0600194 c_ret_type=c_type(ret_type), c_name=c_name(name),
Eric Blakee3c4c3d2015-05-14 06:51:01 -0600195 visitor=type_name(ret_type))
Michael Rothc17d9902011-07-19 14:50:42 -0500196
197 return ret
198
Anthony Liguori776574d2011-09-02 12:34:46 -0500199def gen_marshal_input_decl(name, args, ret_type, middle_mode):
200 if middle_mode:
Eric Blake18df5152015-05-14 06:50:48 -0600201 return 'int qmp_marshal_input_%s(Monitor *mon, const QDict *qdict, QObject **ret)' % c_name(name)
Anthony Liguori776574d2011-09-02 12:34:46 -0500202 else:
Eric Blake18df5152015-05-14 06:50:48 -0600203 return 'static void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name)
Anthony Liguori776574d2011-09-02 12:34:46 -0500204
205
206
207def gen_marshal_input(name, args, ret_type, middle_mode):
208 hdr = gen_marshal_input_decl(name, args, ret_type, middle_mode)
209
Michael Rothc17d9902011-07-19 14:50:42 -0500210 ret = mcgen('''
Anthony Liguori776574d2011-09-02 12:34:46 -0500211%(header)s
Michael Rothc17d9902011-07-19 14:50:42 -0500212{
Markus Armbruster297a3642014-05-07 09:53:54 +0200213 Error *local_err = NULL;
Michael Rothc17d9902011-07-19 14:50:42 -0500214''',
Anthony Liguori776574d2011-09-02 12:34:46 -0500215 header=hdr)
216
217 if middle_mode:
218 ret += mcgen('''
Anthony Liguori776574d2011-09-02 12:34:46 -0500219 QDict *args = (QDict *)qdict;
220''')
Michael Rothc17d9902011-07-19 14:50:42 -0500221
222 if ret_type:
Amos Kong05dfb262014-06-10 19:25:53 +0800223 if is_c_ptr(ret_type):
Michael Rothc17d9902011-07-19 14:50:42 -0500224 retval = " %s retval = NULL;" % c_type(ret_type)
225 else:
226 retval = " %s retval;" % c_type(ret_type)
227 ret += mcgen('''
228%(retval)s
229''',
230 retval=retval)
231
232 if len(args) > 0:
233 ret += mcgen('''
234%(visitor_input_containers_decl)s
235%(visitor_input_vars_decl)s
236
237%(visitor_input_block)s
238
239''',
Markus Armbrusterf9bee752014-05-07 09:53:44 +0200240 visitor_input_containers_decl=gen_visitor_input_containers_decl(args, "QOBJECT(args)"),
Michael Rothc17d9902011-07-19 14:50:42 -0500241 visitor_input_vars_decl=gen_visitor_input_vars_decl(args),
Markus Armbrusterf9bee752014-05-07 09:53:44 +0200242 visitor_input_block=gen_visitor_input_block(args))
Anthony Liguori776574d2011-09-02 12:34:46 -0500243 else:
244 ret += mcgen('''
Markus Armbruster297a3642014-05-07 09:53:54 +0200245
Anthony Liguori776574d2011-09-02 12:34:46 -0500246 (void)args;
247''')
Michael Rothc17d9902011-07-19 14:50:42 -0500248
249 ret += mcgen('''
Michael Rothc17d9902011-07-19 14:50:42 -0500250%(sync_call)s
251''',
252 sync_call=gen_sync_call(name, args, ret_type, indent=4))
Markus Armbruster297a3642014-05-07 09:53:54 +0200253 if re.search('^ *goto out\\;', ret, re.MULTILINE):
254 ret += mcgen('''
Michael Rothc17d9902011-07-19 14:50:42 -0500255
256out:
257''')
Markus Armbruster297a3642014-05-07 09:53:54 +0200258 if not middle_mode:
259 ret += mcgen('''
260 error_propagate(errp, local_err);
261''')
Michael Rothc17d9902011-07-19 14:50:42 -0500262 ret += mcgen('''
263%(visitor_input_block_cleanup)s
Michael Rothc17d9902011-07-19 14:50:42 -0500264''',
Markus Armbrusterf9bee752014-05-07 09:53:44 +0200265 visitor_input_block_cleanup=gen_visitor_input_block(args,
Anthony Liguori776574d2011-09-02 12:34:46 -0500266 dealloc=True))
267
268 if middle_mode:
269 ret += mcgen('''
270
271 if (local_err) {
272 qerror_report_err(local_err);
273 error_free(local_err);
274 return -1;
275 }
276 return 0;
277''')
278 else:
279 ret += mcgen('''
280 return;
281''')
282
283 ret += mcgen('''
284}
285''')
286
Michael Rothc17d9902011-07-19 14:50:42 -0500287 return ret
288
289def gen_registry(commands):
290 registry=""
291 push_indent()
292 for cmd in commands:
Luiz Capitulinod34b8672012-05-08 14:24:44 -0300293 options = 'QCO_NO_OPTIONS'
Eric Blaked708cdb2015-05-04 09:05:19 -0600294 if not cmd.get('success-response', True):
Luiz Capitulinod34b8672012-05-08 14:24:44 -0300295 options = 'QCO_NO_SUCCESS_RESP'
296
Michael Rothc17d9902011-07-19 14:50:42 -0500297 registry += mcgen('''
Luiz Capitulinod34b8672012-05-08 14:24:44 -0300298qmp_register_command("%(name)s", qmp_marshal_input_%(c_name)s, %(opts)s);
Michael Rothc17d9902011-07-19 14:50:42 -0500299''',
Eric Blake18df5152015-05-14 06:50:48 -0600300 name=cmd['command'], c_name=c_name(cmd['command']),
Luiz Capitulinod34b8672012-05-08 14:24:44 -0300301 opts=options)
Michael Rothc17d9902011-07-19 14:50:42 -0500302 pop_indent()
303 ret = mcgen('''
304static void qmp_init_marshal(void)
305{
306%(registry)s
307}
308
309qapi_init(qmp_init_marshal);
310''',
311 registry=registry.rstrip())
312 return ret
313
314def gen_command_decl_prologue(header, guard, prefix=""):
315 ret = mcgen('''
316/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */
317
318/*
319 * schema-defined QAPI function prototypes
320 *
321 * Copyright IBM, Corp. 2011
322 *
323 * Authors:
324 * Anthony Liguori <aliguori@us.ibm.com>
325 *
326 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
327 * See the COPYING.LIB file in the top-level directory.
328 *
329 */
330
331#ifndef %(guard)s
332#define %(guard)s
333
334#include "%(prefix)sqapi-types.h"
Paolo Bonzini7b1b5d12012-12-17 18:19:43 +0100335#include "qapi/qmp/qdict.h"
336#include "qapi/error.h"
Michael Rothc17d9902011-07-19 14:50:42 -0500337
338''',
Anthony Liguori776574d2011-09-02 12:34:46 -0500339 header=basename(header), guard=guardname(header), prefix=prefix)
Michael Rothc17d9902011-07-19 14:50:42 -0500340 return ret
341
342def gen_command_def_prologue(prefix="", proxy=False):
343 ret = mcgen('''
344/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */
345
346/*
347 * schema-defined QMP->QAPI command dispatch
348 *
349 * Copyright IBM, Corp. 2011
350 *
351 * Authors:
352 * Anthony Liguori <aliguori@us.ibm.com>
353 *
354 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
355 * See the COPYING.LIB file in the top-level directory.
356 *
357 */
358
Paolo Bonzini79ee7df2012-12-06 11:22:34 +0100359#include "qemu-common.h"
Paolo Bonzini1de7afc2012-12-17 18:20:00 +0100360#include "qemu/module.h"
Paolo Bonzini7b1b5d12012-12-17 18:19:43 +0100361#include "qapi/qmp/qerror.h"
362#include "qapi/qmp/types.h"
363#include "qapi/qmp/dispatch.h"
364#include "qapi/visitor.h"
Michael Rothc17d9902011-07-19 14:50:42 -0500365#include "qapi/qmp-output-visitor.h"
366#include "qapi/qmp-input-visitor.h"
Paolo Bonzini7b1b5d12012-12-17 18:19:43 +0100367#include "qapi/dealloc-visitor.h"
Michael Rothc17d9902011-07-19 14:50:42 -0500368#include "%(prefix)sqapi-types.h"
369#include "%(prefix)sqapi-visit.h"
370
371''',
372 prefix=prefix)
373 if not proxy:
374 ret += '#include "%sqmp-commands.h"' % prefix
Anthony Liguori776574d2011-09-02 12:34:46 -0500375 return ret + "\n\n"
Michael Rothc17d9902011-07-19 14:50:42 -0500376
Michael Rothc17d9902011-07-19 14:50:42 -0500377c_file = 'qmp-marshal.c'
378h_file = 'qmp-commands.h'
Anthony Liguori776574d2011-09-02 12:34:46 -0500379middle_mode = False
Michael Rothc17d9902011-07-19 14:50:42 -0500380
Markus Armbruster2114f5a2015-04-02 13:12:21 +0200381(input_file, output_dir, do_c, do_h, prefix, opts) = \
382 parse_command_line("m", ["middle"])
Avi Kivity8d3bc512011-12-27 16:02:16 +0200383
Michael Rothc17d9902011-07-19 14:50:42 -0500384for o, a in opts:
Markus Armbruster2114f5a2015-04-02 13:12:21 +0200385 if o in ("-m", "--middle"):
Anthony Liguori776574d2011-09-02 12:34:46 -0500386 middle_mode = True
Michael Rothc17d9902011-07-19 14:50:42 -0500387
388c_file = output_dir + prefix + c_file
389h_file = output_dir + prefix + h_file
390
Avi Kivity8d3bc512011-12-27 16:02:16 +0200391def maybe_open(really, name, opt):
Avi Kivity8d3bc512011-12-27 16:02:16 +0200392 if really:
393 return open(name, opt)
394 else:
Avi Kivity19bf7c82011-12-28 12:26:58 +0200395 import StringIO
396 return StringIO.StringIO()
Avi Kivity8d3bc512011-12-27 16:02:16 +0200397
Michael Rothc17d9902011-07-19 14:50:42 -0500398try:
399 os.makedirs(output_dir)
400except os.error, e:
401 if e.errno != errno.EEXIST:
402 raise
403
LluĂ­s Vilanova33aaad52014-05-02 15:52:35 +0200404exprs = parse_schema(input_file)
Michael Rothc17d9902011-07-19 14:50:42 -0500405commands = filter(lambda expr: expr.has_key('command'), exprs)
Anthony Liguori5dbee472011-12-12 14:29:33 -0600406commands = filter(lambda expr: not expr.has_key('gen'), commands)
Michael Rothc17d9902011-07-19 14:50:42 -0500407
Markus Armbruster72aaa732015-04-02 11:41:22 +0200408fdecl = maybe_open(do_h, h_file, 'w')
409fdef = maybe_open(do_c, c_file, 'w')
410ret = gen_command_decl_prologue(header=basename(h_file), guard=guardname(h_file), prefix=prefix)
411fdecl.write(ret)
412ret = gen_command_def_prologue(prefix=prefix)
413fdef.write(ret)
414
415for cmd in commands:
416 arglist = []
417 ret_type = None
418 if cmd.has_key('data'):
419 arglist = cmd['data']
420 if cmd.has_key('returns'):
421 ret_type = cmd['returns']
422 ret = generate_command_decl(cmd['command'], arglist, ret_type) + "\n"
Michael Rothc17d9902011-07-19 14:50:42 -0500423 fdecl.write(ret)
Markus Armbruster72aaa732015-04-02 11:41:22 +0200424 if ret_type:
425 ret = gen_marshal_output(cmd['command'], arglist, ret_type, middle_mode) + "\n"
426 fdef.write(ret)
427
428 if middle_mode:
429 fdecl.write('%s;\n' % gen_marshal_input_decl(cmd['command'], arglist, ret_type, middle_mode))
430
431 ret = gen_marshal_input(cmd['command'], arglist, ret_type, middle_mode) + "\n"
Michael Rothc17d9902011-07-19 14:50:42 -0500432 fdef.write(ret)
433
Markus Armbruster72aaa732015-04-02 11:41:22 +0200434fdecl.write("\n#endif\n");
Anthony Liguori776574d2011-09-02 12:34:46 -0500435
Markus Armbruster72aaa732015-04-02 11:41:22 +0200436if not middle_mode:
437 ret = gen_registry(commands)
438 fdef.write(ret)
Anthony Liguori776574d2011-09-02 12:34:46 -0500439
Markus Armbruster72aaa732015-04-02 11:41:22 +0200440fdef.flush()
441fdef.close()
442fdecl.flush()
443fdecl.close()