Commit Graph

2058 Commits

Author SHA1 Message Date
Cole Robinson
188fd4adb1 cli: Drop keymap santizing
We shouldn't be validating against a static list of keymaps,
instead we should let libvirt or the hypervisor throw and error.

Also the accompanying code is about to be removed.

It's possible this will break command line usage for some users, like
if they were passing keymap=US and depending on our logic to lower()
it for them. I think this should be rare, and IMO it's acceptable to
tell users to just fix their command line, which should work correctly
with older versions too, so it should be a one time fix.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-24 17:04:29 -05:00
Cole Robinson
419f8cd31b pollhelpers: Streamline usage a bit
* Explicitly define the build 'cb', don't use lambda
* Rename pollhelpers arguments, clarifying use of cb
* Check support status in pollhelpers
* Move 'dopoll' checking up a level in vmmConnection

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-24 17:04:29 -05:00
Cole Robinson
3ad646fef1 pollhelpers: Kill old style polling
All the major hypervisor drivers have supported listAllDomains
since rhel6 vintage libvirt. Most other driver types have had the APIs
since their introduction, or for just as long.

I will be surprised if this affects anyone in any material way

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-24 17:04:18 -05:00
Cole Robinson
4147f760e8 connection: Explicitly error if domain listing APIs are not supported
This will be more important when we drop old domain polling APIs,
because it will be more likely we encounter an old libvirt or weird
connection without the expected API support

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-24 15:39:41 -05:00
Fabiano Fidêncio
a9aeca60bb unattended: Add reg-login option to --unattended
As osinfo-db introduced the first usage of reg-login, let's also
add support for such option when using --unattended.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2020-01-24 10:05:03 -05:00
Cole Robinson
ec50dbd15d devices: disk: Ensure abspath when checking search permissions
Reported-by: Junqin Zhou <juzhou@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-18 15:27:01 -05:00
Cole Robinson
925948a19e virt-install: Add some coverage exclusions
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-15 11:00:21 -05:00
Cole Robinson
637781fca2 cli: Add --serial type= arg, with back compat alias char_type
'type' is the expected naming here

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-12-24 12:02:53 -05:00
Fabiano Fidêncio
616ac2ebe3 installerinject: Check for genisoimage and mkisofs before calling it
Let's check for both genisoimage and mkisofs as some distros will ship
mkisofs without linking it to genisoimage, as OpenSUSE Leap 15.1 does.

And, I know, genisoimage is a requirement of the project. However, it's
not packaged on OpenSUSE Leap 15.1 while mkisofs is present there.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-12-17 17:09:26 -05:00
Michal Privoznik
66be1d009f domcapabilities: Whitelist upstream qemu edk2 paths
Upstream qemu installs
/usr/share/qemu/edk2-$ARCH-(?secure-)code.fd FW images. Whitelist
them too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-12-17 16:27:49 -05:00
Cole Robinson
e879097d1b cli: Clean up process if execv fails
Like if /bin/true is missing, as it was on freebsd. Use /bin/test
instead which appears to have a higher likelyhood of existing

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-12-11 17:57:35 -05:00
Cole Robinson
78ad233653 tests: abide logging options for clitests
We need to restore logging after calling the cli tools. Centralize
the logging reset behavior since we need that too

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-12-11 17:57:28 -05:00
Pavel Hrdina
39366c37f6 controller: don't set default controller index
Libvirt is able to figure this out and it will make usage of the CLI
options more user-friendly.

For example if users wants to add a new pcie-root-port to existing VM
they have to figure out the latest controller index and call it like
this:

    virt-xml \
        --add-device \
        --controller pci,model=pcie-root-port,index=$nextIndex \
        $VM

After this change it will be simply:

    virt-xml \
        --add-device \
        --controller pci,model=pcie-root-port \
        $VM

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-12-04 12:38:28 +01:00
Cole Robinson
7fee1a2814 cli: Fix --cloud-init and --unattended 'none' handling
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 14:19:09 -05:00
Cole Robinson
04b15f0dba cloudinit: Don't regenerate root password
Store the first one we generate for later usage

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 14:03:49 -05:00
Cole Robinson
da996317f8 cli: cloudinit: default to --autoconsole text with --cloud-init
Cloud images all work nicely with text output, and it's likely
the preferred native way to connect to the guest vs graphical.
Plus it simplifies generated password copy+paste

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 14:03:49 -05:00
Cole Robinson
226378d522 unattended: Fix errors when running as root
Tries to use 'root' as VM username, which is forbidden

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 12:02:27 -05:00
Cole Robinson
530befc222 unattended: fix error message variable order
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 11:49:38 -05:00
Cole Robinson
e488696cef cli: Add explicit --autoconsole option
Allows the user to override our implicit '--autoconsole default'
handling

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 06:22:14 -05:00
Cole Robinson
85a33caa76 cli: Expose default console handling through _AutoconsoleData
Rework all console queries to go through that object API

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 06:20:42 -05:00
Cole Robinson
44c519200c cli: Add _AutoconsoleData and use it
This will be expanded later to track explicit requests for certain
console types

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-24 18:12:06 -05:00
Cole Robinson
b55a959e5e installer: Use standard scratchdir for cloudinit tempfiles
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-23 10:38:49 -05:00
Cole Robinson
18ff22f732 cloudinit: Add license header
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-22 22:59:27 -05:00
Cole Robinson
a67237b221 cloudinit: Rework file building
* Ensure files are cleaned up if we fail mid run
* Ensure temp user-data and meta-data files are cleaned up
* Move dest file naming into cloudinit.py

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-22 22:57:43 -05:00
Cole Robinson
89fc06f642 cli: Add --cloud-init meta-data=/path/to/meta-data
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-21 17:34:39 -05:00
Cole Robinson
e1bd5f92cf cli: Add --cloud-init user-data=/path/to/user-data
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-20 17:47:34 -05:00
Cole Robinson
9a3f73710e cloudinit: Only print generated password if it was requested
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-20 17:47:34 -05:00
Cole Robinson
f107aaab02 cloudinit: split out _create_userdata_content
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-20 17:32:49 -05:00
Athina Plaskasoviti
7ae6a60086 cloudinit: Move random password printing and sleeping to virt-install
Fixed:
- Added a do_log flag to print_stdout(), to avoid logging of printed random password.
- Excluded timeout in virt-install from testing

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
AthinaPl
b4daeba6b5 cloudinit: Add ssh-key=/path/to/key cli option
Login to VM with:
ssh root@vm_ip_address

Signed-off-by: AthinaPl <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
3014644f25 cloudinit: Scrub password from logs
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
1b43ae8716 cloudinit: Fix password expiration
Password expiration happens in case of one time random password generation.
When user provides password from file, don't expire the password.

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
7a2c53612f cloudinit: Add root-password-generate=yes|no instead of root-password=xxxx
Now --cloud-init defaults to root-password-generate=yes,disable=yes.
Option for plaintext password given through the cli is completely removed.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
050d4dd62a cloudinit: Add cli option root-password-file=/path/to/file
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
66d95c6792 cloudinit: Move password generation inside class CloudInitData
Function generate_password() provides random 16 digit password and
get_root_password() handling root_password assignment.

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
db0e524e8d cloudinit: Add basic testing for cli option --cloud-init
Tests now cover default --cloud-init behavior, and
root-password=(generate and given password),disable=no.

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
9266cc47c1 cloudinit: Change iso suffix for cloud image installations
Generated iso now called ...-cloudinit.iso.

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
dadaf8eb45 cloudinit: Fixed broken testsuite
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
0e5b1b3048 cloudinit: Clean up create_metadata and create_userdata functions from unused/unwanted arguments
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
0bbfc80b68 cloudinit: Add disable=yes|no
Cli option to permanently disable cloud-init after first boot by user request.
Handled so that bare --cloud-init defaults to --cloud-init root-password=generate,disable=yes.

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:10 -05:00
Cole Robinson
ec47c9dafc cloudinit: Fix setting root password in user-data 2019-11-20 16:41:10 -05:00
Athina Plaskasoviti
19317024cc Introduction of cloud-init configuration in virt-install
Usage:
--cloud-init

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-11-20 16:41:05 -05:00
Cole Robinson
c311b28979 cli: Add 'clearxml' arg for options it doesn't apply to
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-20 16:40:00 -05:00
Fabiano Fidêncio
1d9d91910a installertreemedia: Respect os_variant when setting kernel_url_arg
Currently, the kernel_url_arg is get based on the cached data. However,
when the cached data is created, the store is already set to a "generic"
distro and the os_variant is not respected when getting the
kernel_url_arg.

In order to avoid ignoring os_variant when looking up the kernel_url_arg,
let's also take into the consideration the the os_variant passed via
command line, which was used to set Guest's osinfo name, returning then
the expected value to the caller.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-11-20 16:04:09 -05:00
Fabiano Fidêncio
54edd0a0a6 unattended: Never use "root" as user-login
When running virt-install as root, user-login would be automatically set
to "root", causing an installation failure in the most part of the
distros (if not all of them).

In order to avoid such failures, let's raise a runtime error in case the
user-login used is "root".

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-11-20 16:04:09 -05:00
Fabiano Fidêncio
cdcec1fb03 unattended: Add option to set the user-login
Let's allow setting the login of the guest user.

Using the user from the system is a quite good fallback, but would break
unattended installations when running virt-install as root. Thus, for
those cases, it makes sense to have the option of setting the user
login.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-11-12 16:07:07 -05:00
Cole Robinson
fb2bfd610f details: Use Guest.lookup_domcaps helper
This ensures the Guest object domcaps cache is primed as well, which
prevents the CPU security features handling from constantly refetching
domcaps info.

We need to tweak the cache invalidation check in Guest to handle
some of the test suite hackery we do

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-12 14:20:36 -05:00
Cole Robinson
5d91237386 domcaps: Tweak cpu security feature log statements
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-12 14:17:21 -05:00
Cole Robinson
d934d6f266 domcaps: Fix check for uncached security features
We need to check against None, which is the initial value, otherwise
a host with none of the security features present will repeatedly poll
libvirt baseline APIs

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-12 14:17:21 -05:00
Pavel Hrdina
df48a77e6a virtinst: fix detection if baselineHypervisorCPU API is available
With libvirt-python >= 4.4.0 and libvirt < 4.4.0 we would receive
libvirt.libvirtError exception because the python binding knows about
the function but it's not supported by libvirt.  However, in case that
the python binding is older then 4.4.0 it will raise AttributeError
because the function is not implemented in python binding as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-10-22 13:42:21 +02:00