History | View | Annotate | Download (27.2 kB)
virtio: check virtio_load return code
Otherwise we crash on error.
Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>Signed-off-by: Orit Wassermann <owasserm@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-serial-bus: Unset guest_connected at reset and driver reset
When a guest driver resets the virtio status to not ready, or when qemuis reset, reset all ports' guest_connected bit and let port users knowof this event if they have the guest_close() callback registered....
virtio-serial-bus: fix guest_connected init before driver init
guest_connected should be false before guest driver initialization, andtrue after, both for multiport aware and non multiport aware drivers.
Don't set it before the guest_features are available; instead use...
qom: Unify type registration
Replace device_init() with generalized type_init().
While at it, unify naming convention: type_init([$prefix_]register_types)Also, type_init() is a function, so add preceding blank line wherenecessary and don't put a semicolon after the closing brace....
qdev: register all types natively through QEMU Object Model
This was done in a mostly automated fashion. I did it in three steps and thenrebased it into a single step which avoids repeatedly touching every file inthe tree.
The first step was a sed-based addition of the parent type to the subclass...
qdev: kill off DeviceInfo
It is no longer used in the tree since everything is done natively throughQEMU Object Model.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-serial: convert to QEMU Object Model
qdev: move qdev->info to class
Right now, DeviceInfo acts as the class for qdev. In order to switch to aproper ObjectClass derivative, we need to ween all of the callers off ofinteracting directly with the info pointer.
prepare for future GPLv2+ relicensing
All files under GPLv2 will get GPLv2+ changes starting tomorrow.event_notifier.c and exec-obsolete.h were only ever touched by Red Hatemployees and can be relicensed now.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
virtio-console: Fix failure on unconnected pty
when I tried qemu with -virtio-console pty the guest hangs and attachingon /dev/pts/<x> does not return anything if the attachment is too late.
This results in pty_chr_write() returning 0, which causes the port to...
virtio-serial-bus: Ports are expected to implement 'have_data' callback
There's no need to check if ports can accept any incoming data from theguest each time the guest sends data. Check if the port implements suchfunctionality during port initialisation....
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
virtio-serial: Turn props any virtio-serial-bus device must have into bus props
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-serial: Clean up virtser_bus_dev_print() output
Old version looks like this in info qtree (last four lines):
dev: virtconsole, id "" dev-prop: is_console = 1 dev-prop: nr = 0 dev-prop: chardev = <null>...
Merge remote-tracking branch 'kwolf/for-anthony' into staging
iov: Update parameter usage in iov_(to|from)_buf()
iov_to_buf() has an 'offset' parameter, iov_from_buf() hasn't.This patch adds the missing parameter to iov_from_buf().It also renames the 'offset' parameter to 'iov_off' toemphasize it's the offset into the iovec and not the buffer....
virtio-serial-bus: Fix trailing \n in error_report string
Markus fixed offenders in the file but one instance sneaked in viaanother patch. Fix it.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
virtio-serial-bus: Add trace events
Add some trace events for messages passed between the guest and host.
Merge remote-tracking branch 'amit/for-anthony' into staging
virtio-serial: Fix segfault on guest boot
If I start qemu with:
Strip trailing '\n' from error_report()'s first argument
error_report() prepends location, and appends a newline. The messageconstructed from the arguments should not contain a newline. Fix theobvious offenders.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
virtio-serial: Clean up virtconsole detection
virtio-serial-bus needs to treat "virtconsole" devices specially. Ituses VirtIOSerialPort member is_console to recognize them. It getsits value via property initialization. Cute hack, except it letsusers mess with it: "-device virtconsole,is_console=0" isn't plugged...
virtio-serial: Drop redundant VirtIOSerialPort member info
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Amit Shah <amit.shah@redhat.com>
virtio-serial-bus: use bh for unthrottling
Instead of calling flush_queued_data when unthrottling, schedulea bh. That way we can return immediately to the caller, and theflush uses the same call path as a have_data for callbackee.
No migration change is required because bh are called from vm_stop....
virtio-serial: Plug memory leak on qdev exit()
virtio_serial_init() allocates the VirtIOSerialBus dynamically, butvirtio_serial_exit() doesn't free it.
Fix by getting rid of the allocation.
virtio-serial: Fix endianness bug in the config space
The virtio serial specification requres that the values in the configspace are encoded in native endian of the guest.
The qemu virtio-serial code did not do conversion to the guest endianformat what caused problems when host and guest use different format....
virtio-serial: don't crash on invalid input
Fix crash on invalid input in virtio-serial.Discovered by code review, untested.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
virtio-serial-bus: Simplify handle_output() function
There's no code change, just re-arrangement to simplify the functionafter recent modifications.
Reported-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Amit Shah <amit.shah@redhat.com>
virtio-serial: Use a struct to pass config information from proxy
Instead of using a single variable to pass to the virtio_serial_initfunction, use a struct so that expanding the number of variables to bepassed on later is easier.
virtio-serial: kill VirtIOSerialDevice
VirtIOSerialDevice is like VirtIOSerialPort with just the first twofields, which makes it pretty pointless. Using VirtIOSerialPortdirectly works equally well and is less confusing.
[Amit: - rebase - rename 'dev' to 'port' in function params in virtio-serial.h ]...
virtio-serial: Make sure virtqueue is ready before discarding data
This can happen if a port gets unplugged before guest has chance toinitialise vqs.
Reported-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Amit Shah <amit.shah@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Merge remote branch 'amit/for-anthony' into staging
virtio-serial: Add support for flow control
This commit lets apps signal an incomplete write. When that happens,stop sending out any more data to the app and wait for it to unthrottlethe port.
virtio-serial: save/restore new fields in port struct
The new fields that got added as part of not copying over the guestbuffer to the host need to be saved/restored across migration. Do thatand bump up the version number.
virtio-serial: Don't copy over guest buffer to host
When the guest writes something to a host, we copied over the entirebuffer first into the host and then processed it. Do away with that, itcould result in a malicious guest causing a DoS on the host....
virtio-serial: move out discard logic in a separate function
Instead of combining flush logic into the discard case and not discardcase, have one function doing discard case. This will help later whenadding flow control logic to the do_flush_queued_data() function....
virtio-serial-bus: bump up control vq size to 32
The current default of 16 buffers for the control vq is too small. Wecan get more entries in there, for example when asking the guest to addmax. allowed ports.
Note: a more robust solution would involve some kind of event queueing...
virtio-serial: Cleanup on device hot-unplug
Free malloc'ed memory, unregister from savevm and clean up virtio-commonbits on device hot-unplug.
This was found performing a migration after device hot-unplug.
Reported-by: <lihuang@redhat.com>Signed-off-by: Amit Shah <amit.shah@redhat.com>...
virtio-serial: Check if more max_ports specified than we can handle
Currently virtio-serial supports a maximum of 31 ports. Specifying the'max_ports' parameter to be > 31 on the cmd line causes badness.
Ensure we initialise virtio-serial only if max_ports is within the...
virtio-serial: Check if virtio queue is ready before consuming data
If a virtio-serial port is removed before the guest comes up andinitialises the virtqueues, qemu exits with the message
Guest moved used index from 0 to 61440
This happens because we try to clear any pending buffers from the...
virtio-serial: Assert for virtio queue ready before virtqueue operations
In addition to the previous fix for calling do_flush_queued_data() onlywhen the virtqueue is ready, ensure do_flush_queued_data() gets a vqthat's suitably initialised.
Signed-off-by: Amit Shah <amit.shah@redhat.com>...
savevm: Add DeviceState param
When available, we'd like to be able to access the DeviceStatewhen registering a savevm. For buses with a get_dev_path()function, this will allow us to create more unique savevmid strings.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>...
virtio-serial: Simplify virtio_serial_load()
For all i, ports_map[i] is used in and only in the i-th iteration.Replace the dynamic array by a scalar variable.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Acked-by: Amit Shah <amit.shah@redhat.com>...
virtio-serial-bus: fix ports_map allocation on init
Fix for too small allocation to ports_map
Signed-off-by: Alon Levy <alevy@redhat.com>Signed-off-by: Amit Shah <amit.shah@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-serial: Fix check for 'assert'; prevent NULL derefs
In the flush_queued_data() function, we expect port to be valid. Assertonly for port and not port || discard.
Reported-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Amit Shah <amit.shah@redhat.com>...
iov: Introduce a new file for helpers around iovs, add iov_from_buf()
The virtio-net code uses iov_fill() which fills an iov from a linearbuffer. The virtio-serial-bus code does something similar in anopen-coded function.
Create a new iov.c file that has iov_from_buf()....
virtio-serial: Handle scatter-gather buffers for control messages
Current control messages are small enough to not be split into multiplebuffers but we could run into such a situation in the future or amalicious guest could cause such a situation.
So handle the entire iov request for control messages....
virtio-serial: Handle scatter/gather input from the guest
Current guests don't send more than one iov but it can change later.Ensure we handle that case.
Signed-off-by: Amit Shah <amit.shah@redhat.com>CC: Avi Kivity <avi@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-serial: Apps should consume all data that guest sends out / Fix virtio api abuse
We cannot indicate to the guest how much data was consumed by an app forout_bufs. So we just have to assume the apps will consume all the datathat are handed over to them....
virtio-serial: Discard data that guest sends us when ports aren't connected
Before the earlier patch, we relied on incorrect virtio api usage tosignal to the guest that a particular buffer wasn't consumed by thehost.
After fixing that, we now just discard the data the guest sends us while...
virtio-serial: Implement flow control for individual ports
Individual ports can now signal to the virtio-serial core to stopsending data if the ports cannot immediately handle new data. When aport later unthrottles, any data queued up in the virtqueue are sent to...
virtio-serial: save/load: Ensure target has enough ports
The target could be started with max_nr_ports for a virtio-serial devicelesser than what was available on the source machine. Fail the migrationin such a case.
virtio-serial: save/load: Ensure nr_ports on src and dest are same.
The number of ports on the source as well as the destination machinesshould match. If they don't, it means some ports that got hotplugged onthe source aren't instantiated on the destination. Or that ports that...
virtio-serial: save/load: Ensure we have hot-plugged ports instantiated
If some ports that were hot-plugged on the source are not available onthe destination, fail migration instead of trying to deref a NULLpointer.
virtio-serial: save/load: Send target host connection status if different
If the host connection to a port is closed on the destination machineafter migration, whereas the connection was open on the source, theguest has to be informed of that.
Similar for a host connection open on the destination....
virtio-serial: Use control messages to notify guest of new ports
Allow the port 'id's to be set by a user on the command line. This isneeded by management apps that will want a stable port numbering schemefor hot-plug/unplug and migration.
Since the port numbers are shared with the guest (to identify ports in...
virtio-serial: whitespace: match surrounding code
The virtio-serial code doesn't mix declarations and definitions, soseparate them out on different lines.
Signed-off-by: Amit Shah <amit.shah@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-serial: Remove redundant check for 0-sized write request
The check for a 0-sized write request to a guest port is not necessary;the while loop below won't be executed in this case and all will befine.
virtio-serial: Update copyright year to 2010
virtio-serial: Propagate errors in initialising ports / devices in guest
If adding of ports or devices in the guest fails we can send out a QMPevent so that management software can deal with it.
virtio-serial: Send out guest data to ports only if port is opened
Data should be written only when ports are open.
error: Replace qemu_error() by error_report()
error_report() terminates the message with a newline. Strip it itfrom its arguments.
This fixes a few error messages lacking a newline:net_handle_fd_param()'s "No file descriptor named %s found", andtap_open()'s "vnet_hdr=1 requested, but no kernel support for...
virtio-serial: don't set MULTIPORT for 1 port dev
Since commit 98b19252cf1bd97c54bc4613f3537c5ec0aae263, allserial devices declare MULTIPORT feature.To allow 0.12 compatibility, we should clear this whenmax_nr_ports is 1.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>...
virtio-serial-bus: Fix bus initialisation and allow for bus identification
This commit enables one to use multiple virtio-serial devices and toassign ports to arbitrary devices like this:
-device virtio-serial,id=foo -device virtio-serial,id=bar \ -device virtserialport,bus=foo.0,name=foo \...
virtio-console: qdev conversion, new virtio-serial-bus
This commit converts the virtio-console device to create a newvirtio-serial bus that can host console and generic serial ports. Thefile 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: Maintain guest and host port open/close state
Via control channel messages, the guest can tell us whether a port gotopened or closed. Similarly, we can also indicate to the guest of hostport open/close events.
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 andour bus implementation. This is invocation-dependent and isn't part ofthe guest-host ABI.
To correcly enumerate and map ports between the host and the guest, the...
virtio-serial-bus: Add ability to hot-unplug ports