Commit Graph

9508 Commits

Author SHA1 Message Date
Eric Blake
98ada9ab70 build: drop obsolete qparams test
Otherwise, 'make check' breaks since commit bc1ff160 deleted
qparams.h.  A later patch will ensure that viruri takes over
what qparams used to do.

* tests/qparamtest.c (mymain): Delete, now that we have viruri.
* tests/Makefile.am (check_PROGRAMS, TESTS, qparamtest_SOURCES):
Delete old test.
* .gitignore: Add recent test additions.
2012-03-23 16:12:58 -06:00
Eric Blake
9b6860f5ce build: fix incorrect enum declaration
Recent changes have caused build failures on systems where pdwtags works:
commit a26a196 mistakenly exported a public variable
commits a26a196, 57ddcc2, 487c063 all had copy-paste bugs in
hand-updating the golden API rather than rerunning pdwtags

* include/libvirt/libvirt.h.in (virDomainEventTrayChangeReason):
Make this a typedef, not external storage.
* src/remote_protocol-structs (remote_procedure): Fix spelling.
2012-03-23 14:29:00 -06:00
Li Zhang
8120325750 Add qemu support for ppc64 on FC16 or above for rpm packaging
On Fedora16 or above, qemu is supported now. So it is added
in rpm packaging.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
2012-03-23 12:40:13 -04:00
Daniel P. Berrange
0ceced5868 Fix typo s/virURIFormatQuery/virURIFormatParams/ 2012-03-23 14:27:32 +00:00
Osier Yang
7c5a0c94e4 qemu: Update domain status to running while wakeup event is emitted
This introduces a new running reason VIR_DOMAIN_RUNNING_WAKEUP,
and new suspend event type VIR_DOMAIN_EVENT_STARTED_WAKEUP.

While a wakeup event is emitted, the domain which entered into
VIR_DOMAIN_PMSUSPENDED will be transferred to "running"
with reason VIR_DOMAIN_RUNNING_WAKEUP, and a new domain lifecycle
event emitted with type VIR_DOMAIN_EVENT_STARTED_WAKEUP.
2012-03-23 23:12:29 +08:00
Osier Yang
321fa64bf5 qemu: Update domain state to pmsuspended while suspend event occurs 2012-03-23 23:12:26 +08:00
Osier Yang
54d9026a2c New domain state pmsuspended
This introduces a new domain state pmsuspended to represent
the domain which has been suspended by guest power management,
e.g. (entered itno s3 state). Because a "running" state could
be confused in this case, one will see the guest is paused
actually while playing. And state "paused" is for the domain
which was paused by virDomainSuspend.
2012-03-23 23:12:22 +08:00
Osier Yang
487c063381 Add support for the suspend event
This patch introduces a new event type for the QMP event
SUSPEND:

    VIR_DOMAIN_EVENT_ID_PMSUSPEND

The event doesn't take any data, but considering there might
be reason for wakeup in future, the callback definition is:

typedef void
(*virConnectDomainEventSuspendCallback)(virConnectPtr conn,
                                        virDomainPtr dom,
                                        int reason,
                                        void *opaque);

"reason" is unused currently, always passes "0".
2012-03-23 23:12:18 +08:00
Osier Yang
57ddcc235a Add support for the wakeup event
This patch introduces a new event type for the QMP event
WAKEUP:

    VIR_DOMAIN_EVENT_ID_PMWAKEUP

The event doesn't take any data, but considering there might
be reason for wakeup in future, the callback definition is:

typedef void
(*virConnectDomainEventWakeupCallback)(virConnectPtr conn,
                                       virDomainPtr dom,
                                       int reason,
                                       void *opaque);

"reason" is unused currently, always passes "0".
2012-03-23 23:12:14 +08:00
Osier Yang
2d19e33f97 qemu: Update tray status while tray moved event is emitted
With this patch, libvirt won't start the guest with the medium
source which already ejected by guest when doing migration, or
saving/restoring.
2012-03-23 23:12:09 +08:00
Osier Yang
7fcf943bcd qemu: Prohibit setting tray status as open for block type disk 2012-03-23 23:12:02 +08:00
Osier Yang
ad7db43913 qemu: Do not start with source for removable disks if tray is open
This is similiar with physical world, one will be surprised if the
box starts with medium exists while the tray is open.

New tests are added, tests disk-{cdrom,floppy}-tray are for the qemu
supports "-device" flag, and disk-{cdrom,floppy}-no-device-cap are
for old qemu, i.e. which doesn't support "-device" flag.
2012-03-23 23:11:54 +08:00
Osier Yang
b22eaa7538 conf: Parse and for the tray attribute
The "tray" is only allowed for removable disks, i.e. CDROM and
Floppy disks.
2012-03-23 23:10:34 +08:00
Osier Yang
ab49b392cc docs: Add documentation for new attribute tray of disk target
Example XML:

    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/cdrom.img'/>
      <target dev='hdd' bus='ide' tray='open'/>
    </disk>
2012-03-23 23:10:30 +08:00
Osier Yang
a26a1969c3 Add support for event tray moved of removable disks
This patch introduces a new event type for the QMP event
DEVICE_TRAY_MOVED, which occurs when the tray of a removable
disk is moved (i.e opened or closed):

    VIR_DOMAIN_EVENT_ID_TRAY_CHANGE

The event's data includes the device alias and the reason
for tray status' changing, which indicates why the tray
status was changed. Thus the callback definition for the event
is:

enum {
    VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN = 0,
    VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE,

\#ifdef VIR_ENUM_SENTINELS
    VIR_DOMAIN_EVENT_TRAY_CHANGE_LAST
\#endif
} virDomainEventTrayChangeReason;

typedef void
(*virConnectDomainEventTrayChangeCallback)(virConnectPtr conn,
                                           virDomainPtr dom,
                                           const char *devAlias,
                                           int reason,
                                           void *opaque);
2012-03-23 23:10:26 +08:00
Prerna Saxena
25d3a2e01f Implement sysinfo on PowerPC.
Libvirt on x86 parses 'dmidecode' to gather characteristics of host
system. On PowerPC, this is now implemented by reading /proc/cpuinfo
NOTE: memory-DIMM information is not presently implemented.

Acked-by: Daniel Veillard <veillard@redhat.com>
Acked-by: Daniel P Berrange <berrange@redhat.com>
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
2012-03-23 21:56:20 +08:00
Daniel P. Berrange
4445e16bfa Lookup auth credentials in config file before prompting
When SASL requests auth credentials, try to look them up in the
config file first. If any are found, remove them from the list
that the user is prompted for

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 13:24:07 +00:00
Daniel P. Berrange
c6c66615c2 Refactor code prompting for SASL credentials
SASL may prompt for credentials after either a 'start' or 'step'
invocation. In both cases the code to handle this is the same.
Refactor this code into a separate method to reduce the duplication,
since the complexity is about to grow

* src/remote/remote_driver.c: Refactor interaction with SASL

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 13:24:07 +00:00
Daniel P. Berrange
a4fb88b5c9 Add helper API for finding auth file path
* src/util/virauth.c, src/util/virauth.h: Add virAuthGetConfigFilePath
* include/libvirt/virterror.h, src/util/virterror.c: Add
  VIR_FROM_AUTH error domain

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 13:24:07 +00:00
Daniel P. Berrange
4262e34eb5 Rename virRequest{Username,Password} to virAuthGet{Username,Password}
Ensure that the functions in virauth.h have names matching the file
prefix, by renaming  virRequest{Username,Password} to
virAuthGet{Username,Password}

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 13:24:06 +00:00
Daniel P. Berrange
c8aa3862b1 Rename src/util/authhelper.[ch] to src/util/virauth.[ch]
To follow latest naming conventions, rename src/util/authhelper.[ch]
to src/util/virauth.[ch].

* src/util/authhelper.[ch]: Rename to src/util/virauth.[ch]
* src/esx/esx_driver.c, src/hyperv/hyperv_driver.c,
  src/phyp/phyp_driver.c, src/xenapi/xenapi_driver.c: Update
  for renamed include files

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 13:24:06 +00:00
Daniel P. Berrange
f6632f6b7f Add a virKeyfilePtr object for parsing '.ini' files
The '.ini' file format is a useful alternative to the existing
config file style, when you need to have config files which
are hashes of hashes. The 'virKeyFilePtr' object provides a
way to parse these file types.

* src/Makefile.am, src/util/virkeyfile.c,
  src/util/virkeyfile.h: Add .ini file parser
* tests/Makefile.am, tests/virkeyfiletest.c: Test
  basic parsing capabilities

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 13:24:06 +00:00
Daniel P. Berrange
bc1ff1600e Convert drivers over to use virURIPtr for query params
Convert drivers currently using the qparams APIs, to instead
use the virURIPtr query parameters directly.

* src/esx/esx_util.c, src/hyperv/hyperv_util.c,
  src/remote/remote_driver.c, src/xenapi/xenapi_utils.c: Remove
  use of qparams
* src/util/qparams.h, src/util/qparams.c: Delete
* src/Makefile.am, src/libvirt_private.syms: Remove qparams

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 13:24:06 +00:00
Daniel P. Berrange
4ae4ae4ba4 Store parsed query parameters directly in the virURIPtr struct
Avoid the need for each driver to parse query parameters itself
by storing them directly in the virURIPtr struct. The parsing
code is a copy of that from src/util/qparams.c  The latter will
be removed in a later patch

* src/util/viruri.h: Add query params to virURIPtr
* src/util/viruri.c: Parse query parameters when creating virURIPtr
* tests/viruritest.c: Expand test to cover params

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 13:23:12 +00:00
Daniel P. Berrange
300e60e15b Use a libvirt custom struct for virURIPtr
Instead of just typedef'ing the xmlURIPtr struct for virURIPtr,
use a custom libvirt struct. This allows us to fix various
problems with libxml2. This initially just fixes the query vs
query_raw handling problems.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 12:59:22 +00:00
Daniel P. Berrange
1f66c18f79 Centralize error reporting for URI parsing/formatting problems
Move error reporting out of the callers, into virURIParse
and virURIFormat, to get consistency.

* include/libvirt/virterror.h, src/util/virterror.c: Add VIR_FROM_URI
* src/util/viruri.c, src/util/viruri.h: Add error reporting
* src/esx/esx_driver.c, src/libvirt.c, src/libxl/libxl_driver.c,
  src/lxc/lxc_driver.c, src/openvz/openvz_driver.c,
  src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
  src/remote/remote_driver.c, src/uml/uml_driver.c,
  src/vbox/vbox_tmpl.c, src/vmx/vmx.c, src/xen/xen_driver.c,
  src/xen/xend_internal.c, tests/viruritest.c: Remove error
  reporting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 12:59:21 +00:00
Daniel P. Berrange
94410848e1 s/xmlURIPtr/virURIPtr/ in virURIFormat impl
The parameter in the virURIFormat impl mistakenly used the
xmlURIPtr type, instead of virURIPtr. Since they will soon
cease to be identical, this needs fixing

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 12:59:21 +00:00
Daniel P. Berrange
c33dae3175 Use virURIFree instead of xmlFreeURI
Since we defined a custom virURIPtr type, we should use a
virURIFree method instead of assuming it will always be
a typedef for xmlURIPtr

* src/util/viruri.c, src/util/viruri.h, src/libvirt_private.syms:
  Add a virURIFree method
* src/datatypes.c, src/esx/esx_driver.c, src/libvirt.c,
  src/qemu/qemu_migration.c, src/vmx/vmx.c, src/xen/xend_internal.c,
  tests/viruritest.c: s/xmlFreeURI/virURIFree/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 12:59:20 +00:00
Daniel P. Berrange
6a7ffd4389 Add test case for virURIPtr classs
To ensure we properly escape & unescape IPv6 numeric addresses,
add a test case

* tests/Makefile.am, tests/viruritest.c: URI parsing test

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 12:59:16 +00:00
Daniel P. Berrange
cb640543c8 Leave all child processes running when stopping systemd service
Currently the libvirt.service unit file for systemd does not
specify any kill mode. So systemd kills off every process
inside its cgroup. ie all dnsmasq processes, all virtual
machines. This obviously not what we want. Set KillMode=process
so that it only kills the top level process of libvirtd

* daemon/libvirtd.service.in: Add KillMode=process

Reported-By: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-23 12:46:16 +00:00
Dave Allan
350e6c5e66 Clarify virsh freecell manpage entry 2012-03-22 21:41:34 -06:00
Zhou Peng
d36ccf9f6a docs: fix typo
Bogus <code/>, and incorrect use of it's instead of its.
2012-03-22 21:40:19 -06:00
Dave Allan
ceb1d36b94 Clarify what documentation is being referenced
virsh.pod had several instances in which it referred to "the
documentation" which was a little puzzling to me since it is
documentation.  Reading the document from end to end makes it clear
that it means a specific URI which was noted previously in the text,
but I had never noticed those URIs in several years of referring to
the man page.  This patch adds those URIs to several additional places
in the text.
2012-03-22 16:09:59 -04:00
Guannan Ren
a772f4eebc python: add virDomainGetCPUStats python binding API
dom.getCPUStats(True, 0)
      [{'cpu_time': 24699446159L, 'system_time': 10870000000L, 'user_time': 950000000L}]
    dom.getCPUStats(False, 0)
      [{'cpu_time': 8535292289L}, {'cpu_time': 1005395355L}, {'cpu_time': 9351766377L}, {'cpu_time': 5813545649L}]

    *generator.py Add a new naming rule
    *libvirt-override-api.xml The API function description
    *libvirt-override.c Implement it.
2012-03-22 10:55:48 -04:00
Alex Jia
558ebc256d python: Avoid memory leaks on libvirt_virNodeGetCPUStats
Detected by valgrind. Leaks are introduced in commit 4955602.

* python/libvirt-override.c (libvirt_virNodeGetCPUStats): fix memory leaks
and improve codes return value.

For details, please see the following link:
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=770943

Signed-off-by: Alex Jia <ajia@redhat.com>
2012-03-22 10:19:13 +08:00
Eric Blake
25fb4c65a5 build: drop a painfully long gnulib test
On machines with massive amounts of CPUs, the gnulib 'test-lock'
could take minutes, or even appear to deadlock, because of poor
scaling of timing interactions between multiple cores.

See https://bugzilla.redhat.com/show_bug.cgi?id=797284.
For precedence, note that iwhd has done the same:
https://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00311.html

We can re-enable things if gnulib ever analyzes and improves the
situation.

* bootstrap.conf (gnulib_tool_option_extras): Avoid lock-tests.
2012-03-21 11:12:30 -06:00
Jiri Denemark
1fdc53c385 qemu: Avoid dangling migration-out job when client dies
When a client which started non-p2p migration dies in a bad time, the
source libvirtd never clears the migration job and almost nothing can be
done with the domain without restarting the daemon. This patch makes use
of connection close callbacks and ensures that migration job is properly
discarded when the client disconnects.
2012-03-21 17:31:09 +01:00
Jiri Denemark
527d867a94 qemu: Make autodestroy utilize connection close callbacks 2012-03-21 17:31:09 +01:00
Jiri Denemark
791273603e qemu: Add connection close callbacks
Add support for registering arbitrary callback to be called for a domain
when a connection gets closed.
2012-03-21 17:31:09 +01:00
Jiri Denemark
4f061ea641 qemu: Avoid dangling migration-in job on shutoff domains
Destination daemon should not rely on the client or source daemon
(depending on the type of migration) to call Finish when migration
fails, because the client may crash before it can do so. The domain
prepared for incoming migration is set to be destroyed (and migration
job cleaned up) when connection with the client closes but this is not
enough. If the associated qemu process crashes after Prepare step and
the domain is cleaned up before the connection gets closed, autodestroy
is not called for the domain and migration jobs remains set. In case the
domain is defined on destination host (i.e., it is not completely
removed once destroyed) we keep the job set for ever. To fix this, we
register a cleanup callback which is responsible to clean migration-in
job when a domain dies anywhere between Prepare and Finish steps. Note
that we can't blindly clean any job when spotting EOF on monitor since
normally an API is running at that time.
2012-03-21 17:31:09 +01:00
Jiri Denemark
bf9f0a9726 qemu: Add support for domain cleanup callbacks
Add support for registering cleanup callbacks to be run when a domain
transitions to shutoff state.
2012-03-21 17:31:08 +01:00
Jiri Denemark
9f71368d06 qemu: Use unlimited speed when migrating to file
This reverts commit 61f2b6ba5f and most of
commit d8916dc8e2, which effectively
brings back commit ef1065cf5a written by
Jim Fehlig:

The qemu migration speed default is 32MiB/s as defined in migration.c

/* Migration speed throttling */
static int64_t max_throttle = (32 << 20);

There's no need to throttle migration when targeting a file, so set
migration speed to unlimited prior to migration, and restore to libvirt
default value after migration.

Default units is MB for migrate_set_speed monitor command, so
(INT64_MAX / (1024 * 1024)) is used for unlimited migration speed.

This was reverted because migration to file could not be canceled and
even monitored since qemu was not processing any monitor commands until
the migration finished. This is now different as we make sure the
file descriptor we pass to qemu is able to properly report EAGAIN.
Recent qemu changes might have helped as well.

I tested managedsave with this patch in and indeed, it is 10x faster
while I can still monitor its progress.
2012-03-21 17:26:20 +01:00
Alex Jia
53b45aa494 python: Avoid memory leaks on libvirt_virNodeGetMemoryStats
Detected by valgrind. Leaks are introduced in commit 17c7795.

* python/libvirt-override.c (libvirt_virNodeGetMemoryStats): fix memory leaks
and improve codes return value.

For details, please see the following link:
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=770944

Signed-off-by: Alex Jia <ajia@redhat.com>
2012-03-21 23:32:34 +08:00
Eric Blake
2791b8ab9b python: always include config.h first
On RHEL 5.7, I got this compilation failure:

In file included from /usr/include/python2.4/pyport.h:98,
                 from /usr/include/python2.4/Python.h:55,
                 from libvirt.c:3:
../gnulib/lib/time.h:468: error: expected ';', ',' or ')' before '__timer'

Turns out that our '#define restrict __restrict' from config.h wasn't
being picked up.  Gnulib _requires_ that all .c files include <config.h>
first, otherwise the gnulib header overrides tend to misbehave.

Problem introduced by patch c700613b8.

* python/generator.py (buildStubs): Include <config.h> first.
2012-03-20 16:54:39 -06:00
Martin Kletzander
e22789de17 Minor docs fix
End tag for "host" element was missing in example configuration
2012-03-19 20:33:30 -04:00
Laine Stump
0007237301 conf: forbid use of multicast mac addresses
A few times libvirt users manually setting mac addresses have
complained of a networking failure that ends up being due to a multicast
mac address being used for a guest interface. This patch prevents that
by logging an error and failing if a multicast mac address is
encountered in each of the three following cases:

1) domain xml <interface> mac address.
2) network xml bridge mac address.
3) network xml dhcp/host mac address.

There are several other places where a mac address can be input that
aren't controlled in this manner because failure to do so has no
consequences (e.g., if the address will be used to search through
existing interfaces for a match).

The RNG has been updated to add multiMacAddr and uniMacAddr along with
the existing macAddr, and macAddr was switched to uniMacAddr where
appropriate.
2012-03-19 20:33:30 -04:00
Laine Stump
43d635caf3 conf: return immediately on error in dhcp host element
If an error was encountered parsing a dhcp host entry mac address or
name, parsing would continue and log a less descriptive error that
might make it more difficult to notice the true nature of the problem.

This patch returns immediately on logging the first error.
2012-03-19 20:33:30 -04:00
Laine Stump
5d57104538 util: fail attempts to use same mac address for guest and tap
This patch is in response to:

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

If a guest's tap device is created using the same MAC address the
guest uses for its own network card (which connects to the tap
device), the Linux kernel will log the following message and traffic
will not pass:

 kernel: vnet9: received packet with own address as source address

This patch disallows MAC addresses with a first byte of 0xFE, but only in
the case that the MAC address is used for a guest interface that's
connected by way of a standard tap device. (In other words, the
validation is done at runtime at the same place the MAC address is
modified for the tap device, rather than when mac address is parsed,
the idea being that it is then we know for sure the address will be
problematic.)
2012-03-19 20:33:30 -04:00
Martin Kletzander
d675a922b5 Cpu mapping cleanup
Using inheritance, this patch cleans up the cpu_map.xml file and also
sorts all CPU features according to the feature and registry
values. Model features are sorted the same way as foeatures in the
specification.
Also few models that are related were organized together and parts of
the XML are marked with comments
2012-03-19 11:20:38 -06:00
Eric Blake
7c736bab06 snapshot: make quiesce a bit safer
If a guest is paused, we were silently ignoring the quiesce flag,
which results in unclean snapshots, contrary to the intent of the
flag.  Since we can't quiesce without guest agent support, we should
instead fail if the guest is not running.

Meanwhile, if we attempt a quiesce command, but the guest agent
doesn't respond, and we time out, we may have left the command
pending on the guest's queue, and when the guest resumes parsing
commands, it will freeze even though our command is no longer
around to issue a thaw.  To be safe, we must _always_ pair every
quiesce call with a counterpart thaw, even if the quiesce call
failed due to a timeout, so that if a guest wakes up and starts
processing a command backlog, it will not get stuck in a frozen
state.

* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive):
Always issue thaw after a quiesce, even if quiesce failed.
(qemuDomainSnapshotFSThaw): Add a parameter.
2012-03-19 10:58:18 -06:00