Commit Graph

397 Commits

Author SHA1 Message Date
Cole Robinson
a5ae150201 guest: Rename curvcpus and cpuset to better match XML hierarchy 2019-05-12 17:25:47 -04:00
Cole Robinson
ad36657b72 guest: Set vcpus from cpu.topology, if it's specified
We already did this in cli.py, but that's the wrong place to do it
2019-05-12 17:25:47 -04:00
Cole Robinson
12440b00c1 osdict: return _OsResources to callers
Use the class helper routines to save some tedious dict management
2019-05-12 17:25:47 -04:00
Cole Robinson
135b97637e guest: Rename memory properties to match XML values
Right now we have:

* memory -> ./currentMemory
* maxmem -> ./memory
* hotplugmaxmem -> ./maxMemory

Which is just a mess to know what we might be really setting behind
the scenes. Rename the properties to match the XML element name, and
adjust all users to the new names. cli options aren't changed though
2019-05-12 17:25:47 -04:00
Cole Robinson
3980f79ab8 guest: Fix pylint 'unneeded-not' 2019-04-14 20:49:52 -04:00
Andrea Bolognani
20c212cdfc guest: Enable USB input devices for RISC-V virt guests
If USB support is available, we can use USB input devices too.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-04-04 18:57:39 -04:00
Andrea Bolognani
9bec57723e guest: Enable USB for RISC-V virt guests
Unlike other features we have enabled earlier, this one requires
version checks because RISC-V guests have only started using PCI
by default very recently, and we can't have USB without PCI.

More specifically, we need QEMU commit d6c1bd4a2237 (included
in 4.0.0) and libvirt commit 7c48fb08e0cd (included in 5.3.0).

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-04-04 18:57:39 -04:00
Andrea Bolognani
1c907488f3 guest: RISC-V virt guests support virtio-rng
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-04-04 18:57:39 -04:00
Andrea Bolognani
193879b257 guest: RISC-V virt guests have VirtIO support
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-04-04 18:57:39 -04:00
Andrea Bolognani
a6fa81ba23 guest: Recommend virt machine for RISC-V
The default machine at the QEMU level is spike_v1.10, but most
people will really want to use the virt machine type instead.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-04-04 18:57:39 -04:00
Andrea Bolognani
7b9de27a99 guest: Add default RNG to s390x guests
As long as it's supported by both QEMU and the guest OS,
there's really no reason not to add it.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-03-21 14:16:28 -04:00
Andrea Bolognani
f23b01be53 guest: Add VirtIO input devices to s390x guests with graphics
We're not including any input devices in the generated XML
for s390x guests, and the results is that it's not possible
to interact with them short of using the serial console or
connecting through ssh, which is fine but probably not what
is expected when graphics are present.

USB input devices are not a good fit for s390x guests: USB
requires PCI, and PCI is not widely available or used on
s390x; VirtIO devices, on the other hand, are a perfect
match since s390x guests use basically no emulated devices
and rely on VirtIO for most functionality.

https://bugzilla.redhat.com/show_bug.cgi?id=1683609

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-03-21 15:31:20 +01:00
Andrea Bolognani
5dad99216e guest: Add USB input devices to pSeries guests with graphics
libvirt already does this for us, sort of: it will automatically
add a USB keyboard and mouse to ppc64 guests with graphics;
in addition, these devices are impossible to remove.

Unfortunately this results in a pretty poor experience for the
user, since the relative pointing device makes interacting with
the GUI an exercise in frustration.

As of commit 186bb479d0f4, libvirt will still add the USB
keyboard automatically but will skip the USB mouse if a USB
tablet is already present, so by explicitly including USB input
devices in the generated XML we can create guests that are
actually usable.

We can do this unconditionally, without having to worry about
what version of libvirt we're running against: if it's new
enough we'll take advantage of the fix, and if not then the
resulting guest will not be any more broken than it would have
been before.

https://bugzilla.redhat.com/show_bug.cgi?id=1683609

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-03-21 15:31:20 +01:00
Andrea Bolognani
47753eab26 guest: Use virtio-scsi where supported
Right now we're limiting use of virtio-scsi to ppc64/pseries
and aarch64/virt guests, but there's really no reason not to
use it wherever it's available.

This results in virtio-scsi being now used on s390x, where no
other sensible SCSI controller implementation is available
anyway, and x86, where you alreayd didn't want end up using
lsilogic.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-03-06 14:00:11 -05:00
Andrea Bolognani
c2bcb9e5a6 guest: Add supports_virtioscsi()
This is similar to the existing supports_virtio*() functions,
but for virtio-scsi.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-03-06 14:00:11 -05:00
Andrea Bolognani
1a1875be06 guest: Remove some SCSI-related dead code
The code in _add_implied_controllers() tries to add an ibmvscsi
controller if any disk with spapr-vio address type is found;
however, regardless of the specific SCSI controller in use, all
SCSI disks will use the drive address type, so that condition
will never be triggered - which is actually for the best, since
we want to use virtio-scsi on ppc64 anyway.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-03-06 14:00:11 -05:00
Marc Hartmayer
c9d070da4c guest: Add reorder_boot_order method
Add `reorder_boot_order` method to Guest class. It sets the boot order
of the passed `dev` to `boot_index` and adapts all other boot indices
of the guest accordingly.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2019-03-06 13:15:38 -05:00
Pavel Hrdina
6f5762ab1f guest: remove useless has_virtio_scsi variable
Apart from the fact, that 'virtio' is not a valid scsi controller model
the 'has_virtio_scsi' variable is not needed at all.  It is used only
in one condition where both 'has_any_scsi' and 'has_virtio_scsi' has to
be false which can happen only if there is no 'scsi' controller defined
by user.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-02-28 15:36:24 +01:00
Cole Robinson
fb5aadc636 guest: Move compare_device to Device class
It operates on a Device object, so it makes sense
2019-02-07 17:42:55 -05:00
Cole Robinson
10973c7932 guest: Add find_device to Guest
It operates on a Guest object, so it makes sense
2019-02-07 17:36:10 -05:00
Marc Hartmayer
8d185f3e4b guest: Don't ignore invalid boot_order inputs
A `KeyError` indicates that the `boot_order` input was
invalid. Therefore we shouldn't ignore this error silently.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
2019-02-07 17:15:50 -05:00
Marc Hartmayer
1369549aab guest: Don't exclude redirected devices
Don't exclude redirected devices since they're also bootable. They
won't clutter the UI of virt-manager as we're excluding them
explicitly for the UI in the `get_bootable_devices` method defined in
virtManager/domain.py.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2019-02-07 17:15:50 -05:00
Marc Hartmayer
12e8456da2 domain: Move set boot order responsibility to guest
Move set boot order responsibility to guest XML builder.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2019-02-07 17:15:50 -05:00
Marc Hartmayer
c5f8f3e640 guest: Add get_boot_order method
Add 'get_boot_order' method. This method has an optional parameter for
getting the legacy boot order defined in the OS node of the domain
definition.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2019-02-07 17:15:50 -05:00
Marc Hartmayer
853237aebc domain: Move get boot order methods to guest
Move get boot order methods to guest XML builder. For this we must
replace self.get_bootable_devices() with
self.get_bootable_devices(exclude_redirdev=True) in the
_get_device_boot_order and set_device_boot_order to have no
functionality change.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2019-02-07 17:15:50 -05:00
Marc Hartmayer
d0c2750da5 domain: Move use_device_boot_order to guest
Move use_device_boot_order to guest XML builder and rename it into
'set_device_boot_order'.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2019-02-07 17:15:50 -05:00
Marc Hartmayer
735d8b75c9 domain/guest: Add get_bootable_devices() method
Add a method to the Guest XMLBuilder for getting all bootable devices
of the guest definition with the option to exclude the redirdevs in
the returned list.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2019-02-07 17:15:49 -05:00
Marc Hartmayer
3365838b1b Move (find|compare)_device to guest.py
Move (find_compare)_device functions to guest.py as it will be used
there in an upcoming patch.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2019-02-07 17:15:49 -05:00
Cole Robinson
2f89ecf4a9 Remove Author lines from file headers
Similar to what was done in libvirt. See these commits:

600462834f
c99e954973
2019-01-08 11:45:35 -05:00
Fabiano Fidêncio
5eb47bc00f guest: Default to libosinfo recommended resources
Let's create a new method that defaults to libosinfo's recommended
resources (when they're available) for memory and vcpus.

It'll help us to avoid erroring out whenever virt-install is called
without specifying the memory amount, as the recommended amount of
memory would come from libosinfo.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-01-07 12:24:06 +01:00
Slavomir Kaslev
be1b5e6ebb virtinst: Add vsock device type
VSOCK sockets allow communication between virtual machines and the host they are
running on.

This patch adds vsock device support along with clitest for the new properties.

Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
2019-01-06 18:04:26 -05:00
Cole Robinson
369cf6774b guest: Don't add spicevmc channel if virtio not supported
Not that big of a deal for linux guests, but will add ?
devices on windows
2018-10-14 12:29:33 -04:00
Cole Robinson
edab908f42 guest: Use q35 chipset by default for new qemu + supported OS
There's been various discussions about changing the x86 default
from 'pc' to 'q35' over the years, but it's unlikely to happen
at the qemu or libvirt level for compatibility reasons. So
let's start using it for new enough OS that support it.
2018-10-13 14:58:57 -04:00
Chen Hanxiao
70f9817bdc pylint: fix simplifiable-if-statement issue
pylint complain:
    The if statement can be replaced with 'var = bool(test)'

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2018-10-11 11:19:49 -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
Cole Robinson
469fed08a0 guest: Default to cpu mode=host-model if libvirt is new enough
We check whether host-model is exposed in domcapabilities, which
indicates host-model is using the smarter new safer method in
cooperation with qemu
2018-10-04 14:43:41 -04:00
Cole Robinson
76334bfabd guest: Add DomainCapabilities caching 2018-10-04 12:30:14 -04:00
Cole Robinson
b51104ad22 guest: Tweak error with invalid --os-variant
Try to point people in the right direction if they specify an
unknown distro name on the cli, like was reported here:

https://bugzilla.redhat.com/show_bug.cgi?id=1576473
2018-10-03 19:32:09 -04:00
Cole Robinson
046a242bd4 guest: Use USB3 for x86 qemu if OS supports it
Using new annotations in osinfo-db
2018-10-03 19:02:07 -04:00
Cole Robinson
757910a1bb cli: Add --metadata os_name= and os_full_id=
Allows changing the libosinfo metadata for an existing vm via virt-xml
2018-09-30 20:55:32 -04:00
Cole Robinson
b19f94299b details: Add OS name view/edit, + oslist rework
This is just a big nasty commit.

Turn the OS inspection page into an always available page that
shows the libosinfo name from the domain metadata XML. Use oslist.py
and have it absorb more of the common behavior needed by create.py
and details.py. Add UI tests for it all
2018-09-30 20:55:32 -04:00
Cole Robinson
a741f595ea guest: Drop update_defaults
Fold its one purpose into the UEFI setting bits, fix it and test it
2018-09-13 15:59:27 -04:00
Cole Robinson
d7ff46f7f5 guest: Encode the cli --os-variant in the XML
And add some testdriver examples of it
2018-09-13 15:11:22 -04:00
Cole Robinson
86ef998023 guest: Lookup osinfo object from libosinfo metadata XML 2018-09-13 15:03:36 -04:00
Cole Robinson
bad5eabd93 domain: Add metadata.libosinfo
From the libosinfo discussion here:
https://www.redhat.com/archives/libosinfo/2018-September/msg00003.html

This is a cross-app schema for tracking libosinfo OS ID in the
domain <metadata> XML. Example:

   <metadata>
     <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
       <libosinfo:os id="http://fedoraproject.org/fedora/17"/>
     </libosinfo:libosinfo>
   </metadata>
2018-09-13 12:39:56 -04:00
Cole Robinson
6063538750 guest: Replace os_variant with set_os_name
And have callers directly access osinfo.name if they need it
2018-09-12 17:24:28 -04:00
Cole Robinson
2549e60698 guest: Add an entry point for setting machine=q35 default
We will want this at some point, but it's dependent on libosinfo
work
2018-09-12 15:35:49 -04:00
Cole Robinson
4e30161f44 guest: Absorb UEFI default setup
Rather than force callers to deal with it
2018-09-12 14:02:23 -04:00
Cole Robinson
e903d374c2 guest: Always encode machine= in XML
Don't rely on libvirt's default. This makes any XML changes more
explicit, and can help other parts of the code that may depend on
a machine type being encoded
2018-09-12 12:16:47 -04:00
Cole Robinson
ec69ae44b6 capabilities: Drop build_virtinst_guest
Same as lookup_virtinst_guest
2018-09-06 20:54:59 -04:00
Cole Robinson
1c05db691d guest: Cache capsinfo
Don't repeatedly look it up, was slowing down the test suite by about 5%
2018-09-06 20:38:59 -04:00
Cole Robinson
e61f2b991b guest: Re-organize function locations 2018-09-06 20:12:49 -04:00
Cole Robinson
5f22f41da4 guest: Absorb capabilities defaults setup
Rather than forcing API users to go through the capabilities APIs.
This lets us simplify things in virt-install quite a bit, and is
needed for smarter machine type defaults
2018-09-06 20:12:49 -04:00
Cole Robinson
242844fefa osdict: Make the broken uefi+hyperv bit more explicit
And add links to the relevant bug reports
2018-09-04 14:55:40 -04:00
Cole Robinson
4394eff9fa xmlbuilder: Drop last usages of set_converter
Unfold most of them into manual property() wrappers. It's a bit
noisier but the logic is easier to follow.
2018-09-04 14:55:04 -04:00
Cole Robinson
852d7b564d virtinst: Remove name field validate_cb usage
Either openly do this at callers, or wrap it in a validate() call.
Doing this at set time has always had issues, like the self.replace hack
2018-09-04 14:55:04 -04:00
Cole Robinson
2ac54ac001 guest: Drop self.installer and start_install wrapper
This changes all the callers to invoke start_install directly on the
Installer object. We still stash the installer instance inside the
guest object in create.py, just for simplicity
2018-09-04 14:55:04 -04:00
Cole Robinson
c154bbacd4 guest: Fold add_default_devices into set_defaults
It doesn't have any need anymore to be separate
2018-09-04 14:55:04 -04:00
Cole Robinson
f1bbc5f67a guest: move set_install_defaults to installer class
It's only called explicitly in one place, so update the caller
2018-09-04 14:55:04 -04:00
Cole Robinson
8a6a491306 guest: Drop self.autostart and self.replace
Require callers to pass autostart as an argument to start_install
self.replace isn't even used for guest installs
2018-09-04 14:55:04 -04:00
Cole Robinson
9e05c56397 guest: Drop self.domain
The only user is virt-install, make its usage explicit
2018-09-04 14:55:04 -04:00
Cole Robinson
fdbb1f9e5a installer: Absorb all guest start_install handling
Really it makes more conceptual sense that the Installer class
should handle start_install and friends, but that's difficult
because the layering is all mixed up.

Start to untangle it by moving all those routines to the Installer
class and adding wrapper APIs to Guest to maintain compat for now.
2018-09-04 14:55:04 -04:00
Cole Robinson
1abbdfc551 installer: Drop isinstall parameter
Separate the install from postinstall config case more clearly,
so the installer is only ever altering bits for the install-time
case, and Guest handles actually writing postinstall bits
2018-09-04 14:55:04 -04:00
Cole Robinson
221dd00cb9 devices: disk: remove default_cb usage 2018-09-04 14:55:04 -04:00
Cole Robinson
fff3c88f9c devices: disk: Absorb Guest bus/target default setting
Simplifies cli stuff as a nice side effect
2018-09-04 14:55:04 -04:00
Cole Robinson
4e7652b548 domain: cpu: Add set_defaults 2018-09-04 14:55:04 -04:00
Cole Robinson
cf65bef6f5 domain: clock: add set_defaults 2018-09-04 14:55:04 -04:00
Cole Robinson
d5bff2c987 guest: Remove default_cb usage
This lets us simplify things in create.py a bit, since we don't
need to manually encode a UUID
2018-09-04 14:55:04 -04:00
Cole Robinson
e6219504ce domain: os: Add set_defaults 2018-09-04 14:55:04 -04:00
Cole Robinson
c1443f8a80 guest: Remove fallback xen loader/emulator handling
This has been provided by libvirt caps for a long time, and we
don't even test it
2018-09-04 14:55:04 -04:00
Cole Robinson
468f5e67fa domain: pm: Add set_defaults 2018-09-04 14:55:04 -04:00
Cole Robinson
5517033c79 domain: seclabel: Add set_defaults 2018-09-04 14:55:04 -04:00
Cole Robinson
9a5b903086 domain: features: Add set_defaults
And move all the Guest logic there.

We need to add an xmlbuilder helper _prop_is_unset to be able to
determine if a bool property is unset, in our quest to remove
default_* xmlbuilder bits
2018-09-04 14:55:04 -04:00
Cole Robinson
64dc334538 devices: interface: Add set_default function
Move all the Guest network default logic to it, and drop a now
redundant test
2018-09-04 14:55:04 -04:00
Cole Robinson
7b5f1a304d guest: Publicize _os_object as osinfo 2018-09-04 14:55:04 -04:00
Cole Robinson
35c0cf352f guest: Move graphics defaults handling to DeviceGraphics 2018-09-04 14:55:04 -04:00
Cole Robinson
698c72e60d devices: sound: Add set_defaults 2018-09-04 14:55:04 -04:00
Cole Robinson
40de2c4762 guest: For implied devices, explicitly call set_defaults
These can be added after we initially call set_defaults on all devices,
so require a manual set_defaults call
2018-09-04 14:55:04 -04:00
Cole Robinson
1b0f325813 devices: video: Add set_defaults 2018-09-04 14:55:04 -04:00
Cole Robinson
d25ce81439 guest: Force qxl/vga more often
Letting libvirt choose gives us cirrus, which is really bad.
So for x86 for it more
2018-09-04 14:55:04 -04:00
Cole Robinson
fdd1cc5ca8 guest: Make spice default device additions explicit
Don't lump it in with setting video defaults
2018-09-04 14:55:04 -04:00
Cole Robinson
7738b8f407 devices: panic: Add set_defaults
Move default handling out of Guest and default_cb callbacks, and
make implement it in a standard set_defaults function
2018-09-04 14:55:04 -04:00
Cole Robinson
c3515fa469 guest: Drop multifunction address magic
Seems sufficiently obscure that if someone is manually specifying
addresses we can require them to pass multifunction as well
2018-09-04 14:55:04 -04:00
Cole Robinson
d5638eb140 osdict: Make qemu_ga support solely dependent on virtio-serial support
We shouldn't concern ourselves with whether the OS supports qemu_ga
out of the box, just set up the channel regardless, as long as
virtio-serial is supported.

This adds the channel for some aarch64 cases which didn't have OS
specified, but that's desired IMO
2018-09-01 13:23:01 -04:00
Cole Robinson
8a87c91888 osdict: Move default_netmodel logic to Guest
Make the entry point just return a list of libosinfo device names,
and have Guest choose the preference. This is more future proof
2018-09-01 13:23:01 -04:00
Cole Robinson
b902fbd54f osdict: Move default_videomodel to guest
It's not really osdict specific
2018-09-01 13:23:01 -04:00
Cole Robinson
fb1bb26373 support: Drop lots more checks
- Remove anything for less than qemu 0.12 or libvirt 0.10, basically
  rhel6 vintage stuff
- Open code some simple checks
- Remove some that are only used for unnecessary error reporting
2018-08-31 22:21:15 -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
d8514e19c8 guest: Drop arm vexpress virtio-mmio support
This case will still work, but be a bit slower, which is fine. Nowadays
-M virt is much better for virt usage and nearly everyone is using that,
so save us the complication. This was really only useful when
bootstrapping arm virt support
2018-08-31 17:31:09 -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
b1eb07c26a guest: Don't add usb tablet for xen PV
xen PV doesn't have USB support
2018-08-22 08:38:33 -04:00
Cole Robinson
2b35183352 guest: Don't hardcode /usr/bin/pygrub for xenpv
Let libvirt/libxl fill it in. This was required for rhel5 xen at
least, but we don't support that anymore and modern libvirt seems
to do the right thing and fill it in for us.
2018-08-22 07:37:32 -04:00
Cole Robinson
7cd41ab9ea guest: Default to e1000e if machine=q35
And libosinfo doesn't have any specific recommendation for us
2018-08-21 16:36:38 -04:00
Cole Robinson
2da06fec95 guest: Default to ich9 if machine=q35 (bz 1388177)
It's the pci-e version which we should prefer for q35

https://bugzilla.redhat.com/show_bug.cgi?id=1388177
2018-08-21 16:35:34 -04:00
Cole Robinson
e59c3d969e guest: Remove old xen acpi disabling
This is only for rhel5 vintage xen which is long out of support,
so drop it
2018-08-21 16:35:34 -04:00
Cole Robinson
39a7cbbad7 domain.numatune: Drop cpuset validation
This type of validation should really be done at the libvirt level,
particularly for a non-mandatory feature like cpuset. Otherwise
it's just more code for us to test which will rarely be hit by users
2018-06-05 14:27:29 -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
Charles Arnold
0f2e0a49f9 virtinst: Trivial spelling fix
Trivial spelling fix.

Signed-off-by: Charles Arnold <carnold@suse.com>
2018-04-04 16:49:23 -04:00
Charles Arnold
fd6a815440 virtinst: compare host and domain cpu models
Lookup the domain capabilities CPU model and compare with
the host capabilities CPU model and if they are not equal
set the guest's CPU model to None.

(crobinso: compare against 'custom' list not 'host-model', move
 to separate function)
2018-04-03 10:57:49 -04:00
Cole Robinson
5b111b3d9f guest: Move get_all_devices to devices.get_all 2018-03-21 12:59:46 -04:00
Cole Robinson
7fb1ddbc18 virtinst: s/_XML_ROOT_NAME/XML_NAME/g
No reason for it to be privatized, could be useful in some cases
2018-03-21 11:17:36 -04:00
Cole Robinson
538ea96116 guest: devices: change XML ordering to match libvirt 2018-03-21 11:17:36 -04:00
Cole Robinson
f69b823fad devices: Switch to normal _XML_PROP_ORDER
Drop the register_device stuff, rename virtual_device_type
2018-03-21 11:17:36 -04:00
Cole Robinson
7b61c45d3b guest: Move all_devices to guest.devices.X
The way we enumerate devices doesn't conform with the way all
other XMLBuilder instances expose child objects. Move more towards
that direction.

This requires some virt-xml and cli.py hacks but we will remove those
in future patches
2018-03-21 11:17:36 -04:00
Cole Robinson
fe9ed2340c virtinst: move <domain> XML files to virtinst/domain
And give the classes consistent naming
2018-03-21 11:17:36 -04:00
Cole Robinson
b6dcee8eb7 Use consistent and minimal license header for every file 2018-03-21 07:29:40 -04:00
Cole Robinson
3909c10441 virtinst: Move all devices to virtinst/devices/ 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
6f578ffeff xmlbuilder: Remove get_xml_config prep wrappers
The only user was Guest, and in fact it's not needed for the standard
get_xml_config, only for the custom _get_install_xml. So drop it
2018-02-22 20:49:07 -05:00
Cole Robinson
f04b284f21 xmlbuilder: Abstract libxml2 API and cleanup
Moves the libxml2 bits to a separate xmlapi file and class, a bunch
of cleanups to xmlbuilder internals dealing with XML stuff.

The main point is to experiment with different XML library impls,
since libxml2 is unfun to deal with and we are having python3
issues like

https://bugzilla.gnome.org/show_bug.cgi?id=776815
2018-02-20 11:23:37 -05:00
Cole Robinson
d108bbe143 Convert docstrings to standard reStructuredText param format 2018-02-14 11:08:09 -05:00
Cole Robinson
dae8642bb1 xmlbuilder: centralize adding child new child prop instances
Currently the domain CPU class has a child property like:

  siblings = XMLChildProperty(_CPUCellSibling)

If a user wants to add a new sibling, we add a convenience function:

    def add_sibling(self):
        obj = _CPUCellSibling(self.conn)
        self.add_child(obj)
        return obj

Rather than require every child property to define a similar matching
helper function, this adds infrastructure in xmlbuilder to do this
generically for every child property. Now callers can do

    obj = guest.cpu.siblings.add_new()
2018-02-08 14:03:47 -05:00
Cole Robinson
3086c7fda9 Drop python3 compat imports
We are going completely python3
2018-02-06 18:56:15 -05:00
Radostin Stoyanov
08c23477fd Fix re-raising exception
In Python 2 the raise command can take 3 objects as arguments which
are used to specify the exception to be raise as well as detailed
information and traceback [1].

In Python 3 the sintax is changed and now the keyword "from" and
"with_traceback" keyworkds are used to specify this information. [2]

Example which has the same behaviour for both Python 2 and 3:

    try:
        a = 1/0
    except Exception:
        import sys
        err = sys.exc_info()

        try:
                raise Exception("Test")
        except:
                pass

        if sys.version_info[0] == 2:
            exec("raise err[0], err[1], err[2]")
        else:
            raise
2018-02-06 18:49:17 -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
Wim ten Have
708516c39e virtinst: add vcpupin support
Add vcpupin support to virt-install so that it can create guest
domains with statically allocated vcpu pinning towards a given cpuset.

Syntax: to pin vcpu=0 to cpuset="1,3" and vcpu=1 to cpuset=2

  --cputune vcpupin0.vcpu=0,vcpupin0.cpuset=1,3,vcpupin1.vcpu=1,vcpupin1.cpuset=2

generates below XML description for the guest domain.

  <cputune>
    <vcpupin vcpu="0" cpuset="1,3"/>
    <vcpupin vcpu="1" cpuset="2"/>
  </cputune>

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Signed-off-by: Menno Lageman <menno.lageman@oracle.com>
2018-02-06 10:21:56 -05:00
Pavel Hrdina
bc8c5b0778 cli: append "--attach" to virt-viewer if graphics has listen type none
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1527834

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2018-01-07 08:59:43 +01:00
Scott Garfinkle
249ff1ed36 virtio-scsi by default on power
Power architecture guests should default to virtio-scsi rather than spapr-scsi

Signed-off-by: Scott Garfinkle <scottgar@linux.vnet.ibm.com>
2017-12-20 13:30:45 -05:00
Cole Robinson
8b4befae60 virtinst: Drop UUID validation
It's redundant as libvirt will give us these checks already, and we
aren't even testing it
2017-12-14 12:45:01 -05:00
Cole Robinson
5ac933e98a guest: Set default rendernode= if spice gl requested
Since this is required to work out of the box with qemu:///system
2017-11-25 17:29:02 -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
Pavel Hrdina
9f191da5c5 devicepanic: add all models supported by libvirt
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-09-09 10:09:46 +02: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
f41844f3f2 guest: Use usb3 qemu-xhci for machvirt
This is what libvirt will default to nowadays for those configs,
so let's match it.
2017-07-10 19:46:13 -04:00
Cole Robinson
0633055fb9 guest: Drop old os type=linux back compat
We don't support libvirt versions that require this anymore
2017-07-10 09:34:38 -04:00
Cole Robinson
6d625ae45f guest: Enable spice sound on more arches
If spice is enabled, just assume sound devices will work as well
2017-06-28 16:28:25 -04:00
Cole Robinson
a07a874497 guest: If graphics enabled, add usb tablet/keyboard for machvirt 2017-06-28 16:22:23 -04:00
Cole Robinson
2cabc2e386 guest: Don't add default ps2 or xen mouse
libvirt drivers have added these by default for a long time, so
its redudnant here
2017-06-28 16:17:50 -04:00
Cole Robinson
f2de47cee2 guest: Add USB3 controller for machvirt by default
...if libvirt is new enough to do machvirt PCI by default. We can
just use usb3 since all guest OS that support aarch64 are new enough
to support it
2017-06-28 15:35:07 -04:00
Cole Robinson
ae836304f9 guest: Drop references to ia64
Nothing modern supports it, don't even bother
2017-06-28 15:17:20 -04:00
Cole Robinson
23b971bba8 guest: Rename _hv_supported to _hyperv_supported
Much more clear name
2017-06-28 15:15:31 -04:00
Cole Robinson
225d53c511 guest: Default to video type=virtio for machvirt
That's basically the only working config on KVM
2017-06-28 15:13:44 -04:00
Cole Robinson
0fe76d321b guest: Enable default virtio-rng for pseries and machvirt
arm guys confirmed virtio-rng should be fine. pseries guys didn't
but I think it will be okay
2017-06-28 15:12:00 -04:00
Cole Robinson
47b127b49f guest: Use virtio more for ppc64 pseries, and s390
qemu s390x is virtio only nowadays, and on ppc64 pseries is preferred,
and all relevant OS are going to support it for that case
2017-06-28 15:02:23 -04:00
Cole Robinson
4e7cd661ee guest: Only add input devices if graphics are specified 2017-06-28 12:05:14 -04:00
Pavel Hrdina
b690908aa4 virtinst: enable secure feature together with smm for UEFI
The secure feature actually enforce the secure boot if Secure Boot
Mode is configured.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 20:49:45 +02:00
Pavel Hrdina
4f8e795c6a virtinst: if required by UEFI enable SMM feature and set q35 machine type
If we detect that the UEFI image is build to require SMM feature we
should configure the guest to enable SMM feature and set q35 machine
type.  Without this user wouldn't be able to boot the guest.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-01 09:58:46 +02:00
Cole Robinson
a90d675394 Switch deprecating log.warn to log.warning
Same semantics, but the alias is deprecated
2017-05-05 14:53:28 -04:00
Cole Robinson
62feeb02a8 Switch to python3 style 'except X as Y' notation
Which also works with python2.7
2017-05-05 14:52:11 -04:00
Pavel Hrdina
3ebbeef80e virtinst: introduce support for <maxMemory> element
This element controls hot(un)plugable memory for the guest in
addition to the initial memory configured by <memory> element.

One has to configure <maxMemory> and guest numa nodes using <numa>
element to enable hot(un)plug of memory modules.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-05-05 11:49:27 +02:00
Cole Robinson
8181e86098 guest: Only use define+start logic for vz
Handling this for qemu, which may need UNDEFINE_NVRAM flags to do
the cleanup, is a pain, so move this logic to only apply to vz
driver which doesn't support createXML

Mentioned on list: https://www.redhat.com/archives/virt-tools-list/2017-April/msg00037.html
2017-04-27 14:59:41 -04:00
Cole Robinson
4c4d31d67d tests: Fix after vmvga change 2017-04-19 14:08:04 -04:00
Cole Robinson
93085d2b9d guest: Don't repeatedly overwrite self.domain
Since clearing it is important, just set it at the end when things
have succeeded
2017-04-13 14:56:03 -04:00
Christophe Fergeau
2099a1946e Reset Guest.domain to None on domain creation error
When an error occurs when the VM creation wizard tries to start the VM,
it's then not possible to press again the "Finish" button to try again
to start it, as this errors out with:

Traceback (most recent call last):
  File "/home/teuf/redhat/virt/virt-manager/virtManager/asyncjob.py", line 88, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/home/teuf/redhat/virt/virt-manager/virtManager/create.py", line 2341, in _do_async_install
    guest.start_install(meter=meter)
  File "/home/teuf/redhat/virt/virt-manager/virtinst/guest.py", line 457, in start_install
    raise RuntimeError(_("Domain has already been started!"))
RuntimeError: Domain has already been started!

This is caused by code introduced in commit fc6778 which does not reset
self.domain to None when an exception is caught.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-04-13 14:24:40 -04:00
Mikhail Feoktistov
c25ea6537b Tune default device list for Virtuozzo containers
Virtuozzo supports virtio NIC.
Also add default VNC graphics.
Privnet feature and emulator device have no sense for vz containers.
2017-03-17 13:36:15 -04:00
Cole Robinson
d62e975568 guest: Add default virtio-rng /dev/urandom (bz 1212082)
For guests that support it, per libosinfo, and new enough libvirt
to handle /dev/urandom. See the bug for discussion

https://bugzilla.redhat.com/show_bug.cgi?id=1212082
2017-03-08 17:26:19 -05:00
Cole Robinson
22b6becd5d guest: Add support for qemu cli passthrough
This is for xml like:

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  ...
  </devices>
  <qemu:commandline>
    <qemu:arg value='-newarg'/>
    <qemu:env name='QEMU_ENV' value='VAL'/>
  </qemu:commandline>
</domain>

Requires some extensions to the xmlbuilder infrastructure
2017-03-06 22:15:46 -05:00
Cole Robinson
a2df53db21 guest: Reorder XML output to match libvirt output 2017-03-05 21:04:34 -05:00
Cole Robinson
8ebed65459 guest: Only add default usb redirdev for x86
Since we only attempt to add a default USB controller for x86, match
it by only trying to add redir devices on x86 as well. Fixes a uitests
failure for ppc testing, since the test:/// driver doesn't add an
implied USB controller, and libvirt now validates that one was provided.
2017-03-05 14:32:14 -05:00
Mikhail Feoktistov
f78ff6457b Do not use createXML for non transient domains
For these domains use defineXML

(crobinso: Add undefine on start() failure)
2017-03-01 15:27:37 -05:00