Commit Graph

5790 Commits

Author SHA1 Message Date
Hu Tao
e8e9397cf7 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.
2010-12-10 08:00:05 -07:00
Dan Kenigsberg
91b3e1038f 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.
2010-12-09 16:55:48 -07:00
Josh Durgin
715bf4523e tests: Add tests for network disks
Signed-off-by: Josh Durgin <joshd@hq.newdream.net>
2010-12-09 14:20:53 -07:00
Josh Durgin
85400fb992 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>
2010-12-09 14:20:53 -07:00
MORITA Kazutaka
036ad5052b 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>
2010-12-09 14:09:12 -07:00
Wen Congyang
85d5fb19b1 correct the signal's name
The signal's name is wrong...

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
2010-12-09 12:03:11 -07:00
Hu Tao
e19cdbfcf1 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.
2010-12-09 11:59:27 -07:00
Hu Tao
b4560bf2ef Add a new function doCoreDump
This patch prepares for the next patch.
2010-12-09 11:43:58 -07:00
Hu Tao
482380b587 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
2010-12-09 11:39:17 -07:00
Eric Blake
8e9ee30e8a 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.
2010-12-09 09:14:13 -07:00
Jiri Denemark
c778fe9678 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.
2010-12-09 11:50:48 +01:00
Ryan Harper
aefaeb3d48 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>
2010-12-08 14:43:45 -07:00
Ryan Harper
0cdc982995 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>
2010-12-08 11:03:02 -07:00
Anthony Liguori
560ed3eb78 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>
2010-12-08 09:00:26 -07:00
Osier Yang
981f7c8c9b 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
2010-12-08 08:58:51 -07:00
Jiri Denemark
e878514601 qemu: Enable disabled debug messages 2010-12-08 16:50:08 +01:00
Jiri Denemark
2cfb107905 qemu: Use -vga none only if it is supported
Commit febc591683 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.
2010-12-08 16:45:10 +01:00
Justin Clift
6f7c6f8c1f virsh: fix a typo in the memtune help description 2010-12-09 01:53:56 +11:00
Justin Clift
3b45eec5a4 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.
2010-12-08 17:35:34 +11:00
Justin Clift
b113d279ee 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.
2010-12-08 14:21:58 +11:00
Eric Blake
8f636752b1 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.
2010-12-07 19:51:34 -07:00
Justin Clift
e3cb5a26d2 Moved the nodeinfo command to the 'host' help keyword group 2010-12-08 11:24:37 +11:00
Eric Blake
a0ac00f4f0 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.
2010-12-07 15:40:01 -07:00
Eric Blake
bfd6267bcd 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.
2010-12-07 15:35:36 -07:00
Eric Blake
cc5e2a849c 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.
2010-12-07 15:35:30 -07:00
Eric Blake
ee11729d7f 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.
2010-12-07 15:30:24 -07:00
Jiri Denemark
ea8389dd3d tests: Fix commandtest in VPATH build 2010-12-07 09:34:09 -07:00
Eric Blake
3c63a15b77 tests: fix leaks in commandtest
Most leaks could only occur on error cleanup paths.
2010-12-07 09:34:09 -07:00
Eric Blake
c426d13b73 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.
2010-12-07 09:34:09 -07:00
Jiri Denemark
c1c1ff7e47 tests: Fix detection of expected error 2010-12-07 17:11:25 +01:00
Jiri Denemark
49c612b39e tests: Fix code formating in commandtest 2010-12-07 17:11:24 +01:00
Eric Blake
4117672eaa 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.
2010-12-07 08:49:45 -07:00
Eric Blake
a7666b9e38 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.
2010-12-07 08:49:45 -07:00
Eric Blake
8cad56037b 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.
2010-12-07 08:49:45 -07:00
Eric Blake
575914cf3d 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.
2010-12-07 08:35:05 -07:00
Osier Yang
8eb236c5f7 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
2010-12-07 08:23:09 -07:00
Dan Kenigsberg
e37ff2004a 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
2010-12-06 11:14:42 -07:00
Laurent Léonard
68e5e4672a 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
2010-12-06 11:01:36 -07:00
Eric Blake
e4bc372e1b 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.
2010-12-06 09:50:20 -07:00
Osier Yang
85ccf42cd0 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)
2010-12-06 09:34:54 -07:00
Jiri Denemark
58d0f4d737 tests: Don't ignore return value of getcwd() 2010-12-06 10:12:01 +01:00
Jiri Denemark
5f5c6a1b90 build: Fix internal docs generation in VPATH builds 2010-12-06 10:11:44 +01:00
Jiri Denemark
584c13f356 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 f0c8e1cb37 for further details.
2010-12-06 10:09:50 +01:00
Jiri Denemark
4186f92935 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.
2010-12-06 10:09:00 +01:00
Matthias Bolte
ccf2d0847b qemu: Don't try to set input FD to -1 2010-12-05 00:45:43 +01:00
Matthias Bolte
45ef4d5e8a Implement virVMOperationType{To|From}String independent from WITH_MACVTAP
As this symbols are exported independent from WITH_MACVTAP.
2010-12-03 18:06:42 +01:00
Eric Blake
c6506ff8e9 build: avoid shadowing devname() on BSD systems
* tools/virsh.c (cmdRunConsole, cmdConsole): Rename problematic
symbol.
Reported by Justin Clift.
2010-12-03 08:26:40 -07:00
Osier Yang
2636f50842 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
2010-12-03 08:22:17 -07:00
Jean-Baptiste Rouault
966a1bfe22 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.
2010-12-03 08:08:22 -07:00
Justin Clift
4fa617e6eb man pages: update the description for the virsh help command
Now includes information on keyword usage, and provides examples.
2010-12-03 17:54:16 +11:00