mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2015-11-02' into staging
QAPI patches # gpg: Signature made Mon 02 Nov 2015 09:07:23 GMT 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-qapi-2015-11-02: (25 commits) qapi: Simplify gen_struct_field() qapi: Reserve 'u' member name qapi: Finish converting to new qapi union layout tpm: Convert to new qapi union layout memory: Convert to new qapi union layout input: Convert to new qapi union layout char: Convert to new qapi union layout net: Convert to new qapi union layout sockets: Convert to new qapi union layout block: Convert to new qapi union layout tests: Convert to new qapi union layout qapi-visit: Convert to new qapi union layout qapi: Start converting to new qapi union layout qapi-visit: Remove redundant functions for flat union base qapi: Unbox base members qapi: Prefer typesafe upcasts to qapi base classes qapi-types: Refactor base fields output qapi-visit: Split off visit_type_FOO_fields forward decl vnc: Hoist allocation of VncBasicInfo to callers qapi: Reserve 'q_*' and 'has_*' member names ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
+9
-9
@@ -206,24 +206,24 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, char **export,
|
||||
saddr = g_new0(SocketAddress, 1);
|
||||
|
||||
if (qdict_haskey(options, "path")) {
|
||||
saddr->kind = SOCKET_ADDRESS_KIND_UNIX;
|
||||
saddr->q_unix = g_new0(UnixSocketAddress, 1);
|
||||
saddr->q_unix->path = g_strdup(qdict_get_str(options, "path"));
|
||||
saddr->type = SOCKET_ADDRESS_KIND_UNIX;
|
||||
saddr->u.q_unix = g_new0(UnixSocketAddress, 1);
|
||||
saddr->u.q_unix->path = g_strdup(qdict_get_str(options, "path"));
|
||||
qdict_del(options, "path");
|
||||
} else {
|
||||
saddr->kind = SOCKET_ADDRESS_KIND_INET;
|
||||
saddr->inet = g_new0(InetSocketAddress, 1);
|
||||
saddr->inet->host = g_strdup(qdict_get_str(options, "host"));
|
||||
saddr->type = SOCKET_ADDRESS_KIND_INET;
|
||||
saddr->u.inet = g_new0(InetSocketAddress, 1);
|
||||
saddr->u.inet->host = g_strdup(qdict_get_str(options, "host"));
|
||||
if (!qdict_get_try_str(options, "port")) {
|
||||
saddr->inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT);
|
||||
saddr->u.inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT);
|
||||
} else {
|
||||
saddr->inet->port = g_strdup(qdict_get_str(options, "port"));
|
||||
saddr->u.inet->port = g_strdup(qdict_get_str(options, "port"));
|
||||
}
|
||||
qdict_del(options, "host");
|
||||
qdict_del(options, "port");
|
||||
}
|
||||
|
||||
s->client.is_unix = saddr->kind == SOCKET_ADDRESS_KIND_UNIX;
|
||||
s->client.is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;
|
||||
|
||||
*export = g_strdup(qdict_get_try_str(options, "export"));
|
||||
if (*export) {
|
||||
|
||||
+4
-6
@@ -2738,18 +2738,16 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)
|
||||
ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1);
|
||||
|
||||
*spec_info = (ImageInfoSpecific){
|
||||
.kind = IMAGE_INFO_SPECIFIC_KIND_QCOW2,
|
||||
{
|
||||
.qcow2 = g_new(ImageInfoSpecificQCow2, 1),
|
||||
},
|
||||
.type = IMAGE_INFO_SPECIFIC_KIND_QCOW2,
|
||||
.u.qcow2 = g_new(ImageInfoSpecificQCow2, 1),
|
||||
};
|
||||
if (s->qcow_version == 2) {
|
||||
*spec_info->qcow2 = (ImageInfoSpecificQCow2){
|
||||
*spec_info->u.qcow2 = (ImageInfoSpecificQCow2){
|
||||
.compat = g_strdup("0.10"),
|
||||
.refcount_bits = s->refcount_bits,
|
||||
};
|
||||
} else if (s->qcow_version == 3) {
|
||||
*spec_info->qcow2 = (ImageInfoSpecificQCow2){
|
||||
*spec_info->u.qcow2 = (ImageInfoSpecificQCow2){
|
||||
.compat = g_strdup("1.1"),
|
||||
.lazy_refcounts = s->compatible_features &
|
||||
QCOW2_COMPAT_LAZY_REFCOUNTS,
|
||||
|
||||
+3
-3
@@ -2161,19 +2161,19 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs)
|
||||
ImageInfoList **next;
|
||||
|
||||
*spec_info = (ImageInfoSpecific){
|
||||
.kind = IMAGE_INFO_SPECIFIC_KIND_VMDK,
|
||||
.type = IMAGE_INFO_SPECIFIC_KIND_VMDK,
|
||||
{
|
||||
.vmdk = g_new0(ImageInfoSpecificVmdk, 1),
|
||||
},
|
||||
};
|
||||
|
||||
*spec_info->vmdk = (ImageInfoSpecificVmdk) {
|
||||
*spec_info->u.vmdk = (ImageInfoSpecificVmdk) {
|
||||
.create_type = g_strdup(s->create_type),
|
||||
.cid = s->cid,
|
||||
.parent_cid = s->parent_cid,
|
||||
};
|
||||
|
||||
next = &spec_info->vmdk->extents;
|
||||
next = &spec_info->u.vmdk->extents;
|
||||
for (i = 0; i < s->num_extents; i++) {
|
||||
*next = g_new0(ImageInfoList, 1);
|
||||
(*next)->value = vmdk_get_extent_info(&s->extents[i]);
|
||||
|
||||
+24
-23
@@ -1137,13 +1137,14 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
|
||||
}
|
||||
}
|
||||
|
||||
static void blockdev_do_action(int kind, void *data, Error **errp)
|
||||
static void blockdev_do_action(TransactionActionKind type, void *data,
|
||||
Error **errp)
|
||||
{
|
||||
TransactionAction action;
|
||||
TransactionActionList list;
|
||||
|
||||
action.kind = kind;
|
||||
action.data = data;
|
||||
action.type = type;
|
||||
action.u.data = data;
|
||||
list.value = &action;
|
||||
list.next = NULL;
|
||||
qmp_transaction(&list, errp);
|
||||
@@ -1388,9 +1389,9 @@ static void internal_snapshot_prepare(BlkTransactionState *common,
|
||||
InternalSnapshotState *state;
|
||||
int ret1;
|
||||
|
||||
g_assert(common->action->kind ==
|
||||
g_assert(common->action->type ==
|
||||
TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC);
|
||||
internal = common->action->blockdev_snapshot_internal_sync;
|
||||
internal = common->action->u.blockdev_snapshot_internal_sync;
|
||||
state = DO_UPCAST(InternalSnapshotState, common, common);
|
||||
|
||||
/* 1. parse input */
|
||||
@@ -1536,22 +1537,22 @@ static void external_snapshot_prepare(BlkTransactionState *common,
|
||||
TransactionAction *action = common->action;
|
||||
|
||||
/* get parameters */
|
||||
g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
|
||||
g_assert(action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
|
||||
|
||||
has_device = action->blockdev_snapshot_sync->has_device;
|
||||
device = action->blockdev_snapshot_sync->device;
|
||||
has_node_name = action->blockdev_snapshot_sync->has_node_name;
|
||||
node_name = action->blockdev_snapshot_sync->node_name;
|
||||
has_device = action->u.blockdev_snapshot_sync->has_device;
|
||||
device = action->u.blockdev_snapshot_sync->device;
|
||||
has_node_name = action->u.blockdev_snapshot_sync->has_node_name;
|
||||
node_name = action->u.blockdev_snapshot_sync->node_name;
|
||||
has_snapshot_node_name =
|
||||
action->blockdev_snapshot_sync->has_snapshot_node_name;
|
||||
snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name;
|
||||
action->u.blockdev_snapshot_sync->has_snapshot_node_name;
|
||||
snapshot_node_name = action->u.blockdev_snapshot_sync->snapshot_node_name;
|
||||
|
||||
new_image_file = action->blockdev_snapshot_sync->snapshot_file;
|
||||
if (action->blockdev_snapshot_sync->has_format) {
|
||||
format = action->blockdev_snapshot_sync->format;
|
||||
new_image_file = action->u.blockdev_snapshot_sync->snapshot_file;
|
||||
if (action->u.blockdev_snapshot_sync->has_format) {
|
||||
format = action->u.blockdev_snapshot_sync->format;
|
||||
}
|
||||
if (action->blockdev_snapshot_sync->has_mode) {
|
||||
mode = action->blockdev_snapshot_sync->mode;
|
||||
if (action->u.blockdev_snapshot_sync->has_mode) {
|
||||
mode = action->u.blockdev_snapshot_sync->mode;
|
||||
}
|
||||
|
||||
/* start processing */
|
||||
@@ -1681,8 +1682,8 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp)
|
||||
DriveBackup *backup;
|
||||
Error *local_err = NULL;
|
||||
|
||||
assert(common->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
|
||||
backup = common->action->drive_backup;
|
||||
assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
|
||||
backup = common->action->u.drive_backup;
|
||||
|
||||
blk = blk_by_name(backup->device);
|
||||
if (!blk) {
|
||||
@@ -1754,8 +1755,8 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp)
|
||||
BlockBackend *blk, *target;
|
||||
Error *local_err = NULL;
|
||||
|
||||
assert(common->action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP);
|
||||
backup = common->action->blockdev_backup;
|
||||
assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP);
|
||||
backup = common->action->u.blockdev_backup;
|
||||
|
||||
blk = blk_by_name(backup->device);
|
||||
if (!blk) {
|
||||
@@ -1887,9 +1888,9 @@ void qmp_transaction(TransactionActionList *dev_list, Error **errp)
|
||||
dev_info = dev_entry->value;
|
||||
dev_entry = dev_entry->next;
|
||||
|
||||
assert(dev_info->kind < ARRAY_SIZE(actions));
|
||||
assert(dev_info->type < ARRAY_SIZE(actions));
|
||||
|
||||
ops = &actions[dev_info->kind];
|
||||
ops = &actions[dev_info->type];
|
||||
assert(ops->instance_size > 0);
|
||||
|
||||
state = g_malloc0(ops->instance_size);
|
||||
|
||||
@@ -106,12 +106,15 @@ Types, commands, and events share a common namespace. Therefore,
|
||||
generally speaking, type definitions should always use CamelCase for
|
||||
user-defined type names, while built-in types are lowercase. Type
|
||||
definitions should not end in 'Kind', as this namespace is used for
|
||||
creating implicit C enums for visiting union types. Command names,
|
||||
creating implicit C enums for visiting union types, or in 'List', as
|
||||
this namespace is used for creating array types. Command names,
|
||||
and field names within a type, should be all lower case with words
|
||||
separated by a hyphen. However, some existing older commands and
|
||||
complex types use underscore; when extending such expressions,
|
||||
consistency is preferred over blindly avoiding underscore. Event
|
||||
names should be ALL_CAPS with words separated by underscore.
|
||||
names should be ALL_CAPS with words separated by underscore. Field
|
||||
names cannot start with 'has-' or 'has_', as this is reserved for
|
||||
tracking optional fields.
|
||||
|
||||
Any name (command, event, type, field, or enum value) beginning with
|
||||
"x-" is marked experimental, and may be withdrawn or changed
|
||||
@@ -122,9 +125,10 @@ vendor), even if the rest of the name uses dash (example:
|
||||
__com.redhat_drive-mirror). Other than downstream extensions (with
|
||||
leading underscore and the use of dots), all names should begin with a
|
||||
letter, and contain only ASCII letters, digits, dash, and underscore.
|
||||
It is okay to reuse names that match C keywords; the generator will
|
||||
rename a field named "default" in the QAPI to "q_default" in the
|
||||
generated C code.
|
||||
Names beginning with 'q_' are reserved for the generator: QMP names
|
||||
that resemble C keywords or other problematic strings will be munged
|
||||
in C to use this prefix. For example, a field named "default" in
|
||||
qapi becomes "q_default" in the generated C code.
|
||||
|
||||
In the rest of this document, usage lines are given for each
|
||||
expression type, with literal strings written in lower case and
|
||||
|
||||
@@ -569,8 +569,8 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict)
|
||||
for (client = info->clients; client; client = client->next) {
|
||||
monitor_printf(mon, "Client:\n");
|
||||
monitor_printf(mon, " address: %s:%s\n",
|
||||
client->value->base->host,
|
||||
client->value->base->service);
|
||||
client->value->host,
|
||||
client->value->service);
|
||||
monitor_printf(mon, " x509_dname: %s\n",
|
||||
client->value->x509_dname ?
|
||||
client->value->x509_dname : "none");
|
||||
@@ -638,7 +638,7 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict)
|
||||
for (chan = info->channels; chan; chan = chan->next) {
|
||||
monitor_printf(mon, "Channel:\n");
|
||||
monitor_printf(mon, " address: %s:%s%s\n",
|
||||
chan->value->base->host, chan->value->base->port,
|
||||
chan->value->host, chan->value->port,
|
||||
chan->value->tls ? " [tls]" : "");
|
||||
monitor_printf(mon, " session: %" PRId64 "\n",
|
||||
chan->value->connection_id);
|
||||
@@ -841,11 +841,11 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
|
||||
c, TpmModel_lookup[ti->model]);
|
||||
|
||||
monitor_printf(mon, " \\ %s: type=%s",
|
||||
ti->id, TpmTypeOptionsKind_lookup[ti->options->kind]);
|
||||
ti->id, TpmTypeOptionsKind_lookup[ti->options->type]);
|
||||
|
||||
switch (ti->options->kind) {
|
||||
switch (ti->options->type) {
|
||||
case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH:
|
||||
tpo = ti->options->passthrough;
|
||||
tpo = ti->options->u.passthrough;
|
||||
monitor_printf(mon, "%s%s%s%s",
|
||||
tpo->has_path ? ",path=" : "",
|
||||
tpo->has_path ? tpo->path : "",
|
||||
@@ -1735,15 +1735,15 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict)
|
||||
if (*endp != '\0') {
|
||||
goto err_out;
|
||||
}
|
||||
keylist->value->kind = KEY_VALUE_KIND_NUMBER;
|
||||
keylist->value->number = value;
|
||||
keylist->value->type = KEY_VALUE_KIND_NUMBER;
|
||||
keylist->value->u.number = value;
|
||||
} else {
|
||||
int idx = index_from_key(keyname_buf);
|
||||
if (idx == Q_KEY_CODE_MAX) {
|
||||
goto err_out;
|
||||
}
|
||||
keylist->value->kind = KEY_VALUE_KIND_QCODE;
|
||||
keylist->value->qcode = idx;
|
||||
keylist->value->type = KEY_VALUE_KIND_QCODE;
|
||||
keylist->value->u.qcode = idx;
|
||||
}
|
||||
|
||||
if (!separator) {
|
||||
@@ -1958,12 +1958,12 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
|
||||
value = info->value;
|
||||
|
||||
if (value) {
|
||||
switch (value->kind) {
|
||||
switch (value->type) {
|
||||
case MEMORY_DEVICE_INFO_KIND_DIMM:
|
||||
di = value->dimm;
|
||||
di = value->u.dimm;
|
||||
|
||||
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
|
||||
MemoryDeviceInfoKind_lookup[value->kind],
|
||||
MemoryDeviceInfoKind_lookup[value->type],
|
||||
di->id ? di->id : "");
|
||||
monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr);
|
||||
monitor_printf(mon, " slot: %" PRId64 "\n", di->slot);
|
||||
|
||||
+6
-6
@@ -842,13 +842,13 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
|
||||
ChannelState *s = (ChannelState *)dev;
|
||||
int qcode, keycode;
|
||||
|
||||
assert(evt->kind == INPUT_EVENT_KIND_KEY);
|
||||
qcode = qemu_input_key_value_to_qcode(evt->key->key);
|
||||
assert(evt->type == INPUT_EVENT_KIND_KEY);
|
||||
qcode = qemu_input_key_value_to_qcode(evt->u.key->key);
|
||||
trace_escc_sunkbd_event_in(qcode, QKeyCode_lookup[qcode],
|
||||
evt->key->down);
|
||||
evt->u.key->down);
|
||||
|
||||
if (qcode == Q_KEY_CODE_CAPS_LOCK) {
|
||||
if (evt->key->down) {
|
||||
if (evt->u.key->down) {
|
||||
s->caps_lock_mode ^= 1;
|
||||
if (s->caps_lock_mode == 2) {
|
||||
return; /* Drop second press */
|
||||
@@ -862,7 +862,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
|
||||
}
|
||||
|
||||
if (qcode == Q_KEY_CODE_NUM_LOCK) {
|
||||
if (evt->key->down) {
|
||||
if (evt->u.key->down) {
|
||||
s->num_lock_mode ^= 1;
|
||||
if (s->num_lock_mode == 2) {
|
||||
return; /* Drop second press */
|
||||
@@ -876,7 +876,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
|
||||
}
|
||||
|
||||
keycode = qcode_to_keycode[qcode];
|
||||
if (!evt->key->down) {
|
||||
if (!evt->u.key->down) {
|
||||
keycode |= 0x80;
|
||||
}
|
||||
trace_escc_sunkbd_event_out(keycode);
|
||||
|
||||
+16
-16
@@ -119,33 +119,33 @@ static void hid_pointer_event(DeviceState *dev, QemuConsole *src,
|
||||
assert(hs->n < QUEUE_LENGTH);
|
||||
e = &hs->ptr.queue[(hs->head + hs->n) & QUEUE_MASK];
|
||||
|
||||
switch (evt->kind) {
|
||||
switch (evt->type) {
|
||||
case INPUT_EVENT_KIND_REL:
|
||||
if (evt->rel->axis == INPUT_AXIS_X) {
|
||||
e->xdx += evt->rel->value;
|
||||
} else if (evt->rel->axis == INPUT_AXIS_Y) {
|
||||
e->ydy += evt->rel->value;
|
||||
if (evt->u.rel->axis == INPUT_AXIS_X) {
|
||||
e->xdx += evt->u.rel->value;
|
||||
} else if (evt->u.rel->axis == INPUT_AXIS_Y) {
|
||||
e->ydy += evt->u.rel->value;
|
||||
}
|
||||
break;
|
||||
|
||||
case INPUT_EVENT_KIND_ABS:
|
||||
if (evt->rel->axis == INPUT_AXIS_X) {
|
||||
e->xdx = evt->rel->value;
|
||||
} else if (evt->rel->axis == INPUT_AXIS_Y) {
|
||||
e->ydy = evt->rel->value;
|
||||
if (evt->u.rel->axis == INPUT_AXIS_X) {
|
||||
e->xdx = evt->u.rel->value;
|
||||
} else if (evt->u.rel->axis == INPUT_AXIS_Y) {
|
||||
e->ydy = evt->u.rel->value;
|
||||
}
|
||||
break;
|
||||
|
||||
case INPUT_EVENT_KIND_BTN:
|
||||
if (evt->btn->down) {
|
||||
e->buttons_state |= bmap[evt->btn->button];
|
||||
if (evt->btn->button == INPUT_BUTTON_WHEEL_UP) {
|
||||
if (evt->u.btn->down) {
|
||||
e->buttons_state |= bmap[evt->u.btn->button];
|
||||
if (evt->u.btn->button == INPUT_BUTTON_WHEEL_UP) {
|
||||
e->dz--;
|
||||
} else if (evt->btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
||||
} else if (evt->u.btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
||||
e->dz++;
|
||||
}
|
||||
} else {
|
||||
e->buttons_state &= ~bmap[evt->btn->button];
|
||||
e->buttons_state &= ~bmap[evt->u.btn->button];
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -223,8 +223,8 @@ static void hid_keyboard_event(DeviceState *dev, QemuConsole *src,
|
||||
int scancodes[3], i, count;
|
||||
int slot;
|
||||
|
||||
count = qemu_input_key_value_to_scancode(evt->key->key,
|
||||
evt->key->down,
|
||||
count = qemu_input_key_value_to_scancode(evt->u.key->key,
|
||||
evt->u.key->down,
|
||||
scancodes);
|
||||
if (hs->n + count > QUEUE_LENGTH) {
|
||||
fprintf(stderr, "usb-kbd: warning: key event queue full\n");
|
||||
|
||||
+12
-12
@@ -183,8 +183,8 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
|
||||
int scancodes[3], i, count;
|
||||
|
||||
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
|
||||
count = qemu_input_key_value_to_scancode(evt->key->key,
|
||||
evt->key->down,
|
||||
count = qemu_input_key_value_to_scancode(evt->u.key->key,
|
||||
evt->u.key->down,
|
||||
scancodes);
|
||||
for (i = 0; i < count; i++) {
|
||||
ps2_put_keycode(s, scancodes[i]);
|
||||
@@ -393,25 +393,25 @@ static void ps2_mouse_event(DeviceState *dev, QemuConsole *src,
|
||||
if (!(s->mouse_status & MOUSE_STATUS_ENABLED))
|
||||
return;
|
||||
|
||||
switch (evt->kind) {
|
||||
switch (evt->type) {
|
||||
case INPUT_EVENT_KIND_REL:
|
||||
if (evt->rel->axis == INPUT_AXIS_X) {
|
||||
s->mouse_dx += evt->rel->value;
|
||||
} else if (evt->rel->axis == INPUT_AXIS_Y) {
|
||||
s->mouse_dy -= evt->rel->value;
|
||||
if (evt->u.rel->axis == INPUT_AXIS_X) {
|
||||
s->mouse_dx += evt->u.rel->value;
|
||||
} else if (evt->u.rel->axis == INPUT_AXIS_Y) {
|
||||
s->mouse_dy -= evt->u.rel->value;
|
||||
}
|
||||
break;
|
||||
|
||||
case INPUT_EVENT_KIND_BTN:
|
||||
if (evt->btn->down) {
|
||||
s->mouse_buttons |= bmap[evt->btn->button];
|
||||
if (evt->btn->button == INPUT_BUTTON_WHEEL_UP) {
|
||||
if (evt->u.btn->down) {
|
||||
s->mouse_buttons |= bmap[evt->u.btn->button];
|
||||
if (evt->u.btn->button == INPUT_BUTTON_WHEEL_UP) {
|
||||
s->mouse_dz--;
|
||||
} else if (evt->btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
||||
} else if (evt->u.btn->button == INPUT_BUTTON_WHEEL_DOWN) {
|
||||
s->mouse_dz++;
|
||||
}
|
||||
} else {
|
||||
s->mouse_buttons &= ~bmap[evt->btn->button];
|
||||
s->mouse_buttons &= ~bmap[evt->u.btn->button];
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
+14
-13
@@ -191,44 +191,45 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src,
|
||||
virtio_input_event event;
|
||||
int qcode;
|
||||
|
||||
switch (evt->kind) {
|
||||
switch (evt->type) {
|
||||
case INPUT_EVENT_KIND_KEY:
|
||||
qcode = qemu_input_key_value_to_qcode(evt->key->key);
|
||||
qcode = qemu_input_key_value_to_qcode(evt->u.key->key);
|
||||
if (qcode && keymap_qcode[qcode]) {
|
||||
event.type = cpu_to_le16(EV_KEY);
|
||||
event.code = cpu_to_le16(keymap_qcode[qcode]);
|
||||
event.value = cpu_to_le32(evt->key->down ? 1 : 0);
|
||||
event.value = cpu_to_le32(evt->u.key->down ? 1 : 0);
|
||||
virtio_input_send(vinput, &event);
|
||||
} else {
|
||||
if (evt->key->down) {
|
||||
if (evt->u.key->down) {
|
||||
fprintf(stderr, "%s: unmapped key: %d [%s]\n", __func__,
|
||||
qcode, QKeyCode_lookup[qcode]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INPUT_EVENT_KIND_BTN:
|
||||
if (keymap_button[evt->btn->button]) {
|
||||
if (keymap_button[evt->u.btn->button]) {
|
||||
event.type = cpu_to_le16(EV_KEY);
|
||||
event.code = cpu_to_le16(keymap_button[evt->btn->button]);
|
||||
event.value = cpu_to_le32(evt->btn->down ? 1 : 0);
|
||||
event.code = cpu_to_le16(keymap_button[evt->u.btn->button]);
|
||||
event.value = cpu_to_le32(evt->u.btn->down ? 1 : 0);
|
||||
virtio_input_send(vinput, &event);
|
||||
} else {
|
||||
if (evt->btn->down) {
|
||||
if (evt->u.btn->down) {
|
||||
fprintf(stderr, "%s: unmapped button: %d [%s]\n", __func__,
|
||||
evt->btn->button, InputButton_lookup[evt->btn->button]);
|
||||
evt->u.btn->button,
|
||||
InputButton_lookup[evt->u.btn->button]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INPUT_EVENT_KIND_REL:
|
||||
event.type = cpu_to_le16(EV_REL);
|
||||
event.code = cpu_to_le16(axismap_rel[evt->rel->axis]);
|
||||
event.value = cpu_to_le32(evt->rel->value);
|
||||
event.code = cpu_to_le16(axismap_rel[evt->u.rel->axis]);
|
||||
event.value = cpu_to_le32(evt->u.rel->value);
|
||||
virtio_input_send(vinput, &event);
|
||||
break;
|
||||
case INPUT_EVENT_KIND_ABS:
|
||||
event.type = cpu_to_le16(EV_ABS);
|
||||
event.code = cpu_to_le16(axismap_abs[evt->abs->axis]);
|
||||
event.value = cpu_to_le32(evt->abs->value);
|
||||
event.code = cpu_to_le16(axismap_abs[evt->u.abs->axis]);
|
||||
event.value = cpu_to_le32(evt->u.abs->value);
|
||||
virtio_input_send(vinput, &event);
|
||||
break;
|
||||
default:
|
||||
|
||||
+3
-3
@@ -179,7 +179,7 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
|
||||
NULL);
|
||||
di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
|
||||
|
||||
info->dimm = di;
|
||||
info->u.dimm = di;
|
||||
elem->value = info;
|
||||
elem->next = NULL;
|
||||
**prev = elem;
|
||||
@@ -203,9 +203,9 @@ ram_addr_t get_current_ram_size(void)
|
||||
MemoryDeviceInfo *value = info->value;
|
||||
|
||||
if (value) {
|
||||
switch (value->kind) {
|
||||
switch (value->type) {
|
||||
case MEMORY_DEVICE_INFO_KIND_DIMM:
|
||||
size += value->dimm->size;
|
||||
size += value->u.dimm->size;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
+2
-2
@@ -187,8 +187,8 @@ int net_init_dump(const NetClientOptions *opts, const char *name,
|
||||
NetClientState *nc;
|
||||
DumpNetClient *dnc;
|
||||
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP);
|
||||
dump = opts->dump;
|
||||
assert(opts->type == NET_CLIENT_OPTIONS_KIND_DUMP);
|
||||
dump = opts->u.dump;
|
||||
|
||||
assert(peer);
|
||||
|
||||
|
||||
@@ -285,9 +285,9 @@ int net_init_hubport(const NetClientOptions *opts, const char *name,
|
||||
{
|
||||
const NetdevHubPortOptions *hubport;
|
||||
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT);
|
||||
assert(opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT);
|
||||
assert(!peer);
|
||||
hubport = opts->hubport;
|
||||
hubport = opts->u.hubport;
|
||||
|
||||
net_hub_add_port(hubport->hubid, name);
|
||||
return 0;
|
||||
|
||||
+2
-2
@@ -545,8 +545,8 @@ int net_init_l2tpv3(const NetClientOptions *opts,
|
||||
s->queue_tail = 0;
|
||||
s->header_mismatch = false;
|
||||
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_L2TPV3);
|
||||
l2tpv3 = opts->l2tpv3;
|
||||
assert(opts->type == NET_CLIENT_OPTIONS_KIND_L2TPV3);
|
||||
l2tpv3 = opts->u.l2tpv3;
|
||||
|
||||
if (l2tpv3->has_ipv6 && l2tpv3->ipv6) {
|
||||
s->ipv6 = l2tpv3->ipv6;
|
||||
|
||||
@@ -882,8 +882,8 @@ static int net_init_nic(const NetClientOptions *opts, const char *name,
|
||||
NICInfo *nd;
|
||||
const NetLegacyNicOptions *nic;
|
||||
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_NIC);
|
||||
nic = opts->nic;
|
||||
assert(opts->type == NET_CLIENT_OPTIONS_KIND_NIC);
|
||||
nic = opts->u.nic;
|
||||
|
||||
idx = nic_get_free_idx();
|
||||
if (idx == -1 || nb_nics >= MAX_NICS) {
|
||||
@@ -984,9 +984,9 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)
|
||||
opts = netdev->opts;
|
||||
name = netdev->id;
|
||||
|
||||
if (opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP ||
|
||||
opts->kind == NET_CLIENT_OPTIONS_KIND_NIC ||
|
||||
!net_client_init_fun[opts->kind]) {
|
||||
if (opts->type == NET_CLIENT_OPTIONS_KIND_DUMP ||
|
||||
opts->type == NET_CLIENT_OPTIONS_KIND_NIC ||
|
||||
!net_client_init_fun[opts->type]) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
|
||||
"a netdev backend type");
|
||||
return -1;
|
||||
@@ -997,16 +997,16 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)
|
||||
/* missing optional values have been initialized to "all bits zero" */
|
||||
name = net->has_id ? net->id : net->name;
|
||||
|
||||
if (opts->kind == NET_CLIENT_OPTIONS_KIND_NONE) {
|
||||
if (opts->type == NET_CLIENT_OPTIONS_KIND_NONE) {
|
||||
return 0; /* nothing to do */
|
||||
}
|
||||
if (opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT) {
|
||||
if (opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
|
||||
"a net type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!net_client_init_fun[opts->kind]) {
|
||||
if (!net_client_init_fun[opts->type]) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
|
||||
"a net backend type (maybe it is not compiled "
|
||||
"into this binary)");
|
||||
@@ -1014,17 +1014,17 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp)
|
||||
}
|
||||
|
||||
/* Do not add to a vlan if it's a nic with a netdev= parameter. */
|
||||
if (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC ||
|
||||
!opts->nic->has_netdev) {
|
||||
if (opts->type != NET_CLIENT_OPTIONS_KIND_NIC ||
|
||||
!opts->u.nic->has_netdev) {
|
||||
peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (net_client_init_fun[opts->kind](opts, name, peer, errp) < 0) {
|
||||
if (net_client_init_fun[opts->type](opts, name, peer, errp) < 0) {
|
||||
/* FIXME drop when all init functions store an Error */
|
||||
if (errp && !*errp) {
|
||||
error_setg(errp, QERR_DEVICE_INIT_FAILED,
|
||||
NetClientOptionsKind_lookup[opts->kind]);
|
||||
NetClientOptionsKind_lookup[opts->type]);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
+2
-2
@@ -746,8 +746,8 @@ int net_init_slirp(const NetClientOptions *opts, const char *name,
|
||||
const NetdevUserOptions *user;
|
||||
const char **dnssearch;
|
||||
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_USER);
|
||||
user = opts->user;
|
||||
assert(opts->type == NET_CLIENT_OPTIONS_KIND_USER);
|
||||
user = opts->u.user;
|
||||
|
||||
vnet = user->has_net ? g_strdup(user->net) :
|
||||
user->has_ip ? g_strdup_printf("%s/24", user->ip) :
|
||||
|
||||
+2
-2
@@ -706,8 +706,8 @@ int net_init_socket(const NetClientOptions *opts, const char *name,
|
||||
Error *err = NULL;
|
||||
const NetdevSocketOptions *sock;
|
||||
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_SOCKET);
|
||||
sock = opts->socket;
|
||||
assert(opts->type == NET_CLIENT_OPTIONS_KIND_SOCKET);
|
||||
sock = opts->u.socket;
|
||||
|
||||
if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mcast +
|
||||
sock->has_udp != 1) {
|
||||
|
||||
+2
-2
@@ -767,8 +767,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
|
||||
/* FIXME error_setg(errp, ...) on failure */
|
||||
const NetdevTapOptions *tap;
|
||||
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||
tap = opts->tap;
|
||||
assert(opts->type == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||
tap = opts->u.tap;
|
||||
|
||||
if (!tap->has_ifname) {
|
||||
error_report("tap: no interface name");
|
||||
|
||||
@@ -565,8 +565,8 @@ int net_init_bridge(const NetClientOptions *opts, const char *name,
|
||||
TAPState *s;
|
||||
int fd, vnet_hdr;
|
||||
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_BRIDGE);
|
||||
bridge = opts->bridge;
|
||||
assert(opts->type == NET_CLIENT_OPTIONS_KIND_BRIDGE);
|
||||
bridge = opts->u.bridge;
|
||||
|
||||
helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER;
|
||||
br = bridge->has_br ? bridge->br : DEFAULT_BRIDGE_INTERFACE;
|
||||
@@ -728,8 +728,8 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
|
||||
const char *vhostfdname;
|
||||
char ifname[128];
|
||||
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||
tap = opts->tap;
|
||||
assert(opts->type == NET_CLIENT_OPTIONS_KIND_TAP);
|
||||
tap = opts->u.tap;
|
||||
queues = tap->has_queues ? tap->queues : 1;
|
||||
vhostfdname = tap->has_vhostfd ? tap->vhostfd : NULL;
|
||||
|
||||
|
||||
@@ -115,8 +115,8 @@ int net_init_vde(const NetClientOptions *opts, const char *name,
|
||||
/* FIXME error_setg(errp, ...) on failure */
|
||||
const NetdevVdeOptions *vde;
|
||||
|
||||
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_VDE);
|
||||
vde = opts->vde;
|
||||
assert(opts->type == NET_CLIENT_OPTIONS_KIND_VDE);
|
||||
vde = opts->u.vde;
|
||||
|
||||
/* missing optional values have been initialized to "all bits zero" */
|
||||
if (net_vde_init(peer, "vde", name, vde->sock, vde->port, vde->group,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user