]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agomaint: Add test output files to .gitignore
Peter Krempa [Mon, 6 Feb 2012 17:27:40 +0000 (18:27 +0100)]
maint: Add test output files to .gitignore

Commit 8f00276c8a6140cec6a6d50441c802981d329c0c consolidated other
.gitignore files to the master one, but forgot to add some test output
files.

13 years agoUpdate myself in AUTHORS
Alex Jia [Mon, 6 Feb 2012 10:33:57 +0000 (18:33 +0800)]
Update myself in AUTHORS

Move myself from 'Previous maintainers' section to 'the primary maintainers and
people with commit access rights' section, because I have a commit rights now.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agovirsh: Fix resource leak while listing inactive domains with titles
Peter Krempa [Mon, 6 Feb 2012 14:25:05 +0000 (15:25 +0100)]
virsh: Fix resource leak while listing inactive domains with titles

Commit fad5cd210899dfde4afe36712754dc921c3f3051 introduces a new flag
that allows to show domain's title with domains. This commit introduced
resource leak while listing inactive domains with titles.

13 years agoxen_xm: Fix SIGSEGV in xenXMDomainDefineXML
Philipp Hahn [Mon, 6 Feb 2012 11:50:47 +0000 (12:50 +0100)]
xen_xm: Fix SIGSEGV in xenXMDomainDefineXML

On CentOS5 with xen-3.0.3:

 Program received signal SIGSEGV, Segmentation fault.
 virFree (ptrptr=0x8) at util/memory.c:310
 310         free(*(void**)ptrptr);
 (gdb) bt
 #0  virFree (ptrptr=0x8) at util/memory.c:310
 #1  0x00002aaaaae167c8 in xenXMDomainDefineXML (conn=0x694e80, xml=0x6b2ce0 "P\fk") at xen/xm_internal.c:1199
 #2  0x00002aaaaae070d7 in xenUnifiedDomainDefineXML (conn=0x8,
     xml=0x6ac040 "<domain type='xen'>\n  <name>pv</name>\n  <uuid>20291bc0-453a-4d6c-c6ac-4e5af63b932c</uuid>\n  <memory>1048576</memory>\n  <currentMemory>1048576</currentMemory>\n  <vcpu>1</vcpu>\n  <os>\n    <type arch='x8"...) at xen/xen_driver.c:1524
 #3  0x00002aaaaada7803 in virDomainDefineXML (conn=0x694e80,
     xml=0x6ac040 "<domain type='xen'>\n  <name>pv</name>\n  <uuid>20291bc0-453a-4d6c-c6ac-4e5af63b932c</uuid>\n  <memory>1048576</memory>\n  <currentMemory>1048576</currentMemory>\n  <vcpu>1</vcpu>\n  <os>\n    <type arch='x8"...) at libvirt.c:7823
 #4  0x0000000000426173 in cmdEdit (ctl=0x7fffffffb8e0, cmd=<value optimized out>) at virsh.c:14882
 #5  0x000000000041c9ce in vshCommandRun (ctl=0x7fffffffb8e0, cmd=0x658c50) at virsh.c:17712
 #6  0x000000000042c3b9 in main (argc=1, argv=<value optimized out>) at virsh.c:19317

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agodocs: Enhance documentation of the old-style boot configuration
Jiri Denemark [Fri, 3 Feb 2012 12:33:36 +0000 (13:33 +0100)]
docs: Enhance documentation of the old-style boot configuration

Also encourages people to use per-device boot elements for better
control.

13 years agoqemu: Fix seamless spice migration
Jiri Denemark [Thu, 2 Feb 2012 15:34:08 +0000 (16:34 +0100)]
qemu: Fix seamless spice migration

Calling qemuDomainMigrateGraphicsRelocate notifies spice clients to
connect to destination qemu so that they can seamlessly switch streams
once migration is done. Unfortunately, current qemu is not able to
accept any connections while incoming migration connection is open.
Thus, we need to delay opening the migration connection to the point
spice client is already connected to the destination qemu.

13 years agotests: Fix build with -Werror
Jiri Denemark [Mon, 6 Feb 2012 08:35:47 +0000 (09:35 +0100)]
tests: Fix build with -Werror

13 years agoapparmor: Add missing comma
Jiri Denemark [Mon, 6 Feb 2012 08:22:46 +0000 (09:22 +0100)]
apparmor: Add missing comma

Typo introduced by c18a88ac

13 years agovirsh: Avoid invalid read of size errors
Alex Jia [Mon, 6 Feb 2012 03:39:41 +0000 (11:39 +0800)]
virsh: Avoid invalid read of size errors

Detected by valgrind. the codes are allocating 0 bytes memory to variable
cpumap by vshCalloc function, and then the function VIR_USE_CPU will access
it later, a invalid read error will be hit.

* tools/virsh.c(cmdVcpuPin): fix invalid read error.

* How to reproduce?
% valgrind -v --read-var-info=yes virsh vcpupin <domain> 0 0

* Actual result:

==27271== ERROR SUMMARY: 5 errors from 2 contexts (suppressed: 8 from 6)
==27271==
==27271== 1 errors in context 1 of 2:
==27271== Invalid read of size 1
==27271==    at 0x39CF087E2E: __GI_memcpy (in /lib64/libc-2.12.so)
==27271==    by 0x39CF114FDC: xdrmem_putbytes (in /lib64/libc-2.12.so)
==27271==    by 0x39CF114707: xdr_opaque (in /lib64/libc-2.12.so)
==27271==    by 0x4D56194: xdr_remote_domain_pin_vcpu_args (remote_protocol.c:1844)
==27271==    by 0x4D6CCE1: virNetMessageEncodePayload (virnetmessage.c:341)
==27271==    by 0x4D5A44B: virNetClientProgramCall (virnetclientprogram.c:327)
==27271==    by 0x4D36EDB: callWithFD (remote_driver.c:4546)
==27271==    by 0x4D36F7B: call (remote_driver.c:4567)
==27271==    by 0x4D3B2C1: remoteDomainPinVcpu (remote_client_bodies.h:1566)
==27271==    by 0x4D199D3: virDomainPinVcpu (libvirt.c:8585)
==27271==    by 0x4241F4: cmdVcpuPin (virsh.c:5262)
==27271==    by 0x4150A6: vshCommandRun (virsh.c:17712)
==27271==  Address 0x5602b80 is 0 bytes after a block of size 0 alloc'd
==27271==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==27271==    by 0x4C89BDF: virAllocN (memory.c:129)
==27271==    by 0x423868: _vshCalloc.clone.2 (virsh.c:454)
==27271==    by 0x423EF9: cmdVcpuPin (virsh.c:5190)
==27271==    by 0x4150A6: vshCommandRun (virsh.c:17712)
==27271==    by 0x426583: main (virsh.c:19289)
==27271==
==27271==
==27271== 4 errors in context 2 of 2:
==27271== Invalid read of size 1
==27271==    at 0x424133: cmdVcpuPin (virsh.c:5245)
==27271==    by 0x4150A6: vshCommandRun (virsh.c:17712)
==27271==    by 0x426583: main (virsh.c:19289)
==27271==  Address 0x5602b80 is 0 bytes after a block of size 0 alloc'd
==27271==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==27271==    by 0x4C89BDF: virAllocN (memory.c:129)
==27271==    by 0x423868: _vshCalloc.clone.2 (virsh.c:454)
==27271==    by 0x423EF9: cmdVcpuPin (virsh.c:5190)
==27271==    by 0x4150A6: vshCommandRun (virsh.c:17712)
==27271==    by 0x426583: main (virsh.c:19289)

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agomaint: consolidate several .gitignore files
Eric Blake [Fri, 3 Feb 2012 21:30:06 +0000 (14:30 -0700)]
maint: consolidate several .gitignore files

Unlike .cvsignore under CVS, git allows for ignoring nested
names.  We weren't very consistent where new tests were
being ignored (some in .gitignore, some in tests/.gitignore),
and I found it easier to just consolidate everything.

* .gitignore: Subsume entries from subdirectories.
* daemon/.gitignore: Delete.
* docs/.gitignore: Likewise.
* docs/devhelp/.gitignore: Likewise.
* docs/html/.gitignore: Likewise.
* examples/dominfo/.gitignore: Likewise.
* examples/domsuspend/.gitignore: Likewise.
* examples/hellolibvirt/.gitignore: Likewise.
* examples/openauth/.gitignore: Likewise.
* examples/domain-events/events-c/.gitignore: Likewise.
* include/libvirt/.gitignore: Likewise.
* src/.gitignore: Likewise.
* src/esx/.gitignore: Likewise.
* tests/.gitignore: Likewise.
* tools/.gitignore: Likewise.

13 years agoqemu: eliminate "Ignoring open failure" when using root-squash NFS
Laine Stump [Thu, 12 Jan 2012 18:24:45 +0000 (13:24 -0500)]
qemu: eliminate "Ignoring open failure" when using root-squash NFS

This eliminates the warning message reported in:

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

It was caused by a failure to open an image file that is not
accessible by root (the uid libvirtd is running as) because it's on a
root-squash NFS share, owned by a different user, with permissions of
660 (or maybe 600).

The solution is to use virFileOpenAs() rather than open(). The
codepath that generates the error is during qemuSetupDiskCGroup(), but
the actual open() is in a lower-level generic function called from
many places (virDomainDiskDefForeachPath), so some other pieces of the
code were touched just to add dummy (or possibly useful) uid and gid
arguments.

Eliminating this warning message has the nice side effect that the
requested operation may even succeed (which in this case isn't
necessary, but shouldn't hurt anything either).

13 years agoutil: refactor virFileOpenAs
Laine Stump [Fri, 13 Jan 2012 20:26:45 +0000 (15:26 -0500)]
util: refactor virFileOpenAs

virFileOpenAs previously would only try opening a file as the current
user, or as a different user, but wouldn't try both methods in a
single call. This made it cumbersome to use as a replacement for
open(2). Additionally, it had a lot of historical baggage that led to
it being difficult to understand.

This patch refactors virFileOpenAs in the following ways:

* reorganize the code so that everything dealing with both the parent
  and child sides of the "fork+setuid+setgid+open" method are in a
  separate function. This makes the public function easier to understand.

* Allow a single call to virFileOpenAs() to first attempt the open as
  the current user, and if that fails to automatically re-try after
  doing fork+setuid (if deemed appropriate, i.e. errno indicates it
  would now be successful, and the file is on a networkFS). This makes
  it possible (in many, but possibly not all, cases) to drop-in
  virFileOpenAs() as a replacement for open(2).

  (NB: currently qemuOpenFile() calls virFileOpenAs() twice, once
  without forking, then again with forking. That unfortunately can't
  be changed without at least some discussion of the ramifications,
  because the requested file permissions are different in each case,
  which is something that a single call to virFileOpenAs() can't deal
  with.)

* Add a flag so that any fchown() of the file to a different uid:gid
  is explicitly requested when the function is called, rather than it
  being implied by the presence of the O_CREAT flag. This just makes
  for less subtle surprises to consumers. (Commit
  b1643dc15c5de886fefe56ad18608d65f1325a2c added the check for O_CREAT
  before forcing ownership. This patch just makes that restriction
  more explicit.)

* If either the uid or gid is specified as "-1", virFileOpenAs will
  interpret this to mean "the current [gu]id".

All current consumers of virFileOpenAs should retain their present
behavior (after a few minor changes to their setup code and
arguments).

13 years agoutil: rename netlink.[ch] to virnetlink.[ch]
D. Herrendoerfer [Fri, 3 Feb 2012 14:13:19 +0000 (15:13 +0100)]
util: rename netlink.[ch] to virnetlink.[ch]

Rename the src/util/netlink files to src/util/virnetlink to
better fit the naming scheme. Also rename nlComm to virNetlinkCommand.

Signed-off-by: D. Herrendoerfer <d.herrendoerfer@herrendoerfer.name>
13 years agovirsh: add --graceful switch to destroy command
Laine Stump [Fri, 3 Feb 2012 19:14:36 +0000 (14:14 -0500)]
virsh: add --graceful switch to destroy command

This allows virsh to use the new VIR_DOMAIN_DESTROY_GRACEUL flag for
virDomainDestroyFlags.

13 years agoqemu: new GRACEFUL flag for virDomainDestroy w/ QEMU support
Laine Stump [Fri, 27 Jan 2012 18:28:23 +0000 (13:28 -0500)]
qemu: new GRACEFUL flag for virDomainDestroy w/ QEMU support

When libvirt's virDomainDestroy API is shutting down the qemu process,
it first sends SIGTERM, then waits for 1.6 seconds and, if it sees the
process still there, sends a SIGKILL.

There have been reports that this behavior can lead to data loss
because the guest running in qemu doesn't have time to flush its disk
cache buffers before it's unceremoniously whacked.

This patch maintains that default behavior, but provides a new flag
VIR_DOMAIN_DESTROY_GRACEFUL to alter the behavior. If this flag is set
in the call to virDomainDestroyFlags, SIGKILL will never be sent to
the qemu process; instead, if the timeout is reached and the qemu
process still exists, virDomainDestroy will return an error.

Once this patch is in, the recommended method for applications to call
virDomainDestroyFlags will be with VIR_DOMAIN_DESTROY_GRACEFUL
included. If that fails, then the application can decide if and when
to call virDomainDestroyFlags again without
VIR_DOMAIN_DESTROY_GRACEFUL (to force the issue with SIGKILL).

(Note that this does not address the issue of existing applications
that have not yet been modified to use VIR_DOMAIN_DESTROY_GRACEFUL.
That is a separate patch.)

13 years agovirterror.c: Fix several spelling mistakes
Philipp Hahn [Fri, 3 Feb 2012 18:20:22 +0000 (19:20 +0100)]
virterror.c: Fix several spelling mistakes

compat{a->i}bility
erron{->e}ous
nec{c->}essary.
Either "the" or "a".

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoAdded missing memory reporting into python bindings
Martin Kletzander [Fri, 3 Feb 2012 14:53:06 +0000 (15:53 +0100)]
Added missing memory reporting into python bindings

Two types of memory stats were not reported by python bindings. This
patch fixes both of them.

13 years agopython: use libvirt_util to avoid raw free
Eric Blake [Thu, 2 Feb 2012 22:45:54 +0000 (15:45 -0700)]
python: use libvirt_util to avoid raw free

This patch starts the process of elevating the python binding code
to be on the same level as the rest of libvirt when it comes to
requiring good coding styles.  Statically linking against the
libvirt_util library makes it much easier to write good code,
rather than having to open-code and reinvent things locally.

Done by global search and replace of s/free(/VIR_FREE(/, followed
by hand-inspection of remaining malloc and redundant memset.

* cfg.mk (exclude_file_name_regexp--sc_prohibit_raw_allocation):
Remove python from exemption.
* python/Makefile.am (INCLUDES): Add gnulib and src/util.  Drop
$(top_builddir)/$(subdir), as automake already guarantees that.
(mylibs, myqemulibs): Pull in libvirt_util and gnulib.
(libvirtmod_la_CFLAGS): Catch compiler warnings if configured to
use -Werror.
* python/typewrappers.c (libvirt_charPtrSizeWrap)
(libvirt_charPtrWrap): Convert free to VIR_FREE.
* python/generator.py (print_function_wrapper): Likewise.
* python/libvirt-override.c: Likewise.

13 years agobuild: expand rule to cover testsuite
Eric Blake [Thu, 2 Feb 2012 23:16:43 +0000 (16:16 -0700)]
build: expand rule to cover testsuite

The bulk of this patch was done with:

sed -i 's/\(\bfree *(/VIR_FREE(/g' tests/*.c

followed by fixing the few compile errors that resulted.

* cfg.mk (exclude_file_name_regexp--sc_prohibit_raw_allocation):
Remove tests from exemption.
* tests/testutils.h: Add common header.
* tests/commandhelper.c: Fix offenders.
* tests/cputest.c: Likewise.
* tests/domainsnapshotxml2xmltest.c: Likewise.
* tests/interfacexml2xmltest.c: Likewise.
* tests/networkxml2argvtest.c: Likewise.
* tests/networkxml2xmltest.c: Likewise.
* tests/nodedevxml2xmltest.c: Likewise.
* tests/nodeinfotest.c: Likewise.
* tests/nwfilterxml2xmltest.c: Likewise.
* tests/qemuargv2xmltest.c: Likewise.
* tests/qemuxml2argvtest.c: Likewise.
* tests/qemuxml2xmltest.c: Likewise.
* tests/qemuxmlnstest.c: Likewise.
* tests/qparamtest.c: Likewise.
* tests/sexpr2xmltest.c: Likewise.
* tests/storagepoolxml2xmltest.c: Likewise.
* tests/storagevolxml2xmltest.c: Likewise.
* tests/testutils.c: Likewise.
* tests/virshtest.c: Likewise.
* tests/xencapstest.c: Likewise.
* tests/xmconfigtest.c: Likewise.
* tests/xml2sexprtest.c: Likewise.

13 years agobuild: prohibit raw malloc and free
Eric Blake [Thu, 2 Feb 2012 22:47:04 +0000 (15:47 -0700)]
build: prohibit raw malloc and free

Our HACKING discourages use of malloc and free, for at least
a couple of years now.  But we weren't enforcing it, until now :)

For now, I've exempted python and tests, and will clean those up
in subsequent patches.  Examples should be permanently exempt,
since anyone copying our examples won't have use of our
internal-only memory.h via libvirt_util.la.

* cfg.mk (sc_prohibit_raw_allocation): New rule.
(exclude_file_name_regexp--sc_prohibit_raw_allocation): and
exemptions.
* src/cpu/cpu.c (cpuDataFree): Avoid false positive.
* src/conf/network_conf.c (virNetworkDNSSrvDefParseXML): Fix
offenders.
* src/libxl/libxl_conf.c (libxlMakeDomBuildInfo, libxlMakeVfb)
(libxlMakeDeviceModelInfo): Likewise.
* src/rpc/virnetmessage.c (virNetMessageSaveError): Likewise.
* tools/virsh.c (_vshMalloc, _vshCalloc): Likewise.

13 years agopython: drop redundant function
Eric Blake [Thu, 2 Feb 2012 23:28:26 +0000 (16:28 -0700)]
python: drop redundant function

I noticed some redundant code while preparing my next patch.

* python/generator.py (py_types): Fix 'const char *' mapping.
* python/typewrappers.h (libvirt_charPtrConstWrap): Drop.
* python/typewrappers.c (libvirt_charPtrConstWrap): Delete, since
it is identical to libvirt_constcharPtrWrap.

13 years agobuild: clean up CPPFLAGS/INCLUDES usage
Eric Blake [Thu, 2 Feb 2012 20:20:09 +0000 (13:20 -0700)]
build: clean up CPPFLAGS/INCLUDES usage

Our syntax checker missed all-lower-case variables (this will
be fixed by the next .gnulib update).  Additionally, anywhere
that we mix in-tree files with generated files, automake recommends
listing builddir prior to srcdir for VPATH builds.

* src/Makefile.am (*_la_CFLAGS): Favor $(top_srcdir).
(INCLUDES): Likewise, and follow automake recommendations on
builddir before srcdir.
* python/Makefile.am (INCLUDES): Swap directory order.
* tests/Makefile.am (INCLUDES): Likewise.
* tools/Makefile.am (INCLUDES): Likewise.
* daemon/Makefile.am (INCLUDES): Likewise.
(libvirtd.init, libvirtd.service): Favor $().
* examples/hellolibvirt/Makefile.am (hellolibvirt_LDADD):
Likewise.
* examples/openauth/Makefile.am (openauth_LDADD): Likewise.
* examples/dominfo/Makefile.am (INCLUDES): Drop dead include.
* examples/domsuspend/Makefile.am (INCLUDES): Likewise.

13 years agocommand: allow merging stdout and stderr in string capture
Eric Blake [Fri, 27 Jan 2012 22:40:20 +0000 (15:40 -0700)]
command: allow merging stdout and stderr in string capture

Sometimes, its easier to run children with 2>&1 in shell notation,
and just deal with stdout and stderr interleaved.  This was already
possible for fd handling; extend it to also work when doing string
capture of a child process.

* docs/internals/command.html.in: Document this.
* src/util/command.c (virCommandSetErrorBuffer): Likewise.
(virCommandRun, virExecWithHook): Implement it.
* tests/commandtest.c (test14): Test it.
* daemon/remote.c (remoteDispatchAuthPolkit): Use new command
feature.

13 years agomaint: prune duplicate listings in AUTHORS
Eric Blake [Fri, 3 Feb 2012 16:56:45 +0000 (09:56 -0700)]
maint: prune duplicate listings in AUTHORS

* AUTHORS: Remove duplicates.
* .mailmap: Update accordingly.

13 years agovirsh: extension of virsh attach-disk for rawio
Taku Izumi [Fri, 3 Feb 2012 04:33:13 +0000 (13:33 +0900)]
virsh: extension of virsh attach-disk for rawio

This patch extends "virsh attach-disk" command so that
we can specify "rawio" attribute.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agoFixed connection definition for non-SELinux builds
Martin Kletzander [Fri, 3 Feb 2012 15:03:18 +0000 (16:03 +0100)]
Fixed connection definition for non-SELinux builds

This patch fixes the access of variable "con" in two files where the
variable was declared only on SELinux builds and thus the build failed
without SELinux. It's a rather nasty fix but helps fix the build
quickly and without any major changes to the code.

13 years agoAdded RSS reporting
Martin Kletzander [Tue, 24 Jan 2012 13:25:05 +0000 (14:25 +0100)]
Added RSS reporting

Added RSS information gathering into qemuMemoryStats into qemu driver
and the reporting into virsh dommemstat.

13 years agoAdded RSS information gathering into qemudGetProcessInfo
Martin Kletzander [Tue, 24 Jan 2012 13:25:04 +0000 (14:25 +0100)]
Added RSS information gathering into qemudGetProcessInfo

One more parameter added into the function parsing /proc/<pid>/stat
and the call of the function is fixed as well.

13 years agoReplace TAB with white spaces
Osier Yang [Fri, 3 Feb 2012 10:32:59 +0000 (18:32 +0800)]
Replace TAB with white spaces

13 years agolxc: Fix build with AppArmor
Jiri Denemark [Fri, 3 Feb 2012 09:49:31 +0000 (10:49 +0100)]
lxc: Fix build with AppArmor

13 years agoconf: Plug memory on virDomainDiskDefParseXML
Alex Jia [Fri, 3 Feb 2012 08:42:22 +0000 (16:42 +0800)]
conf: Plug memory on virDomainDiskDefParseXML

Detected by valgrind. Leak is introduced in commit 397e6a7.

* src/conf/domain_conf.c(virDomainDiskDefParseXML): fix memory leak.

How to reproduce?
% make -C tests check TESTS=qemuxml2argvtest
% cd tests && valgrind -v --leak-check=full ./qemuxml2argvtest

* Actual result:

==16352== 4 bytes in 1 blocks are definitely lost in loss record 12 of 147
==16352==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==16352==    by 0x39D90A67DD: xmlStrndup (xmlstring.c:45)
==16352==    by 0x4E83D5: virDomainDiskDefParseXML (domain_conf.c:2894)
==16352==    by 0x4F542D: virDomainDefParseXML (domain_conf.c:7626)
==16352==    by 0x4F8683: virDomainDefParseNode (domain_conf.c:8390)
==16352==    by 0x4F904E: virDomainDefParse (domain_conf.c:8340)
==16352==    by 0x41C626: testCompareXMLToArgvHelper (qemuxml2argvtest.c:105)
==16352==    by 0x41DED1: virtTestRun (testutils.c:142)
==16352==    by 0x418172: mymain (qemuxml2argvtest.c:486)
==16352==    by 0x41D5C7: virtTestMain (testutils.c:697)
==16352==    by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoSet a security context on /dev and /dev/pts mounts
Daniel P. Berrange [Wed, 25 Jan 2012 14:12:54 +0000 (14:12 +0000)]
Set a security context on /dev and /dev/pts mounts

To allow the container to access /dev and /dev/pts when under
sVirt, set an explicit mount option. Also set a max size on
the /dev mount to prevent DOS on memory usage

* src/lxc/lxc_container.c: Set /dev mount context
* src/lxc/lxc_controller.c: Set /dev/pts mount context

13 years agoAdd support for sVirt in the LXC driver
Daniel P. Berrange [Wed, 25 Jan 2012 14:12:53 +0000 (14:12 +0000)]
Add support for sVirt in the LXC driver

For the sake of backwards compat, LXC guests are *not*
confined by default. This is because it is not practical
to dynamically relabel containers using large filesystem
trees. Applications can create confined containers though,
by giving suitable XML configs

* src/Makefile.am: Link libvirt_lxc to security drivers
* src/lxc/libvirtd_lxc.aug, src/lxc/lxc_conf.h,
  src/lxc/lxc_conf.c, src/lxc/lxc.conf,
  src/lxc/test_libvirtd_lxc.aug: Config file handling for
  security driver
* src/lxc/lxc_driver.c: Wire up security driver functions
* src/lxc/lxc_controller.c: Add a '--security' flag to
  specify which security driver to activate
* src/lxc/lxc_container.c, src/lxc/lxc_container.h: Set
  the process label just before exec'ing init.

13 years agoAdd two new security label types
Daniel P. Berrange [Wed, 25 Jan 2012 14:12:52 +0000 (14:12 +0000)]
Add two new security label types

Curently security labels can be of type 'dynamic' or 'static'.
If no security label is given, then 'dynamic' is assumed. The
current code takes advantage of this default, and avoids even
saving <seclabel> elements with type='dynamic' to disk. This
means if you temporarily change security driver, the guests
can all still start.

With the introduction of sVirt to LXC though, there needs to be
a new default of 'none' to allow unconfined LXC containers.

This patch introduces two new security label types

 - default:  the host configuration decides whether to run the
             guest with type 'none' or 'dynamic' at guest start
 - none:     the guest will run unconfined by security policy

The 'none' label type will obviously be undesirable for some
deployments, so a new qemu.conf option allows a host admin to
mandate confined guests. It is also possible to turn off default
confinement

  security_default_confined = 1|0  (default == 1)
  security_require_confined = 1|0  (default == 0)

* src/conf/domain_conf.c, src/conf/domain_conf.h: Add new
  seclabel types
* src/security/security_manager.c, src/security/security_manager.h:
  Set default sec label types
* src/security/security_selinux.c: Handle 'none' seclabel type
* src/qemu/qemu.conf, src/qemu/qemu_conf.c, src/qemu/qemu_conf.h,
  src/qemu/libvirtd_qemu.aug: New security config options
* src/qemu/qemu_driver.c: Tell security driver about default
  config

13 years agoRe-add domain device seclabel parsing / formatting
Daniel P. Berrange [Wed, 25 Jan 2012 14:12:51 +0000 (14:12 +0000)]
Re-add domain device seclabel parsing / formatting

This re-introduces parsing & formatting for per device seclabels.
There is a new virDomainDeviceSeclabelPtr struct and corresponding
APIs for parsing/formatting.

13 years agoRevert changes to sec label parsing
Daniel P. Berrange [Wed, 25 Jan 2012 14:12:50 +0000 (14:12 +0000)]
Revert changes to sec label parsing

Revert parsing changes:

  commit 302fe95ffa1bc5f1c61c0beb31a1adfbc38c668e
  Author: Eric Blake <eblake@redhat.com>
  Date:   Wed Jan 4 16:01:24 2012 -0700

    seclabel: fix regression in libvirtd restart

  commit b43432931aef92325920953ff92beabfbe5224c8
  Author: Eric Blake <eblake@redhat.com>
  Date:   Thu Dec 22 17:47:50 2011 -0700

    seclabel: allow a seclabel override on a disk src

These two commits changed the sec label parsing code so that
the same code dealt with both the VM level sec label, and the
per device label. Unfortunately, as we add more options to the
VM level sec label, the logic required to use the same parsing
code for the per device label becomes unintelligible.

* src/conf/domain_conf.c: Remove support for parsing per
  device sec labels

13 years agoAdd detail to documentation on storage pools and volumes.
Dave Allan [Thu, 2 Feb 2012 22:06:48 +0000 (17:06 -0500)]
Add detail to documentation on storage pools and volumes.

The storage pools page contains details about the capabilities of the
various pool types, but not an overview of how they are intended to be
used.  This patch adds some explanation of what pools and volumes can
be used for and why an administrator might want to use them.

13 years agovirsh: Plug memory leak on cmdUndefine
Alex Jia [Thu, 2 Feb 2012 06:25:25 +0000 (14:25 +0800)]
virsh: Plug memory leak on cmdUndefine

Detected by valgrind. Leak is introduced in commit 3bb6bcf.

Free 'vol' memory before allocating memory, the codes will miss one time
free when 'vol_i = nvolumes' in for loop, so plug memory leak.

* tools/virsh.c: fix memory leak on cmdUndefine.

* How to reproduce?
% dd if=/dev/null of=/var/lib/libvirt/images/foo bs=1 count=1 seek=10M
% virsh define foo.xml                   (disk source file points to '/var/lib/libvirt/images/foo')
% virsh vol-clone foo foo-clone default  (the original guest name is 'foo')
% virsh pool-refresh default
% virsh vol-list default                 (make sure 'foo-clone' volume exists)
% virsh define foo-clone.xml             (disk source file points to '/var/lib/libvirt/images/foo-clone')
% valgrind -v --leak-check=full virsh undefine foo-clone --remove-all-storage

* Actual results:

1. virsh output
Domain foo-clone has been undefined
Volume '/var/lib/libvirt/images/foo-clone' removed.

error: Failed to disconnect from the hypervisor, 1 leaked reference(s)

2. valgrind result

==6515== 92 (40 direct, 52 indirect) bytes in 1 blocks are definitely lost in loss record 46 of 69
==6515==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==6515==    by 0x4C89B71: virAlloc (memory.c:101)
==6515==    by 0x4CFCACE: virGetStorageVol (datatypes.c:724)
==6515==    by 0x4D4A8E0: remoteStorageVolLookupByPath (remote_driver.c:4664)
==6515==    by 0x4D07153: virStorageVolLookupByPath (libvirt.c:12508)
==6515==    by 0x4270E6: cmdUndefine (virsh.c:2828)
==6515==    by 0x4151B6: vshCommandRun (virsh.c:17693)
==6515==    by 0x4264D3: main (virsh.c:19270)
==6515==
==6515== LEAK SUMMARY:
==6515==    definitely lost: 40 bytes in 1 blocks

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

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoUpdate gnulib to fix mingw64 compilation errors
Marc-André Lureau [Thu, 2 Feb 2012 00:28:28 +0000 (01:28 +0100)]
Update gnulib to fix mingw64 compilation errors

13 years agotests: dynamically replace dnsmasq path
Philipp Hahn [Mon, 30 Jan 2012 17:13:08 +0000 (18:13 +0100)]
tests: dynamically replace dnsmasq path

The path to the dnsmasq binary can be configured while in the test data
the path is hard-coded to /usr/bin/. This break the test suite if a the
binary is located in a different location, like /usr/local/sbin/.

Replace the hard coded path in the test data by a token, which is
dynamically replaced in networkxml2argvtest with the configured path
after the test data has been loaded.

(Another option would have been to modify configure.ac to generate the
 test data during configure, but I do not know of an easy way do trick
 configure into mass-generate those test files without listing every
 single one, which I consider less flexible.)

- unit-test the unit-test:
  #include <assert.h>
  #define TEST(in,token,rep,out) { char *buf = strdup(in); assert(!replaceTokens(&buf, token, rep) && !strcmp(buf, out)); free(buf); }
  TEST("", "AA", "B", "");
  TEST("A", "AA", "B", "A");
  TEST("AA", "AA", "B", "B");
  TEST("AAA", "AA", "B", "BA");
  TEST("AA", "AA", "BB", "BB");
  TEST("AA", "AA", "BBB", "BBB");
  TEST("<AA", "AA", "B", "<B");
  TEST("<AA", "AA", "BB", "<BB");
  TEST("<AA", "AA", "BBB", "<BBB");
  TEST("AA>", "AA", "B", "B>");
  TEST("AA>", "AA", "BB", "BB>");
  TEST("AA>", "AA", "BBB", "BBB>");
  TEST("<AA>", "AA", "B", "<B>");
  TEST("<AA>", "AA", "BB", "<BB>");
  TEST("<AA>", "AA", "BBB", "<BBB>");
  TEST("<AA|AA>", "AA", "B", "<B|B>");
  TEST("<AA|AA>", "AA", "BB", "<BB|BB>");
  TEST("<AA|AA>", "AA", "BBB", "<BBB|BBB>");
  TEST("<AAAA>", "AA", "B", "<BB>");
  TEST("<AAAA>", "AA", "BB", "<BBBB>");
  TEST("<AAAA>", "AA", "BBB", "<BBBBBB>");
  TEST("AAAA>", "AA", "B", "BB>");
  TEST("AAAA>", "AA", "BB", "BBBB>");
  TEST("AAAA>", "AA", "BBB", "BBBBBB>");
  TEST("<AAAA", "AA", "B", "<BB");
  TEST("<AAAA", "AA", "BB", "<BBBB");
  TEST("<AAAA", "AA", "BBB", "<BBBBBB");
  alarm(1); /* no infinite loop */
  TEST("A", "A", "A", "A");
  TEST("AA", "A", "A", "AA");
  alarm(0);

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agonetwork: fix testsuite regression
Eric Blake [Wed, 1 Feb 2012 23:42:33 +0000 (16:42 -0700)]
network: fix testsuite regression

I slightly botched commit be9fb5a - I converted '--arg=value' to
'--arg value', which has no semantic change, but did trip up the
testsuite.

* src/network/bridge_driver.c (networkBuildDnsmasqArgv): Restore
expected output.

13 years agotests: virnettlscontexttest needs gnutls-2.6.0
Philipp Hahn [Mon, 30 Jan 2012 17:44:13 +0000 (18:44 +0100)]
tests: virnettlscontexttest needs gnutls-2.6.0

virnettlscontexttest uses gnutls_x509_crt_set_subject_alt_name() and
GNUTLS_FSAN_APPEND, which - according to
<http://www.gnu.org/software/gnutls/manual/gnutls.html> - are only
available since 2.6.0.

Since libvirt still works fine with gnutls-1.0.25 from RHEL5, only
enable the test when the version of GNUTLS is at least 2.6.0.

Signed-off-by: Philipp Hahn <hahn@univention.de>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoxen_xs: name xendConfigVersion magic numbers
Philipp Hahn [Tue, 31 Jan 2012 17:08:09 +0000 (18:08 +0100)]
xen_xs: name xendConfigVersion magic numbers

libvirt supports 4 different versions of the user-land XenD daemon. When
queried the daemon just returns its generation number, which is hard to
match to the version of the Xen tools.

Replace the magic generation numbers by named enum definitions to
improve code readability.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agonetwork: Avoid memory leaks on networkBuildDnsmasqArgv
Alex Jia [Wed, 1 Feb 2012 09:22:21 +0000 (17:22 +0800)]
network: Avoid memory leaks on networkBuildDnsmasqArgv

Detected by valgrind. Leaks introduced in commit 973af236.

* src/network/bridge_driver.c: fix memory leaks on failure and successful path.

* How to reproduce?
% make -C tests check TESTS=networkxml2argvtest
% cd tests && valgrind -v --leak-check=full ./networkxml2argvtest

* Actual result:

==2226== 3 bytes in 1 blocks are definitely lost in loss record 1 of 24
==2226==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226==    by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226==    by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226==    by 0x41E0B7: virAsprintf (util.c:1695)
==2226==    by 0x41A2D9: networkBuildDhcpDaemonCommandLine (bridge_driver.c:545)
==2226==    by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226==    by 0x4156A1: virtTestRun (testutils.c:141)
==2226==    by 0x414332: mymain (networkxml2argvtest.c:123)
==2226==    by 0x414D97: virtTestMain (testutils.c:696)
==2226==    by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== 3 bytes in 1 blocks are definitely lost in loss record 2 of 24
==2226==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226==    by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226==    by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226==    by 0x41E0B7: virAsprintf (util.c:1695)
==2226==    by 0x41A307: networkBuildDhcpDaemonCommandLine (bridge_driver.c:551)
==2226==    by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226==    by 0x4156A1: virtTestRun (testutils.c:141)
==2226==    by 0x414332: mymain (networkxml2argvtest.c:123)
==2226==    by 0x414D97: virtTestMain (testutils.c:696)
==2226==    by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== 5 bytes in 1 blocks are definitely lost in loss record 4 of 24
==2226==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226==    by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226==    by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226==    by 0x41E0B7: virAsprintf (util.c:1695)
==2226==    by 0x41A2AB: networkBuildDhcpDaemonCommandLine (bridge_driver.c:539)
==2226==    by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226==    by 0x4156A1: virtTestRun (testutils.c:141)
==2226==    by 0x414332: mymain (networkxml2argvtest.c:123)
==2226==    by 0x414D97: virtTestMain (testutils.c:696)
==2226==    by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== LEAK SUMMARY:
==2226==    definitely lost: 11 bytes in 3 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoblock rebase: initial qemu implementation
Eric Blake [Wed, 1 Feb 2012 04:52:58 +0000 (21:52 -0700)]
block rebase: initial qemu implementation

This is a trivial implementation, which works with the current
released qemu 1.0 with backports of preliminary block pull but
no partial rebase.  Future patches will update the monitor handling
to support an optional parameter for partial rebase; but as qemu
1.1 is unreleased, it can be in later patches, designed to be
backported on top of the supported API.

* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Add parameter,
and adjust callers.  Drop redundant check.
(qemuDomainBlockPull): Move guts...
(qemuDomainBlockRebase): ...to new function.

13 years agoblock rebase: wire up remote protocol
Eric Blake [Wed, 1 Feb 2012 04:39:18 +0000 (21:39 -0700)]
block rebase: wire up remote protocol

Nice and simple.

* src/remote/remote_protocol.x (REMOTE_PROC_DOMAIN_BLOCK_REBASE):
New RPC.
* src/remote/remote_driver.c (remote_driver): Wire it up.
* src/remote_protocol-structs: Regenerate.

13 years agoblock rebase: add new API virDomainBlockRebase
Eric Blake [Wed, 1 Feb 2012 04:19:51 +0000 (21:19 -0700)]
block rebase: add new API virDomainBlockRebase

Qemu is adding the ability to do a partial rebase.  That is, given:

base <- intermediate <- current

virDomainBlockPull will produce:

current

but qemu now has the ability to leave base in the chain, to produce:

base <- current

Note that current qemu can only do a forward merge, and only with
the current image as the destination, which is fully described by
this API without flags.  But in the future, it may be possible to
enhance this API for additional scenarios by using flags:

Merging the current image back into a previous image (that is,
undoing a live snapshot), could be done by passing base as the
destination and flags with a bit requesting a backward merge.

Merging any other part of the image chain, whether forwards (the
backing image contents are pulled into the newer file) or backwards
(the deltas recorded in the newer file are merged back into the
backing file), could also be done by passing a new flag that says
that base should be treated as an XML snippet rather than an
absolute path name, where the XML could then supply the additional
instructions of which part of the image chain is being merged into
any other part.

* include/libvirt/libvirt.h.in (virDomainBlockRebase): New
declaration.
* src/libvirt.c (virDomainBlockRebase): Implement it.
* src/libvirt_public.syms (LIBVIRT_0.9.10): Export it.
* src/driver.h (virDrvDomainBlockRebase): New driver callback.
* src/rpc/gendispatch.pl (long_legacy): Add exemption.
* docs/apibuild.py (long_legacy_functions): Likewise.

13 years agoqemu: Add support for virDomainGetMetadata and virDomainSetMetadata
Peter Krempa [Wed, 1 Feb 2012 13:03:52 +0000 (14:03 +0100)]
qemu: Add support for virDomainGetMetadata and virDomainSetMetadata

This patch adds support for the new api into the qemu driver to support
modification and retrieval of domain description and title. This patch
does not add support for modifying the <metadata> element.

13 years agovirsh: Add support for modifying domain description and titles
Peter Krempa [Wed, 1 Feb 2012 13:03:51 +0000 (14:03 +0100)]
virsh: Add support for modifying domain description and titles

This patch adds a new command "desc" to show and modify titles and
description for the domains using the new API.

This patch also adds a new flag for the "list" command to show titles in
the domain list, to allow easy identification of VMs by storing a short
description.

Example:
virsh # list --title
 Id Name                 State      Title
 -----------------------------------------------
   0 Domain-0             running    Mailserver 1
   2 fedora               paused

13 years agoAPI: Add api to set and get domain metadata
Peter Krempa [Wed, 1 Feb 2012 13:03:50 +0000 (14:03 +0100)]
API: Add api to set and get domain metadata

This patch adds API to modify domain metadata for running and stopped
domains. The api supports changing description, title as well as the
newly added <metadata> element. The API has support for storing data in
the metadata element using xml namespaces.

* include/libvirt/libvirt.h.in
* src/libvirt_public.syms
        - add function headers
        - add enum to select metadata to operate on
        - export functions
* src/libvirt.c
        - add public api implementation
* src/driver.h
        - add driver support
* src/remote/remote_driver.c
* src/remote/remote_protocol.x
        - wire up the remote protocol
* include/libvirt/virterror.h
* src/util/virterror.c
        - add a new error message note that metadata for domain are
        missing

13 years agoxml: Add element <title> to allow short description of domains
Peter Krempa [Wed, 1 Feb 2012 13:03:49 +0000 (14:03 +0100)]
xml: Add element <title> to allow short description of domains

This patch adds a new element <title> to the domain XML. This attribute
can hold a short title defined by the user to ease the identification of
domains. The title may not contain newlines and should be reasonably short.

 *docs/formatdomain.html.in
 *docs/schemas/domaincommon.rng
        - add schema grammar for the new element and documentation
  *src/conf/domain_conf.c
  *src/conf/domain_conf.h
        - add field to hold the new attribute
        - add code to parse and create XML with the new attribute

13 years agobuild: add missing virStorageFileResize to libvirt_private.syms
Laine Stump [Wed, 1 Feb 2012 21:11:58 +0000 (16:11 -0500)]
build: add missing virStorageFileResize to libvirt_private.syms

This was forgotten when the function was originally written (not
noticed because it wasn't used at the time). It's required for
proper compilation with modules enabled after applying the recent
virStorageVolResize patches.

13 years agobuild: add missing virCommandAddCap to libvirt_private.syms
Laine Stump [Wed, 1 Feb 2012 21:09:54 +0000 (16:09 -0500)]
build: add missing virCommandAddCap to libvirt_private.syms

This was forgotten when the function was initially written (not
noticed because it wasn't used at the time). It's required for proper
compilation with modules enabled after applying the recent rawio
patches.

13 years agoqemu: Silent bogus warning about unitialized variable
Jiri Denemark [Wed, 1 Feb 2012 15:10:46 +0000 (16:10 +0100)]
qemu: Silent bogus warning about unitialized variable

GCC complaints about uninitialized use of len, which however is only
used when errors != NULL and in that case len is always initialized.
It's trivial to silence this by always initializing len.

13 years agodaemon: Allow overriding NOFILES ulimit for the daemon as well
Michal Privoznik [Thu, 12 Jan 2012 17:47:30 +0000 (18:47 +0100)]
daemon: Allow overriding NOFILES ulimit for the daemon as well

One of my latest patches (d8db0f9690) created support for setting
the limit for the maximum of opened files by qemu user. However,
since libvirtd keeps one FD opened per domain (well, for qemu at least)
it will likely hit this limit on huge scenarios.

13 years agopython: Add binding for virDomainGetDiskErrors
Jiri Denemark [Tue, 31 Jan 2012 06:34:51 +0000 (07:34 +0100)]
python: Add binding for virDomainGetDiskErrors

13 years agovirsh: Implement domblkerror command
Jiri Denemark [Wed, 18 Jan 2012 16:46:00 +0000 (17:46 +0100)]
virsh: Implement domblkerror command

This command lists all disk devices with errors

13 years agoqemu: Implement virDomainGetDiskErrors
Jiri Denemark [Thu, 19 Jan 2012 16:58:58 +0000 (17:58 +0100)]
qemu: Implement virDomainGetDiskErrors

13 years agoRemote protocol for virDomainGetDiskErrors
Jiri Denemark [Tue, 31 Jan 2012 06:42:31 +0000 (07:42 +0100)]
Remote protocol for virDomainGetDiskErrors

13 years agovirDomainGetDiskErrors public API
Jiri Denemark [Tue, 31 Jan 2012 06:41:53 +0000 (07:41 +0100)]
virDomainGetDiskErrors public API

We already provide ways to detect when a domain has been paused as a
result of I/O error, but there was no way of getting the exact error or
even the device that experienced it.  This new API may be used for both.

13 years agopython: correct a copy-paste error
Alex Jia [Wed, 1 Feb 2012 07:00:12 +0000 (15:00 +0800)]
python: correct a copy-paste error

* python/libvirt-override-virStream.py: fix a copy-paste error in sendAll().

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agocommand: Fix ATTRIBUTE_UNUSED on virSetCapabilities
Michal Privoznik [Wed, 1 Feb 2012 09:02:30 +0000 (10:02 +0100)]
command: Fix ATTRIBUTE_UNUSED on virSetCapabilities

If we are building not on a WIN32 architecture and without HAVE_CAPNG
virSetCapabilities has unused argument and virClearCapabilities
is unused as well.

13 years agoqemu: Clenup qemuDomainSetInterfaceParameters
Michal Privoznik [Tue, 31 Jan 2012 12:43:56 +0000 (13:43 +0100)]
qemu: Clenup qemuDomainSetInterfaceParameters

which contained some useless lines, copied code, NULL
dereference.

13 years agoqemu: Don't jump to endjob if no job was even started
Michal Privoznik [Tue, 31 Jan 2012 15:59:02 +0000 (16:59 +0100)]
qemu: Don't jump to endjob if no job was even started

In qemuDomainShutdownFlags if we try to use guest agent,
which has error or is not configured, we jump go endjob
label even if we haven't started any job yet. This may
lead to the daemon crash:
1) virsh shutdown --mode agent on a domain without agent configured
2) wait until domain quits
3) virsh edit

13 years agoqemu: fix my typo at commit 74e034964c32edb1732d0ff7642f3977f3587d72
Taku Izumi [Wed, 1 Feb 2012 00:54:08 +0000 (09:54 +0900)]
qemu: fix my typo at commit 74e034964c32edb1732d0ff7642f3977f3587d72

Fix my typo at
  commit 74e034964c32edb1732d0ff7642f3977f3587d72

"disk->rawio == -1" indicates that this value is not
specified. So in case of this, domain must not
be tainted.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agosimplify block of codes
Alex Jia [Tue, 31 Jan 2012 03:20:40 +0000 (11:20 +0800)]
simplify block of codes

Using new function 'virTypedParameterArrayClear' to simplify block of codes.

* daemon/remote.c, src/remote/remote_driver.c: simplify codes.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agobuild: fix text regression
Eric Blake [Tue, 31 Jan 2012 23:51:36 +0000 (16:51 -0700)]
build: fix text regression

Commit 8a09ee410 tickles a bug in libxml2-2.7.6 on RHEL 6.2,
where libxml2 treats the pattern [^\n] as excluding literal
backslash and n, instead of the intended newline, thus failing
to validate any domain name containing 'n'.

* docs/schemas/domaincommon.rng: Use literal newline instead.

13 years agodocs: fill out rawio description
Laine Stump [Tue, 31 Jan 2012 19:55:41 +0000 (14:55 -0500)]
docs: fill out rawio description

The original doc entry for rawio didn't mention the values it could
have, the default, or the fact that setting it to "yes" for one disk
effectively set it to "yes" for all disks in the domain.

13 years agoqemu: make qemu processes to retain rawio capability
Taku Izumi [Tue, 31 Jan 2012 04:52:00 +0000 (23:52 -0500)]
qemu: make qemu processes to retain rawio capability

This patch revises qemuProcessStart() function for qemu
processes to retain CAP_SYS_RAWIO if needed.
And in case of that, add taint flag to domain.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Shota Hirae <m11g1401@hibikino.ne.jp>
13 years agoutil: extend virExecWithHook()
Taku Izumi [Tue, 31 Jan 2012 04:51:00 +0000 (23:51 -0500)]
util: extend virExecWithHook()

This patch extends virExecWithHook() to receive
capability information.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Shota Hirae <m11g1401@hibikino.ne.jp>
13 years agoutil: add functions to keep capabilities
Taku Izumi [Tue, 31 Jan 2012 04:50:00 +0000 (23:50 -0500)]
util: add functions to keep capabilities

This patch introduces virSetCapabilities() function and implements
virCommandAllowCap() function.

Existing virClearCapabilities() is function to clear all capabilities.
Instead virSetCapabilities() is function to set arbitrary capabilities.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Shota Hirae <m11g1401@hibikino.ne.jp>
13 years agoconf: add rawio attribute to disk element of domain XML
Taku Izumi [Tue, 31 Jan 2012 04:49:00 +0000 (23:49 -0500)]
conf: add rawio attribute to disk element of domain XML

 This patch adds a new attribute "rawio" to the "disk" element
 of domain XML. Valid values of "rawio" attribute are "yes"
 and "no".
 rawio='yes' indicates the disk is desirous of CAP_SYS_RAWIO.

 If you specify the following XML:

 <disk type='block' device='lun' rawio='yes'>
  ...
 </disk>

 the domain will be granted CAP_SYS_RAWIO.
 (of course, the domain have to be executed with root privilege)

NOTE:
   - "rawio" attribute is only valid when device='lun'
   - At the moment, any other disks you won't use rawio can use rawio.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agoImplement virStorageVolResize() for FS backend
Zeeshan Ali (Khattak) [Mon, 30 Jan 2012 07:40:00 +0000 (02:40 -0500)]
Implement virStorageVolResize() for FS backend

Currently only VIR_STORAGE_VOL_RESIZE_DELTA flag is supported.

13 years agoresize: slightly alter signature
Eric Blake [Mon, 30 Jan 2012 19:04:20 +0000 (12:04 -0700)]
resize: slightly alter signature

Our existing virDomainBlockResize takes an unsigned long long
argument; if that command is later taught a DELTA and SHRINK flag,
we cannot change its type without breaking API (but at least such
a change would be ABI compatible).  Meanwhile, the only time a
negative size makes sense is if both DELTA and SHRINK are used
together, but if we keep the argument unsigned, applications can
pass the positive delta amount by which they would like to shrink
the system, and have the flags imply the negative value.  So,
since this API has not yet been released, and in the interest of
consistency with existing API, we swap virStorageVolResize to
always pass an unsigned value.

* include/libvirt/libvirt.h.in (virStorageVolResize): Use unsigned
argument.
* src/libvirt.c (virStorageVolResize): Likewise.
* src/driver.h (virDrvStorageVolUpload): Adjust clients.
* src/remote/remote_protocol.x (remote_storage_vol_resize_args):
Likewise.
* src/remote_protocol-structs: Regenerate.
Suggested by Daniel P. Berrange.

13 years agoXenXs: Update documentation
Philipp Hahn [Tue, 17 Jan 2012 08:26:13 +0000 (09:26 +0100)]
XenXs: Update documentation

Fix several references to now renamed functions and parameters when the
functions were moved from src/xen/ to src/xenxs/.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoqemu: add "romfile" support to specify device boot ROM
Laine Stump [Wed, 25 Jan 2012 16:20:49 +0000 (11:20 -0500)]
qemu: add "romfile" support to specify device boot ROM

This patch addresses: https://bugzilla.redhat.com/show_bug.cgi?id=781562

Along with the "rombar" option that controls whether or not a boot rom
is made visible to the guest, qemu also has a "romfile" option that
allows specifying a binary file to present as the ROM BIOS of any
emulated or passthrough PCI device. This patch adds support for
specifying romfile to both passthrough PCI devices, and emulated
network devices that attach to the guest's PCI bus (just about
everything other than ne2k_isa).

One example of the usefulness of this option is described in the
bugzilla report: 82576 sriov network adapters don't provide a ROM BIOS
for the cards virtual functions (VF), but an image of such a ROM is
available, and with this ROM visible to the guest, it can PXE boot.

In libvirt's xml, the new option is configured like this:

   <hostdev>
     ...
     <rom file='/etc/fake/boot.bin'/>
     ...
   </hostdev

(similarly for <interface>).

13 years agoqemu: (and conf) support rombar for network devices
Laine Stump [Wed, 25 Jan 2012 00:54:12 +0000 (19:54 -0500)]
qemu: (and conf) support rombar for network devices

When support for the rombar option was added, it was only added for
PCI passthrough devices, configured with <hostdev>. The same option is
available for any network device that is attached to the guest's PCI
bus. This patch allows setting rombar for any PCI network device type.

After adding cases to test this to qemuxml2argv-hostdev-pci-rombar.*,
I decided to rename those files (to qemuxml2argv-pci-rom.*) to more
accurately reflect the additional tests, and also noticed that up to
now we've only been performing a domainschematest for that case, so I
added the "pci-rom" test to both qemuxml2argv and qemuxml2xml (and in
the process found some bugs whose fixes I squashed into previous
commits of this series).

13 years agoconf: relocate rombar and boot order parse/format
Laine Stump [Tue, 24 Jan 2012 19:11:05 +0000 (14:11 -0500)]
conf: relocate rombar and boot order parse/format

Since these two items are now in the virDomainDeviceInfo struct, it
makes sense to parse/format them in the functions written to
parse/format that structure. Not all types of devices allow them, so
two internal flags are added to indicate when it is appropriate to do
so.

I was lucky - only one test case needed to be re-ordered!

13 years agoconf: put all guest-related HostdevDef data in one object
Laine Stump [Tue, 24 Jan 2012 17:53:59 +0000 (12:53 -0500)]
conf: put all guest-related HostdevDef data in one object

To help consolidate the commonality between virDomainHostdevDef and
virDomainNetDef into as few members as possible (and because I
think it makes sense), this patch moves the rombar and bootIndex
members into the "info" member that is common to both (and to all the
other structs that use them).

It's a bit problematic that this gives rombar and bootIndex to many
device types that don't use them, but this is already the case for the
master and mastertype members of virDomainDeviceInfo, and is properly
commented as such in the definition.

Note that this opens the door to supporting rombar for other devices
that are attached to the guest PCI bus - virtio-blk-pci,
virtio-net-pci, various other network adapters - which which have that
capability in qemu, but previously had no support in libvirt.

13 years agoconf: remove duplicate call to VIR_FREE(info->alias)
Laine Stump [Wed, 25 Jan 2012 16:40:13 +0000 (11:40 -0500)]
conf: remove duplicate call to VIR_FREE(info->alias)

There is another identical call 4 lines up in the same function.

13 years agoqemu: Fix segfault in qemuMonitorTextGetBlockInfo
Hendrik Schwartke [Mon, 30 Jan 2012 12:36:46 +0000 (13:36 +0100)]
qemu: Fix segfault in qemuMonitorTextGetBlockInfo

If some error occurs then the cleanup code calls VIR_FREE(info)
without ensuring that info is initialized.

13 years agoxen: Don't add <console> to xml for dom0
Cole Robinson [Sun, 29 Jan 2012 19:10:00 +0000 (14:10 -0500)]
xen: Don't add <console> to xml for dom0

It just doesn't really make sense and confuses virt-manager

13 years agoAdd virt-host-validate.1 to Mingw32 RPM spec file list
Daniel P. Berrange [Mon, 30 Jan 2012 12:03:30 +0000 (12:03 +0000)]
Add virt-host-validate.1 to Mingw32 RPM spec file list

13 years agoremote handler for virDomainGetCPUStats()
KAMEZAWA Hiroyuki [Sat, 28 Jan 2012 06:21:31 +0000 (15:21 +0900)]
remote handler for virDomainGetCPUStats()

Unlike other users of virTypedParameter with RPC, this interface
can return zero-filled entries because the interface assumes
2 dimensional array. We compress these entries out from the
server when generating the over-the-wire contents, then reconstitute
them in the client.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agodocs: reorder public header
Eric Blake [Sat, 28 Jan 2012 14:37:55 +0000 (07:37 -0700)]
docs: reorder public header

The bottom of the public header is reserved for deprecated APIs;
it's nicer to arrange things in logical groups.

* include/libvirt/libvirt.h.in (virConnectSetKeepAlive)
(virDomainGetCPUStats): Float earlier in the file.

13 years agodocs: tweak recent suspend API additions
Eric Blake [Sat, 28 Jan 2012 14:29:10 +0000 (07:29 -0700)]
docs: tweak recent suspend API additions

* src/libvirt.c (virDomainPMSuspendForDuration): Clarify usage.

13 years agoAdd new public API virDomainGetCPUStats()
KAMEZAWA Hiroyuki [Sat, 28 Jan 2012 06:20:28 +0000 (15:20 +0900)]
Add new public API virDomainGetCPUStats()

add new API virDomainGetCPUStats() for getting cpu accounting information
per real cpus which is used by a domain.  The API is designed to allow
future extensions for additional statistics.

based on ideas by Lai Jiangshan and Eric Blake.

* src/libvirt_public.syms: add API for LIBVIRT_0.9.10
* src/libvirt.c: define virDomainGetCPUStats()
* include/libvirt/libvirt.h.in: add virDomainGetCPUStats() header
* src/driver.h: add driver API
* python/generator.py: add python API (as not implemented)

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agovirsh: Expose new virDomainPMSuspendForDuration API
Michal Privoznik [Thu, 26 Jan 2012 19:20:49 +0000 (20:20 +0100)]
virsh: Expose new virDomainPMSuspendForDuration API

under new command "dompmsuspend"

13 years agoIntroduce virDomainPMSuspendForDuration API
Michal Privoznik [Thu, 26 Jan 2012 18:05:46 +0000 (19:05 +0100)]
Introduce virDomainPMSuspendForDuration API

This API allows a domain to be put into one of S# ACPI states.
Currently, S3 and S4 are supported. These states are shared
with virNodeSuspendForDuration.
However, for now we don't support any duration other than zero.
The same apply for flags.

13 years agoresize: implement remote protocol for virStorageVolResize()
Zeeshan Ali (Khattak) [Fri, 27 Jan 2012 05:29:56 +0000 (07:29 +0200)]
resize: implement remote protocol for virStorageVolResize()

Autogeneration saves the day.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoresize: add virStorageVolResize() API
Zeeshan Ali (Khattak) [Fri, 27 Jan 2012 05:29:56 +0000 (07:29 +0200)]
resize: add virStorageVolResize() API

Add a new function to allow changing of capacity of storage volumes.
Plan out several flags, even if not all of them will be implemented
up front.

Expose the new command via 'virsh vol-resize'.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agotests: fix reversed comparisons
Eric Blake [Fri, 27 Jan 2012 23:35:14 +0000 (16:35 -0700)]
tests: fix reversed comparisons

Otherwise, a failed test gives misleading output.

* tests/commandtest.c (test13, test14, test16): Pass arguments in
correct order.

13 years agoReturn more error output if policykit auth fails.
Cole Robinson [Fri, 27 Jan 2012 22:01:21 +0000 (17:01 -0500)]
Return more error output if policykit auth fails.

Several not uncommon issues can be diagnosed through pkcheck output, like
lack of/malfunctioning desktop agent, or lack of/malfunctioning polkit
dbus agent.

13 years agoAdd new error code VIR_ERROR_AUTH_CANCELLED
Cole Robinson [Fri, 27 Jan 2012 18:06:49 +0000 (13:06 -0500)]
Add new error code VIR_ERROR_AUTH_CANCELLED

And hook it up for policykit auth. This allows virt-manager to detect
that the user clicked the policykit 'cancel' button and not throw
an 'authentication failed' error message at the user.

13 years agoqemu: avoid double free of qemu help output
Eric Blake [Fri, 27 Jan 2012 20:53:11 +0000 (13:53 -0700)]
qemu: avoid double free of qemu help output

If yajl was not compiled in, we end up freeing an incoming
parameter, which leads to a bogus free later on.  Regression
introduced in commit 6e769eb.

* src/qemu/qemu_capabilities.c (qemuCapsParseHelpStr): Avoid alloc
on failure path, which in turn fixes bogus free.
Reported by Cole Robinson.

13 years agobuild: fix missing include
Eric Blake [Fri, 27 Jan 2012 18:16:20 +0000 (11:16 -0700)]
build: fix missing include

Fix a build failure:

virt-host-validate.c: In function 'main':
virt-host-validate.c:82:5: error: implicit declaration of function 'setlocale' [-Werror=implicit-function-declaration]
virt-host-validate.c:82:5: error: nested extern declaration of 'setlocale' [-Werror=nested-externs]
virt-host-validate.c:82:20: error: 'LC_ALL' undeclared (first use in this function)

* tools/virt-host-validate.c: Add <locale.h>.
* .gitignore: Ignore built executable.

13 years agoxml: fix struct typos
Eric Blake [Fri, 27 Jan 2012 18:07:21 +0000 (11:07 -0700)]
xml: fix struct typos

Noticed this while reviewing Dan's patches.

* src/util/xml.c (virXMLRewritFileData): Rename to
virXMLRewriteFileData.

13 years agoMove virEmitXMLWarning into xml.h
Daniel P. Berrange [Fri, 27 Jan 2012 17:35:09 +0000 (17:35 +0000)]
Move virEmitXMLWarning into xml.h

The virEmitXMLWarning function should always have been in
the xml.[hc] files, and should use virXML as its name
prefix

* src/util/util.c, src/util/util.h: Remove virEmitXMLWarning
* src/util/xml.c, src/util/xml.h: Add virXMLEmitWarning

13 years agoMove virMacAddrXXX functions to src/util/virmacaddr.[ch]
Daniel P. Berrange [Fri, 27 Jan 2012 17:23:05 +0000 (17:23 +0000)]
Move virMacAddrXXX functions to src/util/virmacaddr.[ch]

Move the virMacAddrXXX functions out of util.[ch] and into a
new dedicate file virmacaddr.[ch]

13 years agoRename virXXXXMacAddr to virMacAddrXXX
Daniel P. Berrange [Fri, 27 Jan 2012 16:48:38 +0000 (16:48 +0000)]
Rename virXXXXMacAddr to virMacAddrXXX

Rename virFormatMacAddr, virGenerateMacAddr and virParseMacAddr
to virMacAddrFormat, virMacAddrGenerate and virMacAddrParse
respectively