]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agosecurity: Introduce SetSocketLabel
Jiri Denemark [Fri, 26 Aug 2011 07:39:32 +0000 (09:39 +0200)]
security: Introduce SetSocketLabel

This API labels all sockets created until ClearSocketLabel is called in
a way that a vm can access them (i.e., they are labeled with svirt_t
based label in SELinux).

13 years agosecurity: Rename SetSocketLabel APIs to SetDaemonSocketLabel
Jiri Denemark [Fri, 26 Aug 2011 07:05:57 +0000 (09:05 +0200)]
security: Rename SetSocketLabel APIs to SetDaemonSocketLabel

The APIs are designed to label a socket in a way that the libvirt daemon
itself is able to access it (i.e., in SELinux the label is virtd_t based
as opposed to svirt_* we use for labeling resources that need to be
accessed by a vm). The new name reflects this.

13 years agoIgnore unused streams in virStreamAbort
Jiri Denemark [Mon, 15 Aug 2011 09:28:53 +0000 (11:28 +0200)]
Ignore unused streams in virStreamAbort

When virStreamAbort is called on a stream that has not been used yet,
quite confusing error is returned: "this function is not supported by
the connection driver". Let's just ignore such streams as there's
nothing to abort anyway.

13 years agoDo not try to cancel non-existent migration on source
Jiri Denemark [Fri, 12 Aug 2011 18:46:07 +0000 (20:46 +0200)]
Do not try to cancel non-existent migration on source

If migration failed on source daemon, the migration is automatically
canceled by the daemon itself. Thus we don't need to call
virDomainMigrateConfirm3(cancelled=1). Calling it doesn't cause any harm
but the resulting error message printed in logs may confuse people.

13 years agosnapshot: track current snapshot across restarts
Eric Blake [Thu, 25 Aug 2011 21:11:03 +0000 (15:11 -0600)]
snapshot: track current snapshot across restarts

Audit all changes to the qemu vm->current_snapshot, and make them
update the saved xml file for both the previous and the new
snapshot, so that there is always at most one snapshot with
<active>1</active> in the xml, and that snapshot is used as the
current snapshot even across libvirtd restarts.

This patch does not fix the case of virDomainSnapshotDelete(,CHILDREN)
where one of the children is the current snapshot; that will be later.

* src/conf/domain_conf.h (_virDomainSnapshotDef): Alter member
type and name.
* src/conf/domain_conf.c (virDomainSnapshotDefParseString)
(virDomainSnapshotDefFormat): Update clients.
* docs/schemas/domainsnapshot.rng: Tighten rng.
* src/qemu/qemu_driver.c (qemuDomainSnapshotLoad): Reload current
snapshot.
(qemuDomainSnapshotCreateXML, qemuDomainRevertToSnapshot)
(qemuDomainSnapshotDiscard): Track current snapshot.

13 years agosnapshot: only pass snapshot to qemu command line when reverting
Eric Blake [Thu, 25 Aug 2011 20:44:48 +0000 (14:44 -0600)]
snapshot: only pass snapshot to qemu command line when reverting

Changing the current vm, and writing that change to the file
system, all before a new qemu starts, is risky; it's hard to
roll back if starting the new qemu fails for some reason.
Instead of abusing vm->current_snapshot and making the command
line generator decide whether the current snapshot warrants
using -loadvm, it is better to just directly pass a snapshot all
the way through the call chain if it is to be loaded.

This frees up the last use of snapshot->def->active for qemu's
use, so the next patch can repurpose that field for tracking
which snapshot is current.

* src/qemu/qemu_command.c (qemuBuildCommandLine): Don't use active
field of snapshot.
* src/qemu/qemu_process.c (qemuProcessStart): Add a parameter.
* src/qemu/qemu_process.h (qemuProcessStart): Update prototype.
* src/qemu/qemu_migration.c (qemuMigrationPrepareAny): Update
callers.
* src/qemu/qemu_driver.c (qemudDomainCreate)
(qemuDomainSaveImageStartVM, qemuDomainObjStart)
(qemuDomainRevertToSnapshot): Likewise.
(qemuDomainSnapshotSetCurrentActive)
(qemuDomainSnapshotSetCurrentInactive): Delete unused functions.

13 years agosnapshot: don't leak resources on qemu snapshot failure
Eric Blake [Fri, 12 Aug 2011 20:45:39 +0000 (14:45 -0600)]
snapshot: don't leak resources on qemu snapshot failure

https://bugzilla.redhat.com/show_bug.cgi?id=727709
mentions that if qemu fails to create the snapshot (such as what
happens on Fedora 15 qemu, which has qmp but where savevm is only
in hmp, and where libvirt is old enough to not try the hmp fallback),
then 'virsh snapshot-list dom' will show a garbage snapshot entry,
and the libvirt internal directory for storing snapshot metadata
will have a bogus file.

This fixes the fallout bug of polluting the snapshot-list with
garbage on failure (the root cause of the F15 bug of not having
fallback to hmp has already been fixed in newer libvirt releases).

* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Allocate
memory before making snapshot, and cleanup on failure.  Don't
dereference NULL if transient domain exited during snapshot creation.

13 years agolibvirt: avoid dead store in virDomainMigrateVersion3
Alex Jia [Tue, 16 Aug 2011 09:24:26 +0000 (17:24 +0800)]
libvirt: avoid dead store in virDomainMigrateVersion3

* src/qemu/qemu_migration.c: avoid dead 'ret' assignment and silence
  clang warning.

Detected by ccc-analyzer:

libvirt.c:4277:5: warning: Value stored to 'ret' is never read
    ret = domain->conn->driver->domainMigrateConfirm3
    ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

13 years agoqemu: avoid dead store in doPeer2PeerMigrate3
Alex Jia [Tue, 16 Aug 2011 09:24:25 +0000 (17:24 +0800)]
qemu: avoid dead store in doPeer2PeerMigrate3

* src/qemu/qemu_migration.c: avoid dead 'ret' assignment and silence
  clang warning.

Detected by ccc-analyzer:

  CC     libvirt_driver_qemu_la-qemu_migration.lo
qemu/qemu_migration.c:2046:5: warning: Value stored to 'ret' is never read
    ret = qemuMigrationConfirm(driver, sconn, vm,
    ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

13 years agoFix command test wrt gnutls initialize & fix debugging
Daniel P. Berrange [Thu, 25 Aug 2011 11:05:54 +0000 (12:05 +0100)]
Fix command test wrt gnutls initialize & fix debugging

The VIR_TEST_DEBUG and VIR_TEST_VERBOSE env vars did not work
because we replaced 'environ' with 'newenv'. Simply calling
virTestGetDebug/Verbose() before replacing the 'environ' ensures
we have processed the env variables.

The gnutls initialization code opens /dev/urandom and keeps that
FD around for later use. We have code which kills off FDs 3-5
to avoid interfereing with our test case. Move the virInitialize
call before this point, so it kills off the gnutls /dev/urandom
FD which is irrelevant for testing purposes

* tests/commandtest.c: Fix test debugging & make it robust against
  opened FDs

13 years agodaemon: Move TLS initialization to virInitialize
Michal Privoznik [Wed, 24 Aug 2011 14:16:45 +0000 (16:16 +0200)]
daemon: Move TLS initialization to virInitialize

My previous patch 74c75671331d284e1f777f9692b72e9737520bf0
introduced a regression by removing TLS initialization from client.

13 years agoutil: only fchown newly created files in virFileOpenAs
Laine Stump [Wed, 24 Aug 2011 08:50:49 +0000 (04:50 -0400)]
util: only fchown newly created files in virFileOpenAs

virFileOpenAs takes desired uid:gid as arguments, and not only uses
them for a fork/setuid/setgid when retrying failed open operations,
but additionally always forces the opened file to be owned by the
given uid:gid.

One example of the problems this causes is that, when restoring a
domain from a file that is owned by the qemu user, opening the file
chowns it to root. if dynamic_ownership=1 this is coincidentally
expected, but if dynamic_ownership=0, no existing file should ever
have its ownership changed.

This patch adds an extra check before calling fchown() - it only does
it if O_CREAT was passed to virFileOpenAs() in the openflags.

13 years agoqemu: fix off-by-one in pci slot reservation
Shradha Shah [Wed, 24 Aug 2011 15:31:48 +0000 (16:31 +0100)]
qemu: fix off-by-one in pci slot reservation

Signed-off-by: Steve Hodgson <shodgson@solarflare.com>
13 years agomaint: attribute second author of previous patch
Steve Hodgson [Wed, 24 Aug 2011 16:48:20 +0000 (10:48 -0600)]
maint: attribute second author of previous patch

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agopci: fix pciDeviceListSteal on multiple devices
Shradha Shah [Wed, 24 Aug 2011 15:30:51 +0000 (16:30 +0100)]
pci: fix pciDeviceListSteal on multiple devices

pciDeviceListSteal(pcidevs, dev) removes dev from pcidevs reducing
the length of pcidevs, so moving onto what was the next dev is wrong.

Instead callers should pop entry 0 repeatedly until pcidevs is empty.

Signed-off-by: Steve Hodgson <shodgson@solarflare.com>
Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agolibvirt: log all flags parameters
Eric Blake [Tue, 16 Aug 2011 20:24:12 +0000 (14:24 -0600)]
libvirt: log all flags parameters

I was testing a virsh patch, and wanted to see if I had passed the
flags I thought.  But with LIBVIRT_DEBUG in the environment, I just
saw:

14:24:52.359: 15022: debug : virDomainSnapshotNum:15586 : dom=0xc9c180, (VM: name=rhel_6-64, uuid=48f8e8e7-e14f-0e14-02f0-ce71997bdcab),

including a trailing space.  This fixes the issues.

* src/libvirt.c: Log flag parameters, even if currently unused.
(VIR_DOMAIN_DEBUG_0): Drop trailing comma in log.
(VIR_DOMAIN_DEBUG_1): Split guts into...
(VIR_DOMAIN_DEBUG_2): ...new macro.

13 years agovirsh: add list --managed-save
Eric Blake [Fri, 19 Aug 2011 00:09:14 +0000 (18:09 -0600)]
virsh: add list --managed-save

Knowing whether 'virsh start' will resume a saved image or do
a fresh boot is useful enough to expose via 'virsh list'.

Also, translate the state column.

* tools/virsh.c (cmdList): add --managed-save flag
* tools/virsh.pod (list): Document it.
Based on a suggestion by Miklos Vajna.

13 years agoesx: Use $(PYTHON) instead of the shebang to run the generator
Matthias Bolte [Tue, 23 Aug 2011 21:40:40 +0000 (23:40 +0200)]
esx: Use $(PYTHON) instead of the shebang to run the generator

13 years agoqemu: Report error if qemu monitor command not found for BlockJob
Osier Yang [Wed, 24 Aug 2011 06:39:42 +0000 (14:39 +0800)]
qemu: Report error if qemu monitor command not found for BlockJob

* src/qemu/qemu_monitor_json.c: Handle error "CommandNotFound" and
  report the error.

* src/qemu/qemu_monitor_text.c: If a sub info command is not found,
  it prints the output of "help info", for other commands,
  "unknown command" is printed.

Without this patch, libvirt always report:

  An error occurred, but the cause is unknown

This patch was adapted from a patch by Osier Yang <jyang@redhat.com> to
break out detection of unrecognized text monitor commands into a separate
function.

Signed-off-by: Adam Litke <agl@us.ibm.com>
13 years agoesx: Refactor a repeated string in the generator
Matthias Bolte [Tue, 23 Aug 2011 21:15:21 +0000 (23:15 +0200)]
esx: Refactor a repeated string in the generator

13 years agomaint: fix comment typos
Eric Blake [Tue, 23 Aug 2011 17:02:02 +0000 (11:02 -0600)]
maint: fix comment typos

* src/qemu/qemu_driver.c (qemuDomainSaveInternal): Fix typo.
* src/conf/domain_event.c (virDomainEventDispatchMatchCallback):
Likewise.
* daemon/libvirtd.c (daemonRunStateInit): Likewise.
* src/lxc/lxc_container.c (lxcContainerChildMountSort): Likewise.
* src/util/virterror.c (virCopyError, virRaiseErrorFull): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprSound): Likewise.

13 years agovirsh: Substitute goto label out with cleanup
Osier Yang [Tue, 23 Aug 2011 14:22:51 +0000 (22:22 +0800)]
virsh: Substitute goto label out with cleanup

Introduced by 241cbc13a, pushed under urgent rule.

13 years agovirsh: Do not try to free domain if it is NULL
Osier Yang [Tue, 23 Aug 2011 13:42:22 +0000 (21:42 +0800)]
virsh: Do not try to free domain if it is NULL

Without these patch, there will be error like below if domain
is NULL.

error: invalid domain pointer in virDomainFree

Which is useless.

13 years agoxen: Cleanup improper VIR_ERR_NO_SUPPORT use
Osier Yang [Tue, 23 Aug 2011 08:53:15 +0000 (16:53 +0800)]
xen: Cleanup improper VIR_ERR_NO_SUPPORT use

13 years agotest: Cleanup improper VIR_ERR_NO_SUPPORT use
Osier Yang [Tue, 23 Aug 2011 08:32:06 +0000 (16:32 +0800)]
test: Cleanup improper VIR_ERR_NO_SUPPORT use

13 years agostorage: Cleanup improper VIR_ERR_NO_SUPPORT use
Osier Yang [Tue, 23 Aug 2011 08:31:03 +0000 (16:31 +0800)]
storage: Cleanup improper VIR_ERR_NO_SUPPORT use

13 years agoremote: Cleanup improper VIR_ERR_NO_SUPPORT use
Osier Yang [Tue, 23 Aug 2011 08:26:26 +0000 (16:26 +0800)]
remote: Cleanup improper VIR_ERR_NO_SUPPORT use

13 years agoqemu: Cleanup improper VIR_ERR_NO_SUPPORT use
Osier Yang [Tue, 23 Aug 2011 08:23:10 +0000 (16:23 +0800)]
qemu: Cleanup improper VIR_ERR_NO_SUPPORT use

* src/qemu/qemu_command.c: s/VIR_ERR_NO_SUPPORT/VIR_ERR_CONFIG_UNSUPPORTED/

* src/qemu/qemu_driver.c: s/VIR_ERR_NO_SUPPORT/VIR_ERR_OPERATION_INVALID/

* src/qemu/qemu_process.c: s/VIR_ERR_NO_SUPPORT/VIR_ERR_OPERATION_INVALID/

13 years agonodeinfo: Cleanup improper VIR_ERR_NO_SUPPORT use
Osier Yang [Tue, 23 Aug 2011 08:20:35 +0000 (16:20 +0800)]
nodeinfo: Cleanup improper VIR_ERR_NO_SUPPORT use

13 years agolxc: Cleanup improper VIR_ERR_NO_SUPPORT use
Osier Yang [Tue, 23 Aug 2011 08:17:10 +0000 (16:17 +0800)]
lxc: Cleanup improper VIR_ERR_NO_SUPPORT use

s/VIR_ERR_NO_SUPPORT/VIR_ERR_OPERATION_INVALID/

Special case is changes on lxcDomainInterfaceStats, if it's not
implemented on the platform, prints error like:

    lxcError(VIR_ERR_OPERATION_INVALID, "%s",
             _("interface stats not implemented on this platform"));

As the function is supported by driver actually, error like
VIR_ERR_NO_SUPPORT is confused.

13 years agoconf: Cleanup improper use of VIR_ERR_NO_SUPPORT in node_device_conf
Osier Yang [Tue, 23 Aug 2011 07:04:00 +0000 (15:04 +0800)]
conf: Cleanup improper use of VIR_ERR_NO_SUPPORT in node_device_conf

13 years agoqemu: Substitute VIR_ERR_NO_SUPPORT with VIR_ERR_OPERATION_INVALID
Osier Yang [Tue, 23 Aug 2011 06:59:16 +0000 (14:59 +0800)]
qemu: Substitute VIR_ERR_NO_SUPPORT with VIR_ERR_OPERATION_INVALID

* src/qemu/qemu_monitor_text.c: Error like "this function is not
supported by the connection driver" is confused obviously.

13 years agovirsh: Print error if specified bandwidth is invalid for blockjob
Osier Yang [Tue, 23 Aug 2011 06:55:23 +0000 (14:55 +0800)]
virsh: Print error if specified bandwidth is invalid for blockjob

It's strange that the command fails but without any error if one
specifies as not a number.

13 years agosend-key: fix scan keycode map
KAMEZAWA Hiroyuki [Mon, 22 Aug 2011 10:02:15 +0000 (19:02 +0900)]
send-key: fix scan keycode map

Now, bad key-code in send-key can cause segmentation fault in libvirt.
(example)
 % virsh send-key --codeset win32 12
   error: End of file while reading data: Input/output error

This is caused by overrun at scanning keycode array.

Fix it.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
13 years agobuild: work around older systemtap header
Eric Blake [Fri, 1 Jul 2011 18:33:50 +0000 (12:33 -0600)]
build: work around older systemtap header

Systemtap 1.2 <sys/sdt.h> tried to expand STAP_PROBE3 into an
initialization:
  volatile __typeof__(arg) foo = arg;
but that fails if arg was declared as 'char arg[100]'.
Rather than make all callers to PROBE deal with the stupidity
of <sys/sdt.h>, we instead make PROBE cast away the problem.
Some of this preprocessor abuse copies ideas in src/libvirt.c.

* daemon/libvirtd.h (PROBE): Add casts to all arguments, using...
(VIR_ADD_CASTS, VIR_ADD_CAST, VIR_ADD_CAST2, VIR_ADD_CAST3)
(VIR_ADD_CAST_EXPAND, VIR_ADD_CAST_PASTE, VIR_COUNT_ARGS)
(VIR_ARG5, PROBE_EXPAND): New macros.
Reported by Wen Congyang.

13 years agovirsh: properly interleave shared stdout and stderr
Eric Blake [Fri, 19 Aug 2011 15:20:35 +0000 (09:20 -0600)]
virsh: properly interleave shared stdout and stderr

Without this patch, invoking 'virsh >file 2>&1' results in
error messages appearing before normal output, even if they
occurred later in time than the normal output (since stderr
is unbuffered, but stdout waits until a full buffer).

* tools/virsh.c (print_job_progress, vshError): Flush between
stream transitions.
* tests/undefine: Test it.

13 years agomaint: simplify lots of libxml2 clients
Eric Blake [Thu, 18 Aug 2011 21:37:14 +0000 (15:37 -0600)]
maint: simplify lots of libxml2 clients

Repetitive patterns should be factored.  The sign of a good
factorization is a change that kills 5x more lines than it adds :)

* src/conf/domain_conf.c (virDomainDeviceDefParse)
(virDomainSnapshotDefParseString): Use new convenience macros.
* src/conf/storage_conf.c (virStoragePoolDefParseSourceString):
Likewise.
* src/cpu/cpu.c (cpuCompareXML, cpuBaselineXML): Likewise.
* src/esx/esx_vi.c (esxVI_Context_Execute): Likewise.
* src/qemu/qemu_migration.c (qemuMigrationCookieXMLParseStr):
Likewise.
* src/security/virt-aa-helper.c (caps_mockup): Likewise.
* src/test/test_driver.c (testOpenFromFile): Likewise.
* tests/cputest.c (cpuTestLoadXML, cpuTestLoadMultiXML):
Likewise.
* tools/virsh.c (cmdFreecell, makeCloneXML, cmdVNCDisplay)
(cmdTTYConsole, cmdDetachInterface, cmdDetachDisk)
(cmdSnapshotCreate, cmdSnapshotCreateAs, cmdSnapshotCurrent)
(cmdSnapshotList, cmdSnapshotParent): Likewise.

13 years agoxml: add another convenience function
Eric Blake [Thu, 18 Aug 2011 21:01:36 +0000 (15:01 -0600)]
xml: add another convenience function

Often, we want to use XPath functions on the just-parsed document;
fold this into the parser function for convenience.

* src/util/xml.h (virXMLParseHelper): Add argument.
(virXMLParseStrHelper, virXMLParseFileHelper): Delete.
(virXMLParseCtxt, virXMLParseStringCtxt, virXMLParseFileCtxt): New
macros.
* src/libvirt_private.syms (xml.h): Remove deleted functions.
* src/util/xml.c (virXMLParseHelper): Add argument.
(virXMLParseStrHelper, virXMLParseFileHelper): Delete.

13 years agomaint: treat more libxml2 functions as free-like
Eric Blake [Thu, 18 Aug 2011 20:54:43 +0000 (14:54 -0600)]
maint: treat more libxml2 functions as free-like

* cfg.mk (useless_free_options): Add xmlFreeDoc, xmlBufferFree.
* src/esx/esx_vi.c (ESX_VI__TEMPLATE__FREE): Fix offenders.
* tools/virsh.c (cmdFreecell, cmdVNCDisplay, cmdTTYConsole)
(cmdDetachInterface, cmdDetachDisk, cmdSnapshotCreate)
(cmdSnapshotCreateAs, cmdSnapshotList, cmdSnapshotParent):
Likewise.

13 years agotest: rewrite test to match change in behavior
Eric Blake [Fri, 19 Aug 2011 14:57:22 +0000 (08:57 -0600)]
test: rewrite test to match change in behavior

Test failure exposed in commit 7d3390f.

* tests/undefine: Fix to match updated test driver semantics.

13 years agobuild: fix typo in recent test patch
Eric Blake [Fri, 19 Aug 2011 14:14:58 +0000 (08:14 -0600)]
build: fix typo in recent test patch

* src/test/test_driver.c (testDomainUndefineFlags): Use right
variable name.

13 years agoRevert "xen: Allow to undefine a running domain (xm_internal)"
Eric Blake [Fri, 19 Aug 2011 14:19:34 +0000 (08:19 -0600)]
Revert "xen: Allow to undefine a running domain (xm_internal)"

ACK was given too soon.  According to the code, the xm driver is
only used for inactive domains, and has no notion of an active
domain, thus, it cannot support undefine of a running domain.
The real fix for xen needs to be in the unified driver and/or
the xend level.

This reverts commit 49186deda62161599877b0de6f7f4345c50d842a.

13 years agoxen: Allow to undefine a running domain (xm_internal)
Osier Yang [Fri, 19 Aug 2011 13:53:39 +0000 (21:53 +0800)]
xen: Allow to undefine a running domain (xm_internal)

13 years agovmware: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:52:12 +0000 (21:52 +0800)]
vmware: Allow to undefine a running domain

13 years agouml: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:51:42 +0000 (21:51 +0800)]
uml: Allow to undefine a running domain

13 years agotest: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:50:49 +0000 (21:50 +0800)]
test: Allow to undefine a running domain

13 years agoqemu: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:49:37 +0000 (21:49 +0800)]
qemu: Allow to undefine a running domain

13 years agoopenvz: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:48:47 +0000 (21:48 +0800)]
openvz: Allow to undefine a running domain

13 years agolxc: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:47:33 +0000 (21:47 +0800)]
lxc: Allow to undefine a running domain

13 years agolibxl: Allow to undefine a running domain.
Osier Yang [Fri, 19 Aug 2011 13:46:22 +0000 (21:46 +0800)]
libxl: Allow to undefine a running domain.

Undefining a running domain will convert it to trasient, but keep
the domain still running.

13 years agoqemu: Get memory balloon info correctly for text monitor
Osier Yang [Fri, 19 Aug 2011 13:34:59 +0000 (21:34 +0800)]
qemu: Get memory balloon info correctly for text monitor

* src/qemu/qemu_monitor_text.c: BALLOON_PREFIX was defined as
"balloon: actual=", which cause "actual=" is stripped early before
the real parsing. This patch changes BALLOON_PREFIX into "balloon: ",
and modifies related functions, also renames
"qemuMonitorParseExtraBalloonInfo" to "qemuMonitorParseBalloonInfo",
as after the changing, it parses all the info returned by "info balloon".

13 years agobuild: fix compilation on mingw64
Eric Blake [Thu, 18 Aug 2011 00:12:53 +0000 (18:12 -0600)]
build: fix compilation on mingw64

* .gnulib: Update to latest, for getcwd fixes.
* bootstrap: Resync to gnulib.

13 years agostorage: Flush host cache after write
Michal Privoznik [Thu, 18 Aug 2011 12:40:03 +0000 (14:40 +0200)]
storage: Flush host cache after write

Although we are flushing cache after some critical writes (e.g.
volume creation), after some others we do not (e.g. volume cloning).
This patch fix this issue. That is for volume cloning, writing
header of logical volume, and storage wipe.

13 years agodaemon: initialize GnuTLS
Michal Privoznik [Thu, 18 Aug 2011 08:44:08 +0000 (10:44 +0200)]
daemon: initialize GnuTLS

When spice_tls is set but listen_tls is not, we don't initialize
GnuTLS library. So any later gnutls call (e.g. during migration,
where we initialize a certificate) will access uninitialized GnuTLS
internal structs and throws an error.

Although, we might now initialize GnuTLS twice, it is safe according
to the documentation:

    This function can be called many times,
    but will only do something the first time.

This patch creates 2 functions: virNetTLSInit and virNetTLSDeinit
with respect to written above.

13 years agoschedinfo: add missing documentation
Taku Izumi [Fri, 19 Aug 2011 08:53:22 +0000 (16:53 +0800)]
schedinfo: add missing documentation

This patch adds the missing documentation about the scheduler parameter
"vcpu_period" and "vcpu_quota".

13 years agomaint: ignore generated file
Eric Blake [Thu, 18 Aug 2011 23:03:26 +0000 (17:03 -0600)]
maint: ignore generated file

I did 'git add .' while in the middle of 'make syntax-check', and
it picked up a temporary file that should not be committed.

* .gitignore: Ignore sc_* from syntax check.

13 years agobuild: fix virnetsocket on mingw
Eric Blake [Wed, 17 Aug 2011 17:52:38 +0000 (11:52 -0600)]
build: fix virnetsocket on mingw

Regression introduced in commit 5d30db0.

* src/rpc/virnetsocket.c (virNetSocketNewListenUNIX) [WIN32]: Use
correct signature.

13 years agobuild: fix virpidfile on mingw
Eric Blake [Wed, 17 Aug 2011 17:46:35 +0000 (11:46 -0600)]
build: fix virpidfile on mingw

Regression introduced in commit b7e5ca4.

Mingw lacks kill(), but we were only using it for a sanity check;
so we can go with one less check.

Also, on OOM error, this function should outright fail rather than
claim that the pid file was successfully read.

* src/util/virpidfile.c (virPidFileReadPathIfAlive): Skip kill
call where unsupported, and report error on OOM.

13 years agoEnsure async packets never get marked for sync replies
Daniel P. Berrange [Tue, 16 Aug 2011 23:22:44 +0000 (16:22 -0700)]
Ensure async packets never get marked for sync replies

If a client had initiated a stream abort, it will have a call
waiting for a reply in the queue. If more data continues to
arrive on the stream, the abort command could mistakenly get
signalled as complete. Remove the code from async data processing
that looked for waiting calls. Add a sanity check to ensure no
async call can ever be marked as needing a reply

* src/rpc/virnetclient.c: Ensure async data packets can't
  trigger a reply

13 years agoDon't attempt to read from a stream if it is closed
Daniel P. Berrange [Tue, 16 Aug 2011 23:20:58 +0000 (16:20 -0700)]
Don't attempt to read from a stream if it is closed

The I/O event callback processes incoming packets first, and then
does outgoing packets. If the incoming packet caused the stream to
close, then the attempt to process outgoing data resulted in an
error. This caused libvirt to then send an error back to the client,
but the stream had already been stopped. This confused the client
since it sees 2 error events.

* daemon/stream.c: Don't attempt read if stream is closed

13 years agoqemu: disk migration verbose progress
Tom Vijlbrief [Wed, 17 Aug 2011 06:30:02 +0000 (08:30 +0200)]
qemu: disk migration verbose progress

A virsh command like:

migrate --live --copy-storage-all Guest qemu+ssh://user@host/system
--persistent --verbose

shows

Migration: [  0 %]

during the storage copy and does not start counting
until the ram transfer starts

Fix this by scraping optional disk transfer status, and adding it
into the progress meter.

13 years agovirsh: concatenate qemu-monitor-command arguments
Eric Blake [Fri, 5 Aug 2011 23:48:13 +0000 (17:48 -0600)]
virsh: concatenate qemu-monitor-command arguments

Call me lazy, but:

virsh qemu-monitor-command dom --hmp info status

is nicer than:

virsh qemu-monitor-command dom --hmp 'info status'

* tools/virsh.c (cmdQemuMonitorCommand): Allow multiple arguments,
for convenience.

13 years agoqemu: Init reattaching related members of pciDevice before reattach
Osier Yang [Wed, 17 Aug 2011 12:58:33 +0000 (20:58 +0800)]
qemu: Init reattaching related members of pciDevice before reattach

Otherwise the device will still be bound to pci-stub driver even
it's set as "managed=yes" when do detaching. Of course, it won't
triger any driver reprobing too.

13 years agovirsh: tweak misleading wording
Eric Blake [Tue, 16 Aug 2011 22:54:14 +0000 (16:54 -0600)]
virsh: tweak misleading wording

Fixes confusing docs introduced in commit 98369d3.

* tools/virsh.c (cmdSnapshotParent): Operates on named snapshot,
not current.

13 years agoTweak debugging message in RPC client code
Daniel P. Berrange [Tue, 16 Aug 2011 16:48:03 +0000 (09:48 -0700)]
Tweak debugging message in RPC client code

Make it clearer that a log message is for an outgoing message

13 years agoFix race condition in abort of stream
Daniel P. Berrange [Tue, 16 Aug 2011 16:44:28 +0000 (09:44 -0700)]
Fix race condition in abort of stream

If a stream gets a server initiated abort, the client may still
send an abort request before it receives the server side abort.
This causes the server to send back another abort for the
stream. Since the protocol defines that abort is the last thing
to be sent, the client gets confused by this second abort from
the server. If the stream is already shutdown, just drop any
client requested abort, rather than sending back another message.
This fixes the regression from previous versions.

Tested as follows

In one virsh session

  virsh # start foo
  virsh # console foo

In other virsh session

  virsh # destroy foo

The first virsh session should be able to continue issuing
commands without error. Prior to this patch it saw

  virsh # list
  error: Failed to list active domains
  error: An error occurred, but the cause is unknown

  virsh # list
  error: Failed to list active domains
  error: no call waiting for reply with prog 536903814 vers 1 serial 9

* src/rpc/virnetserverprogram.c: Drop abort requests
  for streams which no longer exist

13 years agoEnsure client streams are closed when marking a client for close
Daniel P. Berrange [Sun, 14 Aug 2011 22:44:45 +0000 (15:44 -0700)]
Ensure client streams are closed when marking a client for close

Every active stream results in a reference being held on the
virNetServerClientPtr object. This meant that if a client quit
with any streams active, although all I/O was stopped the
virNetServerClientPtr object would leak. This causes libvirtd
to leak any file handles associated with open streams when a
client quit

To fix this, when we call virNetServerClientClose there is a
callback invoked which lets the daemon release the streams
and thus the extra references

* daemon/remote.c: Add a hook to close all streams
* daemon/stream.c, daemon/stream.h: Add API for releasing
  all streams
* src/rpc/virnetserverclient.c, src/rpc/virnetserverclient.h:
  Allow registration of a hook to trigger when closing client

13 years agoEnsure stream is aborted when exiting console
Daniel P. Berrange [Tue, 1 Mar 2011 14:59:45 +0000 (14:59 +0000)]
Ensure stream is aborted when exiting console

After running 'virsh console' in interactive mode, there was a
missing call to virStreamAbort, which meant the server kept the
stream resources open

* tools/console.c: Abort stream when exiting

13 years agomaint: fix some compilation issues on non-linux platforms (part 2)
Stefan Berger [Tue, 16 Aug 2011 19:36:22 +0000 (15:36 -0400)]
maint: fix some compilation issues on non-linux platforms (part 2)

Get rid of the #if __linux__ check in virPidFileReadPathIfAlive that
was preventing a check of a symbolic link in /proc/<pid>/exe on
non-linux platforms against an expected executable. Replace
this with a run-time check testing whether the /proc/<pid>/exe is a
symbolic link and if so call the function doing the comparison
against the expected file the link is supposed to point to.

13 years agomaint: fix some compilation issues on non-linux platforms
Stefan Berger [Tue, 16 Aug 2011 17:54:15 +0000 (13:54 -0400)]
maint: fix some compilation issues on non-linux platforms

This patch fixes *some* compilation issues on non-Linux platforms (cygwin).

13 years agodaemon: Add early libvirtd start verbose errors.
Peter Krempa [Fri, 12 Aug 2011 11:41:29 +0000 (13:41 +0200)]
daemon: Add early libvirtd start verbose errors.

Early errors during start of libvirtd didn't have
an error reporting mechanism and caused libvirtd
to exit silently (only the return value indicated
an error).

Libvirt logging is initialized very early using
enviroment variables and the internal error reporting
API is used to report early errors.

 v2 changes:
 - print errors unconditionaly before logging starts
 - fix message to US spelling
 v2.5 changes:
 - initialize logging from enviroment
 - log all early errors using VIR_ERROR
 v3 changes:
 - move virSetLogFromEnv() after virInitialize()

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

13 years agomaint: add missing symbols
Stefan Berger [Tue, 16 Aug 2011 16:38:02 +0000 (12:38 -0400)]
maint: add missing symbols

Add missing symbols to libvirt_private.syms.

13 years agomacvtap: Fix getPhysfn to get the PF of a direct attach network interface
Roopa Prabhu [Tue, 16 Aug 2011 04:28:58 +0000 (21:28 -0700)]
macvtap: Fix getPhysfn to get the PF of a direct attach network interface

This patch renames getPhysfn to getPhysfnDev and adds code to get the
Physical function and Virtual Function index of the direct attach linkdev (if
the direct attach interface is a SRIOV VF). The idea is to send the port
profile message to a PF if the direct attach interface is a SRIOV VF.

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
13 years agointerface: Add functions to get sriov PF/VF relationship of a net interface
Roopa Prabhu [Tue, 16 Aug 2011 04:28:53 +0000 (21:28 -0700)]
interface: Add functions to get sriov PF/VF relationship of a net interface

This patch adds the following functions to get PF/VF relationship of an SRIOV
network interface:
ifaceIsVirtualFunction: Function to check if a network interface is a SRIOV VF
ifaceGetVirtualFunctionIndex: Function to get VF index if a network interface is a SRIOV VF
ifaceGetPhysicalFunction: Function to get the PF net interface name of a SRIOV VF net interface

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
13 years agopci: Add helper functions for sriov devices
Roopa Prabhu [Tue, 16 Aug 2011 04:28:48 +0000 (21:28 -0700)]
pci: Add helper functions for sriov devices

This patch adds the following helper functions:
pciDeviceIsVirtualFunction: Function to check if a pci device is a sriov VF
pciGetVirtualFunctionIndex: Function to get the VF index of a sriov VF
pciDeviceNetName: Function to get the network device name of a pci device
pciConfigAddressCompare: Function to compare pci config addresses

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agopci: Move some pci sriov helper code out of node device driver to util/pci
Roopa Prabhu [Tue, 16 Aug 2011 04:28:43 +0000 (21:28 -0700)]
pci: Move some pci sriov helper code out of node device driver to util/pci

This patch moves some of the sriov related pci code from node_device driver
to src/util/pci.[ch]. Some functions had to go thru name and argument list
change to accommodate the move.

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
13 years agomaint: ignore generated file
Eric Blake [Mon, 15 Aug 2011 20:42:43 +0000 (14:42 -0600)]
maint: ignore generated file

* .gitignore: Ignore qemu-sanlock.conf.

13 years agoqemu: support event_idx parameter for virtio disk and net devices
Laine Stump [Sat, 13 Aug 2011 06:32:45 +0000 (02:32 -0400)]
qemu: support event_idx parameter for virtio disk and net devices

In some versions of qemu, both virtio-blk-pci and virtio-net-pci
devices can have an event_idx setting that determines some details of
event processing. When it is enabled, it "reduces the number of
interrupts and exits for the guest". qemu will automatically enable
this feature when it is available, but there may be cases where this
new feature could actually make performance worse (NB: no such case
has been found so far).

As a safety switch in case such a situation is encountered in the
field, this patch adds a new attribute "event_idx" to the <driver>
element of both disk and interface devices. event_idx can be set to
"on" (to force event_idx on in case qemu has it disabled by default)
or "off" (for force event_idx off). In the case that event_idx support
isn't present in qemu, the attribute is ignored (this on the advice of
the qemu developer).

docs/formatdomain.html.in: document the new flag (marking it as
   "don't mess with this!"
docs/schemas/domain.rng: add event_idx in appropriate places
src/conf/domain_conf.[ch]: add event_idx to parser and formatter
src/libvirt_private.syms: export
   virDomainVirtioEventIdx(From|To)String
src/qemu/qemu_capabilities.[ch]: detect and report event_idx in
   disk/net
src/qemu/qemu_command.c: add event_idx parameter to qemu commandline
    when appropriate.
tests/qemuxml2argvdata/qemuxml2argv-event_idx.args,
tests/qemuxml2argvdata/qemuxml2argv-event_idx.xml,
tests/qemuxml2argvtest.c,
tests/qemuxml2xmltest.c: test cases for event_idx.

13 years agoqemu: error message should show uri instead of (null)
Peter Krempa [Mon, 15 Aug 2011 12:58:47 +0000 (14:58 +0200)]
qemu: error message should show uri instead of (null)

Fix pointer for error message uri if domain migration fails.

BZ# 730244

13 years agoqemu: Use fd: protocol for migration
Jiri Denemark [Thu, 11 Aug 2011 13:47:02 +0000 (15:47 +0200)]
qemu: Use fd: protocol for migration

By opening a connection to remote qemu process ourselves and passing the
socket to qemu we get much better errors than just "migration failed"
when the connection is opened by qemu.

13 years agoqemu: Use virNetSocket for tunneled migration
Jiri Denemark [Fri, 12 Aug 2011 08:54:05 +0000 (10:54 +0200)]
qemu: Use virNetSocket for tunneled migration

13 years agoqemu: Refactor do{Tunnel,Native}Migrate functions
Jiri Denemark [Thu, 11 Aug 2011 12:36:04 +0000 (14:36 +0200)]
qemu: Refactor do{Tunnel,Native}Migrate functions

The core of these two functions is very similar and most of it is even
exactly the same. Factor out the core functionality into a separate
function to remove code duplication and make further changes easier.

13 years agoSupport changing UNIX socket owner in virNetSocketNewListenUNIX
Jiri Denemark [Fri, 12 Aug 2011 09:10:19 +0000 (11:10 +0200)]
Support changing UNIX socket owner in virNetSocketNewListenUNIX

This patch allows owner's UID to be changed as well.

13 years agoAdd backlog parameter to virNetSocketListen
Jiri Denemark [Fri, 12 Aug 2011 09:07:51 +0000 (11:07 +0200)]
Add backlog parameter to virNetSocketListen

So that callers can change the default value.

13 years agoAdd API for duplicating a socket/client file descriptor
Daniel P. Berrange [Thu, 7 Jul 2011 14:17:21 +0000 (15:17 +0100)]
Add API for duplicating a socket/client file descriptor

* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Add
  virNetSocketDupFD()
* src/rpc/virnetclient.c, src/rpc/virnetclient.h: Add
  virNetClientDupFD() and virNetClientGetFD()

13 years agolibvirtd.init.in: stop/restart() - wrong return value in case of failure
Douglas Schilling Landgraf [Mon, 15 Aug 2011 07:44:39 +0000 (15:44 +0800)]
libvirtd.init.in: stop/restart() - wrong return value in case of failure

The function stop() was always returning 0 (OK) from killproc() even
in case of error.

13 years agodaemon: Fix regression of libvirtd reloading support
Osier Yang [Mon, 15 Aug 2011 07:40:46 +0000 (15:40 +0800)]
daemon: Fix regression of libvirtd reloading support

This is introduced by commit df0b57a95a, which forgot to
add signal handler for SIGHUP.

A simple reproduce method:

1) Create a domain XML under /etc/libvirt/qemu
2) % kill -SIGHUP $(pidof libvirtd)
3) % virsh list --all (the new created domain XML is not listed)

13 years agomaint: let emacs avoid tabs in rng files
Eric Blake [Sat, 13 Aug 2011 13:27:23 +0000 (07:27 -0600)]
maint: let emacs avoid tabs in rng files

* .dir-locals.el: Add nxml-mode preferences.

13 years agoSwap virDomain / virFomainSnapshot declaration
Philipp Hahn [Tue, 12 Apr 2011 06:06:18 +0000 (08:06 +0200)]
Swap virDomain / virFomainSnapshot declaration

In preparation for storing the domain description with the snapshot,
swap the order of declaration.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agobuild: fix recent build failures
Eric Blake [Fri, 12 Aug 2011 21:54:49 +0000 (15:54 -0600)]
build: fix recent build failures

With gcc 4.5.1:

util/virpidfile.c: In function 'virPidFileAcquirePath':
util/virpidfile.c:308:66: error: nested extern declaration of '_gl_verify_function2' [-Wnested-externs]

Then in tests/commandtest.c, the new virPidFile APIs need to be used.

* src/util/virpidfile.c (virPidFileAcquirePath): Move verify to
top level.
* tests/commandtest.c: Use new pid APIs.

13 years agoConvert libvirtd to use crash-safe pidfile APIs
Daniel P. Berrange [Fri, 5 Aug 2011 14:11:11 +0000 (15:11 +0100)]
Convert libvirtd to use crash-safe pidfile APIs

Remove the current libvirtd pidfile handling code, in favour of
calling out to the new APIs. This ensures libvirtd's pidfile
handling is crashsafe

This also means that the non-root libvirtd instances (for handling
qemu:///session URIs) can now safely use pidfiles without racing

* daemon/libvirtd.c: Switch to use virPidFileAcquire and
  virPidFileRelease

13 years agoAdd some APIs which use locking for crashsafe pidfile handling
Daniel P. Berrange [Wed, 6 Jul 2011 16:12:26 +0000 (17:12 +0100)]
Add some APIs which use locking for crashsafe pidfile handling

In daemons using pidfiles to protect against concurrent
execution there is a possibility that a crash may leave a stale
pidfile on disk, which then prevents later restart of the daemon.

To avoid this problem, introduce a pair of APIs which make
use of virFileLock to ensure crash-safe & race condition-safe
pidfile acquisition & releae

* src/libvirt_private.syms, src/util/virpidfile.c,
  src/util/virpidfile.h: Add virPidFileAcquire and virPidFileRelease

13 years agoIntroduce functions for checking whether a pidfile is valid
Daniel P. Berrange [Fri, 5 Aug 2011 13:41:25 +0000 (14:41 +0100)]
Introduce functions for checking whether a pidfile is valid

In some cases the caller of virPidFileRead might like extra checks
to determine whether the pid just read is really the one they are
expecting. This adds virPidFileReadIfAlive which will check whether
the pid is still alive with kill(0, -1), and (on linux only) will
look at /proc/$PID/path

* libvirt_private.syms, util/virpidfile.c, util/virpidfile.h: Add
  virPidFileReadIfValid and virPidFileReadPathIfValid
* network/bridge_driver.c: Use new APIs to check PID validity

13 years agoMove pidfile functions into util/virpidfile.{c,h}
Daniel P. Berrange [Fri, 5 Aug 2011 13:13:12 +0000 (14:13 +0100)]
Move pidfile functions into util/virpidfile.{c,h}

The functions for manipulating pidfiles are in util/util.{c,h}.
We will shortly be adding some further pidfile related functions.
To avoid further growing util.c, this moves the pidfile related
functions into a dedicated virpidfile.{c,h}. The functions are
also all renamed to have 'virPidFile' as their name prefix

* util/util.h, util/util.c: Remove all pidfile code
* util/virpidfile.c, util/virpidfile.h: Add new APIs for pidfile
  handling.
* lxc/lxc_controller.c, lxc/lxc_driver.c, network/bridge_driver.c,
  qemu/qemu_process.c: Add virpidfile.h include and adapt for API
  renames

13 years agoAdd virFileLock and virFileUnlock APIs
Daniel P. Berrange [Wed, 6 Jul 2011 16:06:58 +0000 (17:06 +0100)]
Add virFileLock and virFileUnlock APIs

Add some simple wrappers around the fcntl() discretionary file
locking capability.

* src/util/util.c, src/util/util.h, src/libvirt_private.syms: Add
  virFileLock and virFileUnlock APIs

13 years agovirsh: fix dead store
Eric Blake [Fri, 12 Aug 2011 18:07:39 +0000 (12:07 -0600)]
virsh: fix dead store

Two copy-and-paste bugs in a row.  :(

* tools/virsh.c (cmdUndefine): Also avoid dead store.

13 years agovirsh: fix logic bug
Eric Blake [Fri, 12 Aug 2011 17:39:35 +0000 (11:39 -0600)]
virsh: fix logic bug

Bug introduced in commit 9a0ec36.

* tools/virsh.c (cmdUndefine): Add missing line.

13 years agovbox, xenapi: add virDomainUndefineFlags
Eric Blake [Thu, 11 Aug 2011 21:44:05 +0000 (15:44 -0600)]
vbox, xenapi: add virDomainUndefineFlags

We forgot to add virDomainUndefineFlags for a couple of hypervisors.
This wires up trivial versions (since neither hypervisor supports
managed save yet, they do not need to support any flags).

* src/vbox/vbox_tmpl.c (vboxDomainCreateXML): Update caller.
(vboxDomainUndefine): Move guts...
(vboxDomainUndefineFlags): ...to new function.
* src/xenapi/xenapi_driver.c (xenapiDomainUndefine)
(xenapiDomainUndefineFlags): Likewise.

13 years agovirsh: don't reject undefine on active domain
Eric Blake [Thu, 11 Aug 2011 22:48:00 +0000 (16:48 -0600)]
virsh: don't reject undefine on active domain

The public API documents that undefine may be used to transition a
running persistent domain into a transient one.  Many drivers still
do not support this usage, but virsh shouldn't be getting in the
way of those that do support it.

This also drops a redundant conditional; vshCommandOptString
guaranteed that name was non-NULL.

* tools/virsh.c (cmdUndefine): Allow undefine on active domains;
the drivers may still reject it, but it is a valid API usage.
* tests/undefine (error): Fix the test to match.

13 years agoImprove tokenizing of linkable terms
Philipp Hahn [Thu, 11 Aug 2011 12:44:00 +0000 (14:44 +0200)]
Improve tokenizing of linkable terms

Currently only tabs and blanks are used for tokenizing the description,
which breaks when a term is at the end of a line or has () appended to
it.
1. Use also other white space characters such as new-lines and carriage
   return for splitting.
2. Remove some common non-word characters from the token before lookup.

Signed-off-by: Philipp Hahn <hahn@univention.de>