Commit Graph

9557 Commits

Author SHA1 Message Date
Jiri Denemark
07dd6fb610 qemu: Shared or readonly disks are always safe wrt migration
No matter what cache mode is used, readonly disks are always safe wrt
migration. Shared disks are required to be readonly or to disable
host-side cache, which makes them safe as well.
2012-03-05 15:24:00 +01:00
Peter Krempa
6c3642e9bc libvirt-guests: Add parallel startup and shutdown of guests
With this patch, it's possible to shut down guests in parallel. Parallel
startup was possible before, but this functionality was not documented
properly.

To enable parallel startup set the START_DELAY to 0.

Parallel shutdown has a configurable parameter PARALLEL_SHUTDOWN that
defines the number of machines being shut down in parallel. Enabling
this feature changes the semantics of SHUTDOWN_TIMEOUT parameter that is
applied as a cumulative timeout to shutdown all guests on a URI.
2012-03-05 13:18:24 +01:00
Jiri Denemark
720bee3008 rpc: Fix client crash on connection close
A multi-threaded client with event loop may crash if one of its threads
closes a connection while event loop is in the middle of sending
keep-alive message (either request or response). The right place for it
is inside virNetClientIOEventLoop() between poll() and
virNetClientLock(). We should only close a connection directly if no-one
is using it and defer the closing to the last user otherwise. So far we
only did so if the close was initiated by keep-alive timeout.
2012-03-05 11:30:02 +01:00
Jiri Denemark
57e677a7c6 build: Fix build with dtrace + apparmor
Building virt-aa-helper with dtrace probes enabled, ldd complained about
undefined references:

./.libs/libvirt_util.a(libvirt_util_la-event_poll.o):(.note.stapsdt+0x24):
undefined reference to `libvirt_event_poll_purge_timeout_semaphore'
...
2012-03-05 11:30:02 +01:00
Osier Yang
3d2da30edb Fix type and add missed comment for diskChange callback
Comment for parameter devAlias is missed. And a typo should
be caused by copy & paste.
2012-03-05 18:43:32 +08:00
Osier Yang
1f77472d5b qemu: Fix indention 2012-03-05 18:32:53 +08:00
Peter Krempa
d2c28911f4 cpu: Add new flag supported by qemu to the cpu definition
Some new cpu features were added to qemu. This patch adds some of them
to our CPU map.
2012-03-05 09:54:26 +01:00
Zeeshan Ali (Khattak)
4f3287a415 Correct a check for capacity arg of storageVolumeResize()
Lets say I got a volume with '1G' allocation and '10G' capacity. The
available space in the parent pool is '5G'. With the current check for
overcapacity, I can only try to resize to <= '6G'. You see the problem?
2012-03-02 21:52:02 -07:00
Laine Stump
d1c310231d util: combine bools in virNetDevTapCreateInBridgePort into flags
With an additional new bool added to determine whether or not to
discourage the use of the supplied MAC address by the bridge itself,
virNetDevTapCreateInBridgePort had three booleans (well, 2 bools and
an int used as a bool) in the arg list, which made it increasingly
difficult to follow what was going on. This patch combines those three
into a single flags arg, which not only shortens the arg list, but
makes it more self-documenting.
2012-03-02 16:04:06 -05:00
Ansis Atteka
c1b164d70c util: centralize tap device MAC address 1st byte "0xFE" modification
When a tap device for a domain is created and attached to a bridge,
the first byte of the tap device MAC address is set to 0xFE, while the
rest is set to match the MAC address that will be presented to the
guest as its network device MAC address. Setting this high value in
the tap's MAC address discourages the bridge from using the tap
device's MAC address as the bridge's own MAC address (Linux bridges
always take on the lowest numbered MAC address of all attached devices
as their own).

In one case within libvirt, a tap device is created and attached to
the bridge with the intent that its MAC address be taken on by the
bridge as its own (this is used to assure that the bridge has a fixed
MAC address to prevent network outages created by the bridge MAC
address "flapping" as guests are started and stopped). In this case,
the first byte of the mac address is *not* altered to 0xFE.

In the current code, callers to virNetDevTapCreateInBridgePort each
make the MAC address modification themselves before calling, which
leads to code duplication, and also prevents lower level functions
from knowing the real MAC address being used by the guest. The problem
here is that openvswitch bridges must be informed about this MAC
address, or they will be unable to pass traffic to/from the guest.

This patch centralizes the location of the MAC address "0xFE fixup"
into virNetDevTapCreateInBridgePort(), meaning 1) callers of this
function no longer need the extra strange bit of code, and 2)
bitNetDevTapCreateBridgeInPort itself now is called with the guest's
unaltered MAC address, and can pass it on, unmodified, to
virNetDevOpenvswitchAddPort.

There is no other behavioral change created by this patch.
2012-03-02 16:04:00 -05:00
Peter Krempa
2dcca3ec0a daemon: Remove deprecated HAL from init script dependencies
The init script for the daemon requests to start HAL although it has
been deprecated long time ago. This patch removes the dependency.
2012-03-02 16:32:37 +01:00
Eric Blake
355ec28167 build: fix output of pid values
Nuke the last vestiges of printing pid_t values with the wrong
types, at least in code compiled on mingw64.  There may be other
places, but for now they are only compiled on systems where the
existing %d doesn't trigger gcc warnings.

* src/rpc/virnetsocket.c (virNetSocketNew): Use %lld and casting,
rather than assuming any particular int type for pid_t.
* src/util/command.c (virCommandRunAsync, virPidWait)
(virPidAbort): Likewise.
(verify): Drop a now stale assertion.
2012-03-02 06:57:57 -07:00
Eric Blake
3e2c3d8f6d build: use correct type for pid and similar types
No thanks to 64-bit windows, with 64-bit pid_t, we have to avoid
constructs like 'int pid'.  Our API in libvirt-qemu cannot be
changed without breaking ABI; but then again, libvirt-qemu can
only be used on systems that support UNIX sockets, which rules
out Windows (even if qemu could be compiled there) - so for all
points on the call chain that interact with this API decision,
we require a different variable name to make it clear that we
audited the use for safety.

Adding a syntax-check rule only solves half the battle; anywhere
that uses printf on a pid_t still needs to be converted, but that
will be a separate patch.

* cfg.mk (sc_correct_id_types): New syntax check.
* src/libvirt-qemu.c (virDomainQemuAttach): Document why we didn't
use pid_t for pid, and validate for overflow.
* include/libvirt/libvirt-qemu.h (virDomainQemuAttach): Tweak name
for syntax check.
* src/vmware/vmware_conf.c (vmwareExtractPid): Likewise.
* src/driver.h (virDrvDomainQemuAttach): Likewise.
* tools/virsh.c (cmdQemuAttach): Likewise.
* src/remote/qemu_protocol.x (qemu_domain_attach_args): Likewise.
* src/qemu_protocol-structs (qemu_domain_attach_args): Likewise.
* src/util/cgroup.c (virCgroupPidCode, virCgroupKillInternal):
Likewise.
* src/qemu/qemu_command.c(qemuParseProcFileStrings): Likewise.
(qemuParseCommandLinePid): Use pid_t for pid.
* daemon/libvirtd.c (daemonForkIntoBackground): Likewise.
* src/conf/domain_conf.h (_virDomainObj): Likewise.
* src/probes.d (rpc_socket_new): Likewise.
* src/qemu/qemu_command.h (qemuParseCommandLinePid): Likewise.
* src/qemu/qemu_driver.c (qemudGetProcessInfo, qemuDomainAttach):
Likewise.
* src/qemu/qemu_process.c (qemuProcessAttach): Likewise.
* src/qemu/qemu_process.h (qemuProcessAttach): Likewise.
* src/uml/uml_driver.c (umlGetProcessInfo): Likewise.
* src/util/virnetdev.h (virNetDevSetNamespace): Likewise.
* src/util/virnetdev.c (virNetDevSetNamespace): Likewise.
* tests/testutils.c (virtTestCaptureProgramOutput): Likewise.
* src/conf/storage_conf.h (_virStoragePerms): Use mode_t, uid_t,
and gid_t rather than int.
* src/security/security_dac.c (virSecurityDACSetOwnership): Likewise.
* src/conf/storage_conf.c (virStorageDefParsePerms): Avoid
compiler warning.
2012-03-02 06:57:43 -07:00
Eric Blake
5c3a15647d build: prohibit cross-inclusion
Make it easier to detect invalid cross-directory includes, by
adding a syntax check.  The check is designed to be extensible:
the default case lists only the non-driver directories, and
specific directories can list a different set (for example,
util/ can only use itself, network/ can only use itself, util/,
or conf/).

* .gnulib: Update to latest, for syntax check improvment.
* cfg.mk (sc_prohibit_cross_inclusion): New check.
(sc_prohibit_strncmp, sc_libvirt_unmarked_diagnostics): Simplify.
2012-03-02 06:22:43 -07:00
Hu Tao
362077e752 avoid global variable shadowed
If "conf/domain_conf.h" included in file nodeinfo.c, gcc complains about
a variable shadowing. fix it for potential further including of the file.

ref: https://www.redhat.com/archives/libvir-list/2012-February/msg00955.html
2012-03-01 20:09:23 -07:00
Laine Stump
3c30fbcd4a util: remove unneeded #include in virrandom.c
Commit 7c90026 added #include "conf/domain_conf.h" to
util/virrandom.c. Fortunately it didn't actually use anything from
domain_conf.h, since as far as I'm aware, files in util aren't allowed
to reference anything in conf (although the opposite is allowed). So
this #include is unnecessary.

I verified it still compiles with the line removed, but have placed a
one day moratorium on me doing any "trivial rule" pushes, so will
wait for someone else to verify/ACK before pushing.
2012-03-01 12:44:12 -05:00
Eric Blake
ff4c25bae9 virsh: expose partial pull
Now virsh can call virDomainBlockRebase.

* tools/virsh.c (cmdBlockPull): Add --base parameter.
(blockJobImpl): Use it to expose BlockRebase API.
* tools/virsh.pod (blockpull): Document it.
2012-02-29 13:44:20 -07:00
Eric Blake
10ec36e2e7 qemu: pass block pull backing file to monitor
This actually wires up the new optional parameter to block_stream:
http://wiki.qemu.org/Features/LiveBlockMigration/ImageStreamingAPI

The error checking is still sparse, since libvirt must not use
qemu-img or header probing on a qcow2 file in use by qemu to
check if the backing file name is valid; so for now, libvirt is
relying on qemu to diagnose an incorrect backing name.  Fixing this
will require libvirt to track the entire backing file chain at the
time qemu is started and keeps it updated with snapshot and pull
operations.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockJob): Add
parameter, and update callers.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockJob): Update
signature.
* src/qemu/qemu_monitor.h (qemuMonitorBlockJob): Likewise.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Update caller.
* src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Likewise.
2012-02-29 13:44:20 -07:00
Eric Blake
68a1300556 qemu: require json for block jobs
Block job commands are not part of upstream qemu until 1.1; and
proper support of job completion and cancellation depends on being
able to receive QMP events, which implies the JSON monitor.
Additionally, some early versions of block job commands were
backported to RHEL qemu, but these versions lacked asynchronous
job cancellation and partial block pull, so there are several
patches that will still be needed in this area of libvirt code
to support both flavors of block job commands.

Due to earlier patches in libvirt, we are guaranteed that all versions
of qemu that support block job commands already require libvirt to
use the JSON monitor.  That means that the text version of block jobs
will not be used, and having to refactor two copies of the block job
handlers makes no sense.  So instead, we delete the text handlers.

* src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Drop text monitor
support.
* src/qemu/qemu_monitor_text.h (qemuMonitorTextBlockJob): Delete.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextParseBlockJobOne)
(qemuMonitorTextParseBlockJob, qemuMonitorTextBlockJob):
Likewise.
2012-02-29 13:44:20 -07:00
Laine Stump
513fc05750 fix alphabetical order of virNetlink functions in symbol file 2012-02-29 15:26:13 -05:00
Laine Stump
e91be41e75 util: wrap virnetlink.c to 80 columns 2012-02-29 15:26:05 -05:00
Eric Blake
47d05109b0 build: update to latest gnulib
It's been a while, and we're between releases, so now's as good
a time as any to resync.  This also fixes a build-breaker on
cygwin, where cygwin 1.7.11 introduced a header bug in <termios.h>.

* .gnulib: Update to latest.
* bootstrap: Resync.
* cfg.mk (sc_prohibit_strncmp): Copy upstream changes to
sc_prohibit_strcmp.
2012-02-29 10:27:40 -07:00
Christophe Fergeau
df873c806e Fix typo in domain XML documentation
s/Modyfing/Modifying
2012-02-29 17:37:32 +01:00
D. Herrendoerfer
723d5c50c0 Add de-association handling to macvlan code
Add de-association handling for 802.1qbg (vepa) via lldpad
netlink messages. Also adds the possibility to perform an
association request without waiting for a confirmation.

Signed-off-by: D. Herrendoerfer <d.herrendoerfer@herrendoerfer.name>
2012-02-29 10:37:32 -05:00
D. Herrendoerfer
e3ba402581 util: Add netlink event handling to virnetlink.c
This code adds a netlink event interface to libvirt.
It is based upon the event_poll code and makes use of
it. An event is generated for each netlink message sent
to the libvirt pid.

Signed-off-by: D. Herrendoerfer <d.herrendoerfer@herrendoerfer.name>
2012-02-29 10:37:24 -05:00
Martin Kletzander
b395f95910 Support for cpu64-rhel* qemu cpu models
In qemu there are 2 cpu models (cpu64-rhel5 and cpu64-rhel6) not
supported by libvirt. This patch adds the support with the flags
specifications from /usr/share/qemu-kvm/cpu-model/cpu-x86_64.conf
The only difference is that AMD-specific features are removed so
the processor type is not vendor-specific. Those features are either
emulated or ignored by qemu if host CPU doesn't support them.
2012-02-29 15:03:13 +01:00
Martin Kletzander
6ba4b300b0 lxc: Cleaner fix for compilation without SELinux
Just a cleanup of commit 32f881c6c4.
2012-02-29 14:55:32 +01:00
Peter Krempa
0531377076 libvirt-guests: Check if URI is reachable before launching commands
This patch adds a check to the libvirt-guests script to check for the
URI to be alive before attempting any calls. This avoids nasty error
messages and allows us to fail gracefully and continue on other URIs
configured in the script.
2012-02-29 12:51:26 +01:00
Peter Krempa
bc72d9a3a9 libvirt-guests: Don't try to do a managed-save of transient guests
The libvirt-guests script tried to do a managed save of transient guest
that failed. This patch notifies which guests are transient (and not
being saved) and saves only the persistent ones.
2012-02-29 12:44:21 +01:00
Peter Krempa
0d77f746ec libvirt-guests: Add documentation and clean up to use virsh's improved list
This patch adds documentation to functions defined in the libvirt-guests
init script and changes use of virsh's new commands to make the script
easier.
2012-02-29 12:40:31 +01:00
Jiri Denemark
04dec5826d qemu: Add pre-migration hook
This hook is called during the Prepare phase on destination host and may
be used for changing domain XML.
2012-02-29 12:27:12 +01:00
Jiri Denemark
8ab785783f hooks: Add support for capturing hook output
Hooks may now be used as filters.
2012-02-29 12:27:12 +01:00
Michal Privoznik
c0f722240d storage: fix typo
* src/storage/storage_driver.c (storageVolumeWipeInternal):
    s/ pfitzner33/pfitzner33/.
2012-02-29 11:44:23 +01:00
Jiri Denemark
238a5a4c3d qemu: Don't emit tls-port spice option if port is -1
Bug introduced by commit eda0fc7a.
2012-02-29 11:12:54 +01:00
Alex Jia
096e9048ff docs: comments wiping supported algorithms
The current scrub version doesn't support pfitzner7, pfitzner33 and schneier
patterns on RHEL, we should comment it in virsh man page.

* tools/virsh.pod: update wiping algorithms docs.

Signed-off-by: Alex Jia <ajia@redhat.com>
2012-02-29 17:50:08 +08:00
Alex Jia
f1c13cf9c9 util: fix a typo
* src/util/event_poll.c: (virEventPollRunOnce): s/imeout/timeout/.

Signed-off-by: Alex Jia <ajia@redhat.com>
2012-02-29 17:42:18 +08:00
Alex Jia
f3e99e9920 storage: fix a typo
* src/storage/storage_driver.c (storageVolumeWipeInternal): s/shneier/schneier.

http://code.google.com/p/diskscrub/

Signed-off-by: Alex Jia <ajia@redhat.com>
2012-02-29 17:41:49 +08:00
Daniel Veillard
4017ec927f Do not include binaries in EXTRA_DIST
commit f27f616ff8 broke "make dist"
by adding qemumonitortest which is a generated binary to the
EXTRA_DIST, hence breaking "make dist"
2012-02-29 15:24:35 +08:00
Michal Privoznik
b30a5cee07 docs: Fix libvirt name in qemu commandline namespace URL
s/libirt/libvirt/g
2012-02-28 17:30:30 +01:00
Laine Stump
3207de308d libxl: eliminate memory leak in libxmlDomainModifyDeviceFlags
This call to virDomainDeviceDefParse is both unnecessary (since
it will again be called at the top of the immediately following if(),
and if not there, then at the top of the if following that), but it
also creates a leak of one virDomainDeviceDef and one [whatever type
of device the DeviceDef is pointing to; probably a virDomainDiskDef]
in the case that the function has been called with
VIR_DOMAIN_DEVICE_MODIFY_CONFIG (the second parse will overwrite the
devicedef that was just created).
2012-02-28 07:43:38 -05:00
Osier Yang
3aab4d7929 virsh: Break long lines in virsh.pod
No content changes, just breaking long lines.
2012-02-28 15:41:37 +08:00
Osier Yang
33855f5d04 virsh: New command cmdChangeMedia
One could use it to eject, insert, or update media of the CDROM
or floppy drive. See the documentation for more details.
2012-02-28 15:36:38 +08:00
Osier Yang
42accf1b67 virsh: Use vshFindDisk and vshPrepareDiskXML in cmdDetachDisk
The first use of the two new helper functions.
2012-02-28 14:38:34 +08:00
Osier Yang
025998eb79 virsh: Two new helper functions for disk device changes
vshFindDisk is to find the disk node in xml doc with given source
path or target of disk device, and type (indicates disk type,
normal disk or changeable disk).

vshPrepareDiskXML is to make changes on the disk node (e.g. create
and insert the new <source> node for inserting media of CDROM drive).

They are marked as unused temporarily.
2012-02-28 14:38:03 +08:00
Osier Yang
c430248643 tests: Add tests for virtio-scsi and ibmvscsi controllers 2012-02-28 14:28:21 +08:00
Osier Yang
c56fe7f1d6 qemu: Build command line for the new address format
For any disk controller model which is not "lsilogic", the command
line will be like:

  -drive file=/dev/sda,if=none,id=drive-scsi0-0-3-0,format=raw \
  -device scsi-disk,bus=scsi0.0,channel=0,scsi-id=3,lun=0,i\
  drive=drive-scsi0-0-3-0,id=scsi0-0-3-0

The relationship between the libvirt address attrs and the qdev
properties are (controller model is not "lsilogic"; strings
inside <> represent libvirt adress attrs):
  bus=scsi<controller>.0
  channel=<bus>
  scsi-id=<target>
  lun=<unit>

* src/qemu/qemu_command.h: (New param "virDomainDefPtr def"
  for function qemuBuildDriveDevStr; new param "virDomainDefPtr
  vmdef" for function qemuAssignDeviceDiskAlias. Both for
  virDomainDiskFindControllerModel's use).

* src/qemu/qemu_command.c:
  - New param "virDomainDefPtr def" for qemuAssignDeviceDiskAliasCustom.
    For virDomainDiskFindControllerModel's use, if the disk bus is "scsi"
    and the controller model is not "lsilogic", "target" is one part of
    the alias name.
  - According change on qemuAssignDeviceDiskAlias and qemuBuildDriveDevStr

* src/qemu/qemu_hotplug.c:
  - Changes to be consistent with declarations of qemuAssignDeviceDiskAlias
    qemuBuildDriveDevStr, and qemuBuildControllerDevStr.

* tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args,
  tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args: Update the
  generated command line.
2012-02-28 14:27:17 +08:00
Osier Yang
05fbe728ee qemu: New cap flag to indicate if channel is supported by scsi-disk 2012-02-28 14:27:13 +08:00
Osier Yang
4288b22fb2 conf: Introduce new attribute for device address format
* src/conf/domain_conf.h: Add new member "target" to struct
  _virDomainDeviceDriveAddress.

* src/conf/domain_conf.c: Parse and format "target"

* Lots of tests (.xml) in tests/domainsnapshotxml2xmlout,
  tests/qemuxml2argvdata, tests/qemuxml2xmloutdata, and
  tests/vmx2xmldata/ are modified for newly introduced
  attribute "target" for address of "drive" type.
2012-02-28 14:27:11 +08:00
Osier Yang
7eadfddad5 conf: Add helper function to look up disk controller model 2012-02-28 14:27:08 +08:00
Paolo Bonzini
8dcac770f1 qemu: add virtio-scsi controller model
Adding a new model for virtio-scsi roughly follows the same scheme
as the previous patch.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-02-28 14:27:03 +08:00