Commit Graph

7035 Commits

Author SHA1 Message Date
Lily Nie
52782a4958 delete: Add _delete_vm method
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2020-01-21 19:53:53 -05:00
Lily Nie
8ae0c8ca0e delete: Add _vm_active_status method
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2020-01-21 19:53:53 -05:00
Lily Nie
92200ef413 delete: Add _get_title_text method
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2020-01-21 19:53:53 -05:00
Lily Nie
1ae83cbb82 delete: Add _get_disk_datas method
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2020-01-21 19:53:53 -05:00
Lily Nie
4971e47566 delete: Add vmmDeleteStorage class
We should try to hide all the self.vm vs self.disk differences into
individual functions to make the code easier to follow and to avoid
touch those values by accident in the future

Reviewed-by: Cole Robinson <crobinso@redhat.com>
2020-01-21 19:53:53 -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
08313ede2b man: virt-install: Improve --tpm docs
* Stop listing sub options, since there's multiple, and most won't
  need to be specified.

* Give an example for type=emulator

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
9346c22134 baseclass: Log if emit() called from non-MainThread
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-15 15:19:55 -05:00
Cole Robinson
5e63e87a8a cli: Default lxc:/// memory to 1024, and print it
My previous patch was misguided as pointed out by Pavel:
https://github.com/virt-manager/virt-manager/issues/73#issuecomment-574680435

And it was setting incorrect memory, which I missed because the tests
are busted here. Add a hack to work around that

Bump up the default to 1024, and print it, so the user can tell if
the default is not to their liking

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-15 11:07:42 -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
Lin Ma
15a9502b7b details: Fix showing the firmware type in case of firmware auto selection
For a shutoff VM, If user select uefi firmware auto selection, e.g.
<os firmware='efi'>
...
</os>

Its firmware information is set to 'BIOS' in details, This is incorrect.
This fixes it.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.com>
2020-01-15 10:21:46 -05:00
Cole Robinson
af3d678bdd domain: Only log once about waiting for qemu agent for set_time
Rather than one every wait period, which spams the debug logs

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-14 14:21:30 -05:00
Michael Weiser
b7a223030b virtManager: object: domain: Stop set time thread
Wire up stoppping of the time setting thread for actions that make
setting of guest time pointless.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-01-14 14:10:28 -05:00
Michael Weiser
f29196f3af virtManager: object: domain: Increase set time timeout
With the potential for annoyance eliminated, raise the timeout for guest
agent connectivity to 30 seconds.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-01-14 14:10:28 -05:00
Michael Weiser
9aa5997dd7 virtManager: object: domain: Add timeout config
Make the guest agent wait timeout and sleep interval properties of the
thread manager class better visibility and easier adjustment.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-01-14 14:10:28 -05:00
Michael Weiser
bfafe1e4b2 virtManager: object: domain: Spawn thread for set time
Sleeping in a loop waiting for the qemu guest agent to come online would
leave an annoying progress dialog while the domain would actually be
fully useable already. Additionally, multiple progress dialogs could
actually accumulate on screen if the user managed to suspend/resume fast
enough or the timeout was just long enough.

Defer regular retries into a separate thread to allow the progress
dialog to disappear immediately after the actual action completed. The
thread is encapsulated in a new class _vmmDomainSetTimeThread which
holds state, decides whether to at all wait for an agent to come online
or even try to set the guest time in the first place. It also holds
state (thread running or not), configuration (timeout and retry
interval) and provides an interface to start and stop the time setting
operation.

A later patch will wire up stopping the operation.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Suggested-by: Cole Robinson <crobinso@redhat.com>
2020-01-14 14:10:28 -05:00
Michael Weiser
4f8a27688d virtManager: object: domain: Refactor guest time setting
Sleeping in a loop waiting for the qemu guest agent to come online
leaves an annoying progress dialog while the domain may actually be
fully useable already. Additionally, multiple progress dialogs can
actually accumulate on screen if the user manages to suspend/resume fast
enough or the timeout is just long enough.

To avoid these, we want to defer retries into a separate thread to allow
the progress dialog to disappear immediately after the actual action
completed.

In preparation for that, add a new class _vmmDomainSetTimeThread that
will eventually manage that separate thread for guest time setting
operations. Move the current code for waiting for the qemu guest agent
into it without any semantic changes.

Make set_time() and agent_read() of vmmDomain accessible from the
outside so that _vmmDomainSetTimeThread can call back into them. Add
has_agent() to be able to find out if the domain has an agent configured
without leaking the actual agent config.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Suggested-by: Cole Robinson <crobinso@redhat.com>
2020-01-14 14:10:28 -05:00
Michael Weiser
827c948121 virtManager: object: domain: Simplify agent ready check
Just return the boolean value of the condition for simlicity.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2020-01-14 14:10:28 -05:00
Cole Robinson
e4f68764b0 virt-install: Set default memory to appease lxc:///
AFAICT the driver doesn't really do anything with it, but libvirt
XML requires it. So just default to --memory 64

Fixes: #73

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-14 13:10:03 -05:00
Pino Toscano
9b7c819c64 Install the AppStream file to the canonical location
The canonical location for AppStream XML files has been changed to
/usr/share/metainfo four years ago at least, with /usr/share/appdata
left as legacy location. It is time to switch to the right location.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-01-14 12:40:44 -05:00
Cole Robinson
a9cbc4e583 error: Set a cap on error dialog text size
Otherwise we can get some crazy sized dialogs with errors from
libvirt

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

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-14 12:40:39 -05:00
Pino Toscano
b1b9e4b688 Avoid string puzzle
Do not join two parts of sentences together, because it is problematic
to translate. Instead, use a different sentence depending on the
condition.

Fixes commit d52c9d1ffa.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-01-14 12:40:25 -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
Lily Nie
2138cca6a5 Handle the warning messages for disk device and non-disk device differently
add a remove-non-disk function and move the yes/no confirmation handling there

Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-12-23 16:43:05 -05:00
Michael Weiser
d62ca8220b details: snapshots: Warn of saved state on creation
Add a confirmation dialog when creating a new snapshot if there is saved
memory state so the user is aware that memory state will not be part of
the snapshot.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Suggested-by: Cole Robinson <crobinso@redhat.com>
2019-12-23 16:27:52 -05:00
Michael Weiser
a8c25450bd details: snapshots: Drop saved state on restore
Refuse to restore a non-running state from snapshot while there is saved
memory state in order to avoid filesystem corruption. Present a message
to the user to that effect and let them choose to either abort the
operation or drop the saved state before restoring the snapshot.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Suggested-by: Cole Robinson <crobinso@redhat.com>
2019-12-23 16:27:52 -05:00
Michael Weiser
8084639cd8 virtManager: object: domain: Fix snapshot run check
snap.is_running() returns a boolean and checking that against
VIR_DOMAIN_RUNNING worked by pure coincidence only. Just use the bool
value and give it a more speaking name while at it.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2019-12-23 15:35:38 -05:00
Cole Robinson
6bec5474db virt-install: Check --transient status in domain --wait
Otherwise when the VM shuts down, we will report an error, because
the VM doesn't exist anymore. The check_domain_inactive() helper
already handles this case, we just weren't using it in the --wait loop.

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

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-12-22 18:03:19 -05:00
Lily Nie
d52c9d1ffa Offer to delete the storage files without removing the VM
we should let users decide whether they want to also delete the
storage files or just dev from UI when they click the Remove button

Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-12-18 16:29:58 -05:00
Lily Nie
8b7854af1f Modify the remove_xml_dev function
add a remove_disk function,so that we can do some special things when remove a disk

Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-12-18 16:29:58 -05:00
Christian Ehrhardt
2a63003133 virtManager: disambiguize LXC
LXC can be many things and in particular when seeing just "LXC" in the
virt-manager UI one might think of either
- Libvirt-LXC => https://libvirt.org/drvlxc.html
- Linuxcontainers LXC => https://linuxcontainers.org

Clarify that this is specifically Libvirt-LXC

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2019-12-17 17:56:54 -05:00
Michael Weiser
adbcb06dd4 virtManager: object: domain: Set time on unpause and revert
Wire up setting of guest time on snapshot restore and resume from pause.
Do not try to set time if the restored snapshot does not contain a
running domain state.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Suggested-by: Cole Robinson <crobinso@redhat.com>
2019-12-17 17:51:05 -05:00
Michael Weiser
fa7d3eeb7b virtManager: object: domain: Check for guest agent
For qemu, only run the API if the VM has the qemu guest agent in the
XML. If it is present, wait for it to come online instead of
unconditionally retrying a number of times.

Reuse agent function agent_ready() from refresh_interface_addresses()
and refactor it into two methods of which get_agent() can be used to
check for agent presence and further work with the channel object.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Suggested-by: Cole Robinson <crobinso@redhat.com>
2019-12-17 17:51:05 -05:00
Michael Weiser
163eea6924 virtManager: object: domain: Restrict time sync to qemu
Only run the API for qemu and test drivers, they are the only ones
that support it. This will save spamming logs with error output.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Suggested-by: Cole Robinson <crobinso@redhat.com>
2019-12-17 17:51:05 -05:00
Michael Weiser
8457145608 virtManager: object: domain: Set time on resume
Use a potentially available agent inside the domain to update guest time
after resume. Based on the same function in Nova[1].

[1] 414df1e56e

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
https: //bugzilla.redhat.com/show_bug.cgi?id=1222069
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2019-12-17 17:51:05 -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
Pavel Hrdina
29f9f5f2d7 virt-xml: fix defined_xml_is_unchanged
Commit <53f075ab76e1c372474ae0d88f202e487d9f213f> added a warning if the
VM XML is not changed after removing default devices but the code was
incorrect.  We have to compare strings instead of string vs Guest object
and also the condition was inverted.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-12-03 13:04:37 +01:00
Cole Robinson
5f0155508d man: Document --autoconsole
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 17:20:37 -05:00
Cole Robinson
b31b28a15e man: Document --cloud-init option
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 17:14:21 -05: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
747c1e9d11 virt-install: Move cloudinit password printing before guest start
Otherwise if the timeout is hit, the user may miss VM boot output

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-25 14:03:49 -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
c5da0d7b07 virt-install: Don't pause for cloudinit pass if stdin is closed
Like if run in a script without any stdin open. Have the test suite
actually hit this path

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