summaryrefslogtreecommitdiffstats
path: root/qga/commands-win32.c
diff options
context:
space:
mode:
authorEric Blake2016-02-09 22:27:16 +0100
committerMichael Roth2016-02-25 16:48:50 +0100
commit0b4b49387cce8358783a493004b77c1603b34b5c (patch)
treedebae516d511132c0a7155aa62148c26615666af /qga/commands-win32.c
parentMerge remote-tracking branch 'remotes/bkoppelmann/tags/pull-tricore-20160225'... (diff)
downloadqemu-0b4b49387cce8358783a493004b77c1603b34b5c.tar.gz
qemu-0b4b49387cce8358783a493004b77c1603b34b5c.tar.xz
qemu-0b4b49387cce8358783a493004b77c1603b34b5c.zip
qga: Support enum names in guest-file-seek
Magic constants are a pain to use, especially when we run the risk that our choice of '1' for QGA_SEEK_CUR might differ from the host or guest's choice of SEEK_CUR. Better is to use an enum value, via a qapi alternate type for back-compatibility. With this, {"command":"guest-file-seek", "arguments":{"handle":1, "offset":0, "whence":"cur"}} becomes a synonym for the older {"command":"guest-file-seek", "arguments":{"handle":1, "offset":0, "whence":1}} Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qga/commands-win32.c')
-rw-r--r--qga/commands-win32.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index cf0757cd0f..2799f5f082 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -385,7 +385,8 @@ done:
}
GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
- int64_t whence_code, Error **errp)
+ GuestFileWhence *whence_code,
+ Error **errp)
{
GuestFileHandle *gfh;
GuestFileSeek *seek_data;
@@ -394,6 +395,7 @@ GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
off_pos.QuadPart = offset;
BOOL res;
int whence;
+ Error *err = NULL;
gfh = guest_file_handle_find(handle, errp);
if (!gfh) {
@@ -401,18 +403,9 @@ GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
}
/* We stupidly exposed 'whence':'int' in our qapi */
- switch (whence_code) {
- case QGA_SEEK_SET:
- whence = SEEK_SET;
- break;
- case QGA_SEEK_CUR:
- whence = SEEK_CUR;
- break;
- case QGA_SEEK_END:
- whence = SEEK_END;
- break;
- default:
- error_setg(errp, "invalid whence code %"PRId64, whence_code);
+ whence = ga_parse_whence(whence_code, &err);
+ if (err) {
+ error_propagate(errp, err);
return NULL;
}