sdk/emulator/qemu.git
14 years agoQDict: Introduce qdict_get_qdict()
Luiz Capitulino [Thu, 21 Jan 2010 21:15:39 +0000 (19:15 -0200)]
QDict: Introduce qdict_get_qdict()

A helper to retrieve a QDict from a QDict.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQList: Introduce QLIST_FOREACH_ENTRY()
Luiz Capitulino [Thu, 21 Jan 2010 21:15:38 +0000 (19:15 -0200)]
QList: Introduce QLIST_FOREACH_ENTRY()

Iterate over QList entries, it's needed to call qlist_entry_obj()
to retrieve the stored QObject.

I'm not sure if it's ok to have this, because it's not as easy as
qlist_iter() and the QListEntry data type is now exposed to the
users, which means we have one more struct to be maintained when
we have libqmp.

Adding anyway, as it's more compact and people are asking for it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoRead-only device changed to opens it's file for read-only.
Naphtali Sprei [Thu, 21 Jan 2010 12:40:41 +0000 (14:40 +0200)]
Read-only device changed to opens it's file for read-only.

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoAsk for read-write permissions when opening files
Naphtali Sprei [Thu, 21 Jan 2010 12:40:39 +0000 (14:40 +0200)]
Ask for read-write permissions when opening files

Found some places that seems needs this explicitly, now that
read-write is not the default.

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoNo need anymoe for bdrv_set_read_only
Naphtali Sprei [Thu, 21 Jan 2010 12:40:37 +0000 (14:40 +0200)]
No need anymoe for bdrv_set_read_only

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoDocumentation: Add missing texi description for command line options
Stefan Weil [Wed, 20 Jan 2010 21:25:27 +0000 (22:25 +0100)]
Documentation: Add missing texi description for command line options

Some more command line options had entries for command line help,
but documentation for texi and derived formats (man, html, info)
was missing.

For conditional options, the texi documentation was added
unconditionally.

This seems reasonable because typically man pages are
shared, and html users expect to see one documentation
(not several nearly identical documents for the different
systems).

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoDocumentation: Improve command line help for -device option
Stefan Weil [Wed, 20 Jan 2010 21:58:35 +0000 (22:58 +0100)]
Documentation: Improve command line help for -device option

* Fix column for help text.

* Give some more help, especially for the new '?' parameters.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqdev: Add help for property value
Stefan Weil [Wed, 20 Jan 2010 21:58:34 +0000 (22:58 +0100)]
qdev: Add help for property value

When called with property value "?",
a help text will be printed (instead of an error message).

This is useful for command lines like
     qemu -device e1000,mac=?
and is already standard for other command line options.

A better help text could be provided by extending
the Property structure with a desc field.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqdev: Add help for device properties
Stefan Weil [Wed, 20 Jan 2010 21:58:33 +0000 (22:58 +0100)]
qdev: Add help for device properties

When called with property "?", a list of supported
properties will be printed (instead of an error message).

This is useful for command lines like
qemu -device e1000,?
and was already standard for other options like model=?

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agommap_frag() users only check for -1 error
Juan Quintela [Tue, 19 Jan 2010 23:56:24 +0000 (00:56 +0100)]
mmap_frag() users only check for -1 error

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoCheck availavility of -fstack-protector-all
Juan Quintela [Tue, 19 Jan 2010 23:56:23 +0000 (00:56 +0100)]
Check availavility of -fstack-protector-all

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoEnable _FORTIFY_SOURCE=2
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:22 +0000 (00:56 +0100)]
Enable _FORTIFY_SOURCE=2

_FORTIFY_SOURCE is a Glibc feature which adds memory and string function
protection.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agocheck pipe() return value
Juan Quintela [Tue, 19 Jan 2010 23:56:21 +0000 (00:56 +0100)]
check pipe() return value

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agolinux-user/mmap.c: fix warnings with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:20 +0000 (00:56 +0100)]
linux-user/mmap.c: fix warnings with _FORTIFY_SOURCE

CC    i386-linux-user/mmap.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'mmap_frag':
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:253: error: ignoring return value of 'pread', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'target_mmap':
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:477: error: ignoring return value of 'pread', declared with attribute warn_unused_result
make[1]: *** [mmap.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomonitor.c: fix warnings with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:19 +0000 (00:56 +0100)]
monitor.c: fix warnings with _FORTIFY_SOURCE

CC    i386-softmmu/monitor.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c: In function 'do_memory_save':
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c:1318: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c: In function 'do_physical_memory_save':
/usr/src/RPM/BUILD/qemu-0.11.92/monitor.c:1345: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result
make[1]: *** [monitor.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovl.c: fix warning with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:18 +0000 (00:56 +0100)]
vl.c: fix warning with _FORTIFY_SOURCE

CC    i386-softmmu/vl.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c: In function 'qemu_event_increment':
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:3404: error: ignoring return value of 'write', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c: In function 'main':
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:5774: error: ignoring return value of 'write', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:6064: error: ignoring return value of 'chdir', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/vl.c:6083: error: ignoring return value of 'chdir', declared with attribute warn_unused_result
make[1]: *** [vl.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agousb-linux.c: fix warning with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:17 +0000 (00:56 +0100)]
usb-linux.c: fix warning with _FORTIFY_SOURCE

CC    usb-linux.o
cc1: warnings being treated as errors
usb-linux.c: In function 'usb_host_read_file':
usb-linux.c:1204: error: ignoring return value of 'fgets', declared with attribute warn_unused_result
make: *** [usb-linux.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet/slirp.c: fix warning with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:16 +0000 (00:56 +0100)]
net/slirp.c: fix warning with _FORTIFY_SOURCE

CC    net/slirp.o
cc1: warnings being treated as errors
net/slirp.c: In function 'slirp_smb_cleanup':
net/slirp.c:470: error: ignoring return value of 'system', declared with attribute warn_unused_result
make: *** [net/slirp.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock/qcow2.c: fix warnings with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:15 +0000 (00:56 +0100)]
block/qcow2.c: fix warnings with _FORTIFY_SOURCE

CC    block/qcow2.o
cc1: warnings being treated as errors
block/qcow2.c: In function 'qcow_create2':
block/qcow2.c:829: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:838: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:839: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:841: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:844: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:849: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:852: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:855: error: ignoring return value of 'write', declared with attribute warn_unused_result
make: *** [block/qcow2.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock/vvfat.c: fix warnings with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:14 +0000 (00:56 +0100)]
block/vvfat.c: fix warnings with _FORTIFY_SOURCE

CC    block/vvfat.o
cc1: warnings being treated as errors
block/vvfat.c: In function 'commit_one_file':
block/vvfat.c:2259: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result
make: *** [block/vvfat.o] Error 1
  CC    block/vvfat.o
In file included from /usr/include/stdio.h:912,
                 from ./qemu-common.h:19,
                 from block/vvfat.c:27:
In function 'snprintf',
    inlined from 'init_directories' at block/vvfat.c:871,
    inlined from 'vvfat_open' at block/vvfat.c:1068:
/usr/include/bits/stdio2.h:65: error: call to __builtin___snprintf_chk will always overflow destination buffer
make: *** [block/vvfat.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock/vmdk.o: fix warnings with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:13 +0000 (00:56 +0100)]
block/vmdk.o: fix warnings with _FORTIFY_SOURCE

CC    block/vmdk.o
cc1: warnings being treated as errors
block/vmdk.c: In function 'vmdk_snapshot_create':
block/vmdk.c:236: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result
block/vmdk.c: In function 'vmdk_create':
block/vmdk.c:775: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/vmdk.c:776: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/vmdk.c:778: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result
block/vmdk.c:784: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/vmdk.c:790: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/vmdk.c:807: error: ignoring return value of 'write', declared with attribute warn_unused_result
make: *** [block/vmdk.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock/qcow.c: fix warnings with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:12 +0000 (00:56 +0100)]
block/qcow.c: fix warnings with _FORTIFY_SOURCE

CC    block/qcow.o
cc1: warnings being treated as errors
block/qcow.c: In function 'qcow_create':
block/qcow.c:804: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow.c:806: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow.c:811: error: ignoring return value of 'write', declared with attribute warn_unused_result
make: *** [block/qcow.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock/cow.c: fix warnings with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:11 +0000 (00:56 +0100)]
block/cow.c: fix warnings with _FORTIFY_SOURCE

CC    block/cow.o
cc1: warnings being treated as errors
block/cow.c: In function 'cow_create':
block/cow.c:251: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/cow.c:253: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result
make: *** [block/cow.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoposix-aio-compat.c: fix warning with _FORTIFY_SOURCE
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:10 +0000 (00:56 +0100)]
posix-aio-compat.c: fix warning with _FORTIFY_SOURCE

CC    posix-aio-compat.o
cc1: warnings being treated as errors
posix-aio-compat.c: In function 'aio_signal_handler':
posix-aio-compat.c:505: error: ignoring return value of 'write', declared with attribute warn_unused_result
make: *** [posix-aio-compat.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoforce to test result for qemu_write_full()
Juan Quintela [Tue, 19 Jan 2010 23:56:09 +0000 (00:56 +0100)]
force to test result for qemu_write_full()

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoIntroduce qemu_write_full()
Kirill A. Shutemov [Tue, 19 Jan 2010 23:56:08 +0000 (00:56 +0100)]
Introduce qemu_write_full()

A variant of write(2) which handles partial write.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqcow2: Don't ignore qcow2_alloc_clusters return value
Kevin Wolf [Wed, 20 Jan 2010 14:04:01 +0000 (15:04 +0100)]
qcow2: Don't ignore qcow2_alloc_clusters return value

Now that qcow2_alloc_clusters can return error codes, we must handle them in
the callers of qcow2_alloc_clusters.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqcow2: Don't ignore update_refcount return value
Kevin Wolf [Wed, 20 Jan 2010 14:03:06 +0000 (15:03 +0100)]
qcow2: Don't ignore update_refcount return value

update_refcount can return errors that need to be handled by the callers.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqcow2: Allow updating no refcounts
Kevin Wolf [Wed, 20 Jan 2010 14:03:05 +0000 (15:03 +0100)]
qcow2: Allow updating no refcounts

There's absolutely no problem with updating the refcounts of 0 clusters.
At least snapshot code is doing this and would fail once the result of
update_refcount isn't ignored any more.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqcow2: Improve error handling in update_refcount
Kevin Wolf [Wed, 20 Jan 2010 14:03:04 +0000 (15:03 +0100)]
qcow2: Improve error handling in update_refcount

If update_refcount fails, try to undo any changes made so far to avoid
inconsistencies in the image file.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqcow2: Fix error handling in grow_refcount_table
Kevin Wolf [Wed, 20 Jan 2010 14:03:03 +0000 (15:03 +0100)]
qcow2: Fix error handling in grow_refcount_table

Return the appropriate error code instead of -EIO.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock: Return original error codes in bdrv_pread/write
Kevin Wolf [Wed, 20 Jan 2010 14:03:02 +0000 (15:03 +0100)]
block: Return original error codes in bdrv_pread/write

Don't assume -EIO but return the real error.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqcow2: Return 0/-errno in qcow2_alloc_cluster_offset
Kevin Wolf [Wed, 20 Jan 2010 14:03:01 +0000 (15:03 +0100)]
qcow2: Return 0/-errno in qcow2_alloc_cluster_offset

Returning 0/-errno allows it to distingush different errors classes. The
cluster offset of newly allocated clusters is now returned in the QCowL2Meta
struct.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqcow2: Return 0/-errno in get_cluster_table
Kevin Wolf [Wed, 20 Jan 2010 14:03:00 +0000 (15:03 +0100)]
qcow2: Return 0/-errno in get_cluster_table

Switching to 0/-errno allows it to distinguish different error cases.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqcow2: Fix error handling in qcow_save_vmstate
Kevin Wolf [Wed, 20 Jan 2010 14:02:59 +0000 (15:02 +0100)]
qcow2: Fix error handling in qcow_save_vmstate

Don't assume success but pass the bdrv_pwrite return value on.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqcow2: Fix error handling in qcow2_grow_l1_table
Kevin Wolf [Wed, 20 Jan 2010 14:02:58 +0000 (15:02 +0100)]
qcow2: Fix error handling in qcow2_grow_l1_table

Return the appropriate error value instead of always using EIO. Don't free the
L1 table on errors, we still need it.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomonitor: convert do_cpu_set() to QObject, QError
Markus Armbruster [Wed, 20 Jan 2010 12:07:35 +0000 (13:07 +0100)]
monitor: convert do_cpu_set() to QObject, QError

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQError: New QERR_INVALID_CPU_INDEX
Markus Armbruster [Wed, 20 Jan 2010 12:07:34 +0000 (13:07 +0100)]
QError: New QERR_INVALID_CPU_INDEX

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomonitor: convert do_physical_memory_save() to QError
Markus Armbruster [Wed, 20 Jan 2010 12:07:33 +0000 (13:07 +0100)]
monitor: convert do_physical_memory_save() to QError

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomonitor: convert do_memory_save() to QError
Markus Armbruster [Wed, 20 Jan 2010 12:07:32 +0000 (13:07 +0100)]
monitor: convert do_memory_save() to QError

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQError: New QERR_OPEN_FILE_FAILED
Markus Armbruster [Wed, 20 Jan 2010 12:07:31 +0000 (13:07 +0100)]
QError: New QERR_OPEN_FILE_FAILED

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomonitor: Don't check for mon_get_cpu() failure
Markus Armbruster [Wed, 20 Jan 2010 12:07:30 +0000 (13:07 +0100)]
monitor: Don't check for mon_get_cpu() failure

mon_get_cpu() can't return null pointer, because it passes its return
value to cpu_synchronize_state() first, which crashes if its argument
is null.

Remove the (pretty cheesy) handling of this non-existing error.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agojson: escape u0000 .. u001F when outputting json
Anthony Liguori [Mon, 25 Jan 2010 14:56:53 +0000 (08:56 -0600)]
json: escape u0000 .. u001F when outputting json

Markus Armbruster pointed out:

JSON requires control characters in strings to be escaped.  RFC 4627
section 2.5:

   A string begins and ends with quotation marks.  All Unicode
   characters may be placed within the quotation marks except for the
   characters that must be escaped: quotation mark, reverse solidus, and
   the control characters (U+0000 through U+001F).

We've been quoting the special escape sequences that JSON defines but we
haven't been encoding the full control character range.  This patch fixes that.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoSparc64: fix initrd
Blue Swirl [Sun, 24 Jan 2010 21:18:00 +0000 (21:18 +0000)]
Sparc64: fix initrd

Fix HdrS offsets for Sparc64. The initrd address must be offset by
KERNBASE.

Use rom_ptr mechanism to actually write to the kernel image.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopflash: Dont open memarea for full IO if already done.
Edgar E. Iglesias [Sun, 24 Jan 2010 18:28:55 +0000 (19:28 +0100)]
pflash: Dont open memarea for full IO if already done.

When wcycle is non zero the area is already opened for readable IO.
Avoiding the re-registration of the memarea significantly speeds up
the flash emulation. In particular for flashes connected through 8 or
16-bit buses.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
14 years agopflash: Reduce writebuf len for 8-bit flashes.
Edgar E. Iglesias [Sun, 24 Jan 2010 17:39:51 +0000 (18:39 +0100)]
pflash: Reduce writebuf len for 8-bit flashes.

Flashes connected through an 8 bit bus cannot handle write buffers
larger than 256 bytes.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
14 years agopflash: Remove dead code, no functional changes.
Edgar E. Iglesias [Sun, 24 Jan 2010 16:19:19 +0000 (17:19 +0100)]
pflash: Remove dead code, no functional changes.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
14 years agomicroblaze: The petalogix s3adsp board uses intel flashes
Edgar E. Iglesias [Sun, 24 Jan 2010 16:15:05 +0000 (17:15 +0100)]
microblaze: The petalogix s3adsp board uses intel flashes

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
14 years agoLoad global config files by default
Anthony Liguori [Thu, 21 Jan 2010 16:57:58 +0000 (10:57 -0600)]
Load global config files by default

A new option, -nodefconfig is introduced to prevent loading from the default
config location.  Otherwise, two configuration files will be searched for,
qemu.conf and target-<TARGET_NAME>.conf.

To ensure that the default configuration is overridden by a user specified
config, we introduce a two stage option parsing mechanism.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoMove out option lookup into a separate function
Anthony Liguori [Fri, 22 Jan 2010 15:18:06 +0000 (09:18 -0600)]
Move out option lookup into a separate function

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoSupport --sysconfdir in configure to specify path to configuration files
Anthony Liguori [Thu, 21 Jan 2010 16:30:29 +0000 (10:30 -0600)]
Support --sysconfdir in configure to specify path to configuration files

The default value is ${prefix}/etc/qemu.  --sysconfdir can be used to override
the default to an absolute path.  The expectation is that when installed to
/usr, --sysconfdir=/etc/qemu will be used.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoSparc32: fix free-run timer
Blue Swirl [Sun, 24 Jan 2010 14:28:21 +0000 (14:28 +0000)]
Sparc32: fix free-run timer

According to Sun4M System Architecture Manual chapter 5.3.2, a limit
of 0 will not generate interrupts.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoMusicpal: Fix descriptor walk in eth_send
Jan Kiszka [Sun, 24 Jan 2010 08:51:49 +0000 (09:51 +0100)]
Musicpal: Fix descriptor walk in eth_send

Commit 930c86820e introduced a regression to eth_send: eth_tx_desc_put
manipulates the host's tx descriptor copy before writing it back, but
two lines down the descriptor is evaluated again, leaving us with an
invalid next address if host and guest endianness differ. So this was
the actual issue commit 2e87c5b937 tried to paper over.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: malc <av1474@comtv.ru>
14 years agoMusicpal: Fix wm8750 I2C address
Jan Kiszka [Sat, 23 Jan 2010 17:51:22 +0000 (18:51 +0100)]
Musicpal: Fix wm8750 I2C address

Commit b3a219883e uncovered that we attached the Wolfson with an I2C
address shifted left by one. Fixing this makes sound work again for
the Musicpal.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: malc <av1474@comtv.ru>
14 years agosparc32 fix np dereference in do_unassigned_access
Artyom Tarasenko [Fri, 22 Jan 2010 21:31:53 +0000 (22:31 +0100)]
sparc32 fix np dereference in do_unassigned_access

fix a potential null pointer dereference introduced in
commit 576c2cdc767ab9e2dc038fa4c99f22e53287a3de

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoSparc64: fix PCI probe problems
Blue Swirl [Fri, 22 Jan 2010 18:39:49 +0000 (18:39 +0000)]
Sparc64: fix PCI probe problems

Byte swap PCI config values.

Remove old bogus PCI config mechanism so that device 0:0.0 can be probed.
This requires OpenBIOS r667.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoRevert "block: prevent multiwrite_merge from creating too large iovecs"
Anthony Liguori [Wed, 20 Jan 2010 16:12:23 +0000 (10:12 -0600)]
Revert "block: prevent multiwrite_merge from creating too large iovecs"

This reverts commit 0076bc0c1d93adcbc7f1af184e04902cf37e9ab8.

Kevin Wolf pointed out that this breaks the mingw32 build.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomake: qemu-img depends on config-host.h
Anthony Liguori [Wed, 20 Jan 2010 16:09:35 +0000 (10:09 -0600)]
make: qemu-img depends on config-host.h

Fixes mingw32 build out of tree.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoreduce number of reinjects on ACK
Gleb Natapov [Wed, 20 Jan 2010 13:37:33 +0000 (15:37 +0200)]
reduce number of reinjects on ACK

Windows 7 BSODs under load with HAL_RTC_IRQF_WILL_NOT_CLEAR error.

It happens here:
hal!HalpRtcUnmaskClock:
8281b93a 8bff            mov     edi,edi
8281b93c 56              push    esi
8281b93d 33f6            xor     esi,esi
8281b93f 6a0c            push    0Ch
8281b941 e8b2ffffff      call    hal!CMOS_READ (8281b8f8)
8281b946 84c0            test    al,al
8281b948 7920            jns     hal!HalpRtcUnmaskClock+0x30 (8281b96a)
8281b94a 6a0a            push    0Ah
8281b94c 46              inc     esi
8281b94d e854c8ffff      call    hal!KeStallExecutionProcessor (828181a6)
8281b952 83fe64          cmp     esi,64h
8281b955 72e8            jb      hal!HalpRtcUnmaskClock+0x5 (8281b93f)
8281b957 6a00            push    0
8281b959 6a00            push    0
8281b95b 6a00            push    0
8281b95d 680a010000      push    10Ah
8281b962 6a5c            push    5Ch
8281b964 ff1500c38082    call    dword ptr [hal!_imp__KeBugCheckEx (8280c300)]
8281b96a 5e              pop     esi
8281b96b c3              ret

So it loops for 100(64h) times reading register C before BSOD. Lets
reduce number of immediate reinjection well under this limit.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock: prevent multiwrite_merge from creating too large iovecs
Christoph Hellwig [Tue, 19 Jan 2010 21:15:39 +0000 (22:15 +0100)]
block: prevent multiwrite_merge from creating too large iovecs

If we go over the maximum number of iovecs support by syscall we get
back EINVAL from the kernel which translate to I/O errors for the guest.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock: fix cache flushing in bdrv_commit
Christoph Hellwig [Sun, 17 Jan 2010 11:32:30 +0000 (12:32 +0100)]
block: fix cache flushing in bdrv_commit

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQMP: Fix asynchronous events delivery
Luiz Capitulino [Wed, 20 Jan 2010 12:37:59 +0000 (10:37 -0200)]
QMP: Fix asynchronous events delivery

Commit f039a563f200beee80cc10fd70b21ea396979dab introduces
a regression as monitor_protocol_event() will return in
the first user Monitor it finds in the QLIST_FOREACH()
loop.

The right thing to do is to only delivery an asynchronous
event if the 'mon' is a QMP Monitor.

The aforementioned commit was an early version, if it was
applied to stable (it should) this one has to be applied
there too.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovnc: Use inet_strfamily()
Luiz Capitulino [Wed, 20 Jan 2010 13:42:40 +0000 (11:42 -0200)]
vnc: Use inet_strfamily()

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: inet_strfamily(): Better unknown family report
Luiz Capitulino [Wed, 20 Jan 2010 13:42:39 +0000 (11:42 -0200)]
net: inet_strfamily(): Better unknown family report

Returning "????" is a bit meaningless, let's call it "unknown".

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: Make inet_strfamily() public
Luiz Capitulino [Wed, 20 Jan 2010 13:42:38 +0000 (11:42 -0200)]
net: Make inet_strfamily() public

So that it can be used by other subsystems.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Use MSI vectors for port virtqueues
Amit Shah [Tue, 19 Jan 2010 19:06:58 +0000 (00:36 +0530)]
virtio-serial: Use MSI vectors for port virtqueues

This commit enables the use of MSI interrupts for virtqueue
notifications for ports. We use nr_ports + 1 (for control channel) msi
entries for the ports, as only the in_vq operations need an interrupt on
the guest.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoMove virtio-serial to Makefile.objs
Amit Shah [Tue, 19 Jan 2010 19:06:57 +0000 (00:36 +0530)]
Move virtio-serial to Makefile.objs

There's nothing target-dependent in the virtio-serial code so allow it
to be compiled just once for all the targets.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Add a 'virtserialport' device for generic serial port support
Amit Shah [Tue, 19 Jan 2010 19:06:56 +0000 (00:36 +0530)]
virtio-serial: Add a 'virtserialport' device for generic serial port support

This commit adds a simple chardev-based serial port. Any data the guest
sends is forwarded to the chardev and vice-versa.

Sample uses for such a device can be obtaining info from the guest like
the file systems used, apps installed, etc. for offline usage and
logged-in users, clipboard copy-paste, etc. for online usage.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial-bus: Add ability to hot-unplug ports
Amit Shah [Tue, 19 Jan 2010 19:06:55 +0000 (00:36 +0530)]
virtio-serial-bus: Add ability to hot-unplug ports

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial-bus: Add a port 'name' property for port discovery in guests
Amit Shah [Tue, 19 Jan 2010 19:06:54 +0000 (00:36 +0530)]
virtio-serial-bus: Add a port 'name' property for port discovery in guests

The port 'id' or number is internal state between the guest kernel and
our bus implementation. This is invocation-dependent and isn't part of
the guest-host ABI.

To correcly enumerate and map ports between the host and the guest, the
'name' property is used.

Example:

    -device virtserialport,name=org.qemu.port.0

This invocation will get us a char device in the guest at:

    /dev/virtio-ports/org.qemu.port.0

which can be a symlink to

    /dev/vport0p3

This 'name' property is exposed by the guest kernel in a sysfs
attribute:

    /sys/kernel/virtio-ports/vport0p3/name

A simple udev script can pick up this name and create the symlink
mentioned above.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial-bus: Maintain guest and host port open/close state
Amit Shah [Tue, 19 Jan 2010 19:06:53 +0000 (00:36 +0530)]
virtio-serial-bus: Maintain guest and host port open/close state

Via control channel messages, the guest can tell us whether a port got
opened or closed. Similarly, we can also indicate to the guest of host
port open/close events.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-console: qdev conversion, new virtio-serial-bus
Amit Shah [Tue, 19 Jan 2010 19:06:52 +0000 (00:36 +0530)]
virtio-console: qdev conversion, new virtio-serial-bus

This commit converts the virtio-console device to create a new
virtio-serial bus that can host console and generic serial ports. The
file hosting this code is now called virtio-serial-bus.c.

The virtio console is now a very simple qdev device that sits on the
virtio-serial-bus and communicates between the bus and qemu's chardevs.

This commit also includes a few changes to the virtio backing code for
pci and s390 to spawn the virtio-serial bus.

As a result of the qdev conversion, we get rid of a lot of legacy code.
The old-style way of instantiating a virtio console using

    -virtioconsole ...

is maintained, but the new, preferred way is to use

    -device virtio-serial -device virtconsole,chardev=...

With this commit, multiple devices as well as multiple ports with a
single device can be supported.

For multiple ports support, each port gets an IO vq pair. Since the
guest needs to know in advance how many vqs a particular device will
need, we have to set this number as a property of the virtio-serial
device and also as a config option.

In addition, we also spawn a pair of control IO vqs. This is an internal
channel meant for guest-host communication for things like port
open/close, sending port properties over to the guest, etc.

This commit is a part of a series of other commits to get the full
implementation of multiport support. Future commits will add other
support as well as ride on the savevm version that we bump up here.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio: Remove duplicate macro definition for max. virtqueues, bump up the max
Amit Shah [Tue, 19 Jan 2010 19:06:51 +0000 (00:36 +0530)]
virtio: Remove duplicate macro definition for max. virtqueues, bump up the max

VIRTIO_PCI_QUEUE_MAX is redefined in hw/virtio.c. Let's just keep it in
hw/virtio.h.

Also, bump up the value of the maximum allowed virtqueues to 64. This is
in preparation to allow multiple ports per virtio-console device.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoDisable fall-back to read-only when cannot open drive's file for read-write
Naphtali Sprei [Sun, 17 Jan 2010 14:48:15 +0000 (16:48 +0200)]
Disable fall-back to read-only when cannot open drive's file for read-write

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoAdded drives' readonly option
Naphtali Sprei [Sun, 17 Jan 2010 14:48:14 +0000 (16:48 +0200)]
Added drives' readonly option

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoClean-up a little bit the RW related bits of BDRV_O_FLAGS. BDRV_O_RDONLY gone (and...
Naphtali Sprei [Sun, 17 Jan 2010 14:48:13 +0000 (16:48 +0200)]
Clean-up a little bit the RW related bits of BDRV_O_FLAGS. BDRV_O_RDONLY gone (and so is BDRV_O_ACCESS). Default value for bdrv_flags (0/zero) is READ-ONLY. Need to explicitly request READ-WRITE.

Instead of using the field 'readonly' of the BlockDriverState struct for passing the request,
pass the request in the flags parameter to the function.

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoMake CDROM a read-only drive
Naphtali Sprei [Sun, 17 Jan 2010 14:48:12 +0000 (16:48 +0200)]
Make CDROM a read-only drive

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoDocumentation: Add missing documentation for qdev related command line options
Stefan Weil [Sat, 16 Jan 2010 17:19:44 +0000 (18:19 +0100)]
Documentation: Add missing documentation for qdev related command line options

The command line options -device, -nodefaults, -readconfig,
-writeconfig had entries for command line help, but
documentation for texi and derived formats (man, html, info)
was missing.

This also required moving "@end table" to the end of
qemu-options.hx again.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agopc: add driver version compat properties
Gerd Hoffmann [Thu, 14 Jan 2010 13:44:14 +0000 (14:44 +0100)]
pc: add driver version compat properties

This patch adds compat property entries for ide-disk.ver and
scsi-disk.ver to pc-0.10 and pc-0.11.  With this patch applied
the scsi and ide disks report "0.10" and "0.11" as version when
you start qemu with "-M pc-0.10" or "-M pc-0.11".

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: device version property
Gerd Hoffmann [Thu, 14 Jan 2010 13:44:13 +0000 (14:44 +0100)]
scsi: device version property

This patch adds a new property named 'ver' to scsi-disk which allows to
specify the version which the virtual disk/cdrom should report to the
guest.  By default this is the qemu version (i.e. 0.12).  usage:

  -drive if=none,id=disk,file=...
  -device lsi
  -device scsi-disk,drive=disk,bus=scsi.0,unit=0,ver=42

You can also switch the version for all scsi drives using:

  -global scsi-disk.ver=42

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoide: device version property
Gerd Hoffmann [Thu, 14 Jan 2010 13:44:12 +0000 (14:44 +0100)]
ide: device version property

This patch adds a new property named 'ver' to ide-drive which allows to
specify the version which the virtual disk/cdrom should report to the
guest.  By default this is the qemu version (i.e. 0.12).  usage:

  -drive if=none,id=disk,file=...
  -device ide-drive,bus=ide.0,unit=0,drive=disk,ver=42

You can also switch the version for all ide drives using:

  -global ide-drive.ver=42

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQMP: Emit asynchronous events on all QMP monitors
Adam Litke [Fri, 15 Jan 2010 14:34:02 +0000 (08:34 -0600)]
QMP: Emit asynchronous events on all QMP monitors

When using a control/QMP monitor in tandem with a regular monitor, asynchronous
messages can get lost depending on the order of the QEMU program arguments.
QEMU events issued by monitor_protocol_event() always go to cur_mon.  If the
user monitor was specified on the command line first (or it has ,default), the
message will be directed to the user monitor (not the QMP monitor).
Additionally, only one QMP session is currently able to receive async messages.

To avoid this confusion, scan through the list of monitors and emit the message
on each QMP monitor.

Signed-off-by: Adam Litke <agl@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoFix QEMU_WARN_UNUSED_RESULT
Kevin Wolf [Fri, 15 Jan 2010 11:56:41 +0000 (12:56 +0100)]
Fix QEMU_WARN_UNUSED_RESULT

Since commit 747bbdf7 QEMU_WARN_UNUSED_RESULT is never defined as it is
conditional on a define from config-host.h which is included only later.
Include that file earlier to get the warnings back.

Reactivating it unfortunately leads to some warnings about unused qdev_init
results. These calls are changed to qdev_init_nofail to avoid build failures.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQMP: Introduce VNC_INITIALIZED event
Luiz Capitulino [Thu, 14 Jan 2010 16:50:59 +0000 (14:50 -0200)]
QMP: Introduce VNC_INITIALIZED event

It's emitted when a VNC client session is activated by QEMU,
client's information such as port, IP and auth ID (if the
session is authenticated) are provided.

Event example:

{ "event": "VNC_INITIALIZED",
    "timestamp": {"seconds": 1263475302, "microseconds": 150772},
    "data": {
        "server": { "auth": "sasl", "family": "ipv4",
                    "service": "5901", "host": "0.0.0.0"},
        "client": { "family": "ipv4", "service": "46089",
                    "host": "127.0.0.1", "sasl_username": "lcapitulino" } } }

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQMP: Introduce VNC_DISCONNECTED event
Luiz Capitulino [Thu, 14 Jan 2010 16:50:58 +0000 (14:50 -0200)]
QMP: Introduce VNC_DISCONNECTED event

It's emitted when a VNC client disconnects from QEMU, client's
information such as port and IP address are provided.

Event example:

{ "event": "VNC_DISCONNECTED",
    "timestamp": { "seconds": 1262976601, "microseconds": 975795 },
    "data": {
        "server": { "auth": "sasl", "family": "ipv4",
                    "service": "5901", "host": "0.0.0.0" },
        "client": { "family": "ipv4", "service": "58425",
                    "host": "127.0.0.1", "sasl_username": "foo" } } }

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQMP: Introduce VNC_CONNECTED event
Luiz Capitulino [Thu, 14 Jan 2010 16:50:57 +0000 (14:50 -0200)]
QMP: Introduce VNC_CONNECTED event

It's emitted when a VNC client connects to QEMU, client's information
such as port and IP address are provided.

Note that this event is emitted right when the connection is
established. This means that it happens before authentication
procedure and session initialization.

Event example:

{ "event": "VNC_CONNECTED",
    "timestamp": { "seconds": 1262976601, "microseconds": 975795 },
    "data": {
        "server": { "auth": "sasl", "family": "ipv4",
                    "service": "5901", "host": "0.0.0.0" },
        "client": { "family": "ipv4", "service": "58425",
                    "host": "127.0.0.1" } } }

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoVNC: Cache client info at connection time
Luiz Capitulino [Thu, 14 Jan 2010 16:50:56 +0000 (14:50 -0200)]
VNC: Cache client info at connection time

When a disconnection happens the client's socket on QEMU
side may become invalid, this way it won't be possible
to query it to get client information, which is going to
be needed by the future QMP VNC_DISCONNECTED event.

To always have this information available we query the
socket at connection time and cache the client info in
struct VncState.

Two function are introduced to perform this job.

vnc_client_cache_addr() is called right when the connection
is made, however the authentication information is not
available at that moment so vnc_client_cache_auth() is
called from protocol_client_init() to get auth info.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoVNC: Add 'family' key
Luiz Capitulino [Thu, 14 Jan 2010 16:50:55 +0000 (14:50 -0200)]
VNC: Add 'family' key

It contains the socket adress family name, like "ipv4" or
"ipv6".

This is useful for clients so that they can interpret the
'host' key reliably.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoVNC: Rename client's 'username' key
Luiz Capitulino [Thu, 14 Jan 2010 16:50:54 +0000 (14:50 -0200)]
VNC: Rename client's 'username' key

It's the SASL username, so it's better to call it 'sasl_username'
to be consistent.

Note that this change wouldn't be allowed if QMP were stable.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoVNC: Make 'auth' key mandatory
Luiz Capitulino [Thu, 14 Jan 2010 16:50:53 +0000 (14:50 -0200)]
VNC: Make 'auth' key mandatory

There is no reason to have it as optional and the code
in the server and client gets slightly simpler if the
key is mandatory.

While there also do some cleanup on how the server info is
collected.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoVNC: Use 'enabled' key instead of 'status'
Luiz Capitulino [Thu, 14 Jan 2010 16:50:52 +0000 (14:50 -0200)]
VNC: Use 'enabled' key instead of 'status'

Currently the 'status' key is a string whose value can be
"disabled" or "enabled", change it to the QMP's standard
'enabled' key, which is a bool.

Note that 'status' in being dropped and this wouldn't be
allowed if QMP were stable.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agochar: Remove redundant qemu_chr_generic_open() call.
Kusanagi Kouichi [Thu, 14 Jan 2010 15:46:24 +0000 (00:46 +0900)]
char: Remove redundant qemu_chr_generic_open() call.

qemu_chr_open_fd() calls qemu_chr_generic_open(),
so qemu_chr_open_tty() doesn't need to call it.

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoraw-posix: Detect legacy floppy via ioctl on linux
Cole Robinson [Thu, 14 Jan 2010 16:19:41 +0000 (11:19 -0500)]
raw-posix: Detect legacy floppy via ioctl on linux

Current legacy floppy detection is hardcoded based on source file
name. Make this smarter on linux by attempting a floppy specific
ioctl.

v2:
    Give ioctl check higher priority than filename check
    s/IDE/legacy/

v3:
    Actually initialize 'prio' variable
    Check for ioctl success rather than absence of specific failure

v4:
    Explicitly mention that change is linux specific.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoraw-posix: Detect CDROM via ioctl on linux
Cole Robinson [Thu, 14 Jan 2010 16:19:40 +0000 (11:19 -0500)]
raw-posix: Detect CDROM via ioctl on linux

Current CDROM detection is hardcoded based on source file name.
Make this smarter on linux by attempting a CDROM specific ioctl.

This makes '-cdrom /dev/sr0' succeed with no media present.

v2:
    Give ioctl check higher priority than filename check.

v3:
    Actually initialize 'prio' variable.
    Check for ioctl success rather than absence of specific failure.

v4:
    Explicitly mention that change is linux specific.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoavoid unreachable statement after break
Paolo Bonzini [Fri, 15 Jan 2010 08:41:01 +0000 (09:41 +0100)]
avoid unreachable statement after break

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoremove assertions
Paolo Bonzini [Fri, 15 Jan 2010 08:42:10 +0000 (09:42 +0100)]
remove assertions

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agochange while to if
Paolo Bonzini [Fri, 15 Jan 2010 08:42:09 +0000 (09:42 +0100)]
change while to if

The while loop will be executed exactly 0 or 1 times, depending on
env->exit_request.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoadd assertions about env->current_tb
Paolo Bonzini [Fri, 15 Jan 2010 08:42:08 +0000 (09:42 +0100)]
add assertions about env->current_tb

By virtue of the previous patch env->current_tb will always be NULL at
the top of cpu_exec's outermost for loop, and at the end of the innermost
while loop.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoclean up env->current_tb
Paolo Bonzini [Fri, 15 Jan 2010 08:42:07 +0000 (09:42 +0100)]
clean up env->current_tb

There are three paths from the innermost while loop of cpu_exec
to the top of the outermost for loop.  Two do not reset
env->current_tb.  Fix this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agofix wrong indentation
Paolo Bonzini [Fri, 15 Jan 2010 07:56:36 +0000 (08:56 +0100)]
fix wrong indentation

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>