Commit Graph

130 Commits

Author SHA1 Message Date
Hongwei Bi
461b1c8b7b Fix memory leak in cmdAttachDisk
When virBufferError is ok in cmdAttachDisk, the latter
should 'goto cleanup', instead of returning a false to
prevent memory leaking.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-08-31 15:50:23 -06:00
Peter Krempa
8c725cc10d virsh-domain: rename print_job_progress to vshPrintJobProgress 2013-08-30 09:38:51 +02:00
Guannan Ren
9eb444364e virsh: fix return value error of cpu-stats
virsh cpu-stats guest --start 0 --count 3
It outputs right but the return value is 1 rather than 0
echo $?
1

Found by running libvirt-autotest
./run -t libvirt --tests virsh_cpu_stats
2013-08-27 15:17:03 +08:00
Tomas Meszaros
a88924bc21 virsh: C99 style for info_domfstrim and opts_lxc_enter_namespace
Change info_domfstrim and opts_lxc_enter_namespace initialization style
to C99.
2013-08-26 10:23:16 -06:00
Peter Krempa
04898f60d2 virsh: Don't leak list of volumes when undefining domain with storage
Use the new semantics of vshStringToArray to avoid leaking the array of
volumes to be deleted. The array would be leaked in case the first
volume was found in the domain definition. Also refactor the code a bit
to sanitize naming of variables hoding arrays and dimensions of the
arrays.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=996050
2013-08-20 17:55:08 +02:00
Don Dugger
d4952d36d0 Add flag to BaselineCPU API to return detailed CPU features
Currently the virConnectBaselineCPU API does not expose the CPU features
that are part of the CPU's model.  This patch adds a new flag,
VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, that causes the API to explicitly
list all features that are part of that model.

Signed-off-by: Don Dugger <donald.d.dugger@intel.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-08-16 15:31:18 -06:00
Peter Krempa
f4ec861641 virsh-domain: Fix memleak in cmdCPUBaseline
https://bugzilla.redhat.com/show_bug.cgi?id=997765

==1349431== 8 bytes in 1 blocks are definitely lost in loss record 11 of 760
==1349431==    at 0x4C2A554: calloc (vg_replace_malloc.c:593)
==1349431==    by 0x4E9AA3E: virAllocN (in /usr/lib64/libvirt.so.0.1001.1)
==1349431==    by 0x4EF28C4: virXPathNodeSet (in /usr/lib64/libvirt.so.0.1001.1)
==1349431==    by 0x130B83: cmdCPUBaseline (in /usr/bin/virsh)
==1349431==    by 0x12C608: vshCommandRun (in /usr/bin/virsh)
==1349431==    by 0x12889A: main (in /usr/bin/virsh)
2013-08-16 10:37:39 +02:00
Peter Krempa
5075248ac9 virsh-domain: Fix memleak in cmdUndefine with storage
When undefining a domain with storage when the volume isn't managed by
libvirt the name and path strings weren't freed properly.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=996050
2013-08-15 16:47:49 +02:00
Peter Krempa
3abb6ec077 virsh-domain: Flip logic in cmdSetvcpus
To avoid having to assign a failure code to the returned variable switch
this function to negative logic. This will fix issue with invalid number
of cpus returning success return code.

https://bugzilla.redhat.com/show_bug.cgi?id=996466
2013-08-13 11:14:56 +02:00
Eric Blake
4c29772845 virsh: nicer abort of blockcopy
I attempted 'virsh blockcopy $dom vda $path --wait --verbose', then
hit Ctrl-C; I was a bit surprised to see this error message:

Block Copy: [  3 %]error: failed to query job for disk vda

when I had been expecting:

Block Copy: [  3 %]
Copy aborted

* tools/virsh-domain.c (cmdBlockCopy): Print graceful exit message
rather than error when ctrl-c interrupts job.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-08-12 11:04:11 -06:00
Guannan Ren
7729a16814 virsh: fix change-media bug on disk block type
Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=923053
When cdrom is block type, the virsh change-media failed to insert
source info because virsh uses "<source block='/dev/sdb'/>" while
the correct name of the attribute for block disks is "dev".
2013-07-23 14:20:56 +08:00
Daniel P. Berrange
afb50d79db Enable FD passing when starting guests with virsh
Add a "--pass-fds N,M,..." arg to the virsh start/create
methods. This allows pre-opened file descriptors from the
shell to be passed on into the guest

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-18 12:07:53 +01:00
Daniel P. Berrange
111f6f4d73 Convert 'int i' to 'size_t i' in tools/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-10 17:40:13 +01:00
Michal Privoznik
76fad65bdc Adapt to VIR_ALLOC and virAsprintf in tools/* 2013-07-10 11:07:33 +02:00
Jiri Denemark
4669543cb8 Introduce VIR_MIGRATE_PARAM_GRAPHICS_URI parameter
The parameter specifies connection parameters to use for migrating
client's connection to domain's graphical console.
2013-06-25 01:33:47 +02:00
Jiri Denemark
bdb6578a42 virsh: Use extensible migration APIs 2013-06-25 01:31:07 +02:00
Peter Krempa
cf6d56ac43 migration: Make erroring out on I/O error controllable by flag
Paolo Bonzini pointed out that it's actually possible to migrate a qemu
instance that was paused due to I/O error and it will be able to work on
the destination if the storage is accessible.

This patch introduces flag VIR_MIGRATE_ABORT_ON_ERROR that cancels the
migration in case an I/O error happens while it's being performed and
allows migration without this flag. This flag can be possibly used for
other error reasons that may be introduced in the future.
2013-06-18 14:52:26 +02:00
Peter Krempa
c2093b2aba Fix commit 29c1e913e4
This patch fixes changes done in commit 29c1e913e4
that was pushed without implementing review feedback.

The flag introduced by the patch is changed to VIR_DOMAIN_VCPU_GUEST and
documentation makes the difference between regular hotplug and this new
functionality more explicit.

The virsh options that enable the use of the new flag are changed to
"--guest" and the documentation is fixed too.
2013-06-10 09:52:49 +02:00
Peter Krempa
29c1e913e4 API: Introduce VIR_DOMAIN_VCPU_AGENT, for agent based CPU hot(un)plug
This flag will allow to use qemu guest agent commands to disable
(offline) and enable (online) processors in a live guest that has the
guest agent running.
2013-06-07 15:58:25 +02:00
Osier Yang
232240d095 virsh: Allow attach-disk to specify disk wwn
Commit 6e73850b01 support to set wwn for disks, but it was not
exposed to attach-disk.
2013-06-04 19:56:07 +08:00
Peter Krempa
08f1c0a9ae virsh-domain: Report errors and don't deref NULL in qemu-agent-command
Check the returned value for NULL and take the cleanup path
appropriately if the API fails.
2013-06-03 17:25:26 +02:00
Peter Krempa
33e300229c virsh-domain: Add --live, --config, --current logic to cmdAttachInterface
Use the approach established in commit
69ce3ffa8d to improve this function too.
2013-06-03 14:23:02 +02:00
Peter Krempa
37772499e0 virsh-domain: Add --live, --config, --current logic to cmdAttachDisk
Use the approach established in commit
69ce3ffa8d to improve this function too.
2013-06-03 14:23:02 +02:00
Peter Krempa
f81c95b31f virsh-domain: Add --live, --config, --current logic to cmdAttachDevice
Use the approach established in commit
69ce3ffa8d to improve this function too.
2013-06-03 14:23:01 +02:00
Cole Robinson
5e1de4fcdd virsh: migrate: Don't disallow --p2p and --migrateuri
Because it's a valid combination. p2p still uses a separate channel
for qemu migration, so there's value in letting the user specify a manual
migrate URI for overriding auto-port, or libvirt's FQDN lookup.

What _isn't_ allowed is --migrateuri and TUNNELLED, since there is
no separate migration channel. Disallow that instead
2013-05-29 12:31:00 -04:00
Eric Blake
146ba114a5 syntax: prefer space after semicolon in for loop
I noticed several unusual spacings in for loops, and decided to
fix them up.  See the next commit for the syntax check that found
all of these.

* examples/domsuspend/suspend.c (main): Fix spacing.
* python/libvirt-override.c: Likewise.
* src/conf/interface_conf.c: Likewise.
* src/security/virt-aa-helper.c: Likewise.
* src/util/virconf.c: Likewise.
* src/util/virhook.c: Likewise.
* src/util/virlog.c: Likewise.
* src/util/virsocketaddr.c: Likewise.
* src/util/virsysinfo.c: Likewise.
* src/util/viruuid.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.
* tools/virsh-domain-monitor.c (vshDomainStateToString): Drop
default case, to let compiler check us.
* tools/virsh-domain.c (vshDomainVcpuStateToString): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-28 07:56:07 -06:00
Martin Kletzander
0a24028f11 virsh: Fix virDomainFree for NULL domain in blkdeviotune 2013-05-23 13:02:19 +02:00
Osier Yang
c96f6ae845 tools: Remove the whitespace before ";" 2013-05-21 23:41:45 +08:00
Osier Yang
b77737372d virsh: Pretty the output of qemu-agent-command
This adds a new option "--pretty" for qemu-agent-command, to
pretty-format the returned JSON string.
2013-05-15 01:02:25 +08:00
Osier Yang
8b9eb14a6d virsh: Use vshPrint instead of printf 2013-05-15 01:02:18 +08:00
Ján Tomko
dcea5a492f get rid of virBufferAsprintf where possible
Use virBufferAddLit or virBufferAddChar instead.
2013-05-07 17:38:58 +02:00
Michal Privoznik
7c9a2d88cd virutil: Move string related functions to virstring.c
The source code base needs to be adapted as well. Some files
include virutil.h just for the string related functions (here,
the include is substituted to match the new file), some include
virutil.h without any need (here, the include is removed), and
some require both.
2013-05-02 16:56:55 +02:00
Peter Krempa
642261a866 virsh-domain: Refactor cmdVcpucount and fix output on inactive domains
This patch factors out the vCPU count retrieval including fallback means
into vshCPUCountCollect() and removes the duplicated code to retrieve
individual counts.

The --current flag (this flag is assumed by default) now works also with
--maximum or --active without the need to explicitly specify the state
of the domain that is requested.

This patch also fixes the output of "virsh vcpucount domain" on inactive
domains:

Before:
$ virsh vcpucount domain
maximum      config         4
error: Requested operation is not valid: domain is not running
current      config         4
error: Requested operation is not valid: domain is not running

After:
$virsh vcpucount domain
maximum      config         4
current      config         4

.. and for transient domains too:

Before:
$ virsh vcpucount transient-domain
error: Requested operation is not valid: cannot change persistent config of a transient domain
maximum      live           3
error: Requested operation is not valid: cannot change persistent config of a transient domain
current      live           1

After:
$ virsh vcpucount transient-domain
maximum      live           3
current      live           1
2013-04-19 14:02:10 +02:00
Peter Krempa
f78266dfc2 virsh-domain: Report errors on invalid --holdtime value for cmdSendKey
Using of a incorrect value for the --holdtime option was silently
ignored and 0 was used. In case a negative number was used, it
overflowed as the API expects a unsigned int.

Fix the data type and getter function type and report errors on
incorrect values.
2013-04-18 15:23:09 +02:00
Peter Krempa
35d0f3b14a virsh-domain: Clean up cmdSendKey
Rename the get_integer_keycode helper to vshKeyCodeGetInt and get rid of
a unneeded typecast.
2013-04-18 15:23:09 +02:00
John Ferlan
6528b7044f Add error handling to optional arguments in cmdCPUStats 2013-04-11 18:53:35 -04:00
John Ferlan
ad86ebb286 Remove extraneous comma in info_cpu_stats and opts_cpu_stats 2013-04-11 18:40:59 -04:00
Michal Privoznik
0aa8397c62 virsh: Update list of shutdown/reboot modes
As of 76d9f65644 we are supporting two new modes: initctl and signal.
However, these are missing in help listing.
2013-04-11 13:03:55 +02:00
Martin Kletzander
e7cd2844ca Allow multiple parameters for schedinfo
virsh schedinfo was able to set only one parameter at a time (not
counting the deprecated options), but it is useful to set more at
once, so this patch adds the possibility to do stuff like this:

virsh schedinfo <domain> cpu_shares=0 vcpu_period=0 vcpu_quota=0 \
emulator_period=0 emulator_quota=0

Invalid scheduler options are reported as well.  These were previously
reported only if the command hadn't updated any values (when
cmdSchedInfoUpdate returned 0).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=810078
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=919372
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=919375
2013-04-03 08:49:30 +02:00
Michal Privoznik
deb86ee912 virsh: Call virDomainFree in cmdDomFSTrim
https://bugzilla.redhat.com/show_bug.cgi?id=928197

The virsh domfstrim command was not freeing allocated domain,
leaving leaked references behind.
2013-04-02 17:36:06 +02:00
Peter Krempa
b685a73ed9 virsh-domain: Add --live, --config, --current logic to cmdDetachDisk
Use the established approach to improve this function too.
2013-04-02 16:18:38 +02:00
Peter Krempa
d87f721073 virsh-domain: Add --live, --config, --current logic to cmdDetachDevice
Use the established approach to improve this function too.
2013-04-02 16:18:32 +02:00
Peter Krempa
c3d9f399b5 virsh-domain: Add --live, --config, --current logic to cmdDetachInterface
Use the established approach to improve this function too.
2013-04-02 16:18:05 +02:00
Peter Krempa
69ce3ffa8d virsh: Fix semantics of --config for "update-device" command
The man page states that with --config the next boot is affected. This
can be understood as if _only_ the next boot was affected. This isn't
true if the machine is running.

This patch adds the full --live, --config, --current infrastructure and
tweaks stuff to correctly support the obsolete --persistent flag.

Note that this patch changes the the behavior of the --config flag to match the
use of this flag in rest of libvirt. This flag was mistakenly renamed from
--persistent that originaly had different semantics.
2013-04-02 16:14:14 +02:00
Peter Krempa
cc0cc6b714 virsh-domain: Fix declarations of flag variables in cmdChangeMedia
The parameter options can be declared directly.

Also use macros for mutual exclusion on some of the incompatible
parameter variables.
2013-04-02 16:02:43 +02:00
Peter Krempa
803e467080 virsh-domain: Simplify usage of --current, --live and --config flags
This patch uses the new helper to avoid the more complex check for
domain state modification flags.
2013-04-02 16:02:43 +02:00
Osier Yang
8893df388e virsh: Add a helper to parse cpulist
The 'virsh vcpupin' and 'virsh emulatorpin' commands use the same
code to parse the cpulist. This patch abstracts the same code as
a helper. Along with various code style fixes, and error improvement
(only error "Physical CPU %d doesn't exist" if the specified CPU
exceed the range, no "cpulist: Invalid format", see the following
for an example of the error prior to this patch).

% virsh vcpupin 4 0 0-8
error: Physical CPU 4 doesn't exist.
error: cpulist: Invalid format.
2013-04-02 12:37:24 +08:00
Yanbing Du
4faf435cbd virsh: Correct DESCRIPTION for virsh help blockcopy
Signed-off-by: Yanbing Du <ydu@redhat.com>
2013-03-26 20:23:30 +01:00
Ján Tomko
41db895f9e virsh: error out on non-numeric timeout values
Some block commands and migrate ignored incorrect values.

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=927495
2013-03-26 17:28:36 +01:00
Yanbing Du
5c925a4d82 Remove the redundant parentheses in migrate help
Signed-off-by: Yanbing Du <ydu@redhat.com>
2013-03-26 11:32:36 +08:00