Commit Graph

2980 Commits

Author SHA1 Message Date
Martin Kletzander
59d30adacd libvirt-guests: Fix dependency ordering in service file
After some debugging and discussion with systemd team it turns out we
are misusing the ordering in libvirt-guests.service.  That happened
because we want to support both monolithic and modular daemon setups and
on top of that we also want to support socket activation and services
without socket activation.  Unfortunately this is impossible to express
in the unit file because of how transactions are handled in systemd when
dependencies are resolved and multiple actions (jobs) are queued.  For
explanation from Michal Sekletar see comment #7 in the BZ this patch is
fixing:

https://bugzilla.redhat.com/show_bug.cgi?id=1964855#c7

In order to support all the scenarios this patch also amends the
manpages so that users that are changing the default can also read how
to correct the dependency ordering in libvirt-guests unit file.

Ideally we would also keep the existing configuration during upgrade,
but due to our huge support matrix this seems hardly feasible as it
could introduce even more problems.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-09-26 13:04:48 +02:00
Peter Krempa
d4f7850d5b Remove support for building the sheepdog storage driver backend
The sheepdog project is unmaintained, with last commit in 2018 and
numerous unanswered issues reported.

Remove the libvirt storage driver support for it to follow the removal
of the client support in qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-09-01 13:11:09 +02:00
Martin Kletzander
6457619d18 Rename iterface type='dummy' to type='null'
When commit bac6b266fb added this "functionality" this was the only
naming I could think of, but after discussion with Dan we found the name
'null' fits a bit better, so change it before we make a release with the
old name.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-08-25 13:27:04 +02:00
Martin Kletzander
0225483adc conf, docs, schemas: Add support for interface type vds
This represents an interface connected to a VMWare Distributed Switch,
previously obscured as a dummy interface.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-18 08:34:31 +02:00
Martin Kletzander
bac6b266fb conf, docs: Add support for dummy network interface
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-08-05 14:37:54 +02:00
Peter Krempa
8e2a043c32 cmdQemuMonitorCommandQMPWrap: Reset ignored errors from JSON parsing
'cmdQemuMonitorCommandQMPWrap' is checking whether the user provided
string is not valid JSON to avoid wrapping it. In cases where it's not
JSON we ignore the error and add the wrapper.

If the caller then reports a different non-libvirt error the error from
the JSON parsing would be printed as well. Reset errors we ignore:

 # virsh qemu-monitor-command cd --pass-fds a asdf
 error: Unable to parse FD number 'a'
 error: internal error: cannot parse json asdf: lexical error: invalid char in json text.
                                        asdf
                      (right here) ------^

In the above case 'asdf' is not valid JSON, but the code did wrap it
into '{"execute":"asdf"}', the only problem is the argument for
--pass-fds.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-07-25 12:25:02 +02:00
Michal Privoznik
e90d48ae6e virsh: Require --xpath for *dumpxml
Historically, the dumpxml command reject any unknown arguments,
for instance:

    virsh dumpxml fedora xxx

However, after v8.5.0-rc1~31 the second argument ('xxx') is
treated as an XPath, but it's not that clearly visible.
Therefore, require the --xpath switch, like this:

    virsh dumpxml fedora --xpath xxx

Yes, this breaks already released virsh, but I think we can argue
that the pool of users of this particular function is very small.
We also document the argument being mandatory:

   dumpxml [--inactive] [--security-info] [--update-cpu] [--migratable]
           [--xpath EXPRESSION] [--wrap] domain

The sooner we do this change, the better.

The same applies for other *dumpxml functions (net-dumpxml,
pool-dumpxml, vol-dumpxl to name a few).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103524
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-07-25 09:50:21 +02:00
Jonathon Jongsma
62ca300530 util: remove virObjectUnref() adapters
These wrapper functions were used to adapt the virObjectUnref() function
signature for different callbacks. But in commit 0d184072, the
virObjectUnref() function was changed to return a void instead of a
bool, so these adapters are no longer necessary.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2022-07-15 16:44:39 -05:00
Michal Privoznik
3ff558c1c1 virsh: Implement --config for iothreadset
Our man page already documents that iothreadset has --config
argument. Well, it doesn't really. Normally, I'd just fix the man
page, but with recent work on the API it's possible to tweak
values for inactive XML too. Therefore, implement the --config
argument for the command.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-07-13 11:55:06 +02:00
Peter Krempa
fe69f5074a virt-admin: Introduce 'daemon-timeout'
Add a simple command to drive the new 'virAdmConnectSetDaemonTimeout'
API.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-07 14:35:30 +02:00
Han Han
89c16bf9dd virt-xml-validate: Fix incorrect wildcards for XML roots
To match the XML roots domainCapabilities and storagepoolCapabilities,
the wildcards should be *domainCap* and *storagepoolCap*.

Fixes: 7b0e2e4a55
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-07-07 12:21:16 +02:00
Jiri Denemark
efa3baeae7 virsh: Add support for VIR_MIGRATE_ZEROCOPY flag
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-23 16:45:39 +02:00
Daniel P. Berrangé
8603b3d76c tools: add '--xpath EXPRESSION --wrap' args to all dumpxml commands
While you can chain the virsh output up to a later 'xmllint' or 'xpath'
command, integrating it into virsh avoids needs for installing extra
binaries which we've often found to be missing on production installs
of libvirt. It also gives better response if the initial virsh command
hits an error, as you don't get an aborted pipeline.

    $ virsh pool-dumpxml --xpath //permissions default
    <permissions>
      <mode>0711</mode>
      <owner>1000</owner>
      <group>1000</group>
      <label>unconfined_u:object_r:svirt_home_t:s0</label>
    </permissions>

If multiple nodes match, they are emitted individually:

    $ virsh dumpxml --xpath '//devices/*/address[@type="pci"]' --wrap demo
    <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
    <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
    ...snip...
    <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
    <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>

but if intending to post-process the output further, the results
can be wrapped in a parent node

    $ virsh dumpxml --xpath '//devices/*/address[@type="pci"]' --wrap demo
    <nodes>
      <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
      <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
      ...snip...
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
    </nodes>

Fixes https://gitlab.com/libvirt/libvirt/-/issues/244
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-20 10:40:45 +01:00
Daniel P. Berrangé
8615c19b5d tools: add helper method for printing an XML document
The trivial case of fully printing an XML document is boring, but
this helper does more by allowing an XPath expression to be given.
It will then print just the subset of nodes which match the
expression. It either print each match as a standalone XML doc
or can put them into one new XML doc wrapped woith <nodes>...</nodes>

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-06-20 10:40:34 +01:00
Peng Liang
1ce16ae098 tools: Remove unused includes
Signed-off-by: Peng Liang <tcx4c70@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-16 06:43:58 +02:00
Michal Privoznik
7162cee68a virsh: Wire up new virDomainSetIOThreadParams parameters
Since virsh implements a wrapper over virDomainSetIOThreadParams()
(command iothreadset) let's wire up new typed parameters there too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-10 14:00:59 +02:00
Michal Privoznik
2177de7b6e virsh: Check whether enough arguments was passed to iothreadset
Virsh has iothreadset command which allows setting various
attributes of IOThreads. However, when the command is called
without any arguments (besides domain and IOThread IDs), then
@params stays NULL and is passed to virDomainSetIOThreadParams()
which produces rather user unfriendly error message:

  error: params in virDomainSetIOThreadParams must not be NULL

Introduce a check and produce better error message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
2022-06-08 15:37:35 +02:00
Jiri Denemark
ce34977c1f virsh: Add --postcopy option for domjobabort command
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:21 +02:00
Jiri Denemark
6280246971 virsh: Add --postcopy-resume option for migrate command
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-06-07 17:40:20 +02:00
Jiri Denemark
aab9d64d4d Introduce VIR_DOMAIN_RUNNING_POSTCOPY_FAILED
This new "post-copy failed" reason for the running state will be used on
the destination host when post-copy migration fails while the domain is
already running there.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2022-06-07 17:40:20 +02:00
Martin Kletzander
1b71b3ac81 virt-host-validate: Improve failure message when no HW virt is found
Make sure that more users understand that without HW virtualization you cannot
have KVM working.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2086677
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-01 11:58:09 +02:00
Michal Privoznik
7f463b4c0d nss: Compare hostname case insensitive
There are some tools that convert hostname to lowercase before
resolving it (e.g. ssh). In a way it makes sense because DNS is
case insensitive and in case of ssh the lowercase version is then
used to find matching record in its config file. However, our NSS
module performs case sensitive comparison, which makes it useless
with ssh. Just consider a machine named FooBar.

Therefore, switch to case insensitive string comparison.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1777873
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-05-27 13:43:14 +02:00
Marc-André Lureau
bf213aa965 virsh: report the D-Bus bus URI for domdisplay
This implementation reports only Unix bus address using the URI format
proposed in https://gitlab.freedesktop.org/dbus/dbus/-/issues/348.

We prefer a URI form over the D-Bus address form, since all other
display protocols use a URI, allowing to distinguish between protocols
and making client implementation simpler.

Other transports (for example TCP) are not yet handled.

The client is assumed to know what to lookup on the bus (the bus name,
path & interface of the VM, eventually matching its UUID)

P2P mode doesn't report any available URI.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-19 12:36:24 +02:00
Han Han
7b0e2e4a55 virt-xml-validate: Add more XML formats support
Add these XML formats validation in manpage or script:
cpu, domainbackup, domaincaps, domaincheckpoint, networkport,
storagepoolcaps.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2022-05-13 17:15:24 +02:00
Andrea Bolognani
b05dfcdfcb meson: Don't attempt to use version scripts on macOS
macOS libraries don't support symbol versioning, so the only
result that we achieve by passing additional flags to the linker
is a bunch of messages like

  ld: warning: ignoring file .../libvirt/build/src/libvirt.syms,
  building for macOS-x86_64 but attempting to link with file built
  for unknown-unsupported file format ( 0x23 0x20 0x57 0x41 ... )

being produced during the build.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-06 11:12:48 +02:00
Andrea Bolognani
fac80100c0 meson: Refactor handling of link_args and link_depends
This ensures variable names and the overall structure of the
code setting and using them is consistent. It will also make
upcoming changes less disruptive.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-05-06 11:12:44 +02:00
Peter Krempa
9223ebbc85 virsh: cmdBlockcopy: Fix generator of block copy disk XML
In a recent commit I've attempted to rewrite the XML generator to use
virXMLFormatElement instead of manual steps. Unfortunately the commit
had multiple problems resulting in a garbled XML:

1) in certain cases the wrong buffer was used resulting in misplaced
   snippets
2) the child element buffer was improperly set up so sub-elements were
   not indented

This resulted in following XML being generated:

 $ virsh blockcopy cd vda /tmp/test.copy --raw --print-xml
 type='file''/tmp/test.copy'/>
 <driver type='raw'/>
 <disk>
 <source file=</disk>

To fix this we'll generate the '<source>' element in one go and use the
proper buffer for it and other places.

Fixes: 1cd95f858a
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2078274
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-25 16:37:05 +02:00
Peter Krempa
69ee066523 virsh: cmdBlockcopy: Add '--print-xml' flag
Useful for knowing how to construct the XML and debugging.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-25 16:37:05 +02:00
Peter Krempa
fb4d109648 Correct links to TLS certificate setup page
When the setup of TLS certs was originally split out of
'docs/remote.html' ( df99aa311a ) links refering to it were not
fixed.

Adjust them to point to the correct document.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-25 16:33:01 +02:00
Ján Tomko
df757e88fd virsh: fix event registration for single event
Allocate a larger 'data' array than strictly needed
for simplicity and use 'ndata' as the index when
filling it to put the single event at the first unused
place, instead of at its index in the virshDomainEventCallbacks
array.

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

Fixes: c6bb274693
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-11 17:03:49 +02:00
Ján Tomko
4f8ae0353f tools: snapshot: remove pointless checks
There's no need to check whether a flag is not set just to set it
in that case.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-04-07 12:02:31 +02:00
Nikolay Shirokovskiy
4fba5770d2 tools: support --remove-logs flag on destroing domain
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-06 10:48:04 +03:00
Michal Privoznik
5e9d8f094c virsh: Remove any reference of KVM device assignment
The KVM device assignment was removed in v5.7.0-rc1~103 but virsh
and its manpage still mention it. Don't do that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2022-04-06 09:40:13 +02:00
Amneesh Singh
5d0eeb8cd7 virsh: Provide completer for PCI backend drivers
Related: https://gitlab.com/libvirt/libvirt/-/issues/9
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-04 16:30:48 +02:00
Amneesh Singh
4f0480a11c virsh: Provide completer for CPU architectures
Related: https://gitlab.com/libvirt/libvirt/-/issues/9
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-04 16:30:44 +02:00
Amneesh Singh
11ad758910 virsh: Provide completer for virtualization types
Related: https://gitlab.com/libvirt/libvirt/-/issues/9
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-04-04 16:30:40 +02:00
Andrea Bolognani
b94239a61e meson: Use dicts to initialize cfg_data objects
Instead of creating an empty object and then setting keys one
at a time, it is possible to pass a dict object to
configuration_data(). This is nicer because it doesn't require
repeating the name of the cfg_data object over and over.

There is one exception: the 'conf' object, where we store values
that are used directly by C code. In that case, using a dict
object is not feasible for two reasons: first of all, replacing
the set_quoted() calls would result in awkward code with a lot
of calls to format(); moreover, since code that modifies it is
sprinkled all over the place, refactoring it would probably
make things more complicated rather than simpler.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2022-04-01 15:33:19 +02:00
Michal Privoznik
d5f81479a6 virsh: Fix integer overflow in allocpages
I've came across an aarch64 system which supports hugepages up to
16GiB of size. However, I was unable to allocate them using
virsh allocpages. This is because cmdAllocpages() uses
vshCommandOptScaledInt(), which scales passed value into bytes,
but since the virNodeAllocPages() expects size in KiB the
variable holding bytes is then divided by 1024. However, the
limit for the biggest value passed to vshCommandOptScaledInt() is
UINT_MAX which is now obviously wrong, as it needs to be UINT_MAX
* 1024.

The same bug is in completer. But here, let's use ULLONG_MAX so
that we don't have to care about it anymore.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-31 14:33:40 +02:00
Michal Privoznik
4aafdf1e1f virsh: Don't open code virshEnumComplete()
Now that we have a function that generates string list for given
enum, let's use that instead of open coding it.

Note, after this there are still some 'candidates' left (e.g,
virshNetworkEventNameCompleter(), or
virshNetworkUpdateCommandCompleter()). These are not converted
because either they don't have a convenient int2str function or
they don't start from the very beginning of the enum.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-03-15 13:36:58 +01:00
Michal Privoznik
d2e8718f3a virsh: Introduce virshEnumComplete()
We have plenty of completers which iterate over all values of
given enum and do nothing more than translate every member into
string (using corresponding virXXXTypeToString()).

Introduce a convenience function so that callers can pass just
VIR_XXX_LAST and virXXXTypeToString and the rest is taken care
of.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-03-15 13:36:56 +01:00
Michal Privoznik
c21e271d36 virsh: Properly terminate string list in virshDomainInterfaceSourceModeCompleter()
A completer must return a NULL terminated list of strings, which
means that when dealing with enums, it has to allocate one
pointer more than the value of VIR_XXX_LAST. But this is not
honoured in virshDomainInterfaceSourceModeCompleter() leading to
out of bounds read.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2022-03-15 13:36:43 +01:00
Haonan Wang
35ba60be36 virsh: Provide completer for vol-wipe algorithms
Related issue: https://gitlab.com/libvirt/libvirt/-/issues/9

Signed-off-by: Haonan Wang <hnwanga1@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-03-11 09:10:24 +01:00
Michal Privoznik
79c613ec8a virsh: fflush(stdout) after fputs()
We are not guaranteed that the string we are printing onto stdout
contains '\n' and thus that the stdout is flushed. In fact, I've
met this problem when virsh asked me whether I want to edit the
domain XML again (vshAskReedit()) but the prompt wasn't displayed
(as it does not contain a newline character) and virsh just sat
there waiting for my input, I sat there waiting for virsh's
output. Flush stdout after all fputs()-s  which do not flush
stdout.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-10 08:57:31 +01:00
Martin Kletzander
89cc0ffdeb wireshark: Fix dissector for quad types
This uses the right type that is expected to make it work even on platforms
where gint64 != quad_t.

Due to indentation changes it is best to view this patch with -w.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-07 12:37:54 +01:00
Peter Krempa
c7dca225e5 virsh: cmdDesc: Fix logic when '-edit' is used along with 'desc' argument
Historically the use of the '-desc' multiple argument parameter was not
forbidden toghether with '-edit', but use of both together has some
unexpected behaviour. Specifically the editor is filled with the
contents passed via '-desc' but if the user doesn't change the text in
any way virsh will claim that the description was not chaged even if it
differs from the currently set description. Similarly, when the user
would edit the description provided via 'desc' so that it's identical
with the one configured for the domain, virsh would claim that it was
updated:

  # virsh desc cd
  No description for domain: cd
  # EDITOR=true virsh desc cd --edit "test desc"
  Domain description not changed

After the fix:

  # virsh desc cd
  No description for domain: cd
  # EDITOR=true virsh desc cd --edit "test desc"
  Domain description updated successfully
  # EDITOR=true virsh desc cd --edit "test desc"
  Domain description not changed

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-03 11:06:57 +01:00
Peter Krempa
420488790e virsh: domain: Don't use ternaries inside vshPrint/vshError functions
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-03 11:06:57 +01:00
Peter Krempa
b72849ce9d virsh: cmdDesc: Remove unneeded 'cleanup'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-03 11:06:57 +01:00
Peter Krempa
5b811a199d virsh: cmdDesc: Automatically free memory
Decrease scope of variables and use automatic freeing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-03 11:06:57 +01:00
Peter Krempa
c344784b88 virsh: cmdDesc: Use 'vshTempFile' type to simplify cleanup
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-03 11:06:57 +01:00
Peter Krempa
8c35dcf9fc vsh: Add helper for auto-removing temporary file
The vsh helpers for user-editing of contents use temporary files.
Introduce 'vshTempFile' type which automatically removes the file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-03-03 11:06:56 +01:00