]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agoqemu: Enable disconnecting SPICE clients without changing password
Peter Krempa [Thu, 14 Jun 2012 12:48:42 +0000 (14:48 +0200)]
qemu: Enable disconnecting SPICE clients without changing password

Libvirt updates the configuration of SPICE server only when something
changes. This is unfortunate when the user wants to disconnect a
existing spice session when the connected attribute is already
"disconnect".

This patch modifies the conditions for calling the password updater to
be called when nothing changes, but the connected attribute is already
"disconnect".

12 years agovirsh: Report name from edited object
Michal Privoznik [Thu, 14 Jun 2012 12:18:31 +0000 (14:18 +0200)]
virsh: Report name from edited object

There is a little easter egg in virsh: one can easily clone
an object (domain, network, ...). Just 'virsh edit' change the name
and remove <uuid>. And then, in the end when reporting success
the new name was printed out.
However, with recent edit rewrite we lost the final part and are
still printing the original name out.

12 years agovirsh: Honor reedit opts printing to a function
Michal Privoznik [Wed, 13 Jun 2012 09:11:27 +0000 (11:11 +0200)]
virsh: Honor reedit opts printing to a function

When printing reedit options we make stdin raw. However,
this results in stdout being raw as well. Therefore we need
to return carriage when doing new line. Unfortunately,
'\r' cannot be part of internationalized messages hence
we must move them to formatting string which then in turn
become huge and disarranged. To solve this, a new function
is introduced which takes variable string arguments and
prepend each with "\r\n" just before printing.

12 years agoqemu: Fix off-by-one error while unescaping monitor strings
Peter Krempa [Thu, 14 Jun 2012 08:29:36 +0000 (10:29 +0200)]
qemu: Fix off-by-one error while unescaping monitor strings

While unescaping the commands the commands passed through to the monitor
function qemuMonitorUnescapeArg() initialized lenght of the input string
to strlen()+1 which is fine for alloc but not for iteration of the
string.

This patch fixes the off-by-one error and drops the pointless check for
a single trailing slash that is automaticaly handled by the default
branch of switch.

12 years agovirsh: Don't generate invalid XML in attach-disk command
Peter Krempa [Wed, 13 Jun 2012 14:55:51 +0000 (16:55 +0200)]
virsh: Don't generate invalid XML in attach-disk command

The attach-disk command used with parameter --cache created an invalid
XML snippet as the beginning of the <driver> element was not printed
when used solely with --cache and no other attribute to driver.

12 years agonetwork: fully support/use VIR_NETWORK_XML_INACTIVE flag
Laine Stump [Mon, 4 Jun 2012 18:45:16 +0000 (14:45 -0400)]
network: fully support/use VIR_NETWORK_XML_INACTIVE flag

commit 52d064f42dbc857f4096dc60c0335395ffac73aa added
VIR_NETWORK_XML_INACTIVE in order to allow suppressing the
auto-generated list of VFs in network definitions, and a --inactive
flag to virsh net-dumpxml to take advantage of the flag. However, it
missed out on two opportunities:

1) Use INACTIVE to get the current config of the network as it
   exists on disk, rather than the currently active config.

2) Add INACTIVE to the flags used for the virsh net-edit command, so
   that it won't include the forward-pool interfaces that were
   autogenerated, and so that a re-edit of the network prior to
   restarting it will show any other edits made since the last restart
   of the network. (prior to this patch, if you edited a network a 2nd
   time without restarting, all of the previous edits would magically
   disappear).

In order to fit with the new #define-based generic edit function in
virsh.c, a new function vshNetworkGetXMLDesc() was added. This
function first tries to call virNetworkGetXMLDesc with the INACTIVE
flag added, then retries without if the first attempt fails (in the
manner expected when the server doesn't support it).

12 years agoAdd some missing hook functions
Daniel P. Berrange [Mon, 28 May 2012 14:04:31 +0000 (15:04 +0100)]
Add some missing hook functions

A core use case of the hook scripts is to be able to do things
to a guest's network configuration. It is possible to hook into
the 'start' operation for a QEMU guest which runs just before
the guest is started. The TAP devices will exist at this point,
but the QEMU process will not. It can be desirable to have a
'started' hook too, which runs once QEMU has started.

If libvirtd is restarted it will re-populate firewall rules,
but there is no QEMU hook to trigger for existing domains.
This is solved with a 'reconnect' hook.

Finally, if attaching to an external QEMU process there needs
to be an 'attach' hook script.

This all also applies to the LXC driver

* docs/hooks.html.in: Document new operations
* src/util/hooks.c, src/util/hooks.c: Add 'started', 'reconnect'
  and 'attach' operations for QEMU. Add 'prepare', 'started',
  'release' and 'reconnect' operations for LXC
* src/lxc/lxc_driver.c: Add hooks for 'prepare', 'started',
  'release' and 'reconnect' operations
* src/qemu/qemu_process.c: Add hooks for 'started', 'reconnect'
  and 'reconnect' operations

12 years agoclient rpc: Fix error checking after poll()
Daniel P. Berrange [Wed, 13 Jun 2012 09:54:02 +0000 (10:54 +0100)]
client rpc: Fix error checking after poll()

First 'poll' can't return EWOULDBLOCK, and second, we're checking errno
so far away from the poll() call that we've probably already trashed the
original errno value.

12 years agoclient rpc: Send keepalive requests from IO event loop
Jiri Denemark [Tue, 12 Jun 2012 12:32:27 +0000 (14:32 +0200)]
client rpc: Send keepalive requests from IO event loop

In addition to keepalive responses, we also need to send keepalive
requests from client IO loop to properly detect dead connection in case
a libvirt API is called from the main loop, which prevents any timers to
be called.

12 years agoserver rpc: Remove APIs for manipulating filters on locked client
Jiri Denemark [Tue, 12 Jun 2012 07:02:38 +0000 (09:02 +0200)]
server rpc: Remove APIs for manipulating filters on locked client

We don't need to add or remove filters when client object is already
locked anymore. There's no reason to keep the *Locked variants of those
APIs.

12 years agorpc: Remove unused parameter in virKeepAliveStopInternal
Jiri Denemark [Tue, 12 Jun 2012 06:58:04 +0000 (08:58 +0200)]
rpc: Remove unused parameter in virKeepAliveStopInternal

The previous commit removed the only usage of ``all'' parameter in
virKeepAliveStopInternal, which was actually the only reason for having
virKeepAliveStopInternal. This effectively reverts most of commit
6446a9e20cc65561ce6061742baf35a3a63d5ba1.

12 years agorpc: Do not use timer for sending keepalive responses
Jiri Denemark [Tue, 12 Jun 2012 07:01:49 +0000 (09:01 +0200)]
rpc: Do not use timer for sending keepalive responses

When a libvirt API is called from the main event loop (which seems to be
common in event-based glib apps), the client IO loop would properly
handle keepalive requests sent by a server but will not actually send
them because the main event loop is blocked with the API. This patch
gets rid of response timer and the thread which is processing keepalive
requests is also responsible for queueing responses for delivery.

12 years agoclient rpc: Separate call creation from running IO loop
Jiri Denemark [Tue, 12 Jun 2012 06:47:13 +0000 (08:47 +0200)]
client rpc: Separate call creation from running IO loop

This makes it possible to create and queue new calls while we are
running IO loop.

12 years agorpc: Add APIs for direct triggering of keepalive timer
Jiri Denemark [Tue, 12 Jun 2012 21:42:32 +0000 (23:42 +0200)]
rpc: Add APIs for direct triggering of keepalive timer

Add virKeepAliveTimeout and virKeepAliveTrigger APIs that can be used to
set poll timeouts and trigger keepalive timer. virKeepAliveTrigger
checks if it is called to early and does nothing in that case.

12 years agorpc: Refactor keepalive timer code
Jiri Denemark [Tue, 12 Jun 2012 21:41:25 +0000 (23:41 +0200)]
rpc: Refactor keepalive timer code

The code that needs to be run every keepalive interval of inactivity was
only called from a timer and thus from the main event loop. We will need
to call the code directly from another place.

12 years agoclient rpc: Drop unused return value of virNetClientSendNonBlock
Jiri Denemark [Fri, 8 Jun 2012 13:24:06 +0000 (15:24 +0200)]
client rpc: Drop unused return value of virNetClientSendNonBlock

As we never drop non-blocking calls, the return value that used to
indicate a call was dropped is no longer needed.

12 years agoclient rpc: Just queue non-blocking call if another thread has the buck
Jiri Denemark [Mon, 11 Jun 2012 12:24:06 +0000 (14:24 +0200)]
client rpc: Just queue non-blocking call if another thread has the buck

As non-blocking calls are no longer dropped, we don't really need to
care that much about their fate and wait for the thread with the buck
to process them. If another thread has the buck, we can just push a
non-blocking call to the queue and be done with it.

12 years agoclient rpc: Don't drop non-blocking calls
Jiri Denemark [Fri, 8 Jun 2012 12:21:00 +0000 (14:21 +0200)]
client rpc: Don't drop non-blocking calls

So far, we were dropping non-blocking calls whenever sending them would
block. In case a client is sending lots of stream calls (which are not
supposed to generate any reply), the assumption that having other calls
in a queue is sufficient to get a reply from the server doesn't work. I
tried to fix this in b1e374a7ac56927cfe62435179bf0bba1e08b372 but
failed and reverted that commit.

With this patch, non-blocking calls are never dropped (unless the
connection is being closed) and will always be sent.

12 years agoclient rpc: Use event loop for writing
Jiri Denemark [Tue, 12 Jun 2012 06:41:59 +0000 (08:41 +0200)]
client rpc: Use event loop for writing

Normally, when every call has a thread associated with it, the thread
may get the buck and be in charge of sending all calls until its own
call is done. When we introduced non-blocking calls, we had to add
special handling of new non-blocking calls. This patch uses event loop
to send data if there is no thread to get the buck so that any
non-blocking calls left in the queue are properly sent without having to
handle them specially. It also avoids adding even more cruft to client
IO loop in the following patches.

With this change in, non-blocking calls may see unpredictable delays in
delivery when the client has no event loop registered. However, the only
non-blocking calls we have are keepalives and we already require event
loop for them, which makes this a non-issue until someone introduces new
non-blocking calls.

12 years agoclient rpc: Improve debug messages in virNetClientIO
Jiri Denemark [Fri, 8 Jun 2012 11:41:25 +0000 (13:41 +0200)]
client rpc: Improve debug messages in virNetClientIO

When analyzing our debug log, I'm always confused about what each of the
pointers mean. Let's be explicit.

12 years agobuild: fix 'make dist' on virgin checkout
Eric Blake [Wed, 13 Jun 2012 03:49:22 +0000 (21:49 -0600)]
build: fix 'make dist' on virgin checkout

'make dist' was depending on *protocol-structs files, which are
stored in git but in turn depended on generated files.  We still
want to ship the protocol-structs files, but by renaming the
tests to something not matching a file name, we separate 'make
check' (which depends on the generated file) from 'make dist'
(which only depends on the git files).  After all, the tarball
should never depend on a generated file not stored in git.

I found one more case of a git file depending on a generated
file, in a bogus virkeycode.c listing; but at least this one
had no associated rules so it never broke 'make dist'.

Reported by Wen Congyang.  Latent bug has been present since
commit 62dee6f, but only recently exposed by commit 7bff56a.

* src/Makefile.am ($(srcdir)/util/virkeycode.c): Drop useless
dependency.
(BUILT_SOURCES): ...and build virkeymaps.h sooner.
(PROTOCOL_STRUCTS): Rather than depend on the struct file...
(check-local): ...convert things into a phony target of...
(check-protocol): ...a new check.
($(srcdir)/remote_protocol-struct): Rename to isolate the distributed
file from the conditional test.
(PDWTAGS): Deal with rename.  Swap to compare 'expected actual'.

12 years agobuild: silence gettext warning
Eric Blake [Wed, 13 Jun 2012 03:46:36 +0000 (21:46 -0600)]
build: silence gettext warning

Otherwise, 'make dist' gives multiple warnings like:

libvirt.pot:20814: warning: internationalized messages should not contain the `\r' escape sequence

* tools/virsh.c (vshAskReedit): Avoid \r in _().

12 years agoopenvz: wire up domainUpdateDeviceFlags
Guido Günther [Fri, 25 May 2012 17:49:32 +0000 (19:49 +0200)]
openvz: wire up domainUpdateDeviceFlags

so we can update file system quota

12 years agoopenvz: add persist parameter to openvzSetDiskQuota
Guido Günther [Fri, 25 May 2012 17:48:33 +0000 (19:48 +0200)]
openvz: add persist parameter to openvzSetDiskQuota

with persist=false the domain config file will not be updated.

12 years agoIntroduce virDomainFSIndexByName
Guido Günther [Tue, 29 May 2012 18:46:38 +0000 (20:46 +0200)]
Introduce virDomainFSIndexByName

for containers matching virDomainDiskIndexByName.

12 years agoFix typo in RPM specfile
Daniel P. Berrange [Tue, 12 Jun 2012 14:54:56 +0000 (15:54 +0100)]
Fix typo in RPM specfile

libvirt.spec.in: s/{?rhel}/%{?rhel}/

12 years agopython: fix snapshot listing bugs
Eric Blake [Mon, 11 Jun 2012 20:49:03 +0000 (14:49 -0600)]
python: fix snapshot listing bugs

Python exceptions are different than libvirt errors, and we had
some corner case bugs on OOM situations.

* python/libvirt-override.c (libvirt_virDomainSnapshotListNames)
(libvirt_virDomainSnapshotListChildrenNames): Use correct error
returns, avoid segv on OOM, and avoid memory leaks on error.

12 years agopython: use simpler methods
Eric Blake [Mon, 11 Jun 2012 20:32:47 +0000 (14:32 -0600)]
python: use simpler methods

* python/libvirt-override.c (libvirt_virDomainGetVcpus)
(libvirt_virDomainGetVcpuPinInfo): Use Py_XDECREF instead of
open-coding it.

12 years agoqemu: Don't overwrite security labels
Michal Privoznik [Mon, 11 Jun 2012 13:57:19 +0000 (15:57 +0200)]
qemu: Don't overwrite security labels

Currently, if qemuProcessStart fail at some point, e.g. because
domain being started wants a PCI/USB device already assigned to
a different domain, we jump to cleanup label where qemuProcessStop
is performed. This unconditionally calls virSecurityManagerRestoreAllLabel
which is wrong because the other domain is still using those devices.

However, once we successfully label all devices/paths in
qemuProcessStart() from that point on, we have to perform a rollback
on failure - that is - we have to virSecurityManagerRestoreAllLabel.

12 years agoqemuProcessStop: Switch to flags
Michal Privoznik [Mon, 11 Jun 2012 13:20:44 +0000 (15:20 +0200)]
qemuProcessStop: Switch to flags

Currently, we are passing only one boolean (migrated) so there is
no real profit in this. But it creates starting position for
next patch.

12 years agosnapshot: implement new APIs for qemu
Eric Blake [Fri, 25 May 2012 02:28:54 +0000 (20:28 -0600)]
snapshot: implement new APIs for qemu

The two APIs are rather trivial; based on bits and pieces of other
existing APIs.  It leaves the door open for future extension to
qemu to report snapshots without metadata based on reading qcow2
internal snapshot names.

* src/qemu/qemu_driver.c (qemuDomainSnapshotIsCurrent)
(qemuDomainSnapshotHasMetadata): New functions.

12 years agodocs: minor fixes to domain interface documentation
Laine Stump [Mon, 11 Jun 2012 21:16:17 +0000 (17:16 -0400)]
docs: minor fixes to domain interface documentation

A few examples for <interface> had a type='direct' interface with no
sub-elements. This is not allowed - a type='direct' interface must
have at least a source element. (Most likely the example was copied
from the type='user' or type='ethernet' examples - they *do* allow an
instance with no sub-elements).

There was also one place that mistakenly used %lt; ... %gt; instead of
&lt; ... &gt; (for some reason, I make that typo all the time).

12 years agosnapshot: RPC for new query APIs
Eric Blake [Thu, 24 May 2012 22:47:04 +0000 (16:47 -0600)]
snapshot: RPC for new query APIs

Pretty straightforward.

* src/remote/remote_protocol.x
(remote_domain_snapshot_is_current_args)
(remote_domain_snapshot_is_current_ret)
(remote_domain_snapshot_has_metadata_args)
(remote_domain_snapshot_has_metadata_ret): New structs.
(REMOTE_PROC_DOMAIN_SNAPSHOT_IS_CURRENT)
(REMOTE_PROC_DOMAIN_SNAPSHOT_HAS_METADATA): New RPC calls.
* src/remote/remote_driver.c (remote_driver): Call them.
* src/remote_protocol-structs: Regenerate.

12 years agosnapshot: add 'virsh snapshot-info'
Eric Blake [Thu, 24 May 2012 21:53:24 +0000 (15:53 -0600)]
snapshot: add 'virsh snapshot-info'

Expose the recent API additions in virsh.  Borrows ideas from 'dominfo'
for the general type of information to display.

Output looks like:

$ tools/virsh snapshot-info fedora-local tmp
Name:           tmp
Domain:         fedora-local
Current:        no
State:          disk-snapshot
Parent:         -
Children:       1
Descendants:    2
Metadata:       yes

possibly with fewer lines when talking to older servers.

* tools/virsh.c (cmdSnapshotInfo): New command.
* tools/virsh.pod (snapshot-info): Document it.

12 years agodocs: link to FLOSS Weekly podcast, virt blogs
Eric Blake [Thu, 7 Jun 2012 19:23:49 +0000 (13:23 -0600)]
docs: link to FLOSS Weekly podcast, virt blogs

Eric Blake and Guido Günther were guests during this week's
FLOSS Weekly podcast, giving insights into libvirt as a Free
Software project.  Also, there are several useful blogs on
virt-related topics.

* docs/relatedlinks.html.in (Blogs and Podcasts): New section.

12 years agoTwo RPM conditional fixes for RHEL-7
Daniel P. Berrange [Mon, 11 Jun 2012 16:57:38 +0000 (17:57 +0100)]
Two RPM conditional fixes for RHEL-7

Ensure systemd is used in RHEL-7 and cgconfig is not used in
RHEL-7

12 years agosnapshot: new query APIs
Eric Blake [Wed, 23 May 2012 23:10:39 +0000 (17:10 -0600)]
snapshot: new query APIs

Right now, starting from just a virDomainSnapshotPtr, and wanting to
know if it is the current snapshot for its respective domain, you have
to use virDomainSnapshotGetDomain(), then virDomainSnapshotCurrent(),
then compare the two names returned by virDomainSnapshotGetName().
It is a bit easier if we can directly query this information from the
snapshot itself.

Right now, it is possible to filter a snapshot listing based on
whether snapshots have metadata that would prevent domain deletion,
but the only way to learn if an individual snapshot has metadata is
to see if that snapshot appears in the list returned by a listing.
Additionally, I hope to expand the qemu driver in a future patch to
use qemu-img to reconstruct snapshot XML corresponding to internal
qcow2 snapshot names not otherwise tracked by libvirt (in part, so
that libvirt can guarantee that new snapshots are not created with
a name that would silently corrupt the existing portion of the qcow2
file); if I ever get that in, then it would no longer be an all-or-none
decision on whether snapshots have metadata, and becomes all the more
important to be able to directly determine that information from a
particular snapshot.

Other query functions (such as virDomainIsActive) do not have a flags
argument, but since virDomainHasCurrentSnapshot takes a flags argument,
I figured it was safer to provide a flags argument here as well.

* include/libvirt/libvirt.h.in (virDomainSnapshotIsCurrent)
(virDomainSnapshotHasMetadata): New declarations.
* src/libvirt.c (virDomainSnapshotIsCurrent)
(virDomainSnapshotHasMetadata): New functions.
* src/libvirt_public.syms (LIBVIRT_0.9.13): Export them.
* src/driver.h (virDrvDomainSnapshotIsCurrent)
(virDrvDomainSnapshotHasMetadata): New driver callbacks.

12 years agosnapshot: virsh indentation cleanup
Eric Blake [Fri, 8 Jun 2012 21:59:21 +0000 (15:59 -0600)]
snapshot: virsh indentation cleanup

No semantic change; this will make it easier to refactor code.

* tools/virsh.c (cmdSnapshotList): Drop level of indentation, and
rename a variable.

12 years agovirsh: make tree listing more flexible
Eric Blake [Fri, 8 Jun 2012 21:01:08 +0000 (15:01 -0600)]
virsh: make tree listing more flexible

Requiring the user to pass in parallel arrays of names and parents
is annoying; it means that you can't qsort one of the arrays without
invalidating the ordering of the other.  By refactoring this function
to use callbacks, we isolate the layout to be independent of the
printing, and a future patch can exploit that to improve layout.

* tools/virsh.c (vshTreePrintInternal): Use callbacks rather than
requiring a char** array.
(vshTreeArrayLookup): New helper function.
(vshTreePrint, cmdNodeListDevices, cmdSnapshotList): Update callers.

12 years agovirsh: remove limits on tree listing
Eric Blake [Fri, 8 Jun 2012 20:26:06 +0000 (14:26 -0600)]
virsh: remove limits on tree listing

I am not a fan of fixed-width buffers.  All it takes is a
linear chain of more than 100 snapshots to mess up 'virsh
snapshot-list --tree'.  Now that virBuffer is more powerful,
we might as well exploit its power.

* tools/virsh.c (cmdNodeListDevicesPrint): Simplify to use a
virBuffer instead of fixed-width prefix, factor guts, and rename...
(vshTreePrint, vshTreePrintInternal): ...along with new helper.
(cmdNodeListDevices, cmdSnapshotList): Update callers.

12 years agobuf: support peeking at string contents
Eric Blake [Fri, 8 Jun 2012 19:50:23 +0000 (13:50 -0600)]
buf: support peeking at string contents

Right now, the only way to get at the contents of a virBuffer is
to destroy it.  But there are cases in my upcoming patches where
peeking at the contents makes life easier.  I suppose this does
open up the potential for bad code to dereference a stale pointer,
by disregarding the docs that the return value is invalid on the
next virBuf operation, but such is life.

* src/util/buf.h (virBufferCurrentContent): New declaration.
* src/util/buf.c (virBufferCurrentContent): Implement it.
* src/libvirt_private.syms (buf.h): Export it.
* tests/virbuftest.c (testBufAutoIndent): Test it.

12 years agorpc: Fix memleak in virNetMessageEncodeHeader
Michal Privoznik [Mon, 11 Jun 2012 12:21:00 +0000 (14:21 +0200)]
rpc: Fix memleak in virNetMessageEncodeHeader

My latest patch for RPC rework (a2c304f6872) introduced a memory leak.
virNetMessageEncodeHeader() is calling VIR_ALLOC_N(msg->buffer, ...)
despite fact, that msg->buffer isn't VIR_FREE()'d on all paths calling
the function. Therefore, rather than injecting free statement switch to
VIR_REALLOC_N().

12 years agoFix privileges on /var/run/libvirt directory
Daniel P. Berrange [Mon, 11 Jun 2012 11:31:16 +0000 (12:31 +0100)]
Fix privileges on /var/run/libvirt directory

Previous commit

  commit 32a9aac2e04c991340b66c855a1095e4e6445e54
  Author: William Jon McCann <william.jon.mccann@gmail.com>
  Date:   Thu May 3 12:36:27 2012 -0400

    Use XDG Base Directories instead of storing in home directory

Accidentally changed the umask when creating /var/run/libvirt
to 077. This prevents /var/run/libvirt being readable by non-root,
which is required for non-root to connect to libvirtd. Fix the
code so that umask 077 is only used for the non-privileged libvirtd
instance.

12 years agoOnly migrate profile in non-privileged libvirtd instance
Daniel P. Berrange [Mon, 11 Jun 2012 11:29:09 +0000 (12:29 +0100)]
Only migrate profile in non-privileged libvirtd instance

Only the non-privileged libvirtd instance uses $HOME. So avoid
running the code for migrating to XDG directories unless using
a non-privileged libvirtd

12 years agosnapshot: avoid virsh crash with older servers
Eric Blake [Fri, 8 Jun 2012 03:46:47 +0000 (21:46 -0600)]
snapshot: avoid virsh crash with older servers

Commits 5108230116d7b39, and 521cc447 introduced support for
'virsh snapshot-list --from' when talking to a server older than
0.9.5, but broke support for plain 'virsh snapshot-list' for the
same old server in the process.  Because the code is not properly
gated, we end up with a SIGSEGV during a strcmp with a NULL argument.

* tools/virsh.c (cmdSnapshotList): Don't waste time on fallbacks
when --from is not present.

12 years agoUpdate AUTHORS
Osier Yang [Mon, 11 Jun 2012 14:08:09 +0000 (22:08 +0800)]
Update AUTHORS

Commit a80bb970 forgot to update authors.

12 years agoLXC: fix memory leak in lxcContainerMountFSBlockAuto
Gao feng [Mon, 11 Jun 2012 05:52:37 +0000 (13:52 +0800)]
LXC: fix memory leak in lxcContainerMountFSBlockAuto

we forgot to free fslist,just add VIR_FREE(fslist).

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
12 years agoLXC: fix incorrect parameter of mount in lxcContainerMountFSBind
Gao feng [Mon, 11 Jun 2012 03:37:36 +0000 (11:37 +0800)]
LXC: fix incorrect parameter of mount in lxcContainerMountFSBind

when do remount,the source and target should be the same
values specified in the initial mount() call.

So change fs->dst to src.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
12 years agoLXC: Delete unused variable src in lxcContainerMountBasicFS
Gao feng [Mon, 11 Jun 2012 03:50:53 +0000 (11:50 +0800)]
LXC: Delete unused variable src in lxcContainerMountBasicFS

There is no code use the variable "src" in lxcContainerMountBasicFS.
so delete it and VIR_FREE.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
12 years agomsg_buf_size is unsigned long not size_t
Guido Günther [Fri, 8 Jun 2012 19:24:13 +0000 (21:24 +0200)]
msg_buf_size is unsigned long not size_t

This fixes the build on 32bit systems which otherwise fails with:

virnetmessagetest.c: In function 'testMessageHeaderEncode':
virnetmessagetest.c:75:9: error: format '%zu' expects argument of type 'size_t', but argument 7 has type 'long unsigned int' [-Werror=format]

12 years agoOnly check for cluster fs if we're using a filesystem
Guido Günther [Wed, 6 Jun 2012 18:36:31 +0000 (20:36 +0200)]
Only check for cluster fs if we're using a filesystem

otherwise migration fails for e.g. network filesystems like sheepdog
with:

   error: Invalid relative path 'virt-name': Invalid argument

while we should fail with:

    Migration may lead to data corruption if disks use cache != none

References:

    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=676328
    https://www.redhat.com/archives/libvirt-users/2012-May/msg00088.html

12 years agosnapshot: add virDomainSnapshotRef API
Eric Blake [Fri, 8 Jun 2012 16:28:55 +0000 (10:28 -0600)]
snapshot: add virDomainSnapshotRef API

virDomainSnapshotPtr has a refcount member, but no one was able
to use it.  Furthermore, all of our other vir*Ptr objects have
a *Ref method to match their *Free method.  Thankfully, this is
client-side only, so we can use this new function regardless of
how old the server side is!  (I have future patches to virsh
that want to use it.)

* include/libvirt/libvirt.h.in (virDomainSnapshotRef): Declare.
* src/libvirt.c (virDomainSnapshotRef): Implement it.
* src/libvirt_public.syms (LIBVIRT_0.9.13): Export it.

12 years agoutil: Fix deadlock in virLogReset
Jiri Denemark [Thu, 7 Jun 2012 13:16:50 +0000 (15:16 +0200)]
util: Fix deadlock in virLogReset

When libvirtd forks off a new child, the child then calls virLogReset(),
which ends up closing file descriptors used as log outputs. However, we
recently started logging closed file descriptors, which means we need to
lock logging mutex which was already locked by virLogReset(). We don't
really want to log anything when we are in the process of closing log
outputs.

12 years agoFix missing ) in 2 strings
Cole Robinson [Thu, 7 Jun 2012 21:37:13 +0000 (17:37 -0400)]
Fix missing ) in 2 strings

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

12 years agoAssign correct address type to spapr-vlan and spapr-vty.
Li Zhang [Tue, 29 May 2012 08:35:17 +0000 (16:35 +0800)]
Assign correct address type to spapr-vlan and spapr-vty.

For pseries guest, spapr-vlan and spapr-vty is based
on spapr-vio address. According to model of network
device, the address type should be assigned automatically.
For serial device, serial pty device is recognized as
spapr-vty device, which is also on spapr-vio.

So this patch is to correct the address type of
spapr-vlan and spapr-vty, and build correct
command line of spapr-vty.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Reviewed-by: Michael Ellerman<michaele@au1.ibm.com>
12 years agomaint: make it easier to copy FORTIFY_SOURCE snippet
Eric Blake [Thu, 7 Jun 2012 16:48:05 +0000 (10:48 -0600)]
maint: make it easier to copy FORTIFY_SOURCE snippet

While libvirt intentionally avoids -Wundef (after all, C99
guarantees sane semantics of treating undefined macros as 0),
the glibc insanity of #warning on _FORTIFY_SOURCE coupled with
what some people feel is the black magic of autoconf means
that other projects are likely to copy our snippet verbatim.
We can be nicer to other projects by making it easier to
integrate into projects that use -Wundef.

Suggested by Christophe Fergeau.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Be nice
to other projects using -Wundef.

12 years agocommand: avoid potential deadlock on handshake
Eric Blake [Sat, 26 May 2012 02:17:01 +0000 (20:17 -0600)]
command: avoid potential deadlock on handshake

There is a theoretical problem of an extreme bug where we can get
into deadlock due to command handshaking.  Thanks to a pair of pipes,
we have a situation where the parent thinks the child reported an
error and is waiting for a message from the child to explain the
error; but at the same time the child thinks it reported success
and is waiting for the parent to acknowledge the success; so both
processes are now blocked.

Thankfully, I don't think this deadlock is possible without at
least one other bug in the code, but I did see exactly that sort
of situation prior to commit da831af - I saw a backtrace where a
double close bug in the parent caused the parent to read from the
wrong fd and assume the child failed, even though the child really
sent success.

This potential deadlock is not quite like commit 858c247 (a deadlock
due to multiple readers on one pipe preventing a write from completing),
although the solution is similar - always close unused pipe fds before
blocking, rather than after.

* src/util/command.c (virCommandHandshakeWait): Close unused fds
sooner.

12 years agoqemu: better detection of crashed domains
Martin Kletzander [Wed, 6 Jun 2012 14:43:41 +0000 (16:43 +0200)]
qemu: better detection of crashed domains

When libvirtd is started and there is an unusable/not-connectable
leftover from earlier started machine, it's more reasonable to say
that the machine "crashed" if we know it was started with
"-no-shutdown".
This patch fixes that and also changes the other result (when machine
was started without "-no-shutdown") to "unknown", because the previous
"failed" reason means (according to include/libvirt/libvirt.h.in:174),
that the machine failed to start.

12 years agobuild: fix build without i18n
Eric Blake [Thu, 7 Jun 2012 03:13:57 +0000 (21:13 -0600)]
build: fix build without i18n

If you compile without NLS support, where _() is a no-op macro,
then we end up passing a string literal to a char*, provoking:

In file included from virsh.c:3639:0:
virsh-edit.c: In function ‘cmdSaveImageEdit’:
virsh-edit.c:97:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror]
virsh-edit.c:106:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror]

* tools/virsh-edit.c: Be const-safe.

12 years agospec: Build against systemd for udev
Cole Robinson [Wed, 6 Jun 2012 18:03:47 +0000 (14:03 -0400)]
spec: Build against systemd for udev

They have now merged. Fedora details here:

https://lists.fedoraproject.org/pipermail/devel/2012-June/168227.html

12 years agobuild: fix build of fresh checkout
Eric Blake [Wed, 6 Jun 2012 15:45:04 +0000 (09:45 -0600)]
build: fix build of fresh checkout

Commit 7bff56a worked in an incremental build, but fails for a
fresh clone; apparently, if make sees both an actual file
spelling and an inference rule, only the exact spelling is used.

  CCLD   libvirt_driver_test.la
  CC     libvirt_driver_remote_la-remote_driver.lo
remote/remote_driver.c:4707:34: fatal error: remote_client_bodies.h: No such file or directory
compilation terminated.

BUILT_SOURCES to the rescue, instead of trying to mess with .lo
dependencies directly.

* src/Makefile.am (REMOTE_DRIVER_PREREQS, %remote_driver.lo): Drop...
(BUILT_SOURCES): ...and add here instead.

12 years agobuild: ensure storage driver is used
Eric Blake [Tue, 5 Jun 2012 16:28:52 +0000 (10:28 -0600)]
build: ensure storage driver is used

Commit 1c275e9a accidentally dropped the storage driver from
libvirtd, because it depended on a C preprocessor macro that
was not defined.  Furthermore, if you do './configure
--without-storage-dir --with-storage-disk' or any other combination
where you explicitly build a subset of storage backends excluding
the dir backend, then the build is broken.

Based on analysis by Osier Yang.

* configure.ac (WITH_STORAGE): Define top-level conditional.
* src/Makefile.am (mod_LTLIBRARIES): Build driver even when
storage_dir is disabled.
* daemon/libvirtd.c: Pick up storage driver for any backend, not
just dir.
* daemon/Makefile.am (libvirtd_LDADD): Likewise.

12 years agorpc: Size up RPC limits
Michal Privoznik [Fri, 27 Apr 2012 12:49:48 +0000 (14:49 +0200)]
rpc: Size up RPC limits

Since we are allocating RPC buffer dynamically, we can increase limits
for max. size of RPC message and RPC string. This is needed to cover
some corner cases where libvirt is run on such huge machines that their
capabilities XML is 4 times bigger than our current limit. This leaves
users with inability to even connect.

12 years agorpc: Switch to dynamically allocated message buffer
Michal Privoznik [Thu, 26 Apr 2012 15:21:24 +0000 (17:21 +0200)]
rpc: Switch to dynamically allocated message buffer

Currently, we are allocating buffer for RPC messages statically.
This is not such pain when RPC limits are small. However, if we want
ever to increase those limits, we need to allocate buffer dynamically,
based on RPC message len (= the first 4 bytes). Therefore we will
decrease our mem usage in most cases and still be flexible enough in
corner cases.

12 years agobuild: fix 'make distcheck' issues
Eric Blake [Wed, 30 May 2012 17:30:18 +0000 (11:30 -0600)]
build: fix 'make distcheck' issues

We had a distributed file (remote_protocol.h, which in turn was
a prereq to remote_driver.c) depending on a generated file
(libvirt_probes.h), which is a no-no for a VPATH build from a
read-only source tree (no wonder 'make distcheck' tests precisely
that situation):

     File `libvirt_driver_remote.la' does not exist.
       File `libvirt_driver_remote_la-remote_driver.lo' does not exist.
             Prerequisite `libvirt_probes.h' is newer than target `../../src/remote/remote_protocol.h'.
            Must remake target `../../src/remote/remote_protocol.h'.
Invoking recipe from Makefile:7464 to update target `../../src/remote/remote_protocol.h'.
make[3]: Entering directory `/home/remote/eblake/libvirt-tmp2/build/libvirt-0.9.12/_build/src'
  GEN    ../../src/remote/remote_protocol.h
cannot create ../../src/remote/remote_protocol.h: Permission denied at ../../src/rpc/genprotocol.pl line 31.
make[3]: *** [../../src/remote/remote_protocol.h] Error 13

Rather than making distributed .c files depend on generated files, we
really want to ensure that compilation into .lo files is not attempted
until the generated files are present, done by this patch.  Since there
were two different sets of conditionally generated files that both
feed the .lo file, I had to introduce a new variable REMOTE_DRIVER_PREREQS
to keep automake happy.

After that fix, the next issue was that make treats './foo' and 'foo'
differently in determining whether an implicit %foo rule is applicable,
with the result that locking/qemu-sanlock.conf wasn't properly being
built at the right times.  Also, the output for using the .aug test
files was a bit verbose.

After fixing the src directory, the next error is related to the docs
directory, where the tarball is missing a stamp file and thus tries to
regenerate files that are already present:

  GEN    ../../docs/apibuild.py.stamp
Traceback (most recent call last):
  File "../../docs/apibuild.py", line 2511, in <module>
    rebuild("libvirt")
  File "../../docs/apibuild.py", line 2495, in rebuild
    builder.serialize()
  File "../../docs/apibuild.py", line 2424, in serialize
    output = open(filename, "w")
IOError: [Errno 13] Permission denied: '../../docs/libvirt-api.xml'
make[5]: *** [../../docs/apibuild.py.stamp] Error 1

and fixing that exposed another case of a distributed file (generated
html) depending on a built file (libvirt.h), but only when doing an
in-tree build, because of a file glob.

* src/Makefile.am ($(srcdir)/remote/remote_driver.c): Change...
(libvirt_driver_remote_la-remote_driver.lo): ...to the real
dependency.
($(builddir)/locking/%-sanlock.conf): Drop $(builddir), so that
rule gets run in time for test_libvirt_sanlock.aug.
(test_libvir*.aug): Cater to silent build.
(conf_DATA): Don't ship qemu-sanlock.conf in the tarball, since it
is trivial to regenerate.
* docs/Makefile.am (EXTRA_DIST): Ship our stamp file.
($(APIBUILD_STAMP)): Don't depend on generated file.

12 years agotests: Refresh qemu-1.1.0 data
Jiri Denemark [Tue, 5 Jun 2012 13:34:09 +0000 (15:34 +0200)]
tests: Refresh qemu-1.1.0 data

QEMU 1.1.0 has been officially released. With 1.1.0 QEMU went back to
three-digits version even for the initial release and I renamed the data
files to match this fact. They were generated with

qemu-system-x86_64 -help >tests/qemuhelpdata/qemu-1.1.0
qemu-system-x86_64 \
    -device ? \
    -device pci-assign,? \
    -device virtio-blk-pci,? \
    -device virtio-net-pci,? \
    -device scsi-disk,? 2>tests/qemuhelpdata/qemu-1.1.0-device

12 years agovirsh: Back out if the argument for vol-create-as is malformed
Osier Yang [Mon, 4 Jun 2012 09:08:34 +0000 (17:08 +0800)]
virsh: Back out if the argument for vol-create-as is malformed

12 years agovirsh: Accept UUID as an argument for net-info and net-start
Osier Yang [Mon, 4 Jun 2012 08:37:55 +0000 (16:37 +0800)]
virsh: Accept UUID as an argument for net-info and net-start

12 years agovirsh: Accept UUID as an argument for storage commands
Osier Yang [Mon, 4 Jun 2012 08:35:34 +0000 (16:35 +0800)]
virsh: Accept UUID as an argument for storage commands

Affected commands are: pool-start, vol-create-from.

12 years agoFix for parallel port passthrough for QEMU
Beat Jörg [Wed, 23 May 2012 05:50:02 +0000 (07:50 +0200)]
Fix for parallel port passthrough for QEMU

I came across a bug that the command line generated for passthrough
of the host parallel port /dev/parport0 by libvirt for QEMU is incorrect.

It currently produces:
-chardev tty,id=charparallel0,path=/dev/parport0
-device isa-parallel,chardev=charparallel0,id=parallel0

The first parameter is "tty". It sould be "parport".

If I launch qemu with -chardev parport,... it works as expected.

I have already filled a bug report (
https://bugzilla.redhat.com/show_bug.cgi?id=823879 ), the topic was
already on the list some months ago:

https://www.redhat.com/archives/libvirt-users/2011-September/msg00095.html

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agomaint: command.c whitespace cleanups
Eric Blake [Mon, 4 Jun 2012 22:32:43 +0000 (16:32 -0600)]
maint: command.c whitespace cleanups

Noticed during the previous commit.

* src/util/command.c: Fix some spacing and break long lines.

12 years agocommand: avoid deadlock on EPIPE situation
Eric Blake [Thu, 31 May 2012 21:50:07 +0000 (15:50 -0600)]
command: avoid deadlock on EPIPE situation

It is possible to deadlock libvirt by having a domain with XML
longer than PIPE_BUF, and by writing a hook script that closes
stdin early.  This is because libvirt was keeping a copy of the
child's stdin read fd open, which means the write fd in the
parent will never see EPIPE (remember, libvirt should always be
run with SIGPIPE ignored, so we should never get a SIGPIPE signal).
Since there is no error, libvirt blocks waiting for a write to
complete, even though the only reader is also libvirt.  The
solution is to ensure that only the child can act as a reader
before the parent does any writes; and then dealing with the
fallout of dealing with EPIPE.

Thankfully, this is not a security hole - since the only way to
trigger the deadlock is to install a custom hook script, anyone
that already has privileges to install a hook script already has
privileges to do any number of other equally disruptive things
to libvirt; it would only be a security hole if an unprivileged
user could install a hook script to DoS a privileged user.

* src/util/command.c (virCommandRun): Close parent's copy of child
read fd earlier.
(virCommandProcessIO): Don't let EPIPE be fatal; the child may
be done parsing input.
* tests/commandhelper.c (main): Set up a SIGPIPE situation.
* tests/commandtest.c (test20): Trigger it.
* tests/commanddata/test20.log: New file.

12 years agoutil: fix "make rpm" when viratomic.h is used
Laine Stump [Mon, 4 Jun 2012 18:40:07 +0000 (14:40 -0400)]
util: fix "make rpm" when viratomic.h is used

Although src/util/viratomic.h has been added to the repo, up until now
it hasn't been used. Stefan Berger is using it in his proposed dhcp
snooping patches, and an rpm build with those patches failed due to
viratomic.h not being packed up with the rest of the sources.

12 years agobuild: allow building with newer glibc-headers and -O0
Eric Blake [Mon, 4 Jun 2012 17:33:20 +0000 (11:33 -0600)]
build: allow building with newer glibc-headers and -O0

glibc 2.15 (on Fedora 17) coupled with explicit disabling of
optimization during development dies a painful death:

In file included from /usr/include/limits.h:27:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:169,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:34,
                 from util/bitmap.c:26:
/usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
cc1: all warnings being treated as errors

Work around this by only conditionally defining _FORTIFY_SOURCE,
in the case where glibc can actually use it.  The trick is using
AH_VERBATIM instead of AC_DEFINE.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Squelch
_FORTIFY_SOURCE when needed to avoid glibc #warnings.

12 years agofix make syntax-check failed
Wen Congyang [Mon, 4 Jun 2012 03:37:50 +0000 (11:37 +0800)]
fix make syntax-check failed

12 years agobuild: fix sc_prohibit_readlink
Eric Blake [Mon, 4 Jun 2012 15:17:36 +0000 (09:17 -0600)]
build: fix sc_prohibit_readlink

I noticed this during 'make syntax-check':

prohibit_readlink
grep: Unmatched ( or \(

* cfg.mk (exclude_file_name_regexp--sc_prohibit_readlink): Fix
mismatched '('.

12 years agofile: Log closing filedescriptors
Jiri Denemark [Wed, 30 May 2012 13:54:18 +0000 (15:54 +0200)]
file: Log closing filedescriptors

EBADF errors are logged as warnings as they normally indicate a double
close bug. This patch also provides VIR_MASS_CLOSE helper to be user in
the only case of mass close after fork when EBADF should rather be
ignored.

12 years agocommand: Fix debug message during handshake
Jiri Denemark [Wed, 30 May 2012 13:36:12 +0000 (15:36 +0200)]
command: Fix debug message during handshake

Probably a result of copy&paste...

12 years agoFix sync issue in virNetClientStreamEventRemoveCallback
Radu Caragea [Mon, 4 Jun 2012 07:32:37 +0000 (09:32 +0200)]
Fix sync issue in virNetClientStreamEventRemoveCallback

The stream lock is unlocked twice instead of being locked and then
unlocked. Probably a typo.

12 years agovirsh: Allow users to reedit rejected XML
Michal Privoznik [Fri, 18 May 2012 10:21:06 +0000 (12:21 +0200)]
virsh: Allow users to reedit rejected XML

If users *-edit but make a mistake in XML all changes are
permanently lost. However, if virsh is not running within
a script we can ask user if he wants to re-edit the file
and correct the mistakes.

12 years agovirsh: Switch from generated cmd*Edit commands to nongenerated
Michal Privoznik [Thu, 17 May 2012 15:08:53 +0000 (17:08 +0200)]
virsh: Switch from generated cmd*Edit commands to nongenerated

Currently, we either generate some cmd*Edit commands (cmdPoolEdit
and cmdNetworkEdit) via sed script or copy the body of cmdEdit
(e.g. cmdInterfaceEdit, cmdNWFilterEdit, etc.). This fact makes
it harder to implement any new feature to our editing system.
Therefore switch to new implementation - define macros to:
- dump XML (EDIT_GET_XML)
- take an action if XML wasn't changed,
  usually just vshPrint() (EDIT_NOT_CHANGED)
- define new object (EDIT_DEFINE) - the edited XML is in @doc_edited
- free object defined by EDIT_DEFINE (EDIT_FREE)
and #include "virsh-edit.c"

12 years agonwfilter: Add multiple IP address support to DHCP snooping
Stefan Berger [Fri, 1 Jun 2012 23:32:06 +0000 (19:32 -0400)]
nwfilter: Add multiple IP address support to DHCP snooping

With support for multiple IP addresses per interface in place, this patch
now adds support for multiple IP addresses per interface for the DHCP
snooping code.

Testing:

Since the infrastructure I tested this with does not provide multiple IP
addresses per MAC address (anymore), I either had to plug the VM's interface
from the virtual bride connected directly to the infrastructure to virbr0
to get a 2nd IP address from dnsmasq (kill and run dhclient inside the VM)
or changed the lease file  (/var/run/libvirt/network/nwfilter.leases) and
restart libvirtd to have a 2nd IP address on an existing interface.
Note that dnsmasq can take a lease timeout parameter as part of the --dhcp-range
command line parameter, so that timeouts can be tested that way
(--dhcp-range 192.168.122.2,192.168.122.254,120). So, terminating and restarting
dnsmasq with that parameter is another choice to watch an IP address disappear
after 120 seconds.

Regards,
   Stefan

12 years agonwfilter: move code for IP address map into separate file
Stefan Berger [Fri, 1 Jun 2012 23:32:06 +0000 (19:32 -0400)]
nwfilter: move code for IP address map into separate file

The goal of this patch is to prepare for support for multiple IP
addresses per interface in the DHCP snooping code.

Move the code for the IP address map that maps interface names to
IP addresses into their own file. Rename the functions on the way
but otherwise leave the code as-is. Initialize this new layer
separately before dependent layers (iplearning, dhcpsnooping)
and shut it down after them.

12 years agonwfilter: add DHCP snooping
Stefan Berger [Fri, 1 Jun 2012 23:32:06 +0000 (19:32 -0400)]
nwfilter: add DHCP snooping

This patch adds DHCP snooping support to libvirt. The learning method for
IP addresses is specified by setting the "CTRL_IP_LEARNING" variable to one of
"any" [default] (existing IP learning code), "none" (static only addresses)
or "dhcp" (DHCP snooping).

Active leases are saved in a lease file and reloaded on restart or HUP.

The following interface XML activates and uses the DHCP snooping:

    <interface type='bridge'>
      <source bridge='virbr0'/>
      <filterref filter='clean-traffic'>
        <parameter name='CTRL_IP_LEARNING' value='dhcp'/>
      </filterref>
    </interface>

All filters containing the variable 'IP' are automatically adjusted when
the VM receives an IP address via DHCP. However, multiple IP addresses per
interface are silently ignored in this patch, thus only supporting one IP
address per interface. Multiple IP address support is added in a later
patch in this series.

Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
12 years agoqemu: move -name arg to be 1st in "ps x" output
Marti Raudsepp [Fri, 1 Jun 2012 16:25:33 +0000 (19:25 +0300)]
qemu: move -name arg to be 1st in "ps x" output

Currently, monitoring QEMU virtual machines with standard Unix
sysadmin tools is harder than it has to be. The QEMU command line is
often miles long and mostly redundant, it's hard to tell which process
is which.

This patch reorders the QEMU -name argument to be the first, so it's
immediately visible in "ps x", htop and "atop -c" output.

12 years agoqemu: fix netdev alias name assignment wrt type='hostdev'
Laine Stump [Fri, 1 Jun 2012 16:50:37 +0000 (12:50 -0400)]
qemu: fix netdev alias name assignment wrt type='hostdev'

This patch resolves:

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

The problem is that an interface with type='hostdev' will have an
alias of the form "hostdev%d", while the function that looks through
existing netdevs to determine the name to use for a new addition will
fail if there's an existing entry that does not match the form
"net%d".

This is another of the handful of places that need an exception due to
the hybrid nature of <interface type='hostdev'> (which is not exactly
an <interface> or a <hostdev>, but is both at the same time).

12 years agotools: make virt-pki-validate work with acls and xattrs
Martin Kletzander [Thu, 31 May 2012 09:00:06 +0000 (11:00 +0200)]
tools: make virt-pki-validate work with acls and xattrs

This patch makes virt-pki-validate work with certificates that have
acl or xattr set. Otherwise it failing due to wrong permissions.

12 years agoqemu: avoid closing fd more than once
Wen Congyang [Wed, 30 May 2012 09:20:44 +0000 (17:20 +0800)]
qemu: avoid closing fd more than once

If we migrate to fd, spec->fwdType is not MIGRATION_FWD_DIRECT,
we will close spec->dest.fd.local in qemuMigrationRun(). So we
should set spec->dest.fd.local to -1 in qemuMigrationRun().

Bug present since 0.9.5 (commit 326176179).

12 years agocommand: check for fork error before closing fd
Wen Congyang [Wed, 30 May 2012 09:20:44 +0000 (17:20 +0800)]
command: check for fork error before closing fd

We should not set *outfd or *errfd if virExecWithHook() failed
because the caller may close these fds.

Bug present since v0.4.5 (commit 60ed1d2a).

12 years agofdstream: avoid double close bug
Eric Blake [Wed, 30 May 2012 15:20:37 +0000 (09:20 -0600)]
fdstream: avoid double close bug

Wen Congyang reported that we have a double-close bug if we fail
virFDStreamOpenInternal, since childfd duplicated one of the fds[]
array contents.  In truth, since we always transfer both members
of fds to other variables, we should close the fds through those
other names, and just use fds[] for pipe().

Bug present since 0.9.0 (commit e886237a).

* src/fdstream.c (virFDStreamOpenFileInternal): Swap scope of
childfd and fds[], to avoid a double close.

12 years agocommand: avoid double close bugs
Eric Blake [Tue, 29 May 2012 23:47:58 +0000 (17:47 -0600)]
command: avoid double close bugs

KAMEZAWA Hiroyuki reported a nasty double-free bug when virCommand
is used to convert a string into input to a child command.  The
problem is that the poll() loop of virCommandProcessIO would close()
the write end of the pipe in order to let the child see EOF, then
the caller virCommandRun() would also close the same fd number, with
the second close possibly nuking an fd opened by some other thread
in the meantime.  This in turn can have all sorts of bad effects.

The bug has been present since the introduction of virCommand in
commit f16ad06f.

This is based on his first attempt at a patch, at
https://bugzilla.redhat.com/show_bug.cgi?id=823716

* src/util/command.c (_virCommand): Drop inpipe member.
(virCommandProcessIO): Add argument, to avoid closing caller's fd
without informing caller.
(virCommandRun, virCommandNewArgs): Adjust clients.

12 years agoavoid fd leak
Wen Congyang [Wed, 30 May 2012 09:20:46 +0000 (17:20 +0800)]
avoid fd leak

virCommandRunAsync() will set errfd if it succeed. We should
close it if virFDStreamOpenInternal() fails.

12 years agoavoid closing uninitialized fd
Wen Congyang [Wed, 30 May 2012 09:20:41 +0000 (17:20 +0800)]
avoid closing uninitialized fd

If the system does not support bypass cache, we will close fd,
but it is uninitialized.

12 years agoFixes for check and rpm builds without sanlock (and qemu)
Martin Kletzander [Wed, 30 May 2012 15:15:22 +0000 (17:15 +0200)]
Fixes for check and rpm builds without sanlock (and qemu)

Apart from the non-sanlock check build, there is also a little fix for
qemu (EXTRA_DIST had qemu.conf and others inside even if the build was
supposed to be without qemu).

12 years agobuild: include augeas-gentest.pl into dist file
Wen Congyang [Wed, 30 May 2012 02:15:13 +0000 (10:15 +0800)]
build: include augeas-gentest.pl into dist file

We generate *.aug from *.aug.in by augeas-gentest.pl, so this script
should be included in dist file.

12 years agobuild: use same perl binary throughout build
Eric Blake [Tue, 29 May 2012 21:57:31 +0000 (15:57 -0600)]
build: use same perl binary throughout build

Some of our rules used $(PERL), while others used 'perl'.  Always
using the variable allows a developer to point to a different (often
better) perl than the default one found on $PATH.

* daemon/Makefile.am ($(srcdir)/remote_dispatch.h): s/perl/$(PERL).
* src/Makefile.am ($(srcdir)/remote/remote_client_bodies.h)
(PDWTAGS, %protocol.c, %_probes.stp): Likewise.

12 years agobuild: fix testing of augeas files in VPATH builds
Eric Blake [Tue, 29 May 2012 21:49:13 +0000 (15:49 -0600)]
build: fix testing of augeas files in VPATH builds

Without this fix, a VPATH build (such as used by ./autobuild.sh)
fails with messages like:

make[3]: Entering directory `/home/remote/eblake/libvirt-tmp2/build/daemon'
../../build-aux/augeas-gentest.pl libvirtd.conf ../../daemon/test_libvirtd.aug.in test_libvirtd.aug
cannot read libvirtd.conf: No such file or directory at ../../build-aux/augeas-gentest.pl line 38.

Since the test files are not part of the tarball, we can generate
them into the build dir, but rather than create a subdirectory
just for the test file, it is easier to test them directly in
libvirt.git/src.

* daemon/Makefile.am (AUG_GENTEST): Factor out definition.
(test_libvirtd.aug): Look for correct file.
* src/Makefile.am (AUG_GENTEST): Use $(PERL).
(qemu/test_libvirtd_qemu.aug, lxc/test_libvirtd_lxc.aug)
(locking/test_libvirt_sanlock.aug): Rename to avoid subdirectories.
(check-augeas-qemu, check-augeas-lxc, check-augeas-sanlock): Reflect
location of built tests.
* configure.ac (PERL): Substitute perl.

12 years agobuild: silence warning from autoconf
Eric Blake [Tue, 29 May 2012 14:10:44 +0000 (08:10 -0600)]
build: silence warning from autoconf

Autoconf 2.60 and later insist on using ${datarootdir}, rather than
the derived ${datadir} (although the latter defaults to the former,
it is possible to set configure arguments so that they differ):

config.status: creating libvirt.pc
config.status: WARNING:  'libvirt.pc.in' seems to ignore the --datarootdir setting

This patch follows the autoconf manual's suggestions for how to
support 2.59 (RHEL 5) and newer simultaneously.

* libvirt.pc.in (datarootdir): Define, so ${datadir} will not ignore
datarootdir when using newer autoconf.

12 years agovirCommand: Extend debug message for handshake
Michal Privoznik [Wed, 30 May 2012 12:17:26 +0000 (14:17 +0200)]
virCommand: Extend debug message for handshake

Currently, we are logging only one side of pipes we
create in virCommandRequireHandshake(); This is enough
in cases where pipe2() returns two consecutive FDs. However,
it is not guaranteed and it may return any FDs.
Therefore, it's wise to log the other ends as well.

12 years agolxc: return correct number of CPUs
Martin Kletzander [Tue, 29 May 2012 07:12:32 +0000 (09:12 +0200)]
lxc: return correct number of CPUs

When getting number of CPUs the host has assigned, there was always
number "1" returned. Even though all lxc domains with no pinning
launched by libvirt run on all pCPUs (by default, no matter what's the
number), we should at least return the same number as the user
specified when creating the domain.