Error reporting patches
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJVdny3AAoJEDhwtADrkYZTF7gQAJ1ucN/L9+gZcWeSnvgJPemZ 75M9wSesYXeTpm0Qqb0nQ1KO95IKWXIBte1yui/2aEDu8oZK5pbSqyw5q1HREv/6 GgLTt66dnQiuKw0ab5vLeFMOxkU/BIfusP6Ac6zIrSte6bZejct6wzL+GO1wi+hB 5HbouTPIvK6jvPhTE7huuPg6S7KMDYVhsUxICIebxHsBTJud4opBqpYMAwNjLrfl s66dfGjNH0fSIR5Fmjbz906F3S6P/9PBtZpGJ19OQy1rWl9A9IIn4QkcLUn0RmQV isNae68Hx0xZBcPd8qGtmq8kiMJKDXvhFeKV8RnmX25xvcwpcl/dMbNRcxx9W6El j/Sud+8sBFpH9gEgkDCFxgokrlsygw3iQxZaGx/+b3FUk4GwzJjb4pv5JtvU303D UIZW3t0rNvzS0d2BEDSF7wr5xpQb09wjkBeVtjtcxMro0frfNOld6xgdWSSOxmaq CkyHWUy2du86BBU1Z+IsO1doEIS8WpF0x17QLGy+p0p3WUUAJcfF85S8BKsx9u73 T2hGm7uYNYWiG2KhjL8Xq0iY1R0DrBTDdSuFtBSYvfZPDCH106/AvtNTeaf2djzW HLopHLxOCXDJwKPEB0hF50eTzWpZlZaUMuztIHto+ggQuV8QDKV13IKZWMkOYidI dP3S+wmXqvPvkVBQpyfA =kn95 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2015-06-09' into staging Error reporting patches # gpg: Signature made Tue Jun 9 06:42:15 2015 BST using RSA key ID EB918653 # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" * remotes/armbru/tags/pull-error-2015-06-09: vhost-user: Improve -netdev/netdev_add/-net/... error reporting QemuOpts: Convert qemu_opt_foreach() to Error QemuOpts: Drop qemu_opt_foreach() parameter abort_on_failure blkdebug: Simplify passing of Error through qemu_opts_foreach() QemuOpts: Convert qemu_opts_foreach() to Error QemuOpts: Drop qemu_opts_foreach() parameter abort_on_failure vl: Fail right after first bad -object vl: Print -device help at most once vl: Report failure to sandbox at most once Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
b781a60b10
@ -216,10 +216,9 @@ static int get_event_by_name(const char *name, BlkDebugEvent *event)
|
||||
struct add_rule_data {
|
||||
BDRVBlkdebugState *s;
|
||||
int action;
|
||||
Error **errp;
|
||||
};
|
||||
|
||||
static int add_rule(QemuOpts *opts, void *opaque)
|
||||
static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
struct add_rule_data *d = opaque;
|
||||
BDRVBlkdebugState *s = d->s;
|
||||
@ -230,10 +229,10 @@ static int add_rule(QemuOpts *opts, void *opaque)
|
||||
/* Find the right event for the rule */
|
||||
event_name = qemu_opt_get(opts, "event");
|
||||
if (!event_name) {
|
||||
error_setg(d->errp, "Missing event name for rule");
|
||||
error_setg(errp, "Missing event name for rule");
|
||||
return -1;
|
||||
} else if (get_event_by_name(event_name, &event) < 0) {
|
||||
error_setg(d->errp, "Invalid event name \"%s\"", event_name);
|
||||
error_setg(errp, "Invalid event name \"%s\"", event_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -319,8 +318,7 @@ static int read_config(BDRVBlkdebugState *s, const char *filename,
|
||||
|
||||
d.s = s;
|
||||
d.action = ACTION_INJECT_ERROR;
|
||||
d.errp = &local_err;
|
||||
qemu_opts_foreach(&inject_error_opts, add_rule, &d, 1);
|
||||
qemu_opts_foreach(&inject_error_opts, add_rule, &d, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
ret = -EINVAL;
|
||||
@ -328,7 +326,7 @@ static int read_config(BDRVBlkdebugState *s, const char *filename,
|
||||
}
|
||||
|
||||
d.action = ACTION_SET_STATE;
|
||||
qemu_opts_foreach(&set_state_opts, add_rule, &d, 1);
|
||||
qemu_opts_foreach(&set_state_opts, add_rule, &d, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
ret = -EINVAL;
|
||||
|
@ -389,7 +389,7 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
|
||||
nd->instantiated = 1;
|
||||
}
|
||||
|
||||
static int qdev_add_one_global(QemuOpts *opts, void *opaque)
|
||||
static int qdev_add_one_global(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
GlobalProperty *g;
|
||||
|
||||
@ -404,5 +404,6 @@ static int qdev_add_one_global(QemuOpts *opts, void *opaque)
|
||||
|
||||
void qemu_add_globals(void)
|
||||
{
|
||||
qemu_opts_foreach(qemu_find_opts("global"), qdev_add_one_global, NULL, 0);
|
||||
qemu_opts_foreach(qemu_find_opts("global"),
|
||||
qdev_add_one_global, NULL, NULL);
|
||||
}
|
||||
|
@ -100,9 +100,11 @@ void qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
|
||||
Error **errp);
|
||||
void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
|
||||
Error **errp);
|
||||
typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque);
|
||||
typedef int (*qemu_opt_loopfunc)(void *opaque,
|
||||
const char *name, const char *value,
|
||||
Error **errp);
|
||||
int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
|
||||
int abort_on_failure);
|
||||
Error **errp);
|
||||
|
||||
QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id);
|
||||
QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
|
||||
@ -125,10 +127,10 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
|
||||
QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict);
|
||||
void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp);
|
||||
|
||||
typedef int (*qemu_opts_loopfunc)(QemuOpts *opts, void *opaque);
|
||||
typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp);
|
||||
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
|
||||
void *opaque, Error **errp);
|
||||
void qemu_opts_print(QemuOpts *opts, const char *sep);
|
||||
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque,
|
||||
int abort_on_failure);
|
||||
void qemu_opts_print_help(QemuOptsList *list);
|
||||
void qemu_opts_free(QemuOptsList *list);
|
||||
QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list);
|
||||
|
@ -370,7 +370,7 @@ char *vnc_display_local_addr(const char *id);
|
||||
int vnc_display_password(const char *id, const char *password);
|
||||
int vnc_display_pw_expire(const char *id, time_t expires);
|
||||
QemuOpts *vnc_parse_func(const char *str);
|
||||
int vnc_init_func(QemuOpts *opts, void *opaque);
|
||||
int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
|
||||
#else
|
||||
static inline int vnc_display_password(const char *id, const char *password)
|
||||
{
|
||||
|
10
net/net.c
10
net/net.c
@ -1329,7 +1329,7 @@ void net_check_clients(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int net_init_client(QemuOpts *opts, void *dummy)
|
||||
static int net_init_client(void *dummy, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
|
||||
@ -1342,7 +1342,7 @@ static int net_init_client(QemuOpts *opts, void *dummy)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int net_init_netdev(QemuOpts *opts, void *dummy)
|
||||
static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
int ret;
|
||||
@ -1373,10 +1373,12 @@ int net_init_clients(void)
|
||||
|
||||
QTAILQ_INIT(&net_clients);
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("netdev"), net_init_netdev, NULL, 1) == -1)
|
||||
if (qemu_opts_foreach(qemu_find_opts("netdev"),
|
||||
net_init_netdev, NULL, NULL)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemu_opts_foreach(net, net_init_client, NULL, 1) == -1) {
|
||||
if (qemu_opts_foreach(net, net_init_client, NULL, NULL)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -157,8 +157,9 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int net_vhost_chardev_opts(const char *name, const char *value,
|
||||
void *opaque)
|
||||
static int net_vhost_chardev_opts(void *opaque,
|
||||
const char *name, const char *value,
|
||||
Error **errp)
|
||||
{
|
||||
VhostUserChardevProps *props = opaque;
|
||||
|
||||
@ -169,33 +170,34 @@ static int net_vhost_chardev_opts(const char *name, const char *value,
|
||||
} else if (strcmp(name, "server") == 0) {
|
||||
props->is_server = true;
|
||||
} else {
|
||||
error_report("vhost-user does not support a chardev"
|
||||
" with the following option:\n %s = %s",
|
||||
name, value);
|
||||
error_setg(errp,
|
||||
"vhost-user does not support a chardev with option %s=%s",
|
||||
name, value);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static CharDriverState *net_vhost_parse_chardev(const NetdevVhostUserOptions *opts)
|
||||
static CharDriverState *net_vhost_parse_chardev(
|
||||
const NetdevVhostUserOptions *opts, Error **errp)
|
||||
{
|
||||
CharDriverState *chr = qemu_chr_find(opts->chardev);
|
||||
VhostUserChardevProps props;
|
||||
|
||||
if (chr == NULL) {
|
||||
error_report("chardev \"%s\" not found", opts->chardev);
|
||||
error_setg(errp, "chardev \"%s\" not found", opts->chardev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* inspect chardev opts */
|
||||
memset(&props, 0, sizeof(props));
|
||||
if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, true) != 0) {
|
||||
if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, errp)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!props.is_socket || !props.is_unix) {
|
||||
error_report("chardev \"%s\" is not a unix socket",
|
||||
opts->chardev);
|
||||
error_setg(errp, "chardev \"%s\" is not a unix socket",
|
||||
opts->chardev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -204,7 +206,7 @@ static CharDriverState *net_vhost_parse_chardev(const NetdevVhostUserOptions *op
|
||||
return chr;
|
||||
}
|
||||
|
||||
static int net_vhost_check_net(QemuOpts *opts, void *opaque)
|
||||
static int net_vhost_check_net(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
const char *name = opaque;
|
||||
const char *driver, *netdev;
|
||||
@ -219,7 +221,7 @@ static int net_vhost_check_net(QemuOpts *opts, void *opaque)
|
||||
|
||||
if (strcmp(netdev, name) == 0 &&
|
||||
strncmp(driver, virtio_name, strlen(virtio_name)) != 0) {
|
||||
error_report("vhost-user requires frontend driver virtio-net-*");
|
||||
error_setg(errp, "vhost-user requires frontend driver virtio-net-*");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -229,7 +231,6 @@ static int net_vhost_check_net(QemuOpts *opts, void *opaque)
|
||||
int net_init_vhost_user(const NetClientOptions *opts, const char *name,
|
||||
NetClientState *peer, Error **errp)
|
||||
{
|
||||
/* FIXME error_setg(errp, ...) on failure */
|
||||
uint32_t queues;
|
||||
const NetdevVhostUserOptions *vhost_user_opts;
|
||||
CharDriverState *chr;
|
||||
@ -237,15 +238,14 @@ int net_init_vhost_user(const NetClientOptions *opts, const char *name,
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_VHOST_USER);
|
||||
vhost_user_opts = opts->vhost_user;
|
||||
|
||||
chr = net_vhost_parse_chardev(vhost_user_opts);
|
||||
chr = net_vhost_parse_chardev(vhost_user_opts, errp);
|
||||
if (!chr) {
|
||||
error_report("No suitable chardev found");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* verify net frontend */
|
||||
if (qemu_opts_foreach(qemu_find_opts("device"), net_vhost_check_net,
|
||||
(char *)name, true) == -1) {
|
||||
(char *)name, errp)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
5
numa.c
5
numa.c
@ -125,7 +125,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
|
||||
max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1);
|
||||
}
|
||||
|
||||
static int parse_numa(QemuOpts *opts, void *opaque)
|
||||
static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
NumaOptions *object = NULL;
|
||||
Error *err = NULL;
|
||||
@ -216,8 +216,7 @@ void parse_numa_opts(MachineClass *mc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa,
|
||||
NULL, 1) != 0) {
|
||||
if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,8 @@ static void qdev_print_devinfos(bool show_no_user)
|
||||
g_slist_free(list);
|
||||
}
|
||||
|
||||
static int set_property(const char *name, const char *value, void *opaque)
|
||||
static int set_property(void *opaque, const char *name, const char *value,
|
||||
Error **errp)
|
||||
{
|
||||
Object *obj = opaque;
|
||||
Error *err = NULL;
|
||||
@ -564,7 +565,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
|
||||
}
|
||||
|
||||
/* set properties */
|
||||
if (qemu_opt_foreach(opts, set_property, dev, 1) != 0) {
|
||||
if (qemu_opt_foreach(opts, set_property, dev, NULL)) {
|
||||
object_unparent(OBJECT(dev));
|
||||
object_unref(OBJECT(dev));
|
||||
return NULL;
|
||||
|
5
tpm.c
5
tpm.c
@ -182,7 +182,7 @@ static int configure_tpm(QemuOpts *opts)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tpm_init_tpmdev(QemuOpts *opts, void *dummy)
|
||||
static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
return configure_tpm(opts);
|
||||
}
|
||||
@ -208,12 +208,11 @@ void tpm_cleanup(void)
|
||||
int tpm_init(void)
|
||||
{
|
||||
if (qemu_opts_foreach(qemu_find_opts("tpmdev"),
|
||||
tpm_init_tpmdev, NULL, 1) != 0) {
|
||||
tpm_init_tpmdev, NULL, NULL)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
atexit(tpm_cleanup);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -583,7 +583,8 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int add_channel(const char *name, const char *value, void *opaque)
|
||||
static int add_channel(void *opaque, const char *name, const char *value,
|
||||
Error **errp)
|
||||
{
|
||||
int security = 0;
|
||||
int rc;
|
||||
@ -782,7 +783,7 @@ void qemu_spice_init(void)
|
||||
spice_server_set_playback_compression
|
||||
(spice_server, qemu_opt_get_bool(opts, "playback-compression", 1));
|
||||
|
||||
qemu_opt_foreach(opts, add_channel, &tls_port, 0);
|
||||
qemu_opt_foreach(opts, add_channel, &tls_port, NULL);
|
||||
|
||||
spice_server_set_name(spice_server, qemu_name);
|
||||
spice_server_set_uuid(spice_server, qemu_uuid);
|
||||
|
2
ui/vnc.c
2
ui/vnc.c
@ -3770,7 +3770,7 @@ QemuOpts *vnc_parse_func(const char *str)
|
||||
return opts;
|
||||
}
|
||||
|
||||
int vnc_init_func(QemuOpts *opts, void *opaque)
|
||||
int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
char *id = (char *)qemu_opts_id(opts);
|
||||
|
@ -335,7 +335,8 @@ struct ConfigWriteData {
|
||||
FILE *fp;
|
||||
};
|
||||
|
||||
static int config_write_opt(const char *name, const char *value, void *opaque)
|
||||
static int config_write_opt(void *opaque, const char *name, const char *value,
|
||||
Error **errp)
|
||||
{
|
||||
struct ConfigWriteData *data = opaque;
|
||||
|
||||
@ -343,7 +344,7 @@ static int config_write_opt(const char *name, const char *value, void *opaque)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int config_write_opts(QemuOpts *opts, void *opaque)
|
||||
static int config_write_opts(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
struct ConfigWriteData *data = opaque;
|
||||
const char *id = qemu_opts_id(opts);
|
||||
@ -353,7 +354,7 @@ static int config_write_opts(QemuOpts *opts, void *opaque)
|
||||
} else {
|
||||
fprintf(data->fp, "[%s]\n", data->list->name);
|
||||
}
|
||||
qemu_opt_foreach(opts, config_write_opt, data, 0);
|
||||
qemu_opt_foreach(opts, config_write_opt, data, NULL);
|
||||
fprintf(data->fp, "\n");
|
||||
return 0;
|
||||
}
|
||||
@ -367,7 +368,7 @@ void qemu_config_write(FILE *fp)
|
||||
fprintf(fp, "# qemu config file\n\n");
|
||||
for (i = 0; lists[i] != NULL; i++) {
|
||||
data.list = lists[i];
|
||||
qemu_opts_foreach(data.list, config_write_opts, &data, 0);
|
||||
qemu_opts_foreach(data.list, config_write_opts, &data, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -596,18 +596,26 @@ void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
|
||||
QTAILQ_INSERT_TAIL(&opts->head, opt, next);
|
||||
}
|
||||
|
||||
/**
|
||||
* For each member of @opts, call @func(@opaque, name, value, @errp).
|
||||
* @func() may store an Error through @errp, but must return non-zero then.
|
||||
* When @func() returns non-zero, break the loop and return that value.
|
||||
* Return zero when the loop completes.
|
||||
*/
|
||||
int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
|
||||
int abort_on_failure)
|
||||
Error **errp)
|
||||
{
|
||||
QemuOpt *opt;
|
||||
int rc = 0;
|
||||
int rc;
|
||||
|
||||
QTAILQ_FOREACH(opt, &opts->head, next) {
|
||||
rc = func(opt->name, opt->str, opaque);
|
||||
if (abort_on_failure && rc != 0)
|
||||
break;
|
||||
rc = func(opaque, opt->name, opt->str, errp);
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
assert(!errp || !*errp);
|
||||
}
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)
|
||||
@ -1046,22 +1054,31 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque,
|
||||
int abort_on_failure)
|
||||
/**
|
||||
* For each member of @list, call @func(@opaque, member, @errp).
|
||||
* Call it with the current location temporarily set to the member's.
|
||||
* @func() may store an Error through @errp, but must return non-zero then.
|
||||
* When @func() returns non-zero, break the loop and return that value.
|
||||
* Return zero when the loop completes.
|
||||
*/
|
||||
int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
|
||||
void *opaque, Error **errp)
|
||||
{
|
||||
Location loc;
|
||||
QemuOpts *opts;
|
||||
int rc = 0;
|
||||
int rc;
|
||||
|
||||
loc_push_none(&loc);
|
||||
QTAILQ_FOREACH(opts, &list->head, next) {
|
||||
loc_restore(&opts->loc);
|
||||
rc |= func(opts, opaque);
|
||||
if (abort_on_failure && rc != 0)
|
||||
break;
|
||||
rc = func(opaque, opts, errp);
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
assert(!errp || !*errp);
|
||||
}
|
||||
loc_pop(&loc);
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t count_opts_list(QemuOptsList *list)
|
||||
|
82
vl.c
82
vl.c
@ -515,7 +515,7 @@ static void res_free(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int default_driver_check(QemuOpts *opts, void *opaque)
|
||||
static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
const char *driver = qemu_opt_get(opts, "driver");
|
||||
int i;
|
||||
@ -961,7 +961,7 @@ static int bt_parse(const char *opt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int parse_sandbox(QemuOpts *opts, void *opaque)
|
||||
static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
/* FIXME: change this to true for 1.3 */
|
||||
if (qemu_opt_get_bool(opts, "enable", false)) {
|
||||
@ -981,7 +981,7 @@ static int parse_sandbox(QemuOpts *opts, void *opaque)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_name(QemuOpts *opts, void *opaque)
|
||||
static int parse_name(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
const char *proc_name;
|
||||
|
||||
@ -1009,7 +1009,7 @@ bool usb_enabled(void)
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
static int parse_add_fd(QemuOpts *opts, void *opaque)
|
||||
static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
int fd, dupfd, flags;
|
||||
int64_t fdset_id;
|
||||
@ -1071,7 +1071,7 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cleanup_add_fd(QemuOpts *opts, void *opaque)
|
||||
static int cleanup_add_fd(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@ -1092,14 +1092,14 @@ static int cleanup_add_fd(QemuOpts *opts, void *opaque)
|
||||
#define MTD_OPTS ""
|
||||
#define SD_OPTS ""
|
||||
|
||||
static int drive_init_func(QemuOpts *opts, void *opaque)
|
||||
static int drive_init_func(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
BlockInterfaceType *block_default_type = opaque;
|
||||
|
||||
return drive_new(opts, *block_default_type) == NULL;
|
||||
}
|
||||
|
||||
static int drive_enable_snapshot(QemuOpts *opts, void *opaque)
|
||||
static int drive_enable_snapshot(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
if (qemu_opt_get(opts, "snapshot") == NULL) {
|
||||
qemu_opt_set(opts, "snapshot", "on", &error_abort);
|
||||
@ -1119,7 +1119,7 @@ static void default_drive(int enable, int snapshot, BlockInterfaceType type,
|
||||
|
||||
opts = drive_add(type, index, NULL, optstr);
|
||||
if (snapshot) {
|
||||
drive_enable_snapshot(opts, NULL);
|
||||
drive_enable_snapshot(NULL, opts, NULL);
|
||||
}
|
||||
|
||||
dinfo = drive_new(opts, type);
|
||||
@ -2127,12 +2127,12 @@ char *qemu_find_file(int type, const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int device_help_func(QemuOpts *opts, void *opaque)
|
||||
static int device_help_func(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
return qdev_device_help(opts);
|
||||
}
|
||||
|
||||
static int device_init_func(QemuOpts *opts, void *opaque)
|
||||
static int device_init_func(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
DeviceState *dev;
|
||||
|
||||
@ -2143,7 +2143,7 @@ static int device_init_func(QemuOpts *opts, void *opaque)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int chardev_init_func(QemuOpts *opts, void *opaque)
|
||||
static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
Error *local_err = NULL;
|
||||
|
||||
@ -2156,7 +2156,7 @@ static int chardev_init_func(QemuOpts *opts, void *opaque)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_VIRTFS
|
||||
static int fsdev_init_func(QemuOpts *opts, void *opaque)
|
||||
static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
int ret;
|
||||
ret = qemu_fsdev_add(opts);
|
||||
@ -2165,7 +2165,7 @@ static int fsdev_init_func(QemuOpts *opts, void *opaque)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int mon_init_func(QemuOpts *opts, void *opaque)
|
||||
static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
CharDriverState *chr;
|
||||
const char *chardev;
|
||||
@ -2576,8 +2576,9 @@ static void free_and_trace(gpointer mem)
|
||||
free(mem);
|
||||
}
|
||||
|
||||
static int machine_set_property(const char *name, const char *value,
|
||||
void *opaque)
|
||||
static int machine_set_property(void *opaque,
|
||||
const char *name, const char *value,
|
||||
Error **errp)
|
||||
{
|
||||
Object *obj = OBJECT(opaque);
|
||||
Error *local_err = NULL;
|
||||
@ -2606,7 +2607,7 @@ static int machine_set_property(const char *name, const char *value,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int object_create(QemuOpts *opts, void *opaque)
|
||||
static int object_create(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
char *type = NULL;
|
||||
@ -3797,20 +3798,24 @@ int main(int argc, char **argv, char **envp)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("sandbox"), parse_sandbox, NULL, 0)) {
|
||||
if (qemu_opts_foreach(qemu_find_opts("sandbox"),
|
||||
parse_sandbox, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("name"), parse_name, NULL, 1)) {
|
||||
if (qemu_opts_foreach(qemu_find_opts("name"),
|
||||
parse_name, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
if (qemu_opts_foreach(qemu_find_opts("add-fd"), parse_add_fd, NULL, 1)) {
|
||||
if (qemu_opts_foreach(qemu_find_opts("add-fd"),
|
||||
parse_add_fd, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("add-fd"), cleanup_add_fd, NULL, 1)) {
|
||||
if (qemu_opts_foreach(qemu_find_opts("add-fd"),
|
||||
cleanup_add_fd, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
@ -3897,8 +3902,10 @@ int main(int argc, char **argv, char **envp)
|
||||
machine_class->default_machine_opts, 0);
|
||||
}
|
||||
|
||||
qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
|
||||
qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
|
||||
qemu_opts_foreach(qemu_find_opts("device"),
|
||||
default_driver_check, NULL, NULL);
|
||||
qemu_opts_foreach(qemu_find_opts("global"),
|
||||
default_driver_check, NULL, NULL);
|
||||
|
||||
if (!vga_model && !default_vga) {
|
||||
vga_interface_type = VGA_DEVICE;
|
||||
@ -4036,10 +4043,14 @@ int main(int argc, char **argv, char **envp)
|
||||
|
||||
socket_init();
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
|
||||
if (qemu_opts_foreach(qemu_find_opts("chardev"),
|
||||
chardev_init_func, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_VIRTFS
|
||||
if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
|
||||
if (qemu_opts_foreach(qemu_find_opts("fsdev"),
|
||||
fsdev_init_func, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
@ -4049,19 +4060,19 @@ int main(int argc, char **argv, char **envp)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0)
|
||||
!= 0) {
|
||||
if (qemu_opts_foreach(qemu_find_opts("device"),
|
||||
device_help_func, NULL, NULL)) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("object"),
|
||||
object_create, NULL, 0) != 0) {
|
||||
object_create, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
machine_opts = qemu_get_machine_opts();
|
||||
if (qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
|
||||
1) < 0) {
|
||||
NULL)) {
|
||||
object_unref(OBJECT(current_machine));
|
||||
exit(1);
|
||||
}
|
||||
@ -4189,9 +4200,10 @@ int main(int argc, char **argv, char **envp)
|
||||
|
||||
/* open the virtual block devices */
|
||||
if (snapshot)
|
||||
qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0);
|
||||
qemu_opts_foreach(qemu_find_opts("drive"),
|
||||
drive_enable_snapshot, NULL, NULL);
|
||||
if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func,
|
||||
&machine_class->block_default_type, 1) != 0) {
|
||||
&machine_class->block_default_type, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -4202,7 +4214,8 @@ int main(int argc, char **argv, char **envp)
|
||||
|
||||
parse_numa_opts(machine_class);
|
||||
|
||||
if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) {
|
||||
if (qemu_opts_foreach(qemu_find_opts("mon"),
|
||||
mon_init_func, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -4268,8 +4281,10 @@ int main(int argc, char **argv, char **envp)
|
||||
}
|
||||
|
||||
/* init generic devices */
|
||||
if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0)
|
||||
if (qemu_opts_foreach(qemu_find_opts("device"),
|
||||
device_init_func, NULL, NULL)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Did we create any drives that we failed to create a device for? */
|
||||
drive_check_orphaned();
|
||||
@ -4321,7 +4336,8 @@ int main(int argc, char **argv, char **envp)
|
||||
|
||||
#ifdef CONFIG_VNC
|
||||
/* init remote displays */
|
||||
qemu_opts_foreach(qemu_find_opts("vnc"), vnc_init_func, NULL, 0);
|
||||
qemu_opts_foreach(qemu_find_opts("vnc"),
|
||||
vnc_init_func, NULL, NULL);
|
||||
if (show_vnc_port) {
|
||||
char *ret = vnc_display_local_addr("default");
|
||||
printf("VNC server running on `%s'\n", ret);
|
||||
|
Loading…
Reference in New Issue
Block a user