Commit Graph

15109 Commits

Author SHA1 Message Date
Peter Krempa
630adbe08d domainsnapshotxml2xml: Move files with conflicting names
The new tests that will be added later would collide with files of
existing tests. Move and rename those files.
2013-12-05 09:41:23 +01:00
Peter Krempa
11daad9a24 domainsnapshotxml2xmltest: Allow for better testing of snapshots
Until now the test was only testing redefinition of snapshot XMLs stored
in tests/domainsnapshotxml2xmlout. This patch adds new infrastructure to
allow testing of files that may differ and will allow to utilize files
in tests/domainsnapshotxml2xmlin as new tests too.
2013-12-05 09:41:23 +01:00
Peter Krempa
af75de308f domainsnapshotxml2xmltest: Clean up labels and use bool instead of int
The 'internal' variable holds only two states; convert it to a boolean
and the 'fail' label should be called 'cleanup'. This patch also fixes a
minor memory leak of driver capabilities in case the XML config object
can't be allocated.
2013-12-05 09:40:13 +01:00
Adam Walters
62774afb6b configure: Resolve compile issue in configure.ac
This patch resolves a compile issue caused by the
removal of examples/domsuspend code in commit
5eb4b04211. This issue
is only seen in a fresh checkout, but causes the build
and configure to fail.
2013-12-05 16:06:59 +08:00
Wangyufei (James)
36ae35f02c qemuAgentDispose: Reset lastError
When an error occurred in qemuAgentIO, it will be saved in mon->lastError,
but it will not be freed at the end.  Present since commit c160ce33;
and compare to commit 9cc8a5af fixing the same problem in qemu_monitor.c.

==22219== 54 bytes in 1 blocks are definitely lost in loss record 982 of 1,379
==22219==    at 0x4C26B9B: malloc (vg_replace_malloc.c:263)
==22219==    by 0x8520521: strdup (in /lib64/libc-2.11.3.so)
==22219==    by 0x52E99CB: virStrdup (virstring.c:554)
==22219==    by 0x52B44C4: virCopyError (virerror.c:195)
==22219==    by 0x52B5123: virCopyLastError (virerror.c:312)
==22219==    by 0x10905877: qemuAgentIO (qemu_agent.c:660)
==22219==    by 0x52B6122: virEventPollDispatchHandles (vireventpoll.c:501)
==22219==    by 0x52B7AEA: virEventPollRunOnce (vireventpoll.c:647)
==22219==    by 0x52B5C1B: virEventRunDefaultImpl (virevent.c:274)
==22219==    by 0x54181FD: virNetServerRun (virnetserver.c:1112)
==22219==    by 0x11EF4D: main (libvirtd.c:1513)

Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-12-04 14:43:54 -07:00
Nehal J Wani
f386d323e6 Fix memory leak in qemuBuildDriveStr()
This patch fixes memory leaks reported by valgrind on running
qemuxml2argvtest; introduced in commit 0df53f04.

Most of them are of the form:

==24777== 15 bytes in 1 blocks are definitely lost in loss record 39 of 129
==24777==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==24777==    by 0x341F485E21: strdup (strdup.c:42)
==24777==    by 0x4CADE5F: virStrdup (virstring.c:554)
==24777==    by 0x4362B6: qemuBuildDriveStr (qemu_command.c:3848)
==24777==    by 0x43EF73: qemuBuildCommandLine (qemu_command.c:8500)
==24777==    by 0x426670: testCompareXMLToArgvHelper (qemuxml2argvtest.c:350)
==24777==    by 0x427C01: virtTestRun (testutils.c:138)
==24777==    by 0x41DDB5: mymain (qemuxml2argvtest.c:658)
==24777==    by 0x4282A2: virtTestMain (testutils.c:593)
==24777==    by 0x341F421A04: (below main) (libc-start.c:225)
==24777==

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-12-04 14:23:50 -07:00
Peter Krempa
df36af589f maint: Kill usage of atoi()
Kill the use of atoi() and introduce syntax check to forbid it and it's
friends (atol, atoll, atof, atoq).

Also fix a typo in variable name holding the cylinders count of a disk
pool (apparently unused).

examples/domsuspend/suspend.c will need a larger scale refactor as the
whole example file is broken thus it will be exempted from the syntax
check for now.
2013-12-04 18:56:06 +01:00
Peter Krempa
5eb4b04211 examples: Remove broken bad example
The domsuspend example code is a really old and bad exmample of (how not
to use) the libvirt API. Remove it as it's apparent that nobody tried to
use it. It was broken and nobody complained.
2013-12-04 18:56:06 +01:00
Daniel P. Berrange
d75d8b46f8 Don't overwrite errors from virConfReadFile
The SELinux security driver would overwrite errors from the
virConfReadFile function.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-12-04 15:40:23 +00:00
Michal Privoznik
78839da0bb virThreadPoolFree: Join worker threads
Even though currently we are freeing the pool of worker threads at the
daemon very end, nothing holds us back in joining the worker threads.
Moreover, we avoid leaks like this:

==26697== 1,680 bytes in 5 blocks are possibly lost in loss record 913 of 942
==26697==    at 0x4C2BDE4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==26697==    by 0x4011131: allocate_dtv (in /lib64/ld-2.16.so)
==26697==    by 0x401176D: _dl_allocate_tls (in /lib64/ld-2.16.so)
==26697==    by 0x8499602: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.16.so)
==26697==    by 0x52F53E9: virThreadCreate (virthreadpthread.c:188)
==26697==    by 0x52F5D4F: virThreadPoolNew (virthreadpool.c:221)
==26697==    by 0x53F30DB: virNetServerNew (virnetserver.c:377)
==26697==    by 0x11C6ED: main (libvirtd.c:1366)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-12-04 16:36:46 +01:00
Shivaprasad G Bhat
81fae6b95c qemu: fix live pinning to memory node on NUMA system
Ever since the subcpusets(vcpu,emulator) were introduced, the parent
cpuset cannot be modified to remove the nodes that are in use by the
subcpusets.
The fix is to break the memory node modification into three steps:
 1. assign new nodes into the parent,
 2. change the nodes in the child nodes,
 3. remove the old nodes on the parent node.

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

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2013-12-04 13:32:07 +01:00
John Ferlan
37a02bab1e storage_driver: Resolve Coverity CHECKED_RETURN warning
The storageRegister() didn't check the return from the
virRegisterStorageDriver() like other callers did, so Coverity
flagged it.  Just check the return and handle.
2013-12-04 06:27:20 -05:00
John Ferlan
b17168cbf6 bridge_driver: Resolve Coverity CHECKED_RETURN warning
The networkRegister() didn't check the return status of the
virRegisterNetworkDriver() call like other callers, so just
check and handle here as well.
2013-12-04 06:27:20 -05:00
John Ferlan
950a493ba9 virnetserverclient: Fix conditional change HAVE_SASL to WITH_SASL 2013-12-04 06:27:20 -05:00
John Ferlan
643b5f843d virnetserverclient: Remove Coverity DEADCODE warning
The x509dname is only set inside a WITH_GNUTLS conditional, so
when used/check later on for NULL, Coverity detects this is not
possible.  Added WITH_GNUTLS around uses to remove message
2013-12-04 06:27:19 -05:00
John Ferlan
5a298ec040 nwfilter: Remove Coverity DEADCODE warning
The nwfilterStateInitialize() would only assign sysbus inside
a WITH_DBUS conditional, thus leaving a subsequent check for sysbus
and nwfilterDriverInstallDBusMatches() as a no-op

Rather than try to add WITH_DBUS conditions which ended up conflicting
with the usage of HAVE_FIREWALLD conditionals, just remove the WITH_DBUS
since virdbus.c has entry points for with and without conditions.
2013-12-04 06:27:19 -05:00
Michal Privoznik
2e1ced5794 src: Align make output
The make inserts six spaces instead of four:

  GEN      access/viraccessapichecklxc.h
  GEN    hyperv/hyperv_wmi.generated.h
  GEN      access/viraccessapichecklxc.c
  GEN    hyperv/hyperv_wmi.generated.c
  GEN    hyperv/hyperv_wmi_classes.generated.typedef
  GEN    hyperv/hyperv_wmi_classes.generated.h
  GEN    hyperv/hyperv_wmi_classes.generated.c
  GEN      libvirt_access_qemu.xml
  GEN      libvirt_access.syms
  GEN      libvirt_access_lxc.xml
  GEN      libvirt_access_qemu.syms
  GEN      libvirt_access_lxc.syms
  GEN      libvirt_qemu.def
  GEN    esx/esx_vi_types.generated.typedef
  GEN    esx/esx_vi_types.generated.typeenum
  GEN    esx/esx_vi_types.generated.typetostring
  GEN    esx/esx_vi_types.generated.typefromstring
  GEN    esx/esx_vi_types.generated.h
  GEN    esx/esx_vi_types.generated.c
  GEN    esx/esx_vi_methods.generated.h
  GEN    esx/esx_vi_methods.generated.c
  GEN    esx/esx_vi_methods.generated.macro
  GEN    esx/esx_vi.generated.h
  GEN    esx/esx_vi.generated.c
  GEN      libvirt_lxc.def

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-12-04 09:41:33 +01:00
Laine Stump
5e12641e0e qemu: report error on attempt to live change virtio-net queues
This resolves:

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

The BZ asked for the capability to change the number of queues used by
a virtio-net device while the device is in use. Because the number of
queues can only be set at the time the device is created, that isn't
possible. However, libvirt also shouldn't be silently reporting
success when someone tries to change the number of queues. So this
patch flags that as an error (just as attempts to change any of the
other virtio-specific parameters already do).
2013-12-03 16:50:59 +02:00
Michal Privoznik
a602e90bc1 daemon: Run virStateCleanup conditionally
https://bugzilla.redhat.com/show_bug.cgi?id=1033061

Currently, initialization of drivers is done in a separate thread. This
is done for several reasons: a driver that is initialized may require
running event loop, it may take ages to initialize driver (e.g. due to
autostarting domains). While the thread is spawn and run, the main()
continues its execution. However, if something goes bad, or the event
loop is just exited (e.g. due to a --timeout or SIGINT) we try to
cleanup all the drivers. So we have two threads running Initialize() and
Cleanup() concurrently. This may result in accessing stale pointers -
e.g. netcf driver will free() itself in stateCleanup callback, while the
init thread may come, open a dummy connection in order to autostart some
domains and voilà: do_open() iterates over interface drivers and
accesses stale netcf driver.

The fix consists in not running stateCleanup if the init thread is still
running.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-12-03 14:32:08 +01:00
Laine Stump
9f6f2fa467 tests: add forgotten boot-strict test files
These *should* have been pushed in commit
96fddee322.
2013-12-03 12:58:50 +02:00
Laine Stump
96fddee322 qemu: add "-boot strict" to commandline whenever possible
This resolves:

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

(which was already closed as CANTFIX because the qemu "-boot strict"
commandline option wasn't available at the time).

Problem: you couldn't have a domain that used PXE to boot, but also
had an un-bootable disk device *even if that disk wasn't listed in the
boot order*, because if PXE timed out (e.g. due to the bridge
forwarding delay), the BIOS would move on to the next target, which
would be the unbootable disk device (again - even though it wasn't
given a boot order), and get stuck at a "BOOT DISK FAILURE, PRESS ANY
KEY" message until a user intervened.

The solution available since sometime around QEMU 1.5, is to add
"-boot strict=on" to *every* qemu command. When this is done, if any
devices have a boot order specified, then QEMU will *only* attempt to
boot from those devices that have an explicit boot order, ignoring the
rest.
2013-12-03 11:58:26 +02:00
Laine Stump
47b9aae0ae qemu: default to vfio for nodedev-detach
This patch resolves:

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

Commit f094aaac48 changed the PCI device assignment in qemu domains
to default to using VFIO rather than legacy KVM device assignment
(when VFIO is available). It didn't change which driver was used by
default for virNodeDeviceDetachFlags(), though, so that API (and the
virsh nodedev-detach command) was still binding to the pci-stub
driver, used by legacy KVM assignment, by default.

This patch publicizes (only within the qemu module, though, so no
additions to the symbol exports are needed) the functions that check
for presence of KVM and VFIO device assignment, then uses those
functions to decide what to do when no driver is specified for
virNodeDeviceDetachFlags(); if the vfio driver is loaded, the device
will be bound to vfio-pci, or if legacy KVM assignment is supported on
this system, the device will be bound to pci-stub; if neither method
is available, the detach will fail.
2013-12-03 11:58:26 +02:00
Peter Krempa
26fb96d8c0 qemu: snapshots: Declare supported and unsupported snapshot configs
Currently the snapshot code did not check if it actually supports
snapshots on various disk backends for domains. To avoid future problems
add checkers that whitelist the supported configurations.
2013-12-03 10:41:05 +01:00
Peter Krempa
bdeb0f0123 qemu: Clear old translated pool source
Clear the old data to avoid leaking it when attempting to re-translate a
pool on the same domain object.
2013-12-03 10:38:40 +01:00
Peter Krempa
0df53f0432 qemu: Refactor disk source string formatting
This patch adds function qemuGetDriveSourceString to produce
qemu-compatible disk source strings that will enable to reuse the code
and refactors building of the qemu commandline of disks to use this new
helper.
2013-12-03 10:36:12 +01:00
Peter Krempa
b384e2b4d7 qemu: Unify formatting of RBD sources 2013-12-03 10:31:19 +01:00
Peter Krempa
d94fd0c9c2 qemu: Split out NBD command generation 2013-12-03 10:28:57 +01:00
Peter Krempa
eaa1539b2f qemu: Migrate sheepdog source generation into common function 2013-12-03 10:27:11 +01:00
Peter Krempa
078a102537 qemu: Use qemuBuildNetworkDriveURI to handle http/ftp and friends
Prepare the function to integrate other protocols and start folding
other network protocols into a common place.
2013-12-03 10:25:11 +01:00
Peter Krempa
927ddae197 qemu: Simplify call pattern of qemuBuildDriveURIString
Automatically assign secret type from the disk source definition and
pull in adding of the comma. Then update callers to keep generated
output the same.
2013-12-03 10:23:16 +01:00
Peter Krempa
a29d33ffcb qemu: Split out formatting of network disk source URI
The snapshot code will need to use qemu-style formatted URIs of network
disks. Split out the code to avoid duplication.
2013-12-03 10:19:30 +01:00
Peter Krempa
e1a4d08baf qemu: Refactor qemuTranslateDiskSourcePool
Before this patch, the translation function still needs a second ugly
helper function to actually format the command line for qemu. But if we
do the right stuff in the translation function, we don't have to bother
with the second function any more.

This patch removes the messy qemuBuildVolumeString function and changes
qemuTranslateDiskSourcePool to set stuff up correctly so that the
regular code paths meant for volumes can be used to format the command
line correctly.

For this purpose a new helper "qemuDiskGetActualType()" is introduced to
return the type of the volume in a pool.

As a part of the refactor the qemuTranslateDiskSourcePool function is
fixed to do decisions based on the pool type instead of the volume type.
This allows to separate pool-type-specific stuff more clearly and will
ease addition of other pool types that will require certain other
operations to get the correct pool source.

The previously fixed tests should make sure that we don't break stuff
that was working before.
2013-12-03 10:16:12 +01:00
Osier Yang
ec2fb767bb Doc: Explicitly declaring that nodedev-destroy only works for vHBA
Though trying to destroy a physical HBA doesn't make sense at all,
it's still a bit misleading with saying "only works for HBA".

Signed-off-by: Osier Yang <jyang@redhat.com>
2013-12-03 16:34:46 +08:00
Eric Blake
aaa7484097 virsh: improve grammar in error message
Based on a suggestion from Mauricio Tavares.

* tools/virsh-domain.c (cmdDetachInterface, vshFindDisk): Improve
wording.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-12-02 14:40:15 -07:00
Eric Blake
00b019b5ad docs: fix some typos
* docs/auditlog.html.in: Spelling fixes.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-12-02 11:59:18 -07:00
Eric Blake
99f7b63568 docs: fix typo in previous patch
Avoid a nested comment compilation error, caused by me editing
Chen's patch.

* include/libvirt/libvirt.h.in: Fix typo.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-12-02 11:27:37 -07:00
Daniel P. Berrange
4cac241a7b Ensure to zero out the virDomainBlockJobInfo arg
The virDomainGetBlockJobInfo method did not zero out the
virDomainBlockJobInfo pointer arg, so when block jobs were
not active it would return garbage for the bandwidth/cur/end
fields.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-12-02 17:34:57 +00:00
Chen Hanxiao
c268af2e9a docs: fix typos in libvirt.h.in
s/causes/cause/

Each event callback has a single detail parameter, and can
thus only report a single cause.  Also, make all the sub-event
documentation use similar wording.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-12-02 10:11:11 -07:00
Peter Krempa
7e6242e9a7 qemu: snapshot: Add functions similar to disk source pool translation
To avoid future pain, add placeholder functions to get the actual
snapshot disk type.
2013-12-02 14:43:13 +01:00
Peter Krempa
cdf02d6474 qemu: snapshot: Touch up error message 2013-12-02 14:43:07 +01:00
Peter Krempa
0018477fb2 conf: Add helper do clear disk source authentication struct
Add virDomainDiskAuthClear to help cleaning out the struct in other
places too.
2013-12-02 14:31:03 +01:00
Peter Krempa
d8cf91ae38 qemu: snapshot: Detect internal snapshots also for sheepdog and RBD
When doing an internal snapshot on a VM with sheepdog or RBD disks we
would not set a flag to mark the domain is using internal snapshots and
might end up creating a mixed snapshot. Move the setting of the variable
to avoid this problem.
2013-12-02 14:31:03 +01:00
Peter Krempa
ae361674ac conf: Add functions to copy and free network disk source definitions
To simplify operations on virDomainDiskHostDef arrays we will need deep
copy and freeing functions. Add and properly export them.
2013-12-02 14:31:03 +01:00
Peter Krempa
5a66c667ff snapshot: conf: Fix NULL dereference when <driver> element is empty
Consider the following valid snapshot XML as the <driver> element is
allowed to be empty in the domainsnapshot.rng schema:

$ cat snap.xml
<domainsnapshot>
  <disks>
    <disk name='vda' snapshot='external'>
      <source file='/tmp/foo'/>
      <driver/>
    </disk>
  </disks>
</domainsnapshot>

produces the following error:

$ virsh snapshot-create domain snap.xml
error: internal error: unknown disk snapshot driver '(null)'

The driver type is parsed as NULL from the XML as the attribute is not
present and then directly used to produce the error message.

With this patch the attempt to parse the driver type is skipped if not
present to avoid changing the schema to forbid the empty driver element.
2013-12-02 14:31:02 +01:00
Peter Krempa
43f2ccdc73 snapshot: conf: Use common parsing and formatting functions for source
Disk source elements for snapshots were using separate code from our
config parser. As snapshots can be stored on more than just regular
files, we will need the universal parser to allow us to expose a variety
of snapshot disk targets. This patch reuses the config parsers and
formatters to do the job.

This initial support only changes the code without any visible XML
change.
2013-12-02 14:28:20 +01:00
Peter Krempa
5f86d11e4a conf: Export disk source formatter and parser
This code will be reused in the snapshot disk definition parser.
2013-12-02 14:02:27 +01:00
Peter Krempa
30f7ca67d9 conf: Split out seclabel formating code for disk source
The code is common for all the various disk types. Split it out to a
common function.
2013-12-02 14:02:27 +01:00
Peter Krempa
03ad83cb5a conf: Clean up virDomainDiskSourceDefFormatInternal
Avoid if statements when used with virBufferEscapeString which
automaticaly omits the whole string. Also add some line breaks to
visualy separate the code.
2013-12-02 14:02:27 +01:00
Peter Krempa
d6b4c2cca9 conf: Support disk source formatting without needing a virDomainDiskDefPtr
The <source> element formatting function was expecting a
virDomainDiskDefPtr to store the data. As snapshots are not using this
data structure to hold the data, we need to add an internal function
which splits out individual fields separately.
2013-12-02 14:02:26 +01:00
Peter Krempa
436fa772fb tests: Fix comment for fake storage pool driver
Commit bae124e40f was accidentaly pushed
without review feedback worked in. Fix it up.
2013-12-02 13:36:09 +01:00