Commit Graph

217 Commits

Author SHA1 Message Date
Cole Robinson
c2de4d7c36 util: Move get_cache_dir to VirtinstConnection
Renaming it get_app_cache_dir so it doesn't conflict with get_cache_dir
usage in virtManager
2019-06-07 17:53:15 -04:00
Cole Robinson
ca10e4094b util: move is_error_nosupport to SupportCache 2019-06-07 16:49:19 -04:00
Cole Robinson
f85e6def55 support: Convert callers to the new format 2019-06-07 16:26:03 -04:00
Cole Robinson
566a4681a8 support: Rework support check invocations
SupportCache.check_support(SUPPORT_FOOBAR, args) becomes
SupportCache.foobar(args)

And SupportCache absorbs the caching infrastructure from
VirtinstConnection.

For now we add some hackery to hide the API change from callers, but
this will be undone in the next patch
2019-06-07 16:25:39 -04:00
Cole Robinson
9e56169813 connection: Drop unused filter_nodedevs devcap value 2019-06-05 16:35:34 -04:00
Cole Robinson
8221061ec5 domain: Absorb conn.get_nodedev_count
It's the only user
2019-06-05 16:35:34 -04:00
Cole Robinson
d2462367ee virt-manager: Add --test-options
Will take a string of comma separated options which we can use to
tweak app behavior, for testing. Convert the existing --test-* options
to use the same abstraction internally. This will make it easier to
add new test options in the future
2019-06-05 16:28:05 -04:00
Cole Robinson
85a7b2cd61 virtManager: interface: Remove unused code after UI removal
Removal all the virtManager bits that are no longer used
2019-05-13 12:08:55 -04:00
Cole Robinson
de773179ef host: Remember window dimensions
Like we do for details and manager windows, save window size in
gsettings and remember it across app runs
2019-04-14 17:05:14 -04:00
Pavel Hrdina
95d1275f57 domcapabilities: get list of CPU models from domcapabilities
Currently we just call libvirt API which will return all CPU models for
specific architecture known to libvirt and we offer all of them to users
in GUI.  Let's switch to domain capabilities where we have more details
about these CPUs such as whether each model is usable with current QEMU
binary.  If libvirt can detect the usability we will offer only CPU
models that QEMU can actually run.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-03-19 13:41:53 +01:00
Cole Robinson
535e34481d libvirtobject: Add is_X object type helpers 2018-10-13 17:23:18 -04:00
Cole Robinson
c23a0d4c96 nodedev: add is_linux_root_hub helper
Move the check out of connection.py, and simplify the addhardware
code
2018-10-13 12:18:50 -04:00
Cole Robinson
155ddcfc17 conn: Move allstats polling before VM polling
So new VMs already have their stats cached
2018-10-10 17:19:44 -04:00
Cole Robinson
f553cb67c2 statsmanager: Move VM stats calls back to domain.tick
Otherwise if we hit an error in connect.tick, connection can be
automatically closed in the UI, plus other parts of the code
were implicitly depending on this ordering, like VM rename support
2018-10-10 08:11:25 -04:00
Simon Kobyda
68a5abe279 statsmanager: new class for VM/conn stats polling
Class will work above connection. Right know, it is possible to
provide stats for domains only, but could be expanded.
To retrieve stats, you can use get_vm_stats(vm).

This class uses new virConnectGetAllDomainStats call, which reduces
number of calls needed to poll stats.
Stats are refreshed with every connection tick.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>

(crobinso: squash commits, move statsmanager to its own file,
           fix pylint)
2018-10-10 07:35:37 -04:00
Cole Robinson
efe4f14fc7 connection: Remove krb5 auth dbus check
kerberos+libvirt is sufficiently obscure that I don't expect this
is of much value. Plus I don't have a setup to test
2018-10-08 09:27:22 -04:00
Cole Robinson
7eaf036acf virtinst: Remove stable_defaults concept
This switch says: if we detect a rhel host, use special version
checks that match rhel backports. This pattern sucks. The way
forward is to have libvirt advertise the bits that are supported,
through domcapabilities. Then virt-manager/virtinst can react
as appropriate.
2018-10-06 19:45:51 -04:00
Christian Ehrhardt
92c610e782 connection: avoid failing on NoneType in _hostinfo
There is a potential race of a backend to be opened and being true on
self._backend.is_open but self._hostinfo not being set yet.

Avoid spurial bugs due to that by also checking against None before
accessing subelements ot self._hostinfo

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2018-10-01 13:58:52 -04:00
Cole Robinson
627bfabc32 pylint: Silence output on Fedora 29 2018-09-29 14:27:34 -04:00
Cole Robinson
967ca4eeda virtinst: Drop direct 'support' usage
Except from connection. This requires some reorg in clitest and
some minor changes in a few other places
2018-08-31 18:31:17 -04:00
Cole Robinson
ea413be214 xmlbuilder: Rename get_xml_config -> get_xml
The config part is redundant. Should have done this a long time ago
2018-08-31 16:52:02 -04:00
Cole Robinson
2b41e130d8 connection: rename fetch_all_guests->fetch_all_domains
The virtinst class is erroneously called Guest, but these
functions are dealing with libvirt <domain> XML, so rename them
2018-08-31 16:50:46 -04:00
Lin Ma
4484f473cd char: Track/Show the state of virtio channels in channel details
crobinso: Add a test case

Signed-off-by: Lin Ma <lma@suse.com>
2018-07-12 15:25:23 -04:00
Lin Ma
8f78b33d1c Output the qemu guest agent lifecycle events in debug mode
Signed-off-by: Lin Ma <lma@suse.com>
2018-07-12 15:19:34 -04:00
Lin Ma
099ec95ac8 connection: Add callback parameter for function _add_domain_xml_event
Further patches will pass in the callback instead of the default one.

Signed-off-by: Lin Ma <lma@suse.com>
2018-07-12 15:19:34 -04:00
Cole Robinson
ffab20782f connection: Handle more openauth cred types
Like ECHOPROMPT which is needed for libssh hosts file management.
Sync the two implementations a bit
2018-05-03 06:16:28 -04:00
Daniel P. Berrangé
48e32b429d Fix copyright header to specify GPLv2 or later, not GPLv2 only.
The copyright headers in every file were chjanged in this previous commit

  commit b6dcee8eb7
  Author: Cole Robinson <crobinso@redhat.com>
  Date:   Tue Mar 20 15:00:02 2018 -0400

    Use consistent and minimal license header for every file

Where before this they said "

  "either version 2 of the License, or (at your option) any later version."

Now they just say

  "GNU GPLv2"

This fixes it to say "GNU GPLv2 or later" again.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-04 16:51:37 -04:00
Cole Robinson
b6dcee8eb7 Use consistent and minimal license header for every file 2018-03-21 07:29:40 -04:00
Cole Robinson
1c911ce567 virtinst: Give device classes consistent DeviceX naming
Previous state was inconsistenty and needlessly wordy. Fix up
a few other class namings that have redundant Virtual in the name
2018-03-21 07:29:40 -04:00
Cole Robinson
dabbc8d5bd engine: Remove centralized conn.open handling
Move connection opening logic to each caller, since needs are
slightly different.
2018-03-15 21:24:48 -04:00
Cole Robinson
cad809fe80 Make all dialogs clean up when vm/conn disappears
Moves all the window cleanup handling to each class and audit for
all --test-leak-debug errors and fix
2018-03-15 21:24:48 -04:00
Cole Robinson
20d5c1887a baseclass: Export GObject.SignalFlags.RUN_FIRST
Saves some typing and imports
2018-03-15 21:24:48 -04:00
Cole Robinson
6959a41ff2 connection: Drop vm-added emission on connect
We don't use this for most other signals and it's kind of unexpected
2018-03-15 21:24:48 -04:00
Cole Robinson
fbf1bc80b5 connection: Dispatch object remove signals on close 2018-03-15 21:24:48 -04:00
Cole Robinson
6ad6f44920 connection: Call virConnectClose and log the return value
This can help us find object leaks within the code. virConnectClose
is just a deference and will return 1 if other references are still
floating around.
2018-03-15 21:24:48 -04:00
Cole Robinson
b3c69a05a2 connection: Fix connecting to conn with no objects
Our thread handling leaves us permanently in the 'connecting' state
2018-03-15 21:24:48 -04:00
Cole Robinson
c6c24c59ac connection: Remove unused argument 2018-03-15 21:24:48 -04:00
Radostin Stoyanov
1ae5c4ff75 pylint: Resolve logging-not-lazy
A new Python checker was added to warn about using a + operator inside
call of logging methods when one of the operands is a literal string.

https://pylint.readthedocs.io/en/latest/whatsnew/1.8.html

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-03-03 16:04:12 -05:00
Cole Robinson
1d8cd69f82 connection: Map event vals to libvirt enum names in debug output
Shove this logic into its own class LibvirtEnumMap in its own file,
since this may grow over time.
2018-02-27 12:31:56 -05:00
Cole Robinson
da0d0600da connection: Show event name in debug output for xml misc events 2018-02-27 11:59:15 -05:00
Radostin Stoyanov
978fb25ac7 Wrap keys(), values() in a list
In Python 3 dict.values() [1] , dict.keys() [2] and dict.items() [3]
return a view [4] of the dictionary’s values, keys and items.

In Python 2 these functions return a list. [5] [6] [7]

To resolve this we can convert the result of these function to a list.

[1] https://docs.python.org/3/library/stdtypes.html#dict.values
[2] https://docs.python.org/3/library/stdtypes.html#dict.keys
[3] https://docs.python.org/3/library/stdtypes.html#dict.items
[4] https://docs.python.org/3/library/stdtypes.html#dict-views
[5] https://docs.python.org/2/library/stdtypes.html#dict.items
[6] https://docs.python.org/2/library/stdtypes.html#dict.keys
[7] https://docs.python.org/2/library/stdtypes.html#dict.values
2018-02-06 18:49:17 -05:00
Chen Hanxiao
3e3ffe1e2d pylint: remove a unnecessary pass
pylint complains:
  Unnecessary pass statement (unnecessary-pass)

Reviewed-by: Pavel Hrdina <phrdina.redhat.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2017-12-22 21:48:35 +08:00
Cole Robinson
c174b5509f connection: Another py3 exception variable fix 2017-12-20 14:16:13 -05:00
Cédric Bosdonnat
60968fa259 py3: store exception variables for use outside except
In python3 exceptions aren't defined outside the except block. Leading
to 'UnboundLocalError: local variable 'e' referenced before assignment'
errors.

To work around this, store the local variable into one that will have a
longer life.
2017-12-20 14:13:27 -05:00
Chen Hanxiao
7f1b4cee82 pycodestyle: fix all E125 warnings
Fix all E125:
     Continuation line with same indent as next logical line

   Also remove ignore options of E125

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2017-10-21 23:26:16 +08:00
Radostin Stoyanov
63fce081ed pycodestyle: Use isinstance() for type checking
This is E721 in pycodestyle [1]:
   "do not compare types, use ‘isinstance()’"

The main differece between "type() is" and "isinstance()" is that
isinstance() supports inheritance. [1]

This can be seen in the example below:
    >>> type(True) is int
    False
    >>> isinstance(True, int)
    True

As we can see in python 'bool' a subclass of 'int'.

[1] https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
[2] https://docs.python.org/2/library/functions.html#isinstance
2017-10-20 11:49:13 -04:00
Pavel Hrdina
12117ba148 connection: change blacklist from array to dict
If initialization of new object fails we put it into blacklist and
newer parse it again until virt-manager is restarted.  This helps to
reduce number of failures if some object fails initialization every
time.

However, there are some cases where we put object into blacklist
incorrectly.  One of the cases is while creating new storage pool.
If the storage pool requires to be build before started but user
doesn't check to build it as well the start of the new storage pool
fails.  The issue is that at first we define that object which triggers
a lifecycle event for storage pool and queues new poll operation over
storage pools.  Before the poll operation starts the starting of the
storage pools fails and we undefine that storage pool before it is
initialized.  The initialization fails and the storage pool is never
managed from that point.

This patch modifies the blacklist to allow 3 failures before we give up
on a specific object and if the object is initialized without error
we remove it from blacklist completely.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1446486
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1093394

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-09-09 10:12:12 +02:00
Chen Hanxiao
c92aade081 pycodestyle: fix all E203 warnings
Fix all E203 whitespace before ':'
   Also remove E203 ignore option of pycodestyle

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2017-08-11 00:01:38 +08:00
Radostin Stoyanov
b93cc3bbc9 pycodestyle: Do not use bare 'except:'
A bare 'except:' catches all exceptions [1], including SystemExit,
KeyboardInterrupt, and GeneratorExit (which is not an error and should
not normally be caught by user code). In situations where you need to
catch all “normal” errors, you can catch the base class for all normal
exceptions, Exception [2].

[1] https://docs.python.org/2/howto/doanddont.html#except
[2] https://docs.python.org/2/library/exceptions.html#Exception
2017-08-02 13:57:43 -04:00
Cole Robinson
a9903ae0e0 connection: Remove clear_cache callback
It doesn't actually accomplish what we want for the virt-manager case,
and cache_new_pool should cover our needs now
2017-07-20 17:30:37 -04:00