Commit Graph

1108 Commits

Author SHA1 Message Date
Ján Tomko
14d5328681 virsh: free the caps list properly if one of them is invalid
VIR_FREE(caps) is not enough to free an array allocated
by vshStringToArray.

==17== 4 bytes in 1 blocks are definitely lost in loss record 4 of 728
==17==    by 0x4EFFC44: virStrdup (virstring.c:554)
==17==    by 0x128B10: _vshStrdup (virsh.c:125)
==17==    by 0x129164: vshStringToArray (virsh.c:218)
==17==    by 0x157BB3: cmdNodeListDevices (virsh-nodedev.c:409)

https://bugzilla.redhat.com/show_bug.cgi?id=1001536
2013-08-28 08:05:56 +02:00
Ján Tomko
785ff34bf8 virsh: free the formatting string when listing pool details
==23== 41 bytes in 1 blocks are definitely lost in loss record 626 of 727
==23==    by 0x4F0099F: virAsprintfInternal (virstring.c:358)
==23==    by 0x15D2C9: cmdPoolList (virsh-pool.c:1268)

https://bugzilla.redhat.com/show_bug.cgi?id=1001536
2013-08-28 08:05:56 +02:00
Ján Tomko
f733eac058 virsh: free the list from ListAll APIs even for 0 items
virsh secret-list leak when no secrets are defined:

==27== 8 bytes in 1 blocks are definitely lost in loss record 6 of 726
==27==    by 0x4E941DD: virAllocN (viralloc.c:183)
==27==    by 0x5037F1A: remoteConnectListAllSecrets (remote_driver.c:3076)
==27==    by 0x5004EC6: virConnectListAllSecrets (libvirt.c:16298)
==27==    by 0x15F813: vshSecretListCollect (virsh-secret.c:397)
==27==    by 0x15F0E1: cmdSecretList (virsh-secret.c:532)

And so do some other *-list commands.

https://bugzilla.redhat.com/show_bug.cgi?id=1001536
2013-08-28 08:05:56 +02:00
Ján Tomko
66d124b454 virsh: free messages after logging them to a file
The messages were only freed on error.

==12== 1,100 bytes in 1 blocks are definitely lost in loss record 698 of 729
==12==    by 0x4E98C22: virBufferAsprintf (virbuffer.c:294)
==12==    by 0x12C950: vshOutputLogFile (virsh.c:2440)
==12==    by 0x12880B: vshError (virsh.c:2254)
==12==    by 0x131957: vshCommandOptDomainBy (virsh-domain.c:109)
==12==    by 0x14253E: cmdStart (virsh-domain.c:3333)

https://bugzilla.redhat.com/show_bug.cgi?id=1001536
2013-08-28 08:05:56 +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
Ján Tomko
784cca89c5 Don't free NULL network in cmdNetworkUpdate
If the network has not been found, virNetworkFree(NULL)
was called, resulting in an extra error:
error: invalid network pointer in virNetworkFree

https://bugzilla.redhat.com/show_bug.cgi?id=1001094
2013-08-26 15:51:15 +02:00
Guido Günther
3e2799add2 Check for --no-copy-dt-needed linker flag
and use it when available
2013-08-22 16:17:36 +02:00
Guido Günther
d9527b6d56 Simplify RELRO_LDFLAGS
by adding it to AM_LDFLAGS instead of every linking rule and
by avoiding a forked grep.
2013-08-22 16:17:35 +02:00
Martin Kletzander
a0b6a36f94 Fix URI connect precedence
Commit abfff210 changed the order of vshParseArgv() and vshInit() in
order to make fix debugging of parameter parsing.  However, vshInit()
did a vshReconnect() even though ctl->name wasn't set according to the
'-c' parameter yet.  In order to keep both issues fixed, I've split
the vshInit() into vshInitDebug() and vshInit().

One simple memleak of ctl->name is fixed as a part of this patch,
since it is related to the issue it's fixing.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=999323
2013-08-22 09:54:41 +02:00
John Ferlan
db1382f322 virsh: Print cephx and iscsi usage
When using virsh secret-list - if the secret types are cephx or iscsi,
then allow fetch/print of the usage information. Prior to the change
the following would print:

UUID                                 Usage
-----------------------------------------------------------
1b40a534-8301-45d5-b1aa-11894ebb1735 Unused
a5ba3efe-6adf-4a6a-b243-f010a043e314 Unused

Afterwards:

UUID                                 Usage
-----------------------------------------------------------
1b40a534-8301-45d5-b1aa-11894ebb1735 ceph ceph_example
a5ba3efe-6adf-4a6a-b243-f010a043e314 iscsi libvirtiscsi
2013-08-20 13:27:44 -04: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
Peter Krempa
5b5da08226 virsh-pool: Improve error message in cmdPoolList
Explicitly let the user know about the unknown pool type.
2013-08-20 17:55:08 +02:00
Peter Krempa
d64af6ce3c virsh: modify vshStringToArray to duplicate the elements too
At a slightly larger memory expense allow stealing of items from the
string array returned from vshStringToArray and turn the result into a
string list compatible with virStringSplit. This will allow to use the
common dealloc function.

This patch also fixes a few forgotten checks of return from
vshStringToArray and one memory leak.
2013-08-20 17:53:49 +02:00
Eric Blake
53924ad5d5 virt-pki-validate: add --help/--version option
Another program gains --help/--version :)

* tools/virt-pki-validate.in: Add option parsing.  Update
documentation to match.
* tools/Makefile.am (virt-pki-validate): Substitute version.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-08-19 20:25:53 -06:00
Eric Blake
ab4304b7e0 virt-xml-validate: add missing schemas
We were failing to autoprobe which schema to use for several
top-level XML elements.

* tools/virt-xml-validate.in (TYPE): Recognize <domainsnapshot>,
<filter>, and <secret>.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-08-19 20:25:49 -06:00
Eric Blake
b2ea248ef7 virt-xml-validate: add --help/--version option
All good tools should have --help and --version output :)

Furthermore, we want to ensure a failed exit if xmllint fails,
or even for 'virt-xml-validate > /dev/full'.

* tools/virt-xml-validate.in: Add option parsing.  Output errors
to stderr.  Update documentation to match.
* tools/Makefile.am (virt-xml-validate): Substitute version.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-08-19 20:23:39 -06:00
Cole Robinson
e7c7e32200 tools: Make sure to distribute conf_DATA, fix RPM build 2013-08-17 15:02:25 -04: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
Ruben Kerkhof
11cdc424d3 virt-login-shell: improve error message grammar
and wrap some long lines

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-08-13 17:28:06 -06:00
Daniel P. Berrange
a396473494 Address missed feedback from review of virt-login-shell
Address a number of code, style and docs issues identified
in review of virt-login-shell after it was merged.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-08-13 14:06:01 +01: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
Daniel P. Berrange
ac692e3af2 Fix double-free and broken logic in virt-login-shell
The virLoginShellAllowedUser method must not free the 'groups'
parameter it is given, as that is owned by the caller.

The virLoginShellAllowedUser method should be checking
'!*ptr' (ie empty string) rather than '!ptr' (NULL string)
since the latter cannot be true.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-08-09 12:55:59 +01:00
Jim Fehlig
26b8a4dd23 build: fix compilation of virt-login-shell.c
virt-login-shell.c was failing to compile with

CC       virt_login_shell-virt-login-shell.o
virt-login-shell.c: In function 'main':
virt-login-shell.c:205:5: error: implicit declaration of function 'setlocale' [-Werror=implicit-function-declaration]
virt-login-shell.c:205:5: error: nested extern declaration of 'setlocale' [-Werror=nested-externs]
virt-login-shell.c:205:20: error: 'LC_ALL' undeclared (first use in this function)
2013-08-08 13:53:25 -06:00
Dan Walsh
54d69f540c Introduce a virt-login-shell binary
Add a virt-login-shell binary that can be set as a user's
shell, such that when they login, it causes them to enter
the LXC container with a name matching their user name.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-08-08 16:36:31 +01:00
Daniel P. Berrange
63d261f395 Rename VIR_DOMAIN_PAUSED_GUEST_PANICKED to VIR_DOMAIN_PAUSED_CRASHED
The VIR_DOMAIN_PAUSED_GUEST_PANICKED constant is badly named,
leaking the QEMU event name. Elsewhere in the API we use
'CRASHED' rather than 'PANICKED', and the addition of 'GUEST'
is redundant since all events are guest related.

Thus rename it to VIR_DOMAIN_PAUSED_CRASHED, which matches
with VIR_DOMAIN_RUNNING_CRASHED and VIR_DOMAIN_EVENT_CRASHED.

It was added in commit 14e7e0ae8d
which post-dates v1.1.0, so is safe to rename before 1.1.1

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-29 18:08:55 +01:00
Daniel P. Berrange
8c20d3f8e7 Remove VIR_DOMAIN_SHUTDOWN_CRASHED from public API
The VIR_DOMAIN_SHUTDOWN_CRASHED state constant does not appear
to be used in the QEMU code anyway. It also doesn't make much
(any) sense, since the 'shutdown' state is a transient state
between 'running' and 'shutoff' and when a guest crashes, it
does not end up in a 'shutdown' state, only 'shutoff'.

It was added in commit 14e7e0ae8d
which post-dates v1.1.0, so is safe to remove before 1.1.1

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-29 18:08:55 +01:00
Jim Fehlig
e3b21cdc31 Fix virsh snapshot-list error reporting
Noticed that the expected "not supported" error is dropped when
invoking 'virsh snapshot-list dom' on a Xen installation running
the libxl driver

 virsh snapshot-list test
 error: Invalid snapshot: virDomainSnapshotFree

The error is overwritten by a call to virDomainSnapshotFree
in cleanup code within cmdSnapshotList.  Prevent overwritting
the real error by not calling virDomainSnapshotFree with a NULL
virDomainSnapshotPtr.
2013-07-25 14:22:47 -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
John Ferlan
57b65c58d0 Allow balloon driver collection to be adjusted dynamically
Use the virDomainSetMemoryStatsPeriodFlags() to pass a period defined by
usage of a new --period option in order to set the collection period for the
balloon driver. This may enable or disable the collection based on the value.

Add the --current, --live, & --config options to dommemstat.
2013-07-16 08:44:53 -04:00
Peter Krempa
acc27c4eaa virsh: Mention --driver in man page for nodedev-detach
https://bugzilla.redhat.com/show_bug.cgi?id=982987

Commit d923f6c8 introduced the --driver option but didn't document it in
the man page. The docs are borrowed from the public API documentation.
2013-07-12 14:02:11 +02:00
John Ferlan
f926804a91 virsh-nodedev: Resolve Coverity issues
Recent changes uncovered FORWARD_NULL and NEGATIVE_RETURNS problems with
the processing of the 'ndevices' and its associated allocated arrays in
'vshNodeDeviceListCollect' due to the possibility of returning -1 in a
call and using the returned value as a for loop index end condition.
2013-07-11 14:18:12 -04:00
John Ferlan
50210ab9ff virsh-interface: Resolve Coverity issues
Recent changes uncovered FORWARD_NULL and NEGATIVE_RETURNS problems with
the processing of the 'nActiveIfaces' and 'nInactiveIfaces' and their
associated allocated arrays in 'vshInterfaceListCollect' due to the
possibility of returning -1 in a call and using the return value as a
for loop index end condition.
2013-07-11 14:18:11 -04:00
John Ferlan
0cfd40ac0c virsh-domain-monitor: Resolve Coverity issues
Recent changes uncovered a pair of NEGATIVE_RETURNS when processing the
'nnames' in 'vshDomainListCollect' in the for loop due to possible -1 value.
2013-07-11 14:18:11 -04: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
Michal Privoznik
dc6f2dadac Introduce OOM reporting to virAsprintf
Actually, I'm turning this function into a macro as filename,
function name and line number needs to be passed. The new
function virAsprintfInternal is introduced with the extended set
of arguments.
2013-07-10 11:07:31 +02:00
Guido Günther
9d5d4700c2 Put virt-sanlock-cleanup into section 8
as indicated by the filename.
2013-07-03 15:06:36 +02:00
Chen Fan
14e7e0ae8d libvirt: Define domain crash event types
This patch introduces domain crashed types and crashed reasons which
will be used while guest panicked.
2013-07-02 12:02:27 -06:00
xuzhang
f542a0dead virsh: Add parenthesis into virsh nodedev-detach help 2013-06-27 17:42:51 +02:00
Ján Tomko
1e3a252974 virsh: edit: don't leak XML string on reedit or redefine
Free the old XML strings before overwriting them if the user
has chosen to reedit the file or force the redefinition.

Found by Alex Jia trying to reproduce another bug:
https://bugzilla.redhat.com/show_bug.cgi?id=977430#c3
2013-06-25 15:37:20 +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
Ján Tomko
d0d0413e48 util: switch virBufferTrim to void
We don't care whether the trim was succesful or not anywhere
except the tests.

Switch it to void and set the buffer error on wrong usage.
2013-06-19 09:21:09 +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
Osier Yang
9046b80d2d virsh: Support SCSI_GENERIC cap flag for nodedev-list
Document for nodedev-list is also updated.
2013-06-18 17:20:28 +08: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
Peter Krempa
36e073ad9e virsh-domain-monitor: Remove ATTRIBUTE_UNUSED from a argument
The "cmd" argument in cmdList is now used. Unmark it as unused.
2013-06-07 15:57:03 +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
Jiri Denemark
634096536c virsh: Obey pool-or-uuid spec when creating volumes
Our documentation says a pool may be referenced by its name or UUID
anywhere if it makes sense (pool-name and pool-uuid are the only
exceptions). However, vol-create and vol-create-as commands did not obey
this.
2013-06-04 10:16:02 +02: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
Jiri Denemark
a923865a0e virsh iface-bridge: Ignore delay if stp is turned off
Delay only makes sense with STP enabled.
2013-06-03 15:15:44 +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
Jiri Denemark
fae2505eee Document that runtime changes may be lost after S4 suspend 2013-05-31 18:03:20 +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
Osier Yang
2a3a725c33 virsh: Fix regression of vol-resize
Introduced by commit 1daa4ba33a. vshCommandOptStringReq returns
0 on *success* or the option is not required && not present, both
are right result. Error out when returning 0 is not correct.
the caller, it doesn't have to check wether it
2013-05-24 16:55:39 +08:00
Michal Privoznik
528f420e03 Adapt to VIR_STRDUP and VIR_STRNDUP in tools/virsh.c 2013-05-24 10:10:03 +02:00
Martin Kletzander
0a24028f11 virsh: Fix virDomainFree for NULL domain in blkdeviotune 2013-05-23 13:02:19 +02:00
Zhang Xiaohe
c0955c3206 virsh: omit OPTION section in 'virsh help' if no option exists
Don't print 'OPTION' if there's no options. Just behaves as DESCRIPTION
does.
This mostly affects 'interface' command group.

Signed-off-by: Zhang Xiaohe <zhangxh@cn.fujitsu.com>
Reported-by: Li Yang <liyang.fnst@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-22 16:17:24 -06:00
Osier Yang
c96f6ae845 tools: Remove the whitespace before ";" 2013-05-21 23:41:45 +08:00
Eric Blake
d7f53c7b97 maint: use LGPL correctly
Several files called out COPYING or COPYING.LIB instead of using
the normal boilerplate.  It's especially important that we don't
call out COPYING from an LGPL file, since COPYING is traditionally
used for the GPL.  A few files were lacking copyright altogether.

* src/rpc/gendispatch.pl: Add missing copyright.
* Makefile.nonreentrant: Likewise.
* src/check-symfile.pl: Likewise.
* src/check-symsorting.pl: Likewise.
* src/driver.h: Likewise.
* src/internal.h: Likewise.
* tools/libvirt-guests.sh.in: Likewise.
* tools/virt-pki-validate.in: Mention copyright in comment, not just code.
* tools/virt-sanlock-cleanup.in: Likewise.
* src/rpc/genprotocol.pl: Spell out license terms.
* src/xen/xend_internal.h: Likewise.
* src/xen/xend_internal.c: Likewise.
* Makefile.am: Likewise.
* daemon/Makefile.am: Likewise.
* docs/Makefile.am: Likewise.
* docs/schemas/Makefile.am: Likewise.
* examples/apparmor/Makefile.am: Likewise.
* examples/domain-events/events-c/Makefile.am: Likewise.
* examples/dominfo/Makefile.am: Likewise.
* examples/domsuspend/Makefile.am: Likewise.
* examples/hellolibvirt/Makefile.am: Likewise.
* examples/openauth/Makefile.am: Likewise.
* examples/python/Makefile.am: Likewise.
* examples/systemtap/Makefile.am: Likewise.
* examples/xml/nwfilter/Makefile.am: Likewise.
* gnulib/lib/Makefile.am: Likewise.
* gnulib/tests/Makefile.am: Likewise.
* include/Makefile.am: Likewise.
* include/libvirt/Makefile.am: Likewise.
* python/Makefile.am: Likewise.
* python/tests/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
* tests/Makefile.am: Likewise.
* tools/Makefile.am: Likewise.
* configure.ac: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-20 14:03:48 -06:00
Guannan Ren
36c0a791e6 virsh: lookup interface by name or mac other than one by one
Use virMacAddrParse() to distinguish interface name from interface
mac address.
2013-05-16 09:12:44 +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
Daniel P. Berrange
71b54636f0 Don't duplicate compiler warning flags when linking
Automake already passes all CFLAGS to the linker too, so it
is not necessary to set WARN_LDFLAGS in addition to the
WARN_CFLAGS variable.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-14 15:02:37 +01:00
Laine Stump
bfe7721d50 util: move virFile* functions from virutil.c to virfile.c
These all existed before virfile.c was created, and for some reason
weren't moved.

This is mostly straightfoward, although the syntax rule prohibiting
write() had to be changed to have an exception for virfile.c instead
of virutil.c.

This movement pointed out that there is a function called
virBuildPath(), and another almost identical function called
virFileBuildPath(). They really should be a single function, which
I'll take care of as soon as I figure out what the arglist should look
like.
2013-05-10 13:09:30 -04:00
John Ferlan
55b46920bb virsh: Resolve Coverity 'MISSING_BREAK'
Recent commit '53531e16' resulted in a new Coverity warning regarding
a missing break in the ':' options processing. Adjust the commit to
avoid the issue.
2013-05-08 06:16:53 -04:00
Ján Tomko
dcea5a492f get rid of virBufferAsprintf where possible
Use virBufferAddLit or virBufferAddChar instead.
2013-05-07 17:38:58 +02:00
Eric Blake
25ae3d3015 build: avoid useless virAsprintf
virAsprintf(&foo, "%s", bar) is wasteful compared to
foo = strdup(bar) (or eventually, VIR_STRDUP(foo, bar),
but one thing at a time...).

Noticed while reviewing Laine's attempt to clean up broken
qemu:///session.

* cfg.mk (sc_prohibit_asprintf): Enhance rule.
* src/esx/esx_storage_backend_vmfs.c
(esxStorageBackendVMFSVolumeLookupByKey): Fix offender.
* src/network/bridge_driver.c (networkStateInitialize): Likewise.
* src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopDHCPOpen):
Likewise.
* src/storage/storage_backend_sheepdog.c
(virStorageBackendSheepdogRefreshVol): Likewise.
* src/util/vircgroup.c (virCgroupAddTaskStrController): Likewise.
* src/util/virdnsmasq.c (addnhostsAdd): Likewise.
* src/xen/block_stats.c (xenLinuxDomainDeviceID): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectOpen): Likewise.
* tools/virsh.c (vshGetTypedParamValue): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-02 13:35:26 -06: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
Ján Tomko
9c51de2b4e libvirt-guests: status: return non-zero when stopped
Return 3 when the service is stopped, whether there
are saved guests or not, to conform with the LSB standards:

http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
2013-04-30 18:38:18 +02:00
Ján Tomko
ce284bb56d virsh: clarify vol-{down,up}load description
Mention file/volume contents instead of just 'file'/'volume'.

Also change Download->download in vol-download help,
to be consistent with other volume commands.

https://bugzilla.redhat.com/show_bug.cgi?id=955537
2013-04-30 14:19:49 +02:00
Ján Tomko
53531e16bf virsh: fix incorrect argument errors for long options
For long options, print:
* the option as specified by the user if it's unknown
* the canonical long option if its argument is not
  a number (and should be)

And for missing arguments, print both the short and
the long option name.
(Doing only one of those would require either parsing
argv ourselves or let getopt print the errors, since
we can't tell long and short options apart by optopt
or longindex)

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

Unsupported long option:

$ virsh --pm
Before:
error: unsupported option '-
After:
error: unsupported option '--pm'. See --help.

Missing parameter:

$ virsh --deb
Before:
error: option '-d' requires an argument
After:
error: option '-d'/'--debug' requires an argument

$ virsh -rd
Before:
error: option '-d' requires an argument
After:
error: option '-d'/'--debug' requires an argument

Non-numeric parameter:

$ virsh --deb duck
Before:
error: option -d takes a numeric argument
After:
error: option --debug takes a numeric argument
2013-04-30 10:23:44 +02:00
Eric Blake
117dc4cc8a virsh: suppress aliases in group help
'virsh help | grep nodedev-det' shows only nodedev-detach, but
'virsh help nodedev | grep nodedev-det' also shows the old alias
nodedev-dettach that we intentionally hid in commit af3f9aab.

See also commit 787f4fe and this bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=956966

* tools/virsh.c (vshCmdGrpHelp): Copy suppression of vshCmdHelp.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-04-26 05:45:11 -06:00
Laine Stump
d923f6c882 virsh: use new virNodeDeviceDetachFlags
The virsh nodedev-detach command has a new --driver option. If it's
given virsh will attempt to use the new virNodeDeviceDetachFlags API
instead of virNodeDeviceDettach. Validation of the driver name string
is left to the hypervisor (qemu accepts "kvm" or "vfio". The only
other hypervisor that implements these functions is xen, and it only
accepts NULL).
2013-04-25 21:28:43 -04: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
Osier Yang
9969ade669 syntax-check: Only allows to include public headers in external tools
With this patch, include public headers in "" form is only allowed
for "internal.h". And only the external tools (examples|tools|python
|include/libvirt) can include the public headers in <> form.
2013-04-18 11:31:19 +08: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
Peter Krempa
b83b31d87a virsh: Document that using incomplete XML files may have unexpected results
Explicitly state that using incomplete XML definition snippets for hot-management
commands may have unexpected results due to autogenerating values for some of
the fields if they aren't specified explicitly.
2013-04-11 16:44:38 +02: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
Ján Tomko
96c45f66fb docs: use MiB/s instead of Mbps for migration speed
https://bugzilla.redhat.com/show_bug.cgi?id=948821
2013-04-09 16:45:24 +02:00
Alex Jia
c3e33e68d9 sanlock: add missing test command in virt-sanlock-cleanup.in
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=949483

Signed-off-by: Alex Jia <ajia@redhat.com>
2013-04-09 13:01:33 +08:00
Eric Blake
00d69b4af1 build: use proper pod for nested bulleted VIRSH_DEBUG list
Newer pod (hello rawhide) complains if you attempt to mix bullets
and non-bullets in the same list:

virsh.pod around line 3177: Expected text after =item, not a bullet

As our intent was to nest an inner list, we make that explicit to
keep pod happy.

* tools/virsh.pod (ENVIRONMENT): Use correct pod syntax.
2013-04-05 10:02:33 -06:00
Peter Krempa
69ab07560a virsh: Register and unregister the close callback also in cmdConnect
This patch improves the error message after disconnecting from the
hypervisor and adds the close callback operations required not to leak
the callback reference.
2013-04-05 10:36:03 +02:00
Peter Krempa
ca9e73ebb6 virsh: Move cmdConnect from virsh-host.c to virsh.c
The function is used to establish connection so it should be in the main
virsh file. This movement also enables further improvements done in next
patches.

Note that the "connect" command has moved from the host section of virsh to the
main section. It is now listed by 'virsh help virsh' instead of 'virsh help
host'.
2013-04-05 10:36:03 +02:00
Viktor Mihajlovski
e964ba2786 virsh: Unregister the connection close notifier upon termination
Before closing the connection we unregister the close callback
to prevent a reference leak.

Further, the messages on virConnectClose != 0 are a bit more specific
now.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2013-04-05 10:36:03 +02:00
Daniel P. Berrange
fc8c1787d8 Enable full RELRO mode
By passing the flags -z relro -z now to the linker, we can force
it to resolve all library symbols at startup, instead of on-demand.
This allows it to then make the global offset table (GOT) read-only,
which makes some security attacks harder.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-04-03 16:19:35 +01:00
Daniel P. Berrange
1150999ca4 Build all binaries with PIE
PIE (position independent executable) adds security to executables
by composing them entirely of position-independent code (PIC. The
.so libraries already build with -fPIC. This adds -fPIE which is
the equivalent to -fPIC, but for executables. This for allows Exec
Shield to use address space layout randomization to prevent attackers
from knowing where existing executable code is during a security
attack using exploits that rely on knowing the offset of the
executable code in the binary, such as return-to-libc attacks.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-04-03 16:19:35 +01:00
Peter Krempa
f006f19561 virsh: Fix typo in docs
s/persitent/persistent/
2013-04-03 11:38:57 +02:00