Commit Graph

2746 Commits

Author SHA1 Message Date
Pavel Hrdina
b2b1702341 src: add missing headers to various files
All these headers are indirectly included provided by virfile.h having
virstoragefile.h which will be removed in the following patch.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-06 13:15:17 +01:00
Peter Krempa
781bc9201b virsh-domain: Add quotes around '%s' formatting domain name
Domain name can contain spaces in which case it's not immediately clear
from virsh messages where the boundary of the name is. Enclose all %s
formatters in apostrophes as delimiters.

Done via the following vim regex:

 %s/omain %s/omain '%s'/g

This patch changes:

 $ virsh undefine --snapshots-metadata 'OWASP Broken Web Apps VM v1.2'
 Domain OWASP Broken Web Apps VM v1.2 has been undefined

to:

 $ virsh undefine --snapshots-metadata 'OWASP Broken Web Apps VM v1.2'
 Domain 'OWASP Broken Web Apps VM v1.2' has been undefined

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-06 09:25:07 +01:00
Michal Privoznik
7f93905e45 nss: handle leases with infinite expiry time
After v6.3.0-rc1~64 a lease can have infinite expiry time. This
means that the expiration time will appear as a value of zero.
Do the expiration check only if the expiration time is not zero.

Fixes: 97a0aa2467
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-04 15:33:31 +01:00
Ján Tomko
3d016477cc virsh: virshAddressParse: check for malformed address
The refactor left in the 'if (addr)' check,
but before 'addr' was the return value of strchr
and now it's the return value of virshAddressParse.

Check 'a' instead since that's the return of strchr now.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 67bf91e1c3
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-10 12:58:54 +01:00
Shalini Chellathurai Saroja
385ade999c virsh: nodedev: filter by AP Matrix capability
Add support to filter by 'ap_matrix' capability.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-12-09 14:03:05 +01:00
Shalini Chellathurai Saroja
2f984adf2d nodedev: detect AP matrix device
Add support for AP matrix device in libvirt node device driver.

https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#the-design

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-12-09 14:03:05 +01:00
Farhan Ali
d2c731c9e2 virsh: nodedev: Filter by AP card and AP queue capabilities
Add support to filter by 'ap_card' and 'ap_queue' capabilities.

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-12-09 14:03:05 +01:00
Shalini Chellathurai Saroja
0415611fe0 nodedev: detect AP queues
Each AP card device can support upto 256 AP queues.  AP queues are
also detected by udev, so add support for libvirt nodedev driver.

https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#ap-architectural-overview

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-12-09 14:03:05 +01:00
Shalini Chellathurai Saroja
7a2b898895 nodedev: detect AP card device
Introduce support for the Adjunct Processor (AP) crypto card device.
Udev already detects the device, so add support for libvirt nodedev
driver.

https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#ap-architectural-overview

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-12-09 14:03:05 +01:00
Michal Privoznik
b9dcaede65 virsh: cmdSetUserSSHKeys: Error early if the file doesn't contain any keys
When removing SSH keys via set-user-sshkeys virsh command, then
files to remove are read from passed file. But when
experimenting, I've passed /dev/null as the file which resulted
in API checks which caught that @keys argument of
virDomainAuthorizedSSHKeysSet() can't be NULL. This is because if
the file is empty then its content is an empty string and thus
the buffer the file was read in to is not NULL.

Long story short, error is reported correctly, but it's not
necessary to go through public API to catch it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-08 14:39:13 +01:00
Michal Privoznik
22e785b8ef virsh: Fix logical error in cmdSetUserSSHKeys()
In v6.10.0-rc1~104 I've added a virsh command that exposes
virDomainAuthorizedSSHKeysSet() API under "set-user-sshkeys"
command. The command accepts mutually exclusive "--reset" and
"--remove" options (among others). While the former controls the
VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_APPEND flag, the latter
controls the VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_REMOVE flag.
These flags are also mutually exclusive. But the code that sets
them has a logical error which may result in both flags being
set. In fact, this results in user being not able to set just the
remove flag.

Fixes: 87d12effbe
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1904674
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-08 14:39:04 +01:00
Kevin Locke
4ac265173c libvirt-guests: Remove obsolete Windows comment
The comment that

> For instance, qemu-ga doesn't support guest time synchronization on
> Windows guests, but Linux ones.

Was correct at the time, but has since been addressed by
qemu/qemu@105fad6bb2, which added support for set-time without a time
argument, as used by `virsh domtime --sync` by libvirt-guests.sh.  I can
confirm that `virsh domtime --sync` works correctly on a Windows 10
guest, as does `SYNC_TIME=1`.  (Note that there can be a significant
delay between when the command completes and when the guest time
finishes synchronizing due to QEMU GA calling `w32tm` with `/nowait`,
which complicates testing.)

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2020-12-07 10:38:44 +00:00
Peter Krempa
a6e4c87299 libvirt_recover_xattrs: Allow fixing multiple PATHs
Loop for multiple PATH arguments to support shell pattern expansion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-04 16:27:22 +01:00
Peter Krempa
ea6bc0557d libvirt_recover_xattrs: Add unsafe operation mode
In some cases you want to fix a certain directory while you don't really
care whether there are other VMs running. Add a option to disable the
check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-04 16:27:22 +01:00
Peter Krempa
5377177f80 libvirt_recover_xattrs: Use only the correct xattr prefix
Linux and FreeBSD have different prefix. In the current state we've
tried to reset the labels for both systems which resulted in errors like
this:

Fixing /tmp/bitmaps2.qcow2
setfattr: /tmp/bitmaps2.qcow2: Operation not supported
setfattr: /tmp/bitmaps2.qcow2: Operation not supported
setfattr: /tmp/bitmaps2.qcow2: Operation not supported
setfattr: /tmp/bitmaps2.qcow2: Operation not supported
setfattr: /tmp/bitmaps2.qcow2: Operation not supported
setfattr: /tmp/bitmaps2.qcow2: Operation not supported

The 6 failed 'setfattrs' correspond to the wrong prefix.

Select the correct prefix based on the kernel name and modify the code
appropriately.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-04 16:27:22 +01:00
Peter Krempa
7b6bc11f65 libvirt_recover_xattrs: Avoid backticks for subshell
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-12-04 16:27:22 +01:00
Daniel P. Berrangé
d4745bb909 src: use singular form instead of plural, for guest disk info
Existing practice with the filesystem fields reported for the
virDomainGetGuestInfo API is to use the singular form for
field names. Ensure the disk info follows this practice.

Fixes

  commit 05a75ca2ce
  Author: Marc-André Lureau <marcandre.lureau@redhat.com>
  Date:   Fri Nov 20 22:09:46 2020 +0400

    domain: add disk informations to virDomainGetGuestInfo

  commit 0cb2d9f05d
  Author: Marc-André Lureau <marcandre.lureau@redhat.com>
  Date:   Fri Nov 20 22:09:47 2020 +0400

    qemu_driver: report guest disk informations

  commit 172b830435
  Author: Marc-André Lureau <marcandre.lureau@redhat.com>
  Date:   Fri Nov 20 22:09:48 2020 +0400

    virsh: add --disk informations to guestinfo command

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-12-03 13:10:29 +00:00
Michal Privoznik
b7d4e6b67e lib: Replace VIR_AUTOSTRINGLIST with GStrv
Glib provides g_auto(GStrv) which is in-place replacement of our
VIR_AUTOSTRINGLIST.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-12-02 15:43:07 +01:00
Marc-André Lureau
172b830435 virsh: add --disk informations to guestinfo command
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
2020-12-01 11:23:52 +01:00
Ryan Gahagan
8d7708ac61 virsh: Added attach-disk support for network disk
Related issue: https://gitlab.com/libvirt/libvirt/-/issues/16
Added in support for the following parameters in attach-disk:
--source-protocol
--source-host-name
--source-host-socket
--source-host-transport

Added documentation to virsh.rst specifying usage.

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
61c8164502 virsh: cmdAttachDisk: Use virXMLFormatElement
Convert the code to the new XML formatting approach for simpler code and
future additions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
34f830022b virsh: cmdAttachDisk: Use enum for disk source type
For extendability and clarity add enum virshAttachDiskSourceType and
use it to drive the XML formatting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
8448605568 virsh: virshAddress*: Move out of cmdAttachDisk block
The helper started as helper for cmdAttachDisk but is now used outside
of it too.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
2978c06c4e virsh: Rename 'struct DiskAddress' and friends
Use 'virshAddress' prefix for all the related structs and enums.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
67bf91e1c3 virsh: Refactor str2DiskAddress
Rewrite and rename the address parser.

As a fallout the use of the removed 'str2PCIAddress' is replaced by
virshAddressParse and virshAddressFormat.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
565d922b5b virsh: Unify code for <address type='drive'
DISK_ADDR_TYPE_SATA, DISK_ADDR_TYPE_IDE and DISK_ADDR_TYPE_SCSI are
driven by basically identical data types. Unify them. Note that
changes to 'str2DiskAddress' are deliberately lazy as it will be
refactored later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
464629223e virsh: Extract address formatting from cmdAttachDiskFormatAddress
Introduce virshAddressFormat with code from cmdAttachDiskFormatAddress
to format the address.

Note that this patch fixes some whitespace inconsistencies in the
formatted addresses.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
a4dca3ec0b virsh: cmdAttachDisk: Split out formatting of disk address
First step is to remove all of the address handling code to a new
function called 'cmdAttachDiskFormatAddress'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
5c9fc43e69 virsh: cmdAttachDisk: Don't assume type='block' if file can't be examined
'virsh attach-disk' uses stat() to determine if the 'source' is a
regular file. If stat fails though it assumes that the file is block.

Since it's way more common to have regular files and the detection does
not work at all when accessing a remote host, modify the default to
assume type='file' by default.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
426369ebfa virsh: cmdAttachDisk: Refactor control flow
Remove the unnecessary 'cleanup:' label since we can directly return as
the memory clearing is now automated.

We can also remove the 'functionReturn' variable and use the usual
pattern of returning success.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
62903cb11f virsh: cmdAttachDisk: Use automatic memory clearing for 'xml' and 'dom'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Peter Krempa
6524af14c2 virsh: cmdAttachDisk: Declare one variable per line
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-23 14:44:39 +01:00
Pavel Hrdina
126cb34a20 virt-host-validate: fix detection with cgroups v2
Using virtCgroupNewSelf() is not correct with cgroups v2 because the
the virt-host-validate process is executed from from the same cgroup
context as the terminal and usually not all controllers are enabled
by default.

To do a proper check we need to use the root cgroup to see what
controllers are actually available. Libvirt or systemd ensures that
all controllers are available for VMs as well.

This still doesn't solve the devices controller with cgroups v2 where
there is no controller as it was replaced by eBPF. Currently libvirt
tries to query eBPF programs which usually works only for root as
regular users will get permission denied for that operation.

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/94

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-19 01:18:35 +01:00
Michal Privoznik
87d12effbe virsh: Expose OpenSSH authorized key file mgmt APIs
The new virsh commands are:

  get-user-sshkeys
  set-user-sshkeys

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-11-18 16:18:25 +01:00
Peter Krempa
d2d23aa2a6 tools: virsh: Reset error when keepalive registration fails
We try to enable keepalive oportunistically. If it's not supported by
the connection driver and it was not explicitly requested we keep the
error object set and can report it in some cases accidentally:

 --- stdout ---
 TEST: /home/pipo/libvirt/tests/virsh-self-test
       !                                        1   FAILED
 --- stderr ---
 error: parameter 'target' of command 'attach-disk' must be listed before optional parameters
 error: this function is not supported by the connection driver: virConnectSetKeepAlive
 -------

Clear the stored libvirt error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:30 +01:00
Peter Krempa
a1ed7f37ce tools: vshCmddefOptParse: Remove return value
The function can't fail so there's no need to return a value or check it
in the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:30 +01:00
Peter Krempa
fde5b4cf9d tools: vshCmddefHelp: Don't call vshCmddefOptParse
The help formatter called vshCmddefOptParse just for validation
purposes. Since vshCmddefOptParse no longer validates the command itself
and we don't need the bitmaps returned by it we can drop the call
entirely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:30 +01:00
Peter Krempa
cd0602290a tools: vshCmddefOptParse: Remove 'optional' command validation
Since vshCmddefCheckInternals now has this check we no longer need it in
vshCmddefOptParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Peter Krempa
0d00e95298 tools: cmdSelfTest: Drop misleading comment
We no longer print help for every command to validate the args.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Peter Krempa
fa7265e127 tools: vshCmddefCheckInternals: Port mandatory options check from vshCmddefOptParse
'vshCmddefCheckInternals' is the go-to place for all checks related to
the definition of parameters for commands, but the check that all
mandatory parameters must be ordered before optional parameters was
still only in vshCmddefOptParse.

Adding a non-compliant option would not be caught by our test suite as
'virsh self-test' doesn't call vshCmddefOptParse.

Re-implement the check in vshCmddefCheckInternals.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Peter Krempa
b070332261 tools: vshCmddefCheckInternals: Add parameter name to error message
If a parameter definition is invalid we can include the name of the
parameter for simpler debugging.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Peter Krempa
f2a602f5a3 tools: vsh: Unexport vshCmddefHelp
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-13 11:12:29 +01:00
Lin Ma
d44a8203e7 Add lifecycle action completion to set-lifecycle-action command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:33 +01:00
Lin Ma
bb331d90b8 virsh: Add lifecycle type completion to set-lifecycle-action command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:31 +01:00
Lin Ma
96d01ce969 virsh: Add signal name completion to send-process-signal command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:29 +01:00
Lin Ma
7a975279b1 virsh: Move/add some of function declarations to virsh-domain.h
The upcoming patches introduce completers into virsh-completer-domain.c,
They will invoke the functions which are defined in virsh-domain.c, So
these functions need to be declared in virsh-domain.h.

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:26 +01:00
Lin Ma
aa54cb9d35 virsh: Add mac completion to net-dhcp-leases command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:23 +01:00
Lin Ma
8a4343a436 vsh: Fix completion error in case of multiple mac addresses
We know that the bash completer automatically handle colon by preceding
it with an escape character backslash.
While our bash autompletion file vsh completes multiple items, In case
there're multiple items which have same prefix and the content of completion
items contain colon(say mac address), The vsh needs to correctly hands
the backslash which are added by bash completer, Otherwise the completion
won't be successful. This patch fixes this problem.

e.g.:

 # virsh domiflist --domain VM
 Interface   Type      Source    Model    MAC
-------------------------------------------------------------
 vnet0       network   default   virtio   52:54:00:fb:7b:f5
 vnet1       bridge    br0       virtio   52:54:00:80:1b:21

Before:
 # virsh detach-interface --domain VM --mac <TAB>
 # virsh detach-interface --domain VM --mac 52\:54\:00\:<TAB><TAB>

After:
 # virsh detach-interface --domain VM --mac <TAB>
 # virsh detach-interface --domain VM --mac 52\:54\:00\:<TAB><TAB>
 52:54:00:80:1b:21  52:54:00:fb:7b:f5
 # virsh detach-interface --domain VM --mac 52\:54\:00\:

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:18 +01:00
Lin Ma
f2fbf2dc95 virsh: Add interface name completion to iface-mac command
Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:16 +01:00
Lin Ma
498046daa6 virsh: Add interface name completion to iface-bridge command
Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:13 +01:00
Lin Ma
bfb82029a1 virsh: Add interface mac completion to iface-name command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:11 +01:00
Lin Ma
9b751469ea virsh-interface: Add a static helper virshInterfaceStringHelper
It will be helpful to get the desired string of interface name/mac in a
consistent way.

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:07 +01:00
Lin Ma
f8b3e98a01 virsh: Add serial/parallel device name completion to console command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:04 +01:00
Lin Ma
4583a49ccf virsh: Add logical CPU IDs completion for nodecpustats command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:34:02 +01:00
Lin Ma
a9327362cd virsh: Add vcpu list completion to guestvcpus command
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-10 18:33:59 +01:00
Daniel P. Berrangé
2a917e6756 Fix name prefix of VIR_DOMAIN_CHECKPOINT_REDEFINE_VALIDATE
The enum constant names should all have a prefix that matches the enum
name. VIR_DOMAIN_CHECKPOINT_REDEFINE_VALIDATE was missing the "CREATE_"
part of the name prefix.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-11-09 16:29:06 +00:00
Peter Krempa
f37d306f6e virsh: checkpoint-create: Add support for VIR_DOMAIN_CHECKPOINT_REDEFINE_VALIDATE
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:50 +01:00
Michal Privoznik
0995f20d0a virsh: Allow listing just domain IDs
Some completers for libvirt related tools might want to list
domain IDs only. Just like the one I've implemented for
virt-viewer [1]. I've worked around it using some awk magic,
but if it was possible to just 'virsh list --id' then I could
drop awk.

1: https://www.redhat.com/archives/virt-tools-list/2019-May/msg00014.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-11-09 11:28:23 +01:00
Yi Li
ed3cc76b48 virsh-domain: Remove unused virshNodeIsSuperset
The function is marked as unused. Remove it from the tree
until a new use case can be found.
Unused since: 38cc07b7bc

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-11-05 10:47:47 +01:00
Orion Poplawski
a501fa7cae libvirt-guests: Sync time for autostarted guests
Setting SYNC_TIME=1 does not work on autostarted guests.

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

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-11-04 12:18:05 +01:00
Laine Stump
c0ae4919e3 change DIR* int g_autoptr(DIR) where appropriate
All of these conversions are trivial - VIR_DIR_CLOSE() (aka
virDirClose()) is called only once on the DIR*, and it happens just
before going out of scope.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-02 22:01:36 -05:00
Laine Stump
59fc1e35eb tools: reduce scope of a DIR* in virHostValidateIOMMU()
This will make the trivial nature of a conversion to g_autoptr (in a
later patch) more obvious.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-02 22:01:36 -05:00
Jonathon Jongsma
53aec799fa Include vdpa devices in node device list
The current udev node device driver ignores all events related to vdpa
devices. Since libvirt now supports vDPA network devices, include these
devices in the device list.

Example output:

virsh # nodedev-list
[...ommitted long list of nodedevs...]
vdpa_vdpa0

virsh # nodedev-dumpxml vdpa_vdpa0
<device>
  <name>vdpa_vdpa0</name>
  <path>/sys/devices/vdpa0</path>
  <parent>computer</parent>
  <driver>
    <name>vhost_vdpa</name>
  </driver>
  <capability type='vdpa'>
    <chardev>/dev/vhost-vdpa-0</chardev>
  </capability>
</device>

NOTE: normally the 'parent' would be a PCI device instead of 'computer',
but this example output is from the vdpa_sim kernel module, so it
doesn't have a normal parent device.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2020-10-26 02:39:29 -04:00
zhenwei pi
b866adf8d9 libvirt: support memory failure event
Introduce memory failure event. Libvirt should monitor domain's
event, then posts it to uplayer. According to the hardware memory
corrupted message, a cloud scheduler could migrate domain to another
health physical server.

Several changes in this patch:
public API:
    include/*
    src/conf/*
    src/remote/*
    src/remote_protocol-structs

client:
    examples/c/misc/event-test.c
    tools/virsh-domain.c

With this patch, each driver could implement its own method to run
this new event.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-23 09:41:52 +02:00
Jonathon Jongsma
08f8fd8413 conf: Add support for vDPA network devices
This patch adds new schema and adds support for parsing and formatting
domain configurations that include vdpa devices.

vDPA network devices allow high-performance networking in a virtual
machine by providing a wire-speed data path. These devices require a
vendor-specific host driver but the data path follows the virtio
specification.

When a device on the host is bound to an appropriate vendor-specific
driver, it will create a chardev on the host at e.g.  /dev/vhost-vdpa-0.
That chardev path can then be used to define a new interface with
type='vdpa'.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-10-20 14:46:52 -04:00
Pavel Hrdina
7c878cf9a7 tools: use g_autoptr for virCgroup
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2020-10-09 16:24:51 +02:00
Pavel Hrdina
5ad8272888 util: vircgroup: change virCgroupFree to take only virCgroupPtr
As preparation for g_autoptr() we need to change the function to take
only virCgroupPtr.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2020-10-09 16:24:35 +02:00
Ján Tomko
2820ee5229 tools: spell out the type instead of using typeof
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-08 11:11:10 +02:00
Roman Bolshakov
45006fa408 wireshark: Fix missing bool_t on macOS
The header has to be explicitly added to pull definition of bool_t and a
few other types. Otherwise packet-libvirt.c can't be compiled.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-10-07 19:17:53 +02:00
Tim Wiederhake
9702659807 virsh: Add "validate" argument to [hypervisor-]cpu-compare
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-07 11:26:27 +02:00
Ján Tomko
37043008b7 Fix incorrect g_new0 conversions
I left in a 'return' or 'goto cleanup' in a few places
where I did the conversion manually.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2020-10-06 14:26:43 +02:00
Ján Tomko
20bbf85954 virsh: network-port: remove pointless comment
We do not have a legacy API for listing network ports
so there's nothing to fall back on.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-06 09:01:46 +02:00
Ján Tomko
1647e376e8 virsh: delete vsh[CM]alloc
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-06 09:01:46 +02:00
Ján Tomko
504913bf23 virsh: use g_new0 instead of vsh[CM]alloc
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-06 09:01:46 +02:00
Ján Tomko
ed2206cd70 virsh: do not add bools into size calculations
Switch the allocation in virshSnapshotListCollect and
its cargo-culted Checkpoint counterpart to two separate
g_new0 calls and move the boolean expression to
the if condition that chooses between them.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-10-06 09:01:46 +02:00
Peter Krempa
cb6fdb0125 virBitmapNew: Don't check return value
Remove return value check from all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00
Peter Krempa
dad2009de4 util: bitmap: Remove virBitmapNewQuiet
We no longer report any errors so all callers can be replaced by
virBitmapNew. Additionally virBitmapNew can't return NULL now so error
handling is not necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 12:57:46 +02:00
Daniel P. Berrangé
e0f54d6663 tools: fix misc spelling errors reported by codespell
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-05 10:28:45 +01:00
Laine Stump
a79e7639da build: eliminate useless WITH_VIRTUALPORT check
WITH_VIRTUALPORT just checks that we are building on Linux and that
IFLA_PORT_MAX is defined in linux/if_link.h. Back when 802.11Qb[gh]
support was added, the IFLA_* stuff was new (introduced in kernel
2.6.35, backported to RHEL6 2.6.32 kernel at some point), and so this
extra check was necessary, because libvirt was being built on Linux
distros that didn't yet have IFLA_* (e.g. older RHEL6, all
RHEL5). It's been in the kernel for a *very* long time now, so all
supported versions of all Linux platforms libvirt builds on have it.

Note that the above paragraph implies that the conditional compilation
should be changed to #if defined(__linux__). However, the astute
reader will notice that the code in question is sending and receiving
netlink messages, so it really should be conditional on WITH_LIBNL
(which implies __linux__) instead, so that's what this patch does.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-01 14:02:34 -04:00
Ján Tomko
157b17f706 tools: use g_new0 instead of VIR_ALLOC*
With the exception of vsh*alloc.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-01 12:34:13 +02:00
Ján Tomko
92047567cf Reduce scope of some variables
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-09-24 11:19:06 +02:00
Ján Tomko
ce5eb7ecac virsh: virshStreamSourceSkip: remove unused 'off'
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-09-24 11:19:06 +02:00
Ján Tomko
bb93310aa8 tools: virshCheckpointListCollect: remove unused names
Introduced by:
commit 689beaa47c
and unused since.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-09-24 11:19:05 +02:00
Ján Tomko
dbe3cf6c64 virsh: do not return bool in virshNetworkPortUUIDCompleter
portability: Returning an integer in a function with pointer
return type is not portable. [CastIntegerToAddressAtReturn]

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-09-23 13:26:35 +02:00
Lin Ma
ea17253970 virsh: event: options --list, --all and --event are mutually exclusive
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 12:25:53 +02:00
Lin Ma
29f6ba3f18 virsh: net-port-create: log errors for non-existent xml file
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-17 12:25:45 +02:00
Ján Tomko
221f2c0383 virsh-completer: use g_new0 instead of VIR_ALLOC_N
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-15 13:46:11 +02:00
Ján Tomko
acdac34c45 virsh-completer: use g_free instead of VIR_FREE
All of them are in the cleanup section right before the variables
they free go out of scope.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-15 13:46:11 +02:00
Ján Tomko
a698dfae9b virsh-completer: use g_clear_pointer in virshCommaStringListComplete
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-15 13:46:11 +02:00
Boris Fiuczynski
ab655afa18 virsh: nodedev: ability to filter CSS capabilities
Allow to filter for CSS devices.

Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2020-09-15 09:06:24 +02:00
Boris Fiuczynski
05e6cdafa6 node_device: detect CSS devices
Make channel subsystem (CSS) devices available in the node_device driver.
The CCS devices reside in the computer system and provide CCW devices, e.g.:

  +- css_0_0_003a
      |
      +- ccw_0_0_1a2b
          |
          +- scsi_host0
              |
              +- scsi_target0_0_0
                  |
                  +- scsi_0_0_0_0

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2020-09-15 09:06:15 +02:00
Lin Ma
60719bedbc virsh: limit completion of checkpoint-{create, delete} to active domains
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
9124b9f736 virsh: limit completion of backup-{begin, dumpxml} to active domains
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
b5335e956b virsh: limit completion of net-port* to active networks
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
81dd306fa7 virsh: limit completion of net-dhcp-leases to active networks
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
a9aac97fdb virsh: Add logical CPU list completion for --cpulist argument
Currently this patch works for the commands emulatorpin, iothreadpin and
vcpupin.

Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
b3198b95d6 virsh: Add vcpu list completion to setvcpu command
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
6c74a2e23a virsh: Add vcpu IDs completion to vcpupin command
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
ab4ef5de67 virsh: Add iothread IDs completion to iothread* commands
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
889bdba38d virsh: Add domain uuid completion to domname command
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
f6e69f03e3 virsh: Add network uuid completion to network-name command
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
d9a320bf97 vshReadlineParse: Ignore vshReadlineOptionsGenerator for VSH_OT_INT options
Commit c7151b0 added the completion for VSH_OT_INT options, say '--cellno'
and '--pagesize', So we need to ignore VSH_OT_INT otherwise we get the
incorrect completion.

before:
 # virsh freepages --pagesize <TAB><TAB>
--all     --cellno  1GiB      2MiB      4KiB

after:
 # virsh freepages --pagesize <TAB><TAB>
1GiB  2MiB  4KiB

Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
eddd9932ee virsh: Add event completer to --enable/--disable args of perf command
Signed-off-by: Lin Ma <lma@suse.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
a2ab5eb8e1 virsh: checkpoint: Only return domains that have checkpoints
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
89193486dc virsh: managedsave-*: Only return domains that have a managed save image
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
2fcf599bd2 virsh: snapshot: Only return domains that have snapshot images
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
b9f2f44949 virshDomainNameCompleter: Add some of VIR_CONNECT_LIST_DOMAINS_ flags
Commit 3b225256 removed unused VIR_CONNECT_LIST_DOMAINS_* flags, But some
of them will be used in upcoming patches, So add some of them back.

Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-14 15:52:40 +02:00
Lin Ma
1619c87eea virsh: pool-list: options --all and --inactive are mutually exclusive
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-12 12:49:32 +02:00
Lin Ma
b34c571e25 virsh: iface-list: options --all and --inactive are mutually exclusive
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-12 12:49:31 +02:00
Lin Ma
b7b53c651a virsh: domdisplay: options --all and --type are mutually exclusive
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-12 12:49:31 +02:00
Lin Ma
dfdacbeb39 virsh: domblkinfo: options --all and --device are mutually exclusive
Signed-off-by: Lin Ma <lma@suse.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-12 12:49:31 +02:00
Tim Wiederhake
b668054209 tools: Use glib memory functions in vshCompleterFilter
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-09-11 18:19:59 +02:00
Yi Li
b1f10ed031 tools: virsh-domain: Remove redundant conditional before virshDomainFree
virshDomainFree handles NULL pointers gracefully, so there's no need to
check the pointer before the call.

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-09-11 10:12:09 +02:00
Ján Tomko
3144e881b1 virsh: cmdScreenshot: fix cbdata passing to virshStreamSink
The changes for sparse stream support started passing
virshStreamCallbackDataPtr to virshStreamSink
instead of passing a simple file descriptor, but
forgot to adjust all the callers.

Fix it in cmdScreenshot as well.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 9e745a9717
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-09-09 14:37:19 +02:00
Michal Privoznik
caa9560c15 wireshark: Prefer ws_version.h over config.h
A wireshark plugin must declare what major and minor version it
was built with as these are checked when wireshark loads plugins.
On the top of that, we use major + minor + micro to adapt to
changed API between releases. So far, we were getting these
version numbers from wireshark/config.h.

And while most distributions install wireshark/config.h file some
don't. On distros shipping it it's hack^Wsaved during built by
packaging system and installed later. But some distros are not
doing that. At least not for new enough wireshark because as of
wireshark's commit v2.9.0~1273 the ws_version.h is installed
which contains the version macros we need and is installed by
wireshark itself.

But of course, some distros which have new enough wireshark
packaged do not ship ws_version.h and stick to the hack. That is
why we can't simply bump the minimal version and switch to the
new header file. We need a configure check and adopt our code to
deal with both ways. At least for the time being.

Based on Andrea's original patch:

https://www.redhat.com/archives/libvir-list/2020-September/msg00156.html

Closes: https://gitlab.com/libvirt/libvirt/-/issues/74
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-09-08 10:58:24 +02:00
Daniel P. Berrangé
7bd8621291 tools: avoid unused parameter warning when readline is disabled
The vshReadlineHistoryAdd stub method does not use its parameter.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-09-04 10:17:30 +01:00
Martin Kletzander
49186372db qemu: Allow NBD migration over UNIX socket
Adds new typed param for migration and uses this as a UNIX socket path that
should be used for the NBD part of migration.  And also adds virsh support.

Partially resolves: https://bugzilla.redhat.com/1638889

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-09-04 10:20:49 +02:00
Martin Kletzander
e31f24e299 virsh: Reuse existing variable when parsing migrate --disks-port
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-09-04 10:20:49 +02:00
Michal Privoznik
4bb1a0e488 vsh: Define HAVE_STDARG_H before including readline
As it turned out my previous commits which switched from HAVE_ to
WITH_ and dropped stdarg.h detection were a bit too aggressive.
Because of reasons described in 9ea3424a17 we need to define
HAVE_STDARG_H before including readline otherwise macos build
fails. Honestly, I still don't fully understand the problem so I
am not going to bother you with "explanation".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-03 16:25:43 +02:00
Michal Privoznik
f123412b53 vsh: Introduce wrapper for add_history()
This allows us to drop include of readline header files from
virsh.c and virt-admin.c because they needed it only because of
the add_history() function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-03 16:25:43 +02:00
Michal Privoznik
95b9db4ee2 lib: Prefer WITH_* prefix for #if conditionals
Currently, we are mixing: #if HAVE_BLAH with #if WITH_BLAH.
Things got way better with Pavel's work on meson, but apparently,
mixing these two lead to confusing and easy to miss bugs (see
31fb929eca for instance). While we were forced to use HAVE_
prefix with autotools, we are free to chose our own prefix with
meson and since WITH_ prefix appears to be more popular let's use
it everywhere.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-02 10:28:10 +02:00
Michal Privoznik
59d896ced1 nss: Drop needless include of rpc/types.h
In packet-libvirt.c in wireshark dissector we include rpc/types.h
but guard the include with a condition (that is supposed to be
true if we detected during configure phase that the host system
has the header file). Thing is, it looks like we were never doing
the configure check and thus the file was never included and yet,
the NSS plugin works. Drop the include then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-09-02 10:28:10 +02:00
Ján Tomko
6fab37da59 Prefer https: everywhere where possible
Use https: links for websites that support them.

The URIs which are used as namespace identifiers
are left alone.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-09-01 21:58:46 +02:00
Ján Tomko
610b0c9e65 tools: wireshark: fix link to wireshark repo
It seems wireshark has migrated to gitlab in the meantime.
Point there instead of to the dead svn repo.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-09-01 21:58:45 +02:00
Andrea Bolognani
88c3490aa1 meson: Use @BASENAME@ more
This patch takes care of just the obvious cases: there are
many more situations where the data we pass to configure_file()
could likely be obtained in a more effective way, but we can
address the low-hanging fruits as a first approximation.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-09-01 13:22:24 +02:00
Michal Privoznik
31fb929eca nss: Finish renaming of HAVE_BSD_NSS macro
When switching to meson, some of HAVE_* macros were renamed to
WITH_ because they did not reflect whether the build platform has
or doesn't have something, but whether we are building with some
functionality turned on or off. This is the case with
HAVE_BSD_NSS macro too. As a result, the NSS plugin built on BSD
did not expose nss_module_register() function which made the
plugin unusable:

https://www.redhat.com/archives/libvir-list/2020-September/msg00000.html

Fixes: c742687055
Reported-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-09-01 11:39:49 +02:00
Ján Tomko
0a37e0695b Split declarations from initializations
Split those initializations that depend on a statement
above them.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-08-25 19:03:11 +02:00
Ján Tomko
a5152f23e7 Move declarations before statements
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-08-25 19:03:11 +02:00
Han Han
8eebceef43 virsh: Add source-initiator opt to build the initiator of pool XML
For iscsi-direct pool, the initiator is necessary for pool defining:
<pool type="iscsi-direct">
 ...
    <initiator>
      <iqn name="iqn.2013-06.com.example:iscsi-initiator"/>
    </initiator>
...
</pool>

Add --source-initiator to fill the initiator iqn for
pool-create-as/pool-define-as subcommands.

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

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-08-25 09:32:05 +02:00
Michal Privoznik
9e0ba037cd virshStreamInData: Handle block devices
This is very similar to previous commit.

The virshStreamInData() callback is used by virStreamSparseSendAll()
to detect whether the file the data is read from is in data or hole
section. The SendAll() will then send corresponding type of virStream
message to make server create a hole or write actual data. But the
callback uses virFileInData() even for block devices, which results in
an error. Just like in previous commit, emulate a DATA section
for block devices.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1852528

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-08-24 13:39:55 +02:00
Michal Privoznik
c2e1c414ef virshStreamSkip: Emulate skip for block devices
This callback is called when the server sends us STREAM_HOLE
meaning there is no real data, only zeroes. For regular files
we would just seek() beyond EOF and ftruncate() to create the
hole. But for block devices this won't work. Not only we can't
seek() beyond EOF, and ftruncate() will fail, this approach won't
fill the device with zeroes. We have to do it manually.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1852528

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-08-24 13:32:53 +02:00
Michal Privoznik
8a0c327f11 virsh: Track if vol-upload or vol-download work over a block device
We can't use virFileInData() with block devices, but we can
emulate being in data section all the time (vol-upload case).
Alternatively, we can't just lseek() beyond EOF with block
devices to create a hole, we will have to write zeroes
(vol-download case).  But to decide we need to know if the FD we
are reading data from / writing data to is a block device. Store
this information in _virshStreamCallbackData.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-08-24 13:32:53 +02:00
Michal Privoznik
9e745a9717 virsh: Pass virshStreamCallbackDataPtr to virshStreamSink() and virshStreamSkip()
These callback will need to know more that the FD they are
working on. Pass the structure that is passed to other stream
callbacks (e.g. virshStreamSource() or virshStreamSourceSkip())
instead of inventing a new one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-08-24 13:32:53 +02:00
Andrea Bolognani
69980ab798 meson: Improve RPATH handling
Right now we're unconditionally adding RPATH information to the
installed binaries and libraries, but that's not always desired.

autotools seem to be smart enough to only include that information
when targeting a non-standard prefix, so most distro packages
don't actually contain it; moreover, both Debian and Fedora have
wiki pages encouraging packagers to avoid setting RPATH:

  https://wiki.debian.org/RpathIssue
  https://fedoraproject.org/wiki/RPath_Packaging_Draft

Implement RPATH logic that Does The Right Thing™ in the most
common cases, while still offering users the ability to override
the default behavior if they have specific needs.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-08-24 12:58:51 +02:00
Tomáš Golembiovský
c7547a16f8 virsh: guest-agent-timeout: set default value for optional argument
The timeout argument for guest-agent-timeout is optional but it did not
have proper default value specified. Also update the virsh man page
accordingly.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-08-24 10:08:06 +02:00
Christian Ehrhardt
ab5b5f22b9
tools: fix libvirt-guests.sh text assignments
In libvirt 6.6 stopping guests with libvirt-guests.sh is broken.
As soon as there is more than one guest one can see
`systemctl stop libvirt-guests` failing and in the log we see:
  libvirt-guests.sh[2455]: Running guests on default URI:
  libvirt-guests.sh[2457]: /usr/lib/libvirt/libvirt-guests.sh: 120:
      local: 2a49cb0f-1ff8-44b5-a61d-806b9e52dae2: bad variable name
  libvirt-guests.sh[2462]: no running guests.

That is due do mutliple guests becoming a list of UUIDs. Without
recognizing this as one single string the assignment breaks when using 'local'
(which was recently added in 6.3.0). This is because local is defined as
  local [option] [name[=value] ... | - ]
which makes the shell trying handle the further part of the string as
variable names. In the error above that string isn't a valid variable
name triggering the issue that is seen.

This depends on the shell being used. POSIX shells don't have 'local'
specified yet and for the common shells it depends. It worked in bash and
bash-in-POSIX-mode, but for example dash in POSIX mode triggers the issue.

To resolve that 'textify' all assignments that are strings or potentially
can become such lists (even if they are not using the local qualifier).

Fixes: 08071ec0 "tools: variables clean-up in libvirt-guests script"

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2020-08-21 08:31:18 +02:00
Boris Fiuczynski
e2bd2af6e4 tools: avoid potential null pointer dereference by GCC 10
GCC 10 complains about "arg" possibly being a NULL dereference.
Even though it might be a false positive, we can easily avoid it.

Avoiding
 ../tools/vsh.c: In function ‘vshCommandOptStringReq’:
 ../tools/vsh.c:1034:19: error: potential null pointer dereference [-Werror=null-dereference]
  1034 |     else if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
       |                ~~~^~~~~~

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-08-17 08:25:28 +02:00
Ján Tomko
8003fe0361 util: recommend g_strfreev instead of virStringListFree
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:37:36 +02:00
Ján Tomko
ee247e1d3f Use g_strfeev instead of virStringFreeList
Both accept a NULL value gracefully and virStringFreeList
does not zero the pointer afterwards, so a straight replace
is safe.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:37:36 +02:00
Ján Tomko
d339113ab0 virt-login-shell: correctly calculate string length
virLoginShellGetShellArgv was not dereferencing the pointer
to the string list containing the shell parameters from the
config file, thus setting some random number as shargvlen.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 740e4d7052
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:37:35 +02:00
Ján Tomko
24b2f96a41 tools: remove unnecessary includes
After the split of virsh to multiple files, and the subsequent
split to vsh/virt-admin, there are quite a few leftovers.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:30:40 +02:00
Ján Tomko
e05487610c tools: virt-admin: do not leak daemon-log settings
The commands daemon-log-filters and daemon-log-outputs
are used both for getting and setting the variables.
But the getter receives an allocated string, which
we do not free.

Use separate variables for the getter and the setter
to get rid of the memory leak and to stop casting
away the const.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:19:29 +02:00
Ján Tomko
9c4730c54b tools: remove unread variables
Some of libvirt APIs return the number of elements, but we
don't need them, only whether the API failed or not.

Delete the redundant variables.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:19:29 +02:00
Ján Tomko
ce2483f619 virsh: completer: use signed variable for XPathNodeSet errors
Although virXPathNodeSet is unlikely to return -1, we should
check for it properly or not at all.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-08-03 15:19:29 +02:00
Pavel Hrdina
7dc94bafe3 meson: tests: add nss specific tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:06 +02:00
Pavel Hrdina
faf8dfc2d4 meson: tools/wireshark: build libvirt.so wireshark module
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
fd90c83585 meson: tools/wireshark: generate protocol header files
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
9cabfd07ea meson: tools: modify genxdrstub to work with meson
Instead of using environment variables pass the values to the script
as arguments.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
851d619f13 meson: tools: introduce wireshark directory
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
f1cc0164ba meson: tools: build libnss_libvirt_guest.so shared_library
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00