Commit graph

43697 commits

Author SHA1 Message Date
Janosch Frank 368e3adc89 scripts/dump-guest-memory.py: Introduce multi-arch support
By modelling the ELF with ctypes we not only gain full python 3
support but can also create dumps for different architectures more easily.

Tested-by: Andrew Jones <drjones@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1453464520-3882-6-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:14 +01:00
Janosch Frank 6782c0e785 scripts/dump-guest-memory.py: Cleanup functions
Increase readability by adding newlines and comments, as well as
removing wrong whitespaces and C style braces around conditionals and
loops.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1453464520-3882-5-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:14 +01:00
Janosch Frank 7cb1089d5f scripts/dump-guest-memory.py: Improve python 3 compatibility
This commit does not make the script python 3 compatible, it is a
preparation that fixes the easy and common incompatibilities.

Print is a function in python 3 and therefore needs braces around its
arguments.

Range does not cast a gdb.Value object to int in python 3, we have to
do it ourselves.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1453464520-3882-4-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:14 +01:00
Janosch Frank 4789020384 scripts/dump-guest-memory.py: Make methods functions
The functions dealing with qemu components rarely used parts of the
class, so they were moved out of the class.

As the uintptr_t variable is needed both within and outside the class,
it was made a constant and moved to the top.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1453464520-3882-3-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:14 +01:00
Janosch Frank ca81ce72b4 scripts/dump-guest-memory.py: Move constants to the top
The constants bloated the class definition and were therefore moved to
the top.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1453464520-3882-2-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:14 +01:00
Denis V. Lunev e5f3e12e84 nbd: add missed aio_context_acquire in nbd_export_new
blk_invalidate_cache() can call qcow2_invalidate_cache which performs
IO inside.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1453273940-15382-3-git-send-email-den@openvz.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:14 +01:00
Luiz Capitulino fae947b096 memory: exit when hugepage allocation fails if mem-prealloc
When -mem-prealloc is passed on the command-line, the expected
behavior is to exit if the hugepage allocation fails.  However,
this behavior is broken since commit cc57501dee which made
hugepage allocation fall back to regular ram in case of faliure.

This commit restores the expected behavior for -mem-prealloc.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Message-Id: <20160122091501.75bbd42a@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:14 +01:00
Dr. David Alan Gilbert 96bce6831b cpus: use broadcast on qemu_pause_cond
Jiri saw a hang on pause_all_vcpus called from postcopy_start,
where the cpus are all apparently stopped ('stopped' flag set)
but pause_all_vcpus is still stuck on a cond_wait on qemu_paused_cond.
We suspect this is happening if a qmp_stop is called at about the
same time as the postcopy code calls that pause_all_vcpus;
although they both should have the main lock held, Paolo spotted
the cond_wait unlocks the global lock so perhaps they both
could end up waiting at the same time?

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reported-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <1453716498-27238-1-git-send-email-dgilbert@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:14 +01:00
Janosch Frank a013bd2f7b scripts/kvm/kvm_stat: Add optparse description
Added a description text that explains what the script does and which
requirements have to be met to let it run.

The help formatter class is needed as the default optparse formatter
makes the text unreadable.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-35-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank 7f786a9a06 scripts/kvm/kvm_stat: Add interactive filtering
Interactively changing the filter is much more useful than the
drilldown, because it is more versatile.

With this patch, the filter can be changed by pressing 'f' in the text
ui and entering a new filter regex.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-34-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank 126b33e619 scripts/kvm/kvm_stat: Fixup filtering
When filtering, the group leader event should not be disabled, as all
other events under it will also be disabled. Also we should make sure
that values from disabled fields will not be displayed.

This also filters the fields from the log and batch output for better
readability.

Also the drilldown update now directly checks for the stats' field
filter and (un)sets drilldown accordingly.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-33-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank 1cd55f9dc7 scripts/kvm/kvm_stat: Fix rlimit for unprivileged users
Setting the hard limit as a unprivileged user either returns an error
when it is higher than the current one or irreversibly sets it lower.

Therefore we leave the hardlimit untouched as long as we don't need to
raise it as this needs CAP_SYS_RESOURCE.

This gives admins the possibility to run the script as an unprivileged
user to increase security.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-32-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank d8e44802f8 scripts/kvm/kvm_stat: Read event values as u64
The struct read_format, which denotes the returned values on a read
states that the values are u64 and not long long which is used for
struct unpacking.

Therefore the 'q' long long formatter was exchanged with 'Q' which is
the format for u64 data.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-31-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank 00842aaca5 scripts/kvm/kvm_stat: Cleanup and pre-init perf_event_attr
All initializations of the ctypes struct that don't need additional
information were moved to its init method. The unneeded
initializations for sample_type and sample_period were removed as they
do not affect the counters that are read.

This improves readability of the setup_event_attribute by halfing its
LOC.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-30-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank c887d9a25e scripts/kvm/kvm_stat: Fix output formatting
The key names in log mode were capped to 10 characters which is not
enough for distinguishing between keys. Capping was therefore removed.

In batch mode the spacing between keys and values was too narrow and
therefore had to be extended to 42.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-29-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank 8a2a33316c scripts/kvm/kvm_stat: Make tui function a class
The tui function itself had a few sub-functions and therefore
basically already was class-like. Making it an actual one with proper
methods improved readability.

The curses wrapper was dropped in favour of __entry/exit__ methods
that implement the same behaviour.

Also renamed single character variable name, so the name reflects the
content.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-28-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank 9c0ab054ed scripts/kvm/kvm_stat: Remove unneeded X86_EXIT_REASONS
The architecture detection method directly accesses vmx and smv exit
reason constants. Therefore we don't need it anymore.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-27-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank 068294a1ca scripts/kvm/kvm_stat: Group arch specific data
Using global variables and multiple initialization functions for arch
specific data makes the code hard to read. By grouping them in the
Arch classes we encapsulate and initialize them in one place.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-26-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank d895493b7c scripts/kvm/kvm_stat: Cleanup of Event class
Added additional newlines for readability.
Factored out attribute and event setup code into own methods.
Exchanged file() with preferred open().

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-25-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank fc9fdeebd5 scripts/kvm/kvm_stat: Cleanup of Groups class
Introduced separating newlines for readability and removed special
treatment/variable of the group leader. Renamed fmt to read_format.

The group leader's file descriptor will not be turned into a file
object anymore, instead os.read is used to read from the descriptor.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-24-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank e75a36abb4 scripts/kvm/kvm_stat: Cleanup of Stats class
Converted class definition to new style and renamed improper named
variables.

Introduced property for fields_filter.

Moved member variable declaration to init, so one can see all class
variables when reading the init method.

Completely clear the values dict, as we don't need to keep single values.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-23-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank dd0b6a4e10 scripts/kvm/kvm_stat: Encapsulate filters variable
The variable was only used in one class but still was defined
globally. Additionaly the detect_platform routine which prepares the
data that goes into the variable was called on each start of the
script, no matter if the class was needed.

To make the variable local to the TracepointProvider class, a new
function that calls detect_platform and returns the filters was
introduced.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-22-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank 357bc1e74f scripts/kvm/kvm_stat: Cleanup cpu list retrieval
Reading /sys/devices/system/cpu/online makes opening the cpu
directories unnecessary and works on more/older systems.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-21-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank e06715a363 scripts/kvm/kvm_stat: Cleanup of TracepointProvider
Variables with bad names like f and m were renamed to their full name,
so it is clearer which data they contain.

Unneeded variables were removed and the field generating code was
moved in an own function.

dict.iteritems() was removed as directly iterating over a dictionary
also yields the needed keys.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-20-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:13 +01:00
Janosch Frank a90b87bf25 scripts/kvm/kvm_stat: Introduce properties for providers
As previous commit authors used a mixture of setters/getters and
direct access to class variables consolidating them the python way
improved readability.

Properties allow us to assign a value to a class variable through a
setter without the need to call the setter ourselves.

Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-19-git-send-email-frankja@linux.vnet.ibm.com>
[prop.setter is new in Python 2.6, which is the earliest supported
 version. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank 312bf62b7c scripts/kvm/kvm_stat: Rename _perf_event_open
The underscore in front of the function name does not comply with the
python coding guidelines.

Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-18-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank 3e46a5c272 scripts/kvm/kvm_stat: Make cpu detection a function
The online cpus detection method is in the Stats class but does not
use any class variables.

Moving it out of the class to the platform detection function makes
the Stats class more readable.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-17-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank 8d3b5ddc4e scripts/kvm/kvm_stat: Cleanup of platform detection
s390 machines can also be detected via uname -m, i.e. python's
os.uname, no need for more complicated checks.

Calling uname once and saving its value for multiple checks is
perfectly sufficient. We don't expect the machine's architecture to
change when the script is running anyway.

On multi-cpu systems x86_init currently will get called multiple
times, returning makes sure we don't waste cicles on that.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-16-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank 392a7fa3ca scripts/kvm/kvm_stat: Set sensible no. files rlimit
As num cpus * 1000 is NOT a sensible rlimit, we need to calculate a
more accurate rlimit.

The number of open files is directly dependent on the cpu count and on
the number of trace points per cpu. A additional constant works as a
buffer for files that are needed by python or do get opened when the
script runs.

Hence we have:
      cpus * traces + constant

Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-15-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank 400b3cb519 scripts/kvm/kvm_stat: Fixup syscall error reporting
In 2008 a patch was written that introduced ctypes.get_errno() and
set_errno() as official interfaces to the libc errno variable. Using
them we can avoid accessing private libc variables.
The patch was included in python 2.6.

Also we need to raise the right exception, with the right parameters
and a helpful message.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-14-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank f4109dba21 scripts/kvm/kvm_stat: Moved DebugfsProvider
When it is next to the TracepointProvider less scrolling is needed to
change related, surrounding code.

Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-13-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank a4b2be204b scripts/kvm/kvm_stat: Rename variables that redefine globals
Filter, id and byte are builtin python modules which should not be
redefined by local variables.

Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-12-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank e02d896e45 scripts/kvm/kvm_stat: Fix spaces around keyword assignments
Keyword assignments should not not have spaces around the equal
character according to PEP8.

Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-11-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank 639ce18310 scripts/kvm/kvm_stat: Introduce main function
The main function should be the main location for initialization and
helps encapsulating variables into a scope. This way they don't have
to be global and might be mistaken for local ones.

As the providers variable is scoped now it can't be accessed from
within the Stats class. Hence, the global access to the variable was
changed to a local one.

Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-10-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank 7aa4ee5a60 scripts/kvm/kvm_stat: Improve debugfs access checking
Access checking with F_OK was replaced with the better readable
os.path.exists().

On Linux exists() returns False when the user doesn't have sufficient
permissions for statting the directory. Therefore the error message
now states that sufficient rights are needed when the check fails.

Also added check for /sys/kernel/debug/tracing/.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-9-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank 6fbff649d7 scripts/kvm/kvm_stat: Cleanup of path variables
Paths to debugfs and trace dirs are now specified globally to remove
redundancies in the code.

Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-8-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank a6ad61f987 scripts/kvm/kvm_stat: Invert dictionaries
The exit reasons dictionaries were defined number -> value but later
on were accessed the other way around. Therefore a invert function
inverted them.

Defining them the right way removes the need to invert them and
therefore also speeds up the script's setup process.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-7-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank dbedce0ebc scripts/kvm/kvm_stat: Mark globals in functions
Updating globals over the globals().update() method is not the
standard way of changing globals. Marking variables as global and
modifying them the standard way is better readable.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-6-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank fff51233b7 scripts/kvm/kvm_stat: Removed unneeded PERF constants
Only two of the constants are actually needed to set up the events, so
the others were removed. All variables that used them were also removed.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-5-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:12 +01:00
Janosch Frank db3e5d9a22 scripts/kvm/kvm_stat: Make constants uppercase
Constants should be uppercase with separating underscores, as
requested in PEP8. This helps identifying them when reading the code.

Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-4-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:11 +01:00
Janosch Frank 6590045e5d scripts/kvm/kvm_stat: Replaced os.listdir with os.walk
Os.walk gives back lists of directories and files, no need to filter
directories from the list that listdir gives back.

To make it better understandable a wrapper with docstring was
introduced.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-3-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:11 +01:00
Janosch Frank c81ab0ac90 scripts/kvm/kvm_stat: Cleanup of multiple imports
Removed multiple imports of the same module and moved all imports to
the top.

It is not necessary to import a module each time one of its
functions/classes is used.
For readability each import should get its own line.

Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-2-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:11 +01:00
Paolo Bonzini 27ef9cb0e7 qemu-char: avoid leak in qemu_chr_open_pp_fd
drv leaks if qemu_chr_alloc returns an error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:11 +01:00
Sitsofe Wheeler 8485140fa0 docs: Style the command and its options in the synopsis
Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
Message-Id: <1452718226-25001-1-git-send-email-sitsofe@yahoo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:11 +01:00
Daniel P. Berrange a8fb542705 char: introduce support for TLS encrypted TCP chardev backend
This integrates support for QIOChannelTLS object in the TCP
chardev backend. If the 'tls-creds=NAME' option is passed with
the '-chardev tcp' argument, then it will setup the chardev
such that the client is required to establish a TLS handshake
when connecting. There is no support for checking the client
certificate against ACLs in this initial patch. This is pending
work to QOM-ify the ACL object code.

A complete invocation to run QEMU as the server for a TLS
encrypted serial dev might be

  $ qemu-system-x86_64 \
      -nodefconfig -nodefaults -device sga -display none \
      -chardev socket,id=s0,host=127.0.0.1,port=9000,tls-creds=tls0,server \
      -device isa-serial,chardev=s0 \
      -object tls-creds-x509,id=tls0,endpoint=server,verify-peer=off,\
         dir=/home/berrange/security/qemutls

To test with the gnutls-cli tool as the client:

  $ gnutls-cli --priority=NORMAL -p 9000 \
       --x509cafile=/home/berrange/security/qemutls/ca-cert.pem \
       127.0.0.1

If QEMU was told to use 'anon' credential type, then use the
priority string 'NORMAL:+ANON-DH' with gnutls-cli

Alternatively, if setting up a chardev to operate as a client,
then the TLS credentials registered must be for the client
endpoint. First a TLS server must be setup, which can be done
with the gnutls-serv tool

  $ gnutls-serv --priority=NORMAL -p 9000 --echo \
       --x509cafile=/home/berrange/security/qemutls/ca-cert.pem \
       --x509certfile=/home/berrange/security/qemutls/server-cert.pem \
       --x509keyfile=/home/berrange/security/qemutls/server-key.pem

Then QEMU can connect with

  $ qemu-system-x86_64 \
      -nodefconfig -nodefaults -device sga -display none \
      -chardev socket,id=s0,host=127.0.0.1,port=9000,tls-creds=tls0 \
      -device isa-serial,chardev=s0 \
      -object tls-creds-x509,id=tls0,endpoint=client,\
        dir=/home/berrange/security/qemutls

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1453202071-10289-5-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:11 +01:00
Daniel P. Berrange f2001a7e05 char: don't assume telnet initialization will not block
The current code for doing telnet initialization is writing to
a socket without checking the return status. While it is highly
unlikely to be a problem when writing to a bare socket, as the
buffers are large enough to prevent blocking, this cannot be
assumed safe with TLS sockets. So write the telnet initialization
code into a memory buffer and then use an I/O watch to fully
send the data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1453202071-10289-4-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:11 +01:00
Daniel P. Berrange 9894dc0cdc char: convert from GIOChannel to QIOChannel
In preparation for introducing TLS support to the TCP chardev
backend, convert existing chardev code from using GIOChannel
to QIOChannel. This simplifies the chardev code by removing
most of the OS platform conditional code for dealing with
file descriptor passing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1453202071-10289-3-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:58:11 +01:00
Daniel P. Berrange 0ff0fad23d char: remove fixed length filename allocation
A variety of places were snprintf()ing into a fixed length
filename buffer. Some of the buffers were stack allocated,
while another was heap allocated with g_malloc(). Switch
them all to heap allocated using g_strdup_printf() avoiding
arbitrary length restrictions.

This also facilitates later patches which will want to
populate the filename by calling external functions
which do not support use of a pre-allocated buffer.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1453202071-10289-2-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-01-26 15:50:54 +01:00
Peter Maydell 1535a6d699 -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
 
 iQIcBAABAgAGBQJWpnoOAAoJEH3vgQaq/DkOqbgP/1E09vMe/KT50k0vgkIvX5KL
 gCLExCYwhOhE53x8QIZQp6gGWzvombqlNFhoZz6FmIU1Q+BW9khhohiecLQUlYUX
 pILkhyjFe1E1uTZ6wuDT4juhE9CGsyjIXjY0tGTyuvWqXfWJR5KAAZ9Udxo1vnfu
 +lA975W8htqenkRe/J5lB4k1ZMmKTaMYr4rIo2Bconu8sOebHXfdmY78qswY0vaG
 SP1JhauFaXJBM3lGLdlXL5cIjs7yLR5XKxOGWFtQ8rCaJxzuiCup4//Ciabckf3E
 57VGGsBPqyFFLrF3vQ7NoBVlbWf9aaxdCN5niwhmyWfTnbVdLYRvhqWNHW5gvP6G
 1VCqNGvCd8lDlM4Ad/DdlFzRk6F8ybsP64slut9Tmg4kpXfSMljbXuMd+SC1+xxC
 eGwfr4GTHmt2iGhJZUn9iguvGID0ssfP20knLXLZbZG2ans8eYO/w9ALLt4vm2HS
 WepTRBuGQD0dUTm7IIIeL2KAGaSGRWVQqgwbtvIBa3MLMzIIYyUHv54+8/AOfF2L
 hMW6tD5TKzgGdDgITtG9DqI0l/xRODCS6rND2/9aJ5MZS0yU/P0LCcYA6qV1qCY4
 jTlRI3dCxppdlCq7qCu52hQg886RIMF4VYs7HjmTf4E+WkHIgEWbAGyNMtNYodWq
 HbNTXxXChymt1CBrzTZ3
 =lTrI
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging

# gpg: Signature made Mon 25 Jan 2016 19:39:58 GMT using RSA key ID AAFC390E
# gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>"

* remotes/jnsnow/tags/ide-pull-request:
  fdc: change auto fallback drive for ISA FDC to 288
  qtest/fdc: Support for 2.88MB drives
  fdc: rework pick_geometry
  fdc: add physical disk sizes
  fdc: add drive type option
  fdc: Add fallback option
  fdc: add pick_drive
  fdc: Throw an assertion on misconfigured fd_formats table
  fdc: add disk field
  fdc: add drive type qapi enum
  fdc: reduce number of pick_geometry arguments
  fdc: move pick_geometry
  ide: Correct the CHS 'cyls_max' limit to be 65535

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-01-26 09:16:07 +00:00
John Snow 4812fa27fa fdc: change auto fallback drive for ISA FDC to 288
The 2.88 drive is more suitable as a default because
it can still read 1.44 images correctly, but the reverse
is not true.

Since there exist virtio-win drivers that are shipped on
2.88 floppy images, this patch will allow VMs booted without
a floppy disk inserted to later insert a 2.88MB floppy and
have that work.

This patch has been tested with msdos, freedos, fedora,
windows 8 and windows 10 without issue: if problems do
arise for certain guests being unable to cope with 2.88MB
drives as the default, they are in the minority and can use
type=144 as needed (or insert a proper boot medium and omit
type=144/288 or use type=auto) to obtain different drive types.

As icing, the default will remain auto/144 for any pre-2.6
machine types, hopefully minimizing the impact of this change
in legacy hw to basically zero.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1453495865-9649-13-git-send-email-jsnow@redhat.com
2016-01-25 14:36:01 -05:00