Commit Graph

13519 Commits

Author SHA1 Message Date
Osier Yang
107130cc71 storage_conf: Improve the memory deallocation of virStorageVolDefParseXML
Changes:
  * Add a new goto label "error"
  * Free the strings at "cleanup"
  * Remove the unnecessary frees
2013-05-29 18:05:55 +08:00
Osier Yang
6afdfc8e13 storage_conf: Improve the memory deallocation of pool def parsing
Changes:
    * Free all the strings at "cleanup", instead of freeing them
      in the middle
    * Remove xmlFree
    * s/tmppath/target_path/, to make it more sensible
    * Add new goto label "error"
2013-05-29 18:04:33 +08:00
Michal Privoznik
d10cfaec3b qemuOpenVhostNet: Decrease vhostfdSize on open failure
Currently, if there's an error opening /dev/vhost-net (e.g. because
it doesn't exist) but it's not required we proceed with vhostfd array
filled with -1 and vhostfdSize unchanged. Later, when constructing
the qemu command line only non-negative items within vhostfd array
are taken into account. This means, vhostfdSize may be greater than
the actual count of non-negative items in vhostfd array. This results
in improper command line arguments being generated, e.g.:

-netdev tap,fd=21,id=hostnet0,vhost=on,vhostfd=(null)
2013-05-29 09:20:04 +02:00
Eric Blake
f6817c70b4 build: fix build with older gcc
gcc 4.1.2 (hello, RHEL 5!) fails to build on 32-bit platforms with:

conf/domain_conf.c: In function 'virDomainDefParseXML':
conf/domain_conf.c:10581: warning: integer constant is too large for 'long' type

Problem introduced in commit f8e3221f9.

* src/conf/domain_conf.c (virDomainDefParseXML): Mark large constants.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-28 17:34:50 -06:00
Eric Blake
327d4db83e build: drop unused variable
Compilation for mingw failed:

../../src/util/virutil.c: In function 'virGetWin32DirectoryRoot':
../../src/util/virutil.c:1094:9: error: unused variable 'ret' [-Werror=unused-variable]

* src/util/virutil.c (virGetWin32DirectoryRoot): Silence compiler
warning.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-28 17:11:48 -06:00
Eric Blake
0c8926daf9 syntax: fix broken error message in previous patch
Osier Yang pointed out that I introduced a syntax error in my
syntax check (I really shouldn't make last-minute changes without
testing them....).

/bin/sh: -c: line 2: syntax error near unexpected token `;'
/bin/sh: -c: line 2: `  { echo 'maint.mk: incorrect whitespace, see HACKING for rules' 2>&; \'
make: *** [bracket-spacing-check] Error 1

* cfg.mk (bracket-spacing-check): Fix copy-and-paste error.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-28 09:52:03 -06:00
Cole Robinson
406d8a9809 qemu: Don't report error on successful media eject
If we are just ejecting media, ret == -1 even after the retry loop
determines that the tray is open, as requested. This means media
disconnect always report's error.

Fix it, and fix some other mini issues:

- Don't overwrite the 'eject' error message if the retry loop fails
- Move the retries decrement inside the loop, otherwise the final loop
  might succeed, yet retries == 0 and we will raise error
- Setting ret = -1 in the disk->src check is unneeded
- Fix comment typos

cc: mprivozn@redhat.com
2013-05-28 11:45:19 -04:00
Eric Blake
134e685b1d syntax-check: mandate space after mid-line semicolon
Enforce the style cleanup in the previous patch.

* build-aux/bracket-spacing.pl: Enforce trailing spacing.
* cfg.mk (bracket-spacing-check): Tweak error wording.
* docs/hacking.html.in: Document the rule.
* HACKING: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-28 08:26:05 -06: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
yangdongsheng
2da3bc646e util: fix the VIR_STRDUP when src is NULL
When src is NULL, VIR_STRDUP will return 0 directly.
This patch will set dest to NULL before VIR_STRDUP return.

Example:
[root@yds-pc libvirt]# virsh
Welcome to virsh, the virtualization interactive terminal.

Type: 'help' for help with commands
'quit' to quit

virsh # connect
error: Failed to connect to the hypervisor
error: internal error Unable to parse URI �N�*

Signed-off-by: yangdongsheng <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-28 05:57:01 -06:00
Jiri Denemark
c6f2523fb1 qemu: Fix build without gnutls
"error" label in qemuMigrationCookieGraphicsAlloc is now used
unconditionally thanks to VIR_STRDUP.
2013-05-27 10:19:36 +02:00
Sergey Fionov
2697c8a116 qemu: save domain state to XML after reboot
Currently qemuDomainReboot() does reboot in two phases:
qemuMonitorSystemPowerdown() and qemuProcessFakeReboot().

qemuMonitorSystemPowerdown() shutdowns the domain and saves domain
state/reason as VIR_DOMAIN_SHUTDOWN_UNKNOWN.

qemuProcessFakeReboot() sets domain state/reason to
VIR_DOMAIN_RESUMED_UNPAUSED but does not save domain state changes.

Subsequent restart of libvirtd leads to restoring domain state/reason to
saved that is VIR_DOMAIN_SHUTDOWN_UNKNOWN and to automatic shutdown of
the domain. This commit adds virDomainSaveStatus() into
qemuProcessFakeReboot() to avoid unexpected shutdowns.
2013-05-24 15:29:22 -06:00
Matthias Bolte
befc36a81d esx: Fix dynamic VI object type detection
VI objects support inheritance with subtype polymorphism. For example the
FileInfo object type is extended by FloppyImageFileInfo, FolderFileInfo
etc. Then SearchDatastore_Task returns an array of FileInfo objects and
depending on the represented file the FileInfo is actually a FolderFileInfo
or FloppyImageFileInfo etc. The actual type information is stored as XML
attribute that allows clients such as libvirt to distinguish between the
actual types. esxVI_GetActualObjectType is used to extract the actual type.

I assumed that this mechanism would be used for all VI object types that
have subtypes. But this is not the case. It seems only to be used for types
that are actually used as generic base type such as FileInfo. But it is not
used for types that got extended later such as ElementDescription that was
extended by ExtendedElementDescription (added in vSphere API 4.0) or that
are not meant to be used with subtype polymorphism.

This breaks the deserialization of types that contain ElementDescription
properties such as PerfCounterInfo or ChoiceOption, because the code
expects an ElementDescription object to have an XML attribute named type
that is not present, since ExtendedElementDescription was added to the
esx_vi_generator.input in commit 60f0f55ee4.
This in turn break virtual machine question handling and auto answering.

Fix this by using the base type if no XML type attribute is present.
2013-05-24 21:31:42 +02:00
Viktor Mihajlovski
831909a94e spec: Build vbox packages only for x86 architectures
Commit 6ab6bc19f0 has introduced separate
daemon/driver packages for vbox. These should only be built for x86
architectures which is done hereby.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2013-05-24 10:11:00 -06:00
Osier Yang
fb6a05e75d security_dac: Fix the coding style
Pushed under trivial rule.
2013-05-24 23:33:09 +08:00
Michal Privoznik
0fc5d09cbb Adapt to new VIR_STRNDUP behavior
With previous patch, we accept negative value as length of string to
duplicate. So there is no need to pass strlen(src) in case we want to do
duplicate the whole string.
2013-05-24 17:00:39 +02:00
Michal Privoznik
c93571968b virStrndup: Accept negative values as string length
It may shorten the code a bit as the following pattern:

  VIR_STRNDUP(dst, src, cond ? n : strlen(src))

is used on several places among our code. However, we can
move the strlen into virStrndup and thus write just:

  VIR_STRNDUP(dst, src, cond ? n : -1)
2013-05-24 16:59:30 +02:00
Osier Yang
267915ee69 storage_conf: Fix the error type
s/VIR_ERR_INTERNAL_ERROR/VIR_ERR_XML_ERROR/.
2013-05-24 22:34:16 +08:00
Osier Yang
3c37730efc storage_conf: Put "%s" at the same line with error type
Trivial, but it allows the "error message" to have more spaces.
2013-05-24 22:34:03 +08:00
Osier Yang
0175f03cde storage_conf: Use xmlStrEqual instead of STREQ
And improve the error message
2013-05-24 22:33:50 +08:00
Osier Yang
7ae5999fa3 storage_conf: Remove the useless casting 2013-05-24 22:33:35 +08:00
Osier Yang
61c6227341 storage_conf: Don't leak "uuid" in virStoragePoolDefParseAuthCephx
Any string returned from virXPathString should be freed.
2013-05-24 22:33:23 +08:00
Osier Yang
49598fab61 storage_conf: Fix the wrong error message
It's for parsing "login" attribute of "auth".
2013-05-24 22:33:07 +08:00
Ján Tomko
711ca22a20 syntax-check: ignore all quoted strings in bracket-spacing
Ignore strings with an escaped double quote too.

This removes the need for special handling of quotes in the
semicolon check.
2013-05-24 15:57:45 +02:00
Stefan Berger
b9c4bd0c07 nwfilter: Remove error report in virNWFilterDHCPSnoopEnd
Remove error reporting when calling the virNWFilterDHCPSnoopEnd
function with an interface for which no thread is snooping traffic.

Document the usage of this function.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2013-05-24 08:01:03 -04:00
Martin Kletzander
5af3ce8277 Fix blkdeviotune for shutoff domain
Function qemuDomainSetBlockIoTune() was checking QEMU capabilities
even when !(flags & VIR_DOMAIN_AFFECT_LIVE) and the domain was
shutoff, resulting in the following problem:

 virsh # domstate asdf; blkdeviotune asdf vda --write-bytes-sec 100
 shut off

 error: Unable to change block I/O throttle
 error: unsupported configuration: block I/O throttling not supported with this QEMU binary

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=965016
2013-05-24 13:29:20 +02:00
Viktor Mihajlovski
eb21408f44 cgroups: Do not enforce nonexistent controllers
Currently, the controllers argument to virCgroupDetect acts both as
a result filter and a required controller specification, which is
a bit overloaded. If both functionalities are needed, it would be
better to have them seperated into a filter and a requirement mask.
The only situation where it is used today is to ensure that only
CPU related controllers are used for the VCPU directories. But here
we clearly do not want to enforce the existence of cpu, cpuacct and
specifically not cpuset at the same time.
This commit changes the semantics of controllers to "filter only".
Should a required mask ever be needed, more work will have to be done.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2013-05-24 12:11:24 +02: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
d1527ba5d7 Introduce syntax-check rule to prefer VIR_STRDUP over strdup 2013-05-24 10:13:02 +02:00
Michal Privoznik
528f420e03 Adapt to VIR_STRDUP and VIR_STRNDUP in tools/virsh.c 2013-05-24 10:10:03 +02:00
Michal Privoznik
f48ba88b35 Adapt to VIR_STRDUP and VIR_STRNDUP in src/util/* 2013-05-24 10:10:03 +02:00
Michal Privoznik
eb8e5e8774 Adapt to VIR_STRDUP and VIR_STRNDUP in src/util/vircgroup.c
This commit is separate due to unusual paradigm compared to the
most source files.
2013-05-24 10:10:03 +02:00
Michal Privoznik
b43bb98a31 virCgroupAddTaskStrController: s/-1/-ENOMEM/
Within whole vircgroup.c we 'return -errno', e.g. 'return -ENOMEM'.
However, in this specific function virCgroupAddTaskStrController
we weren't returning -ENOMEM but -1 despite fact that later in
the function we are returning one of errno values indeed.
2013-05-24 10:03:22 +02:00
John Ferlan
677981d1be xen: Resolve Coverity FORWARD_NULL issue
Commit '18b14012' refactored the Xen code resulting in a Coverity
warning about possible NULL reference if the path where the XM driver
takes puts the def on it's list.  Moved/duplicated the virGetDomain()
call to pacify the possible NULL deref.
2013-05-23 19:19:21 -04:00
Cole Robinson
e4de214b38 docs: domain: /dev/urandom isn't a valid rng patch
Only /dev/random and /dev/hwrng are accepted, list them explicitly.
2013-05-23 14:37:08 -04:00
Ján Tomko
23195651f5 conf: add missing OOM errors 2013-05-23 18:56:36 +02:00
Ján Tomko
2326006410 qemu: fix NBD migration to hosts with IPv6 enabled
Since f03dcc5 we use [::] as the listening address both on qemu
command line in -incoming and in nbd-server-start QMP command.
However the latter requires just :: without the braces.
2013-05-23 17:55:34 +02:00
Ján Tomko
a32b41746c conf: fix use after free in virChrdevOpen
Don't free the stream on error if we've successfully added it
to the hash table, since it will be freed by virChrdevHashEntryFree
callback.

Preserve the error message before calling virStreamFree, since it
resets the error.

Introduced by 4716138, crashing since 6921892.

Reported by Sergey Fionov on libvir-list.
2013-05-23 17:55:34 +02:00
Michal Privoznik
a551e9e1fc Adapt to VIR_STRDUP and VIR_STRNDUP in src/xenxs/* 2013-05-23 17:29:49 +02:00
Michal Privoznik
63ee3b664d Adapt to VIR_STRDUP and VIR_STRNDUP in src/xenapi/* 2013-05-23 17:29:49 +02:00
Michal Privoznik
5162a07651 Adapt to VIR_STRDUP and VIR_STRNDUP in src/xen/* 2013-05-23 17:29:49 +02:00
Michal Privoznik
ed2193b16b virNetMessageSaveError: Fix copy and paste error
Previously, we were freeing verr fields instead of rerr which we've
allocated just a line above.
2013-05-23 16:00:56 +02:00
Michal Privoznik
e3d1f6aa7c virNWFilterHashTablePut: Free the correct variable
In bf1fe848 I've introduced 'newName' variable to substitute the old
'const char *name' as previously we had an ugly code there:

  name = strdup(name);

However, some parts of the function were not updated, so they were still
calling VIR_FREE(name) instead of VIR_FREE(newName).
2013-05-23 15:58:41 +02:00
Michal Privoznik
4f3729f812 umlConnectTapDevice: initialize tapfd variable
There is possibility to jump to 'cleanup' label without tapfd variable
being initialized. In the label, VIR_FORCE_CLOSE(tapfd) is called which
can have fatal consequences.
2013-05-23 15:22:35 +02:00
Marek Marczykowski
03d813bbcd remote: fix dom->id after virDomainCreateWithFlags
The same issue as (already fixed) in virDomainCreate -
REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS doesn't return new domain ID, only
-1 on error or 0 on success.

Besides this one fix it is more general problem - local domain object
ID can desynchronize with the real one, for example in case of another
client creates/destroys domain in the meantime. Perhaps virDomainGetID
should be called remotely (with all performance implications...)? Or
some event-based notification used?

Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com>
2013-05-23 15:07:16 +02:00
Osier Yang
4756228247 Fix the build failure
Commit 16251193af forgot to include "virstring.h". Pushed under
build-breaker rule.
2013-05-23 19:58:28 +08:00
Martin Kletzander
0a24028f11 virsh: Fix virDomainFree for NULL domain in blkdeviotune 2013-05-23 13:02:19 +02:00
Michal Privoznik
aaa42912ae Adapt to VIR_STRDUP and VIR_STRNDUP in src/security/* 2013-05-23 09:56:38 +02:00
Michal Privoznik
16251193af Adapt to VIR_STRDUP and VIR_STRNDUP in src/rpc/* 2013-05-23 09:56:38 +02:00
Michal Privoznik
d2846c25bd Adapt to VIR_STRDUP and VIR_STRNDUP in src/remote/* 2013-05-23 09:56:38 +02:00