When watching a job (save, managedsave, dump, migrate) virsh spawns a
thread to call the appropriate API and waits for the result while
watching for interruption signals (SIGINT, Ctrl-C on the terminal).
Whenever such signal is caught, virsh calls virDomainAbortJob, stops
waiting for the job, and returns the result of virDomainAbortJob.
This is wrong because the job might have finished in the meantime or it
might have been cancelled by someone else and virsh would just report
the failure to abort the job. However, we are not interested in the
virDomainAbortJob's result at all, we need to keep waiting for the main
job to finish and report its result instead.
https://bugzilla.redhat.com/show_bug.cgi?id=1131755
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This will allow us to use vshError() to report errors from inside
vshCommandOpt*(), instead of replicating the same logic and error
messages all over the place.
We also have more context inside the vshCommandOpt*() functions,
for example the actual value used on the command line, which means
we can produce more detailed error messages.
vshCommandOptBool() is the exception here, because it's explicitly
designed not to report any error.
When shrinking a volume by a certain size, instead of typing
vol-resize volume 1G --delta --shrink
we allow the convience of specifying a negative value:
vol-resize volume -1G --delta --shrink
getting the same results with one more character.
A negative value only makes sense as a delta. Imply the
--delta parameter if the value is negative.
Still require --shrink, because the operation is potentially
destructive.
https://bugzilla.redhat.com/show_bug.cgi?id=1224088
commit id 'bd00e00e' neglected to add the new adapter source options
into the if condition that allowed printing the <source> XML fields.
The <adapter type='fc_host'.../> doesn't require other options in order
to be complete.
Some virsh commands have a size parameter, which is handled as scaled
integer. We don't have any *feature* that would allow to use '-1' as
maximum size, so it's safe to reject any negative values for those
commands.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1159171
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
The option didn't have VSH_OT_INT type even thought it's expected
to be numeric, as shown by the fact that vshCommandOptInt() is later
used to retrieve its value.
Replace more than 30 ad-hoc error messages with a single, generic one
that contains the name of the option being processed and some hints
to help the user understand what could have gone wrong.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1207043
When parsing a cpulist, the virBitmapParse is used. On an invalid
bitmap an error is reported, but the error gets cleared
immediately by subsequent public APIs call, e.g. virDomainFree().
Moreover, we don't check whether bitmap fits into maximal CPU ID
on the host. Therefore the following examples failed without any
error:
# virsh vcpupin test3 1 aaa
# virsh vcpupin test3 1 1000
Signed-off-by: Luyao Huang <lhuang@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1191227
Since 0fa15b19 we have this variable SYNC_TIME which allows users to
synchronize time on domain resume. However, despite what documentation
says, it's by default on because it's never initialized. Fix this by
setting it to zero at the beginning of the libvirt-guests script.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Extend it to a universal helper used for clearing lists of any objects.
Note that the argument type is specifically void * to allow implicit
typecasting.
Additionally add a helper that works on non-NULL terminated arrays once
we know the length.
The --maximum option wasn't properly parsed and the equivalent flag
wasn't set. Fix this bug and also rewrite the way we check this option
by using new macro. The new approach is that --maximum requires
--config, no other combination is allowed, because they don't make sense.
The new error will be:
# virsh setvcpus test --maximum 10
error: Option --config is required by option --maximum
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1204033
Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1161617
Add command to allow adding and removing IOThreads from the domain including
the configuration and live domain.
$ virsh iothreadadd --help
NAME
iothreadadd - add an IOThread to the guest domain
SYNOPSIS
iothreadadd <domain> <id> [--config] [--live] [--current]
DESCRIPTION
Add an IOThread to the guest domain.
OPTIONS
[--domain] <string> domain name, id or uuid
[--id] <number> iothread for the new IOThread
--config affect next boot
--live affect running domain
--current affect current domain
$ virsh iothreaddel --help
NAME
iothreaddel - delete an IOThread from the guest domain
SYNOPSIS
iothreaddel <domain> <id> [--config] [--live] [--current]
DESCRIPTION
Delete an IOThread from the guest domain.
OPTIONS
[--domain] <string> domain name, id or uuid
[--id] <number> iothread_id for the IOThread to delete
--config affect next boot
--live affect running domain
--current affect current domain
Assuming a running $dom with multiple IOThreads assigned and that
that the $dom has disks assigned to IOThread 1 and IOThread 2:
$ virsh iothreadinfo $dom
IOThread ID CPU Affinity
---------------------------------------------------
1 2
2 3
3 0-1
$ virsh iothreadadd $dom 1
error: invalid argument: an IOThread is already using iothread_id '1' in iothreadpids
$ virsh iothreadadd $dom 1 --config
error: invalid argument: an IOThread is already using iothread_id '1' in persistent iothreadids
$ virsh iothreadadd $dom 4
$ virsh iothreadinfo $dom
IOThread ID CPU Affinity
---------------------------------------------------
1 2
2 3
3 0-1
4 0-3
$ virsh iothreadinfo $dom --config
IOThread ID CPU Affinity
---------------------------------------------------
1 2
2 3
3 0-1
$ virsh iothreadadd $dom 4 --config
$ virsh iothreadinfo $dom --config
IOThread ID CPU Affinity
---------------------------------------------------
1 2
2 3
3 0-1
4 0-3
Assuming the same original configuration
$ virsh iothreaddel $dom 1
error: invalid argument: cannot remove IOThread 1 since it is being used by disk 'vde'
$ virsh iothreaddel $dom 3
$ virsh iothreadinfo $dom
IOThread ID CPU Affinity
---------------------------------------------------
1 2
2 3
$ virsh iothreadinfo $dom --config
IOThread ID CPU Affinity
---------------------------------------------------
1 2
2 3
3 0-1
virDomainGetJobStats is able to report statistics of a completed
migration, however to get usable downtime and total time statistics both
hosts have to keep synchronized time. To provide at least some
estimation of the times even when NTP daemons are not running on both
hosts we can just ignore the time needed to transfer a migration cookie
to the destination host. The result will be also inaccurate but a bit
more predictable. The total/down time will just be at least what we
report.
https://bugzilla.redhat.com/show_bug.cgi?id=1213434
Commit a0670ae caused a regression in 'virsh event' and
'virsh qemu-monitor-event' - if a user tries to filter the
command to a specific domain, an error message is printed:
$ virsh event dom --loop
error: internal error: virsh qemu-monitor-event: no domain VSH_OT_DATA option
and then the command continues as though no domain had been
supplied (giving events for ALL domains, instead of the
requested one). This is because the code was incorrectly
assuming that all "domain" options would be supplied via a
mandatory VSH_OT_DATA, even though "domain" is optional for
these two commands, so we had changed them to VSH_OT_STRING
to quit failing for other reasons (ever since it was decided
that VSH_OT_DATA and VSH_OT_STRING should no longer be
synonyms).
In looking at the situation, though, the code for looking up
a domain was making a pointless check for whether the option
exists prior to finding the option's string value, as
vshCommandOptStringReq does just fine at reporting any errors
when looking up a string whether or not the option was present.
So this is a case of regression fixing by pure code deletion :)
* tools/virsh-domain.c (vshCommandOptDomainBy): Drop useless filter.
* tools/virsh-interface.c (vshCommandOptInterfaceBy): Likewise.
* tools/virsh-network.c (vshCommandOptNetworkBy): Likewise.
* tools/virsh-nwfilter.c (vshCommandOptNWFilterBy): Likewise.
* tools/virsh-secret.c (vshCommandOptSecret): Likewise.
* tools/virsh.h (vshCmdHasOption): Drop unused function.
* tools/virsh.c (vshCmdHasOption): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
When set guest memory with a invalid parameter of --soft-limit,
it posts weird error:
$ virsh memtune r7 --hard-limit 20417224 --soft-limit 9007199254740992 \
--swap-hard-limit 35417224
error: Unable to parse integer parameter 'NAME
Change it to
error: Unable to parse integer parameter soft-limit
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1211550
Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Use virBitmapDataToString instead of constructing the ranges bit
by bit, remove the checking of parameters (that is already done
by the callers).
Let the callers choose the right bitmap, since there's only
one that uses this helper on a matrix-in-an-array.
$ sudo virsh change-media f19 hdc /mnt/data/devel/media/Fedora-16-x86_64-Live-KDE.iso
succeeded to complete action update on media
Change the message to:
Successfully {inserted,ejected,changed} media.
https://bugzilla.redhat.com/show_bug.cgi?id=967946
In virsh we have two printing functions: vshPrint() which prints a
string onto stdout and vshPrintExtra() which does not print anything
if virsh is run in quiet mode. Usually, the former is used to print
actual results, while the latter to print strings like table headers
and other formatting stuff. However, in cmdDomIfAddr we have
mistakenly used vshPrintExtra even for actual data. After this patch,
the output should look like the following:
# virsh -q domifaddr test3 --source agent
lo 00:00:00:00:00:00 ipv4 127.0.0.1/8
- - ipv6 ::1/128
ens8 52:54:00:1a:cb:3f ipv6 fe80::5054:ff:fe1a:cb3f/64
virbr0 52:54:00:db:51:e7 ipv4 192.168.122.1/24
virbr0-nic 52:54:00:db:51:e7 N/A N/A
Signed-off-by: Luyao Huang <lhuang@redhat.com>
Dependant is flagged as wrong in US dictionary (only valid in UK
dictionary, and even then, it has only the financial sense and not the
inter-relatedness sense that we are more prone to be wanting throughout
code).
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1206479
As described in virDomainBlockCopy() parameters description, the
VIR_DOMAIN_BLOCK_COPY_GRANULARITY parameter may require the value to
have some specific attributes (e.g. be a power of two or fall within a
certain range). And in qemu, a power of two is required. However, our
code does not check that and let qemu operation fail. Moreover, the
virsh man page is not as exact as it could be in this respect.
Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
The overflow check for the bandwidth parameter did not jump to the
cleanup label.
Additionally virsh should use vshError instead of virReportError.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1206987
Signed-off-by: Luyao Huang <lhuang@redhat.com>
Commit 2f36e6944 (re-)introduced a use of an identifier 'interface',
which causes this build failure on mingw:
../../tools/virsh-domain-monitor.c: In function 'cmdDomIfAddr':
../../tools/virsh-domain-monitor.c:2233:17: error: expected identifier or '(' before 'struct'
const char *interface = NULL;
^
See also commit 6512c8b. Sadly, I'm not quite sure how to write a
syntax check that can poison the use of this identifier.
* tools/virsh-domain-monitor.c (cmdDomIfAddr): Use ifacestr instead.
Signed-off-by: Eric Blake <eblake@redhat.com>
The virNodeDeviceDettach API only works on PCI devices.
Originally added by commit 10d3272e, but the API never
supported USB devices.
Reported by: Martin Polednik <mpolednik@redhat.com>
Wikipedia's list of common misspellings [1] has a machine-readable
version. This patch fixes those misspellings mentioned in the list
which don't have multiple right variants (as e.g. "accension", which can
be both "accession" and "ascension"), such misspellings are left
untouched. The list of changes was manually re-checked for false
positives.
[1] https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
When libvirt is starting a domain, it reports the state as SHUTOFF until
it's RUNNING. This is not ideal because domain startup may take a long
time (usually because of some configuration issues, firewalls blocking
access to network disks, etc.) and domain lists provided by libvirt look
awkward. One can see weird shutoff domains with IDs in a list of active
domains or even shutoff transient domains. In any case, it looks more
like a bug in libvirt than a normal state a domain goes through.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
The variable holds formatted suffix to each line printed out
(address type, address and prefix). However, the variable is
never freed. At the same time, honour fact, that data held in
the variable is not constant.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Make sure we don't print (null) (which in fact is printf()'s
cleverness anyway, not ours). If no HW address is present, print
"N/A" string just like we do for other fields.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
The command did not modify the disk type and thus didn't allow to change
media from a file image to a block backed image or vice versa. In
addition when operating on a network backed removable devices the
command would replace the while <source> subelement with an invalid one.
This patch adds the --block option that allows to specify that the new
image is block backed and assumes that without that option all images
are file backed. Since network backends were always mangled it should
not cause problems.
Since cmdDetachDisk() calls into vshPrepareDiskXML() with
type == VSH_PREPARE_DISK_XML_NONE && source == NULL this would result
into skipping all the checks and effectively turn the function into a
XML formatter.
This patch changes the code to use the formatter directly so that the
function can be refactored in a easier way.