]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 years agoMove QEMU command line management into a separate file
Daniel P. Berrange [Thu, 16 Dec 2010 15:07:07 +0000 (15:07 +0000)]
Move QEMU command line management into a separate file

The qemu_conf.c code is doing three jobs, driver config file
loading, QEMU capabilities management and QEMU command line
management. Move the command line code into its own file

* src/qemu/qemu_command.c, src/qemu/qemu_command.h: New
  command line management code
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Delete command
  line code
* src/qemu/qemu_conf.h, src/qemu_conf.c: Adapt for API renames
* src/Makefile.am: add src/qemu/qemu_command.c
* src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_text.c: Add
  import of qemu_command.h

14 years agoMove QEMU capabilities management into a separate file
Daniel P. Berrange [Thu, 16 Dec 2010 15:07:07 +0000 (15:07 +0000)]
Move QEMU capabilities management into a separate file

The qemu_conf.c code is doing three jobs, driver config file
loading, QEMU capabilities management and QEMU command line
management. Move the capabilities code into its own file

* src/qemu/qemu_capabilities.c, src/qemu/qemu_capabilities.h: New
  capabilities management code
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Delete capabilities
  code
* src/qemu/qemu_conf.h: Adapt for API renames
* src/Makefile.am: add src/qemu/qemu_capabilities.c

14 years agomaint: doc fix
Eric Blake [Thu, 16 Dec 2010 18:43:08 +0000 (11:43 -0700)]
maint: doc fix

* src/libvirt.c: Avoid duplicate word.

14 years agoAdd a new function doStartCPUs
Hu Tao [Tue, 14 Dec 2010 07:40:31 +0000 (15:40 +0800)]
Add a new function doStartCPUs

14 years agoAdd a new function doStopCPUs
Hu Tao [Tue, 14 Dec 2010 07:40:26 +0000 (15:40 +0800)]
Add a new function doStopCPUs

14 years agoAdd a macro timeval_to_ms to compute micro seconds from timeval
Hu Tao [Tue, 14 Dec 2010 07:40:12 +0000 (15:40 +0800)]
Add a macro timeval_to_ms to compute micro seconds from timeval

14 years agocpu: Unify CPUID data structures
Jiri Denemark [Wed, 30 Jun 2010 11:08:57 +0000 (13:08 +0200)]
cpu: Unify CPUID data structures

So far, CPUID data were stored in two different data structures. First
of them was a structure allowing direct access for CPUID data according
to function number and the second was a plain array of struct
cpuX86cpuid. This was a silly design which resulted in converting data
from one type to the other and back again or implementing similar
functionality for both data structures.

The patch leaves only the direct access structure. This makes the code
both smaller and more maintainable since operations on different objects
can use common low-level operations.

All 57 tests for cpu subsystem still pass after this rewrite.

14 years agoutil: Fix logical error in virReportSystemErrorFull
Jiri Denemark [Mon, 13 Dec 2010 10:32:40 +0000 (11:32 +0100)]
util: Fix logical error in virReportSystemErrorFull

14 years agoutil: Fix error message in __virExec
Jiri Denemark [Mon, 13 Dec 2010 10:36:52 +0000 (11:36 +0100)]
util: Fix error message in __virExec

Remove superfluous ": %s" suffix from the error message.

14 years agodaemon: Change CWD to / before daemonizing
Jiri Denemark [Mon, 13 Dec 2010 10:18:45 +0000 (11:18 +0100)]
daemon: Change CWD to / before daemonizing

We were doing so for child processes but not for libvirtd itself.

14 years agoesx: Add support for storage volume cloning
Matthias Bolte [Mon, 6 Dec 2010 20:07:35 +0000 (21:07 +0100)]
esx: Add support for storage volume cloning

14 years agoselinux: avoid memory overhead of matchpathcon
Eric Blake [Wed, 1 Dec 2010 01:22:54 +0000 (18:22 -0700)]
selinux: avoid memory overhead of matchpathcon

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

* src/security/security_selinux.c
(SELinuxRestoreSecurityFileLabel): Use selabel_lookup instead of
matchpathcon.
Suggested by Daniel Walsh.

14 years agodaemon, threads: plug a memory leak
Eric Blake [Sat, 11 Dec 2010 00:35:58 +0000 (17:35 -0700)]
daemon, threads: plug a memory leak

* daemon/libvirtd.c (qemudStartWorker, qemudStartEventLoop): Avoid
leaking pthread_attr resources.
* src/util/threads-pthread.c (virThreadCreate): Likewise.

14 years agotests: test Fedora 14 qemu-kvm -help parsing
Eric Blake [Wed, 8 Dec 2010 17:10:51 +0000 (10:10 -0700)]
tests: test Fedora 14 qemu-kvm -help parsing

* tests/qemuhelpdata/qemu-kvm-0.13.0: New file.
* tests/qemuhelptest.c (mymain): New test from Fedora 14 qemu-kvm,
which covers some options (like -fstype passthrough) not tested elsewhere.

14 years agotests: test RHEL 6.0 qemu-kvm -help parsing
Eric Blake [Wed, 8 Dec 2010 16:29:54 +0000 (09:29 -0700)]
tests: test RHEL 6.0 qemu-kvm -help parsing

* tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel60: New file.
* tests/qemuhelptest.c (mymain): New test from RHEL 6.0 qemu-kvm,
which covers some options (like -vga=qxl) not tested elsewhere.
* .x-sc_prohibit_empty_lines_at_EOF: Exempt qemu help output.

14 years agosysinfo: convert to virCommand
Eric Blake [Fri, 3 Dec 2010 21:32:12 +0000 (14:32 -0700)]
sysinfo: convert to virCommand

* src/util/sysinfo.c (virSysinfoRead): Use virCommand instead of
virExec.

14 years agosysinfo: formatting cleanups
Eric Blake [Tue, 7 Dec 2010 19:20:46 +0000 (12:20 -0700)]
sysinfo: formatting cleanups

* src/util/sysinfo.c: Indentation and () fixups.

14 years agobuild: allow mingw compilation with virCommand
Eric Blake [Fri, 10 Dec 2010 23:46:23 +0000 (16:46 -0700)]
build: allow mingw compilation with virCommand

Allows compilation, but no creation of child processes yet.  Take it
one step at a time.

* src/util/util.c (virExecWithHook) [WIN32]: New dummy function.
* src/libvirt_private.syms: Export it.

14 years agobuild: update gnulib for pipe on mingw
Eric Blake [Fri, 10 Dec 2010 22:49:52 +0000 (15:49 -0700)]
build: update gnulib for pipe on mingw

* .gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Import pipe-posix and waitpid
for mingw.
* src/remote/remote_driver.c (pipe) [WIN32]: Drop dead macro.
* daemon/event.c (pipe) [WIN32]: Drop dead function.

14 years agotest: fix commandtest under autobuild.sh
Eric Blake [Fri, 10 Dec 2010 22:30:56 +0000 (15:30 -0700)]
test: fix commandtest under autobuild.sh

* tests/commandtest.c (mymain): Kill off any leaked-in fds.
* autobuild.sh: Don't leak fds.

Signed-off-by: Eric Blake <eblake@redhat.com>
14 years agobuild: quote AC_LANG_PROGRAM to avoid warnings with autoconf 2.68
Diego Elio Pettenò [Mon, 13 Dec 2010 13:44:47 +0000 (14:44 +0100)]
build: quote AC_LANG_PROGRAM to avoid warnings with autoconf 2.68

14 years agobuild: properly handle ./configure --with-libpcap
Diego Elio Pettenò [Mon, 13 Dec 2010 13:44:46 +0000 (14:44 +0100)]
build: properly handle ./configure --with-libpcap

Without this fix, ./configure --with-libpcap will cause --with-libpcap=yes
to be implicitly passed down, which cause yes/bin/pcap-config to be
searched for rather than /usr/bin/pcap-config.

Also output pcap: no when pcap is not found or disabled.

14 years agoqemu: Introduce two new job types
Osier Yang [Mon, 13 Dec 2010 08:30:30 +0000 (16:30 +0800)]
qemu: Introduce two new job types

Currently, all of domain "save/dump/managed save/migration"
use the same function "qemudDomainWaitForMigrationComplete"
to wait the job finished, but the error messages are all
about "migration", e.g. when a domain saving job is canceled
by user, "migration was cancled by client" will be throwed as
an error message, which will be confused for user.

As a solution, intoduce two new job types(QEMU_JOB_SAVE,
QEMU_JOB_DUMP), and set "priv->jobActive" to "QEMU_JOB_SAVE"
before saving, to "QEMU_JOB_DUMP" before dumping, so that we
could get the real job type in
"qemudDomainWaitForMigrationComplete", and give more clear
message further.

And as It's not important to figure out what's the exact job
is in the DEBUG and WARN log, also we don't need translated
string in logs, simply repace "migration" with "job" in some
statements.

* src/qemu/qemu_driver.c

14 years agoMissing "Default-Stop" field in LSB comment in libvirt-guests
Laurent Léonard [Sun, 5 Dec 2010 18:49:39 +0000 (19:49 +0100)]
Missing "Default-Stop" field in LSB comment in libvirt-guests

The "Default-Stop" field in LSB comment in libvirt-guests is missing and should
be added. I also suggests to add runlevel 2 to the "Default-Start" field.

--
Laurent Léonard

14 years agodaemon: plug a memory leak
Eric Blake [Sat, 11 Dec 2010 00:28:58 +0000 (17:28 -0700)]
daemon: plug a memory leak

* daemon/libvirtd.c (qemudFreeClient): Avoid a leak.
(qemudDispatchServer): Avoid null dereference.

14 years ago802.1Qbh: Add support for IFLA_VF_MAC
Roopa Prabhu [Mon, 13 Dec 2010 16:07:38 +0000 (11:07 -0500)]
802.1Qbh: Add support for IFLA_VF_MAC

Current code does not pass VM mac address to a 802.1Qbh direct attach
interface using IFLA_VF_MAC.  This patch adds support in macvtap code to
send IFLA_VF_MAC netlink request during port profile association on a
802.1Qbh interface.

Stefan Cc'ed for comments because this patch changes a condition for
802.1Qbg

802.1Qbh support for IFLA_VF_MAC in enic driver has been posted and is
pending acceptance at http://marc.info/?l=linux-netdev&m=129185244410557&w=2

14 years agocommand: ease use with virBuffer, and fix qemu leak
Eric Blake [Fri, 10 Dec 2010 18:33:53 +0000 (11:33 -0700)]
command: ease use with virBuffer, and fix qemu leak

* src/util/command.h (virCommandAddArgBuffer)
(virCommandAddEnvBuffer): New prototypes.
* src/util/command.c (virCommandAddArgBuffer)
(virCommandAddEnvBuffer): Implement them.
* src/libvirt_private.syms (command.h): Export them.
* src/qemu/qemu_conf.c (qemudBuildCommandLine): Use them, plugging
a memory leak on rbd_hosts in the process.

14 years agoconf: plug memory leaks
Eric Blake [Fri, 10 Dec 2010 17:57:42 +0000 (10:57 -0700)]
conf: plug memory leaks

* src/conf/domain_conf.c (virDomainGraphicsDefParseXML)
(virDomainDeviceVirtioSerialAddressParseXML)
(virDomainDiskDefFree): Free various leaks.

14 years agotests: plug memory leaks
Eric Blake [Fri, 10 Dec 2010 18:08:23 +0000 (11:08 -0700)]
tests: plug memory leaks

* tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Don't
allocate, since we don't use virDomainChrDefFree.

14 years agovirExec: avoid undefined behavior
Eric Blake [Fri, 3 Dec 2010 22:02:01 +0000 (15:02 -0700)]
virExec: avoid undefined behavior

* src/util/util.c (__virExec): Don't use FD_ISSET on out-of-bounds fd.

14 years agoConvert dhcpStartDhcpDaemon from virRun to virCommand
Laine Stump [Fri, 10 Dec 2010 18:54:48 +0000 (13:54 -0500)]
Convert dhcpStartDhcpDaemon from virRun to virCommand

This is pretty straightforward - even though dnsmasq gets daemonized
and uses a pid file, those things are both handled by the dnsmasq
binary itself. And libvirt doesn't need any of the output of the
dnsmasq command either, so we just setup the args and call
virRun(). Mainly it was just a (mostly) mechanical job of replacing
the APPEND_ARG() macro (and some other *printfs()) with
virCommandAddArg*().

14 years agoesx: Refactor storage pool type lookup into a function
Matthias Bolte [Mon, 6 Dec 2010 19:40:59 +0000 (20:40 +0100)]
esx: Refactor storage pool type lookup into a function

14 years agoesx: Improve error reporting for failed tasks
Matthias Bolte [Mon, 6 Dec 2010 12:53:36 +0000 (13:53 +0100)]
esx: Improve error reporting for failed tasks

Instead of just reporting that a task failed get the
localized message from the TaskInfo error and include
it in the reported error message.

Implement minimal deserialization support for the
MethodFault type in order to obtain the actual fault
type.

For example, this changes the reported error message
when trying to create a volume with zero size from

  Could not create volume

to

  Could not create volume: InvalidArgument - A specified parameter was not correct.

Not perfect yet, but better than before.

14 years agocommand: plug memory leak
Eric Blake [Fri, 10 Dec 2010 15:56:30 +0000 (08:56 -0700)]
command: plug memory leak

* src/util/command.c (virCommandFree): Free data from
virCommandSetInputBuffer.

14 years agobuild: distribute commandtest files
Eric Blake [Fri, 10 Dec 2010 15:09:13 +0000 (08:09 -0700)]
build: distribute commandtest files

* tests/Makefile.am (SUBDIRS): Add commanddata.
* tests/commandtest.c (checkoutput): Delete correct file.
(test4): Delete pid file.
(mymain): Delete unused variable.
* tests/commanddata/Makefile.am: New file.
* configure.ac (AC_OUTPUT): Build new makefile.
Reported by Dominik Klein.

14 years agoUpdate documentation of watchdog dump option and add test data for it
Hu Tao [Fri, 10 Dec 2010 05:52:11 +0000 (13:52 +0800)]
Update documentation of watchdog dump option and add test data for it

The xml watchdog dump option is converted to qemu watchdog pause arg
but it is not reasonable to convert it back from qemu watchdog pause
arg since there already is a xml watchdog pause option, so a test for
the dump option to convert it from arg to xml is not added.

14 years agospec: do not start libvirt-guests if that service is off
Dan Kenigsberg [Tue, 7 Dec 2010 16:05:44 +0000 (18:05 +0200)]
spec: do not start libvirt-guests if that service is off

starting a service during rpm installation is impolite. It is even worse if done
during upgrade, for a service that was explicitly turned off.

14 years agotests: Add tests for network disks
Josh Durgin [Tue, 7 Dec 2010 19:57:33 +0000 (11:57 -0800)]
tests: Add tests for network disks

Signed-off-by: Josh Durgin <joshd@hq.newdream.net>
14 years agoqemu: Add RBD support and some network disk fixes
Josh Durgin [Tue, 7 Dec 2010 19:56:34 +0000 (11:56 -0800)]
qemu: Add RBD support and some network disk fixes

Changes common to all network disks:
-Make source name optional in the domain schema, since NBD doesn't use it
-Add a hostName type to the domain schema, and use it instead of genericName, which doesn't include .
-Don't leak host names or ports
-Set the source protocol in qemuParseCommandline

Signed-off-by: Josh Durgin <joshd@hq.newdream.net>
14 years agoadd network disk support
MORITA Kazutaka [Mon, 6 Dec 2010 07:24:09 +0000 (16:24 +0900)]
add network disk support

This patch adds network disk support to libvirt/QEMU.  The currently
supported protocols are nbd, rbd, and sheepdog.  The XML syntax is like
this:

    <disk type="network" device="disk">
      <driver name="qemu" type="raw" />
      <source protocol='rbd|sheepdog|nbd' name="...some image identifier...">
        <host name="mon1.example.org" port="6000">
        <host name="mon2.example.org" port="6000">
        <host name="mon3.example.org" port="6000">
      </source>
      <target dev="vda" bus="virtio" />
    </disk>

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
14 years agocorrect the signal's name
Wen Congyang [Thu, 9 Dec 2010 06:41:03 +0000 (14:41 +0800)]
correct the signal's name

The signal's name is wrong...

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
14 years agoAdd a watchdog action `dump'
Hu Tao [Wed, 8 Dec 2010 06:19:17 +0000 (14:19 +0800)]
Add a watchdog action `dump'

`dump' watchdog action lets libvirtd to dump the guest when receives a
watchdog event (which probably means a guest crash)

Currently only qemu is supported.

14 years agoAdd a new function doCoreDump
Hu Tao [Wed, 8 Dec 2010 06:19:12 +0000 (14:19 +0800)]
Add a new function doCoreDump

This patch prepares for the next patch.

14 years agothreadpool impl
Hu Tao [Wed, 8 Dec 2010 06:19:06 +0000 (14:19 +0800)]
threadpool impl

* src/util/threadpool.c, src/util/threadpool.h: Thread pool
  implementation
* src/Makefile.am: Build thread pool
* src/libvirt_private.syms: Export public functions

14 years agocommand: avoid memory leak
Eric Blake [Wed, 8 Dec 2010 15:03:29 +0000 (08:03 -0700)]
command: avoid memory leak

* src/util/command.c (virCommandRun): Fix yesterday's regression
on logging, and avoid leaking log-only output captures.
Reported by Hu Tao.

14 years agoqemu: Distinguish between domain shutdown and crash
Jiri Denemark [Thu, 9 Dec 2010 10:18:32 +0000 (11:18 +0100)]
qemu: Distinguish between domain shutdown and crash

When we get an EOF event on monitor connection, it may be a result of
either crash or graceful shutdown. QEMU which supports async events
(i.e., we are talking to it using JSON monitor) emits SHUTDOWN event on
graceful shutdown. In case we don't get this event by the time monitor
connection is closed, we assume the associated domain crashed.

14 years agoqemu: call drive_del in DetachPciDiskDevice
Ryan Harper [Wed, 8 Dec 2010 21:30:12 +0000 (14:30 -0700)]
qemu: call drive_del in DetachPciDiskDevice

Currently libvirt doesn't confirm whether the guest has responded to the
disk removal request.  In some cases this can leave the guest with
continued access to the device while the mgmt layer believes that it has
been removed.  With a recent qemu monitor command[1] we can
deterministically revoke a guests access to the disk (on the QEMU side)
to ensure no futher access is permitted.

This patch adds support for the drive_del() command and introduces it
in the disk removal paths.  If the guest is running in a QEMU without this
command we currently explicitly check for unknown command/CommandNotFound
and log the issue.

If QEMU supports the command we issue the drive_del command after we attempt
to remove the device.  The guest may respond and remove the block device
before we get to attempt to call drive_del.  In that case, we explicitly check
for 'Device not found' from the monitor indicating that the target drive
was auto-deleted upon guest responds to the device removal notification.

1. http://thread.gmane.org/gmane.comp.emulators.qemu/84745

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
14 years agoqemu: call drive_unplug in DetachPciDiskDevice
Ryan Harper [Fri, 22 Oct 2010 14:14:22 +0000 (09:14 -0500)]
qemu: call drive_unplug in DetachPciDiskDevice

Currently libvirt doesn't confirm whether the guest has responded to the
disk removal request.  In some cases this can leave the guest with
continued access to the device while the mgmt layer believes that it has
been removed.  With a recent qemu monitor command[1] we can
deterministically revoke a guests access to the disk (on the QEMU side)
to ensure no futher access is permitted.

This patch adds support for the drive_unplug() command and introduces it
in the disk removal paths.  There is some discussion to be had about how
to handle the case where the guest is running in a QEMU without this
command (and the fact that we currently don't have a way of detecting
what monitor commands are available).

Changes since v2:
 - use VIR_ERROR to report when unplug command not found
Changes since v1:
 - return > 0 when command isn't present, < 0 on command failure
 - detect when drive_unplug command isn't present and log error
   instead of failing entire command

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
14 years agoqemud: fix memory leak in io error events
Anthony Liguori [Wed, 1 Dec 2010 15:29:31 +0000 (09:29 -0600)]
qemud: fix memory leak in io error events

The extra data isn't being free()'d for IO error events that have a reason.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqemu: Only build devstr when needs (attach PCI controller)
Osier Yang [Sat, 4 Dec 2010 15:34:01 +0000 (23:34 +0800)]
qemu: Only build devstr when needs (attach PCI controller)

- qemudDomainAttachPciControllerDevice: Don't build "devstr"
  if "-device" of qemu is not available, as "devstr" will only
  be used by "qemuMonitorAddDevice", which depends on "-device"
  argument of qemu is supported.

- "qemudDomainSaveImageOpen": Fix indent problem.

* src/qemu/qemu_driver.c

14 years agoqemu: Enable disabled debug messages
Jiri Denemark [Tue, 7 Dec 2010 16:03:11 +0000 (17:03 +0100)]
qemu: Enable disabled debug messages

14 years agoqemu: Use -vga none only if it is supported
Jiri Denemark [Wed, 8 Dec 2010 13:45:00 +0000 (14:45 +0100)]
qemu: Use -vga none only if it is supported

Commit febc591683cf51e4551f8bcf3ce279a776056e1c introduced -vga none in
case no video card is included in domain XML. However, old qemu
versions do not support this and such domain cannot be successfully
started.

14 years agovirsh: fix a typo in the memtune help description
Justin Clift [Wed, 8 Dec 2010 04:18:40 +0000 (15:18 +1100)]
virsh: fix a typo in the memtune help description

14 years agodocs: updated virsh command reference download links to new version
Justin Clift [Wed, 8 Dec 2010 06:29:32 +0000 (17:29 +1100)]
docs: updated virsh command reference download links to new version

The new version lists every virsh command, its description, and
the version of libvirt where it became available.

14 years agoconfigure: improve misleading libnl missing error message
Justin Clift [Tue, 7 Dec 2010 23:01:03 +0000 (10:01 +1100)]
configure: improve misleading libnl missing error message

This fixes a misleading error message saying the libnl package
needs to be installed, when it's really the libnl-devel package
needing to be installed.

14 years agomaint: update to latest gnulib
Eric Blake [Wed, 8 Dec 2010 00:31:14 +0000 (17:31 -0700)]
maint: update to latest gnulib

* .gnulib: Update to latest, for at least a stdint.h fix
* src/storage/storage_driver.c (storageVolumeZeroSparseFile)
(storageWipeExtent): Use better type, although it still triggers
spurious -Wformat warning on MacOS's gcc.

14 years agoMoved the nodeinfo command to the 'host' help keyword group
Justin Clift [Tue, 7 Dec 2010 22:16:42 +0000 (09:16 +1100)]
Moved the nodeinfo command to the 'host' help keyword group

14 years agoopenvz: avoid potential buffer overflow
Eric Blake [Tue, 7 Dec 2010 19:18:30 +0000 (12:18 -0700)]
openvz: avoid potential buffer overflow

* src/openvz/openvz_conf.c (openvzLoadDomains): Replace unsafe
sscanf with safe direct parsing.
(openvzGetVEID): Avoid lost integer overflow detection.
(openvzAssignUUIDs): Likewise, and detect readdir failure.

14 years agoopenvz: convert popen to virCommand
Eric Blake [Fri, 3 Dec 2010 00:29:34 +0000 (17:29 -0700)]
openvz: convert popen to virCommand

popen must be matched with pclose (not fclose), or it will leak
resources.  Furthermore, it is a lousy interface when it comes to
signal handling.  We're much better off using our decent command
wrapper.  Note that virCommand guarantees that VIR_FREE(outbuf) is
both required and safe to call, whether virCommandRun succeeded or
failed.

* src/openvz/openvz_conf.c (openvzLoadDomains, openvzGetVEID):
Replace popen with virCommand usage.

14 years agocommand: improve behavior on no output
Eric Blake [Fri, 3 Dec 2010 21:14:16 +0000 (14:14 -0700)]
command: improve behavior on no output

Guarantee that outbuf/errbuf are allocated on success, even if to the
empty string.  Caller always has to free the result, and empty output
check requires checking if *outbuf=='\0'.  Makes the API easier to use
safely.  Failure is best effort allocation (some paths, like
out-of-memory, cannot allocate a buffer, but most do), so caller must
free buffer on failure.

* docs/internals/command.html.in: Update documentation.
* src/util/command.c (virCommandSetOutputBuffer)
(virCommandSetErrorBuffer, virCommandProcessIO) Guarantee empty
string on no output.
* tests/commandtest.c (test17): New test.

14 years agocommand: enforce fd vs. buffer considerations
Eric Blake [Mon, 6 Dec 2010 23:36:34 +0000 (16:36 -0700)]
command: enforce fd vs. buffer considerations

* docs/internals/command.html.in: Better documentation of buffer
vs. fd considerations.
* src/util/command.c (virCommandRunAsync): Reject raw execution
with string io.
(virCommandRun): Reject execution with user-specified fds not
visiting a regular file.

14 years agotests: Fix commandtest in VPATH build
Jiri Denemark [Mon, 6 Dec 2010 12:03:26 +0000 (13:03 +0100)]
tests: Fix commandtest in VPATH build

14 years agotests: fix leaks in commandtest
Eric Blake [Mon, 6 Dec 2010 21:48:11 +0000 (14:48 -0700)]
tests: fix leaks in commandtest

Most leaks could only occur on error cleanup paths.

14 years agocommand: improve allocation failure reporting
Eric Blake [Mon, 6 Dec 2010 20:58:52 +0000 (13:58 -0700)]
command: improve allocation failure reporting

* src/util/command.c (virCommandAddEnvString): Remove duplicate
code.
(virCommandToString, virCommandRun, virCommandRunAsync)
(virCommandWait): Report NULL command as ENOMEM, not invalid
usage.
Reported by Jiri Denemark.

14 years agotests: Fix detection of expected error
Jiri Denemark [Mon, 6 Dec 2010 11:58:56 +0000 (12:58 +0100)]
tests: Fix detection of expected error

14 years agotests: Fix code formating in commandtest
Jiri Denemark [Mon, 6 Dec 2010 10:51:41 +0000 (11:51 +0100)]
tests: Fix code formating in commandtest

14 years agouuid: require smbios uuid and domain uuid to match
Eric Blake [Fri, 3 Dec 2010 20:16:31 +0000 (13:16 -0700)]
uuid: require smbios uuid and domain uuid to match

* src/conf/domain_conf.c (virDomainDefParseXML): Prefer sysinfo
uuid over generating one, and if both uuids are present, require
them to be identical.
* src/qemu/qemu_conf.c (qemuBuildSmbiosSystemStr): Allow skipping
the uuid.
(qemudBuildCommandLine): Adjust caller; <smbios mode=host/> must
not use host uuid in place of guest uuid.

14 years agosmbios: allow () in smbios strings
Eric Blake [Thu, 2 Dec 2010 00:45:19 +0000 (17:45 -0700)]
smbios: allow () in smbios strings

* docs/schemas/domain.rng (sysinf-value): Expand pattern.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.xml: Prefer '' over
"" for attribute values.  Copy real hardware values.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.args: Likewise.

14 years agosmbios: support system family
Eric Blake [Thu, 2 Dec 2010 00:07:41 +0000 (17:07 -0700)]
smbios: support system family

* docs/schemas/domain.rng (sysinfo-system-name): Also allow
family.
* src/util/sysinfo.h (struct _virSysinfoDef): Add system_family.
* src/conf/domain_conf.c (virSysinfoParseXML)
(virDomainSysinfoDefFormat): Support it.
* src/util/sysinfo.c (virSysinfoDefFree, virSysinfoRead): Likewise.
* src/qemu/qemu_conf.c (qemuBuildSmbiosSystemStr): Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.xml: Adjust test.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.args: Likewise.

14 years agoqemu: avoid adding "" in smbios arguments
Eric Blake [Wed, 1 Dec 2010 23:50:59 +0000 (16:50 -0700)]
qemu: avoid adding "" in smbios arguments

The log lists things like -smbios type=1,vendor="Red Hat", which
is great for shell parsing, but not so great when you realize that
execve() then passes those literal "" on as part of the command
line argument, such that qemu sets SMBIOS with extra literal quotes.

The eventual addition of virCommand is needed before we have the API
to shell-quote a string representation of a command line, so that the
log can still be pasted into a shell, but without inserting extra
bytes into the execve() arguments.

* src/qemu/qemu_conf.c (qemuBuildSmbiosBiosStr)
(qemuBuildSmbiosSystemStr): Qemu doesn't like quotes around uuid
arguments, and the remaining quotes are passed literally to
smbios, making <smbios mode='host'/> inaccurate.  Removing the
quotes makes the log harder to parse, but that can be fixed later
with virCommand improvements.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.args: 'Fix' test; it
will need fixing again once virCommand learns how to shell-quote a
potential command line.

14 years agovirsh: Remove redundant commands in group domain
Osier Yang [Tue, 7 Dec 2010 07:25:47 +0000 (15:25 +0800)]
virsh: Remove redundant commands in group domain

"echo" is already in group "virsh", "freecell" and "hostname" are
already in group "host", so remove them from group "domain"

* tools/virsh.c

14 years agoFix funny off-by-one error in clock-variable
Dan Kenigsberg [Mon, 6 Dec 2010 07:59:30 +0000 (09:59 +0200)]
Fix funny off-by-one error in clock-variable

Humans consider January as month #1, while gmtime_r(3) calls it month #0.

While fixing it, render qemu's rtc parameter with leading zeros, as is more
commonplace.

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

14 years agosyntax error "Bad fd number" when stopping libvirt-guests
Laurent Léonard [Sun, 5 Dec 2010 17:53:26 +0000 (18:53 +0100)]
syntax error "Bad fd number" when stopping libvirt-guests

When libvirt-guests is being stopped, I get the following message:
$Running guests on default URI: test-vm
$Suspending guests on default URI...
$Suspending test-vm: /etc/init.d/libvirt-guests: 340: Syntax error: Bad fd
number

14 years agothreads: add virThreadID for debugging use
Eric Blake [Sat, 4 Dec 2010 21:33:23 +0000 (14:33 -0700)]
threads: add virThreadID for debugging use

* src/util/threads.h (virThreadID): New prototype.
* src/util/threads-pthread.c (virThreadID): New function.
* src/util/threads-win32.c (virThreadID): Likewise.
* src/libvirt_private.syms (threads.h): Export it.
* daemon/event.c (virEventInterruptLocked): Use it to avoid
warning on BSD systems.

14 years agoutil: Fix bug which will cause libvirtd crash
Osier Yang [Mon, 6 Dec 2010 09:41:10 +0000 (17:41 +0800)]
util: Fix bug which will cause libvirtd crash

"virCommandRun": if "cmd->outbuf" or "cmd->errbuf" is NULL,
libvirtd will be crashed when trying to start a qemu domain
(which invokes "virCommandRun"), it caused by we try to use
"*cmd->outbuf" and "*cmd->errbuf" regardless of cmd->outbuf
or cmd->errbuf is NULL.

* src/util/command.c (virCommandRun)

14 years agotests: Don't ignore return value of getcwd()
Jiri Denemark [Fri, 3 Dec 2010 16:10:31 +0000 (17:10 +0100)]
tests: Don't ignore return value of getcwd()

14 years agobuild: Fix internal docs generation in VPATH builds
Jiri Denemark [Fri, 3 Dec 2010 16:06:14 +0000 (17:06 +0100)]
build: Fix internal docs generation in VPATH builds

14 years agoqemu: Fix a possible deadlock in p2p migration
Jiri Denemark [Fri, 3 Dec 2010 09:48:31 +0000 (10:48 +0100)]
qemu: Fix a possible deadlock in p2p migration

Two more calls to remote libvirtd have to be surrounded by
qemuDomainObjEnterRemoteWithDriver() and
qemuDomainObjExitRemoteWithDriver() to prevent possible deadlock between
two communicating libvirt daemons.

See commit f0c8e1cb3774d6f09e2681ca1988bf235a343007 for further details.

14 years agoChange return value of VIR_DRV_SUPPORTS_FEATURE to bool
Jiri Denemark [Fri, 3 Dec 2010 08:31:48 +0000 (09:31 +0100)]
Change return value of VIR_DRV_SUPPORTS_FEATURE to bool

virDrvSupportsFeature API is allowed to return -1 on error while all but
one uses of VIR_DRV_SUPPORTS_FEATURE only check for (non)zero return
value. Let's make this macro return zero on error, which is what
everyone expects anyway.

14 years agoqemu: Don't try to set input FD to -1
Matthias Bolte [Sat, 4 Dec 2010 23:45:43 +0000 (00:45 +0100)]
qemu: Don't try to set input FD to -1

14 years agoImplement virVMOperationType{To|From}String independent from WITH_MACVTAP
Matthias Bolte [Fri, 3 Dec 2010 17:02:59 +0000 (18:02 +0100)]
Implement virVMOperationType{To|From}String independent from WITH_MACVTAP

As this symbols are exported independent from WITH_MACVTAP.

14 years agobuild: avoid shadowing devname() on BSD systems
Eric Blake [Fri, 3 Dec 2010 15:26:40 +0000 (08:26 -0700)]
build: avoid shadowing devname() on BSD systems

* tools/virsh.c (cmdRunConsole, cmdConsole): Rename problematic
symbol.
Reported by Justin Clift.

14 years agovirsh: Remove redundant optional option for cmdHelp
Osier Yang [Fri, 3 Dec 2010 07:34:23 +0000 (15:34 +0800)]
virsh: Remove redundant optional option for cmdHelp

Remove the optional option "group", as cmdHelp should accepts
only one option ("virsh help" supports both command and command
group now, and user rarely uses the options, so it doesn't matter
much for it being longer, :-)

* tools/virsh.c

14 years agoCreate file in virFileWriteStr() if it doesn't exist
Jean-Baptiste Rouault [Fri, 3 Dec 2010 09:47:08 +0000 (10:47 +0100)]
Create file in virFileWriteStr() if it doesn't exist

This patch adds a mode_t parameter to virFileWriteStr().
If mode is different from 0, virFileWriteStr() will try
to create the file if it doesn't exist.

* src/util/util.h (virFileWriteStr): Alter signature.
* src/util/util.c (virFileWriteStr): Allow file creation.
* src/network/bridge_driver.c (networkEnableIpForwarding)
(networkDisableIPV6): Adjust clients.
* src/node_device/node_device_driver.c
(nodeDeviceVportCreateDelete): Likewise.
* src/util/cgroup.c (virCgroupSetValueStr): Likewise.
* src/util/pci.c (pciBindDeviceToStub, pciUnBindDeviceFromStub):
Likewise.

14 years agoman pages: update the description for the virsh help command
Justin Clift [Thu, 2 Dec 2010 12:49:38 +0000 (23:49 +1100)]
man pages: update the description for the virsh help command

Now includes information on keyword usage, and provides examples.

14 years agovirsh: move two commands from domain group to storage pool group
Osier Yang [Thu, 2 Dec 2010 00:25:17 +0000 (08:25 +0800)]
virsh: move two commands from domain group to storage pool group

* tools/virsh.c (find-storage-pool-sources-as and find-storage-pool-sources
should't be in command group "Domain Management", move them to group
"Storage Pool".

14 years agoRemove bogus includes
Daniel P. Berrange [Tue, 25 May 2010 11:17:56 +0000 (12:17 +0100)]
Remove bogus includes

14 years agouml: convert to virCommand
Daniel P. Berrange [Tue, 25 May 2010 13:17:48 +0000 (14:17 +0100)]
uml: convert to virCommand

* src/uml/uml_conf.c (umlBuildCommandLineChr)
(umlBuildCommandLine): Rewrite with virCommand.
* src/uml/uml_conf.h (umlBuildCommandLine): Update signature.
* src/uml/uml_driver.c (umlStartVMDaemon): Adjust caller.

14 years agoqemu: convert to virCommand
Eric Blake [Mon, 22 Nov 2010 23:09:13 +0000 (16:09 -0700)]
qemu: convert to virCommand

* src/qemu/qemu_conf.c (qemudExtractVersionInfo): Check for file
before executing it here, rather than in callers.
(qemudBuildCommandLine): Rewrite with virCommand.
* src/qemu/qemu_conf.h (qemudBuildCommandLine): Update signature.
* src/qemu/qemu_driver.c (qemuAssignPCIAddresses)
(qemudStartVMDaemon, qemuDomainXMLToNative): Adjust callers.

14 years agoPort hooks and iptables code to new command execution APIs
Daniel P. Berrange [Tue, 25 May 2010 11:18:53 +0000 (12:18 +0100)]
Port hooks and iptables code to new command execution APIs

This proof of concept shows how two existing uses of virExec
and virRun can be ported to the new virCommand APIs, and how
much simpler the code becomes

14 years agovirCommand: docs for usage of new command APIs
Daniel P. Berrange [Tue, 25 May 2010 13:14:46 +0000 (14:14 +0100)]
virCommand: docs for usage of new command APIs

* docs/internals/command.html.in: New file.
* docs/Makefile.am: Build new docs.
* docs/subsite.xsl: New glue file.
* docs/internals.html.in, docs/sitemap.html.in: Update glue.

14 years agoIntroduce new APIs for spawning processes
Daniel P. Berrange [Tue, 25 May 2010 11:14:06 +0000 (12:14 +0100)]
Introduce new APIs for spawning processes

This introduces a new set of APIs in src/util/command.h
to use for invoking commands. This is intended to replace
all current usage of virRun and virExec variants, with a
more flexible and less error prone API.

* src/util/command.c: New file.
* src/util/command.h: New header.
* src/Makefile.am (UTIL_SOURCES): Build it.
* src/libvirt_private.syms: Export symbols internally.
* tests/commandtest.c: New test.
* tests/Makefile.am (check_PROGRAMS): Run it.
* tests/commandhelper.c: Auxiliary program.
* tests/commanddata/test2.log - test15.log: New expected outputs.
* cfg.mk (useless_free_options): Add virCommandFree.
(msg_gen_function): Add virCommandError.
* po/POTFILES.in: New translation.
* .x-sc_avoid_write: Add exemption.
* tests/.gitignore: Ignore new built file.

14 years agoutil: add virVasprintf
Eric Blake [Mon, 22 Nov 2010 23:39:47 +0000 (16:39 -0700)]
util: add virVasprintf

* src/util/util.h (virVasprintf): New declaration.
* src/util/util.c (virVasprintf): New function.
(virAsprintf): Use it.
* src/util/virtaudit.c (virAuditSend): Likewise.
* src/libvirt_private.syms: Export it.
* cfg.mk (sc_prohibit_asprintf): Also prohibit vasprintf.
* .x-sc_prohibit_asprintf: Add exemption.

14 years agoutil: fix saferead type
Eric Blake [Mon, 22 Nov 2010 23:50:00 +0000 (16:50 -0700)]
util: fix saferead type

* src/util/util.c (saferead): Fix return type.
(safewrite): Fix indentation.

14 years agoTweak daemon event debug to include errno
Daniel P. Berrange [Wed, 1 Dec 2010 16:41:14 +0000 (16:41 +0000)]
Tweak daemon event debug to include errno

* daemon/event.c: Include errno in debug info upon poll() failure

14 years agoFix memory leak in logging setup
Daniel P. Berrange [Wed, 1 Dec 2010 16:42:17 +0000 (16:42 +0000)]
Fix memory leak in logging setup

The logging setup requires const char * strings, but the
virLogSetFromEnv() strdup's the env variables, thus causing
a memory leak

* src/util/logging.c: Avoid strdup'ing env variables

14 years agotests: Add tests for CPU selection in qemu driver
Jiri Denemark [Fri, 16 Apr 2010 06:21:23 +0000 (08:21 +0200)]
tests: Add tests for CPU selection in qemu driver

14 years agotests: Support for faking emulator in qemuxml2argv
Jiri Denemark [Fri, 16 Apr 2010 06:20:33 +0000 (08:20 +0200)]
tests: Support for faking emulator in qemuxml2argv

This patch allows for using custom scripts instead of /usr/bin/qemu
emulator in domain XML. To do so, one would specify relative path to the
custom script in <emulator/>. The path needs to be relative to
qemuxml2argvdata directory and it will be transparently made absolute in
runtime. The expected command line needs to contain the exact relative
path as was used in domain XML.

The problem is RelaxNG schema for domain XML only allows for absolute
path within <emulator/>. To workaround it, an extra '/' must be added at
the beginning of the path. That is, instead of "./qemu.sh" or
"../emulator/qemu.sh" one would use "/./qemu.sh" or
"/../emulator/qemu.sh". The extra slash is removed before further
processing. I don't like this workaround, it's very ugly but it's the
best option I was able to come up with. Relaxing domain XML schema is
not an option IMO.

14 years agoschemas: Fix cpu element schema
Jiri Denemark [Wed, 1 Dec 2010 14:25:48 +0000 (15:25 +0100)]
schemas: Fix cpu element schema

Both vendor and topology elements are optional.

14 years agovirsh: Remove using phy as default disk driver in cmdAttachDisk
Osier Yang [Thu, 2 Dec 2010 01:19:30 +0000 (09:19 +0800)]
virsh: Remove using phy as default disk driver in cmdAttachDisk

* tools/virsh.c (virsh shouldn't use 'phy' as the disk driver if
user doesn't specify "--driver", it causes bugs, as not all of
hypervisor driver supports 'phy', and actually hypervisor should
known the correct default disk driver and subdriver, so remove it)