mirror of https://github.com/xemu-project/xemu.git
Merge remote-tracking branch 'luiz/queue/qmp' into staging
# By Kevin Wolf (4) and others # Via Luiz Capitulino * luiz/queue/qmp: add timestamp to error_report() qapi-schema: Use existing type for drive-backup arguments qapi-schema: Use BlockdevSnapshot type for blockdev-snapshot-sync qapi.py: Allow top-level type reference for command definitions qapi.py: Avoid code duplication qemu-char: Fix ringbuf option size Message-id: 1373478767-20965-1-git-send-email-lcapitulino@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
commit
c170a23ca0
|
@ -14,6 +14,7 @@
|
||||||
#define QEMU_ERROR_H
|
#define QEMU_ERROR_H
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include "qemu/compiler.h"
|
#include "qemu/compiler.h"
|
||||||
|
|
||||||
typedef struct Location {
|
typedef struct Location {
|
||||||
|
@ -40,5 +41,6 @@ void error_print_loc(void);
|
||||||
void error_set_progname(const char *argv0);
|
void error_set_progname(const char *argv0);
|
||||||
void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
|
void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
|
||||||
const char *error_get_progname(void);
|
const char *error_get_progname(void);
|
||||||
|
extern bool enable_timestamp_msg;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1709,16 +1709,7 @@
|
||||||
#
|
#
|
||||||
# Generates a synchronous snapshot of a block device.
|
# Generates a synchronous snapshot of a block device.
|
||||||
#
|
#
|
||||||
# @device: the name of the device to generate the snapshot from.
|
# For the arguments, see the documentation of BlockdevSnapshot.
|
||||||
#
|
|
||||||
# @snapshot-file: the target of the new image. If the file exists, or if it
|
|
||||||
# is a device, the snapshot will be created in the existing
|
|
||||||
# file/device. If does not exist, a new file will be created.
|
|
||||||
#
|
|
||||||
# @format: #optional the format of the snapshot image, default is 'qcow2'.
|
|
||||||
#
|
|
||||||
# @mode: #optional whether and how QEMU should create a new image, default is
|
|
||||||
# 'absolute-paths'.
|
|
||||||
#
|
#
|
||||||
# Returns: nothing on success
|
# Returns: nothing on success
|
||||||
# If @device is not a valid block device, DeviceNotFound
|
# If @device is not a valid block device, DeviceNotFound
|
||||||
|
@ -1726,8 +1717,7 @@
|
||||||
# Since 0.14.0
|
# Since 0.14.0
|
||||||
##
|
##
|
||||||
{ 'command': 'blockdev-snapshot-sync',
|
{ 'command': 'blockdev-snapshot-sync',
|
||||||
'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str',
|
'data': 'BlockdevSnapshot' }
|
||||||
'*mode': 'NewImageMode'} }
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# @human-monitor-command:
|
# @human-monitor-command:
|
||||||
|
@ -1801,42 +1791,14 @@
|
||||||
# The operation can be stopped before it has completed using the
|
# The operation can be stopped before it has completed using the
|
||||||
# block-job-cancel command.
|
# block-job-cancel command.
|
||||||
#
|
#
|
||||||
# @device: the name of the device which should be copied.
|
# For the arguments, see the documentation of DriveBackup.
|
||||||
#
|
|
||||||
# @target: the target of the new image. If the file exists, or if it
|
|
||||||
# is a device, the existing file/device will be used as the new
|
|
||||||
# destination. If it does not exist, a new file will be created.
|
|
||||||
#
|
|
||||||
# @format: #optional the format of the new destination, default is to
|
|
||||||
# probe if @mode is 'existing', else the format of the source
|
|
||||||
#
|
|
||||||
# @mode: #optional whether and how QEMU should create a new image, default is
|
|
||||||
# 'absolute-paths'.
|
|
||||||
#
|
|
||||||
# @speed: #optional the maximum speed, in bytes per second
|
|
||||||
#
|
|
||||||
# @on-source-error: #optional the action to take on an error on the source,
|
|
||||||
# default 'report'. 'stop' and 'enospc' can only be used
|
|
||||||
# if the block device supports io-status (see BlockInfo).
|
|
||||||
#
|
|
||||||
# @on-target-error: #optional the action to take on an error on the target,
|
|
||||||
# default 'report' (no limitations, since this applies to
|
|
||||||
# a different block device than @device).
|
|
||||||
#
|
|
||||||
# Note that @on-source-error and @on-target-error only affect background I/O.
|
|
||||||
# If an error occurs during a guest write request, the device's rerror/werror
|
|
||||||
# actions will be used.
|
|
||||||
#
|
#
|
||||||
# Returns: nothing on success
|
# Returns: nothing on success
|
||||||
# If @device is not a valid block device, DeviceNotFound
|
# If @device is not a valid block device, DeviceNotFound
|
||||||
#
|
#
|
||||||
# Since 1.6
|
# Since 1.6
|
||||||
##
|
##
|
||||||
{ 'command': 'drive-backup',
|
{ 'command': 'drive-backup', 'data': 'DriveBackup' }
|
||||||
'data': { 'device': 'str', 'target': 'str', '*format': 'str',
|
|
||||||
'*mode': 'NewImageMode', '*speed': 'int',
|
|
||||||
'*on-source-error': 'BlockdevOnError',
|
|
||||||
'*on-target-error': 'BlockdevOnError' } }
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# @drive-mirror
|
# @drive-mirror
|
||||||
|
|
|
@ -3115,7 +3115,7 @@ static void qemu_chr_parse_memory(QemuOpts *opts, ChardevBackend *backend,
|
||||||
|
|
||||||
backend->memory = g_new0(ChardevMemory, 1);
|
backend->memory = g_new0(ChardevMemory, 1);
|
||||||
|
|
||||||
val = qemu_opt_get_number(opts, "size", 0);
|
val = qemu_opt_get_size(opts, "size", 0);
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
backend->memory->has_size = true;
|
backend->memory->has_size = true;
|
||||||
backend->memory->size = val;
|
backend->memory->size = val;
|
||||||
|
|
|
@ -3100,6 +3100,17 @@ property must be set. These objects are placed in the
|
||||||
'/objects' path.
|
'/objects' path.
|
||||||
ETEXI
|
ETEXI
|
||||||
|
|
||||||
|
DEF("msg", HAS_ARG, QEMU_OPTION_msg,
|
||||||
|
"-msg timestamp[=on|off]\n"
|
||||||
|
" change the format of messages\n"
|
||||||
|
" on|off controls leading timestamps (default:on)\n",
|
||||||
|
QEMU_ARCH_ALL)
|
||||||
|
STEXI
|
||||||
|
@item -msg timestamp[=on|off]
|
||||||
|
@findex -msg
|
||||||
|
prepend a timestamp to each log message.(default:on)
|
||||||
|
ETEXI
|
||||||
|
|
||||||
HXCOMM This is the last statement. Insert new options before this line!
|
HXCOMM This is the last statement. Insert new options before this line!
|
||||||
STEXI
|
STEXI
|
||||||
@end table
|
@end table
|
||||||
|
|
|
@ -78,10 +78,8 @@ def parse(tokens):
|
||||||
def evaluate(string):
|
def evaluate(string):
|
||||||
return parse(map(lambda x: x, tokenize(string)))[0]
|
return parse(map(lambda x: x, tokenize(string)))[0]
|
||||||
|
|
||||||
def parse_schema(fp):
|
def get_expr(fp):
|
||||||
exprs = []
|
|
||||||
expr = ''
|
expr = ''
|
||||||
expr_eval = None
|
|
||||||
|
|
||||||
for line in fp:
|
for line in fp:
|
||||||
if line.startswith('#') or line == '\n':
|
if line.startswith('#') or line == '\n':
|
||||||
|
@ -90,27 +88,36 @@ def parse_schema(fp):
|
||||||
if line.startswith(' '):
|
if line.startswith(' '):
|
||||||
expr += line
|
expr += line
|
||||||
elif expr:
|
elif expr:
|
||||||
expr_eval = evaluate(expr)
|
yield expr
|
||||||
if expr_eval.has_key('enum'):
|
|
||||||
add_enum(expr_eval['enum'])
|
|
||||||
elif expr_eval.has_key('union'):
|
|
||||||
add_enum('%sKind' % expr_eval['union'])
|
|
||||||
exprs.append(expr_eval)
|
|
||||||
expr = line
|
expr = line
|
||||||
else:
|
else:
|
||||||
expr += line
|
expr += line
|
||||||
|
|
||||||
if expr:
|
if expr:
|
||||||
|
yield expr
|
||||||
|
|
||||||
|
def parse_schema(fp):
|
||||||
|
exprs = []
|
||||||
|
|
||||||
|
for expr in get_expr(fp):
|
||||||
expr_eval = evaluate(expr)
|
expr_eval = evaluate(expr)
|
||||||
|
|
||||||
if expr_eval.has_key('enum'):
|
if expr_eval.has_key('enum'):
|
||||||
add_enum(expr_eval['enum'])
|
add_enum(expr_eval['enum'])
|
||||||
elif expr_eval.has_key('union'):
|
elif expr_eval.has_key('union'):
|
||||||
add_enum('%sKind' % expr_eval['union'])
|
add_enum('%sKind' % expr_eval['union'])
|
||||||
|
elif expr_eval.has_key('type'):
|
||||||
|
add_struct(expr_eval)
|
||||||
exprs.append(expr_eval)
|
exprs.append(expr_eval)
|
||||||
|
|
||||||
return exprs
|
return exprs
|
||||||
|
|
||||||
def parse_args(typeinfo):
|
def parse_args(typeinfo):
|
||||||
|
if isinstance(typeinfo, basestring):
|
||||||
|
struct = find_struct(typeinfo)
|
||||||
|
assert struct != None
|
||||||
|
typeinfo = struct['data']
|
||||||
|
|
||||||
for member in typeinfo:
|
for member in typeinfo:
|
||||||
argname = member
|
argname = member
|
||||||
argentry = typeinfo[member]
|
argentry = typeinfo[member]
|
||||||
|
@ -180,6 +187,18 @@ def type_name(name):
|
||||||
return name
|
return name
|
||||||
|
|
||||||
enum_types = []
|
enum_types = []
|
||||||
|
struct_types = []
|
||||||
|
|
||||||
|
def add_struct(definition):
|
||||||
|
global struct_types
|
||||||
|
struct_types.append(definition)
|
||||||
|
|
||||||
|
def find_struct(name):
|
||||||
|
global struct_types
|
||||||
|
for struct in struct_types:
|
||||||
|
if struct['type'] == name:
|
||||||
|
return struct
|
||||||
|
return None
|
||||||
|
|
||||||
def add_enum(name):
|
def add_enum(name):
|
||||||
global enum_types
|
global enum_types
|
||||||
|
|
|
@ -196,6 +196,7 @@ void error_print_loc(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool enable_timestamp_msg;
|
||||||
/*
|
/*
|
||||||
* Print an error message to current monitor if we have one, else to stderr.
|
* Print an error message to current monitor if we have one, else to stderr.
|
||||||
* Format arguments like sprintf(). The result should not contain
|
* Format arguments like sprintf(). The result should not contain
|
||||||
|
@ -206,6 +207,15 @@ void error_print_loc(void)
|
||||||
void error_report(const char *fmt, ...)
|
void error_report(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
GTimeVal tv;
|
||||||
|
gchar *timestr;
|
||||||
|
|
||||||
|
if (enable_timestamp_msg) {
|
||||||
|
g_get_current_time(&tv);
|
||||||
|
timestr = g_time_val_to_iso8601(&tv);
|
||||||
|
error_printf("%s ", timestr);
|
||||||
|
g_free(timestr);
|
||||||
|
}
|
||||||
|
|
||||||
error_print_loc();
|
error_print_loc();
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
26
vl.c
26
vl.c
|
@ -516,6 +516,18 @@ static QemuOptsList qemu_realtime_opts = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static QemuOptsList qemu_msg_opts = {
|
||||||
|
.name = "msg",
|
||||||
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_msg_opts.head),
|
||||||
|
.desc = {
|
||||||
|
{
|
||||||
|
.name = "timestamp",
|
||||||
|
.type = QEMU_OPT_BOOL,
|
||||||
|
},
|
||||||
|
{ /* end of list */ }
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get machine options
|
* Get machine options
|
||||||
*
|
*
|
||||||
|
@ -1503,6 +1515,12 @@ static void configure_realtime(QemuOpts *opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void configure_msg(QemuOpts *opts)
|
||||||
|
{
|
||||||
|
enable_timestamp_msg = qemu_opt_get_bool(opts, "timestamp", true);
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* USB devices */
|
/* USB devices */
|
||||||
|
|
||||||
|
@ -2942,6 +2960,7 @@ int main(int argc, char **argv, char **envp)
|
||||||
qemu_add_opts(&qemu_object_opts);
|
qemu_add_opts(&qemu_object_opts);
|
||||||
qemu_add_opts(&qemu_tpmdev_opts);
|
qemu_add_opts(&qemu_tpmdev_opts);
|
||||||
qemu_add_opts(&qemu_realtime_opts);
|
qemu_add_opts(&qemu_realtime_opts);
|
||||||
|
qemu_add_opts(&qemu_msg_opts);
|
||||||
|
|
||||||
runstate_init();
|
runstate_init();
|
||||||
|
|
||||||
|
@ -3838,6 +3857,13 @@ int main(int argc, char **argv, char **envp)
|
||||||
}
|
}
|
||||||
configure_realtime(opts);
|
configure_realtime(opts);
|
||||||
break;
|
break;
|
||||||
|
case QEMU_OPTION_msg:
|
||||||
|
opts = qemu_opts_parse(qemu_find_opts("msg"), optarg, 0);
|
||||||
|
if (!opts) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
configure_msg(opts);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
os_parse_cmd_args(popt->index, optarg);
|
os_parse_cmd_args(popt->index, optarg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue