]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 years agoGive each virtual network bridge its own fixed MAC address
Laine Stump [Wed, 9 Feb 2011 08:28:12 +0000 (03:28 -0500)]
Give each virtual network bridge its own fixed MAC address

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

The problem was that, since a bridge always acquires the MAC address
of the connected interface with the numerically lowest MAC, as guests
are started and stopped, it was possible for the MAC address to change
over time, and this change in the network was being detected by
Windows 7 (it sees the MAC of the default route change), so on each
reboot it would bring up a dialog box asking about this "new network".

The solution is to create a dummy tap interface with a MAC guaranteed
to be lower than any guest interface's MAC, and attach that tap to the
bridge as soon as it's created. Since all guest MAC addresses start
with 0xFE, we can just generate a MAC with the standard "0x52, 0x54,
0" prefix, and it's guaranteed to always win (physical interfaces are
never connected to these bridges, so we don't need to worry about
competing numerically with them).

Note that the dummy tap is never set to IFF_UP state - that's not
necessary in order for the bridge to take its MAC, and not setting it
to UP eliminates the clutter of having an (eg) "virbr0-nic" displayed
in the output of the ifconfig command.

I chose to not auto-generate the MAC address in the network XML
parser, as there are likely to be consumers of that API that don't
need or want to have a MAC address associated with the
bridge.

Instead, in bridge_driver.c when the network is being defined, if
there is no MAC, one is generated. To account for virtual network
configs that already exist when upgrading from an older version of
libvirt, I've added a %post script to the specfile that searches for
all network definitions in both the config directory
(/etc/libvirt/qemu/networks) and the state directory
(/var/lib/libvirt/network) that are missing a mac address, generates a
random address, and adds it to the config (and a matching address to
the state file, if there is one).

docs/formatnetwork.html.in: document <mac address.../>
docs/schemas/network.rng: add nac address to schema
libvirt.spec.in: %post script to update existing networks
src/conf/network_conf.[ch]: parse and format <mac address.../>
src/libvirt_private.syms: export a couple private symbols we need
src/network/bridge_driver.c:
    auto-generate mac address when needed,
    create dummy interface if mac address is present.
tests/networkxml2xmlin/isolated-network.xml
tests/networkxml2xmlin/routed-network.xml
tests/networkxml2xmlout/isolated-network.xml
tests/networkxml2xmlout/routed-network.xml: add mac address to some tests

14 years agoAllow brAddTap to create a tap device that is down
Laine Stump [Wed, 9 Feb 2011 06:20:39 +0000 (01:20 -0500)]
Allow brAddTap to create a tap device that is down

An upcoming patch has a use for a tap device to be created that
doesn't need to be actually put into the "up" state, and keeping it
"down" keeps the output of ifconfig from being unnecessarily cluttered
(ifconfig won't show down interfaces unless you add "-a").

bridge.[ch]: add "up" as an arg to brAddTap()
uml_conf.c, qemu_command.c: add "up" (set to "true") to brAddTap() call.

14 years agoAdd txmode attribute to interface XML for virtio backend
Laine Stump [Thu, 3 Feb 2011 20:20:01 +0000 (15:20 -0500)]
Add txmode attribute to interface XML for virtio backend

This is in response to:

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

Explanation

qemu's virtio-net-pci driver allows setting the algorithm used for tx
packets to either "bh" or "timer". This is done by adding ",tx=bh" or
",tx=timer" to the "-device virtio-net-pci" commandline option.

'bh' stands for 'bottom half'; when this is set, packet tx is all done
in an iothread in the bottom half of the driver. (In libvirt, this
option is called the more descriptive "iothread".)

'timer' means that tx work is done in qemu, and if there is more tx
data than can be sent at the present time, a timer is set before qemu
moves on to do other things; when the timer fires, another attempt is
made to send more data. (libvirt retains the name "timer" for this
option.)

The resulting difference, according to the qemu developer who added
the option is:

    bh makes tx more asynchronous and reduces latency, but potentially
    causes more processor bandwidth contention since the cpu doing the
    tx isn't necessarily the cpu where the guest generated the
    packets.

Solution

This patch provides a libvirt domain xml knob to change the option on
the qemu commandline, by adding a new attribute "txmode" to the
<driver> element that can be placed inside any <interface> element in
a domain definition. It's use would be something like this:

    <interface ...>
      ...
      <model type='virtio'/>
      <driver txmode='iothread'/>
      ...
    </interface>

I chose to put this setting as an attribute to <driver> rather than as
a sub-element to <tune> because it is specific to the virtio-net
driver, not something that is generally usable by all network drivers.
(note that this is the same placement as the "driver name=..."
attribute used to choose kernel vs. userland backend for the
virtio-net driver.)

Actually adding the tx=xxx option to the qemu commandline is only done
if the version of qemu being used advertises it in the output of

    qemu -device virtio-net-pci,?

If a particular txmode is requested in the XML, and the option isn't
listed in that help output, an UNSUPPORTED_CONFIG error is logged, and
the domain fails to start.

14 years agoRestructure domain struct interface "driver" data for easier expansion
Laine Stump [Thu, 3 Feb 2011 18:52:08 +0000 (13:52 -0500)]
Restructure domain struct interface "driver" data for easier expansion

When the <driver> element (and its "name" attribute) was added to the
domain XML's interface element, a "backend" enum was simply added to
the toplevel of the virDomainNetDef struct.

Ignoring the naming inconsistency ("name" vs. "backend"), this is fine
when there's only a single item contained in the driver element of the
XML, but doesn't scale well as we add more attributes that apply to
the backend of the virtio-net driver, or add attributes applicable to
other drivers.

This patch changes virDomainNetDef in two ways:

1) Rename the item in the struct from "backend" to "name", so that
   it's the same in the XML and in the struct, hopefully avoiding
   confusion for someone unfamiliar with the function of the
   attribute.

2) Create a "driver" union within virDomainNetDef, and a "virtio"
   struct in that struct, which contains the "name" enum value.

3) Move around the virDomainNetParse and virDomainNetFormat functions
   to allow for simple plugin of new attributes without disturbing
   existing code. (you'll note that this results in a seemingly
   redundant if() in the format function, but that will no longer be
   the case as soon as a 2nd attribute is added).

In the future, new attributes for the virtio driver backend can be
added to the "virtio" struct, and any other network device backend that
needs an attribute will have its own struct added to the "driver"
union.

14 years agobuild: Fix VPATH build
Jiri Denemark [Wed, 16 Feb 2011 14:09:09 +0000 (15:09 +0100)]
build: Fix VPATH build

Even VPATH make dist succeeds now

14 years agoMove all the QEMU migration code to a new file
Daniel P. Berrange [Mon, 31 Jan 2011 10:47:03 +0000 (10:47 +0000)]
Move all the QEMU migration code to a new file

The introduction of the v3 migration protocol, along with
support for migration cookies, will significantly expand
the size of the migration code. Move it all to a separate
file to make it more manageable

The functions are not moved 100%. The API entry points
remain in the main QEMU driver, but once the public
virDomainPtr is resolved to the internal virDomainObjPtr,
all following code is moved.

This will allow the new v3 API entry points to call into the
same shared internal migration functions

* src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Add
  qemuDomainFormatXML helper method
* src/qemu/qemu_driver.c: Remove all migration code
* src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Add
  all migration code.

14 years agoSplit all QEMU process mangement code into separate file
Daniel P. Berrange [Mon, 14 Feb 2011 16:09:39 +0000 (16:09 +0000)]
Split all QEMU process mangement code into separate file

Move the qemudStartVMDaemon and qemudShutdownVMDaemon
methods into a separate file, renaming them to
qemuProcessStart, qemuProcessStop. All helper methods
called by these are also moved & renamed to match

* src/Makefile.am: Add qemu_process.c/.h
* src/qemu/qemu_command.c: Add qemuDomainAssignPCIAddresses
* src/qemu/qemu_command.h: Add VNC port min/max
* src/qemu/qemu_domain.c, src/qemu/qemu_domain.h: Add
  domain event queue helpers
* src/qemu/qemu_driver.c, src/qemu/qemu_driver.h: Remove
  all QEMU process startup/shutdown functions
* src/qemu/qemu_process.c, src/qemu/qemu_process.h: Add
  all QEMU process startup/shutdown functions

14 years agostorage: Allow to delete device mapper disk partition
Osier Yang [Thu, 17 Feb 2011 07:29:07 +0000 (15:29 +0800)]
storage: Allow to delete device mapper disk partition

The name convention of device mapper disk is different, and 'parted'
can't be used to delete a device mapper disk partition. e.g.

Name                 Path
-----------------------------------------
3600a0b80005ad1d7000093604cae912fp1 /dev/mapper/3600a0b80005ad1d7000093604cae912fp1

Error: Expecting a partition number.

This patch introduces 'dmsetup' to fix it.

Changes:
  - New function "virIsDevMapperDevice" in "src/utils/utils.c"
  - remove "is_dm_device" in "src/storage/parthelper.c", use
    "virIsDevMapperDevice" instead.
  - Requires "device-mapper" for 'with-storage-disk" in "libvirt.spec.in"
  - Check "dmsetup" in 'configure.ac' for "with-storage-disk"
  - Changes on "src/Makefile.am" to link against libdevmapper
  - New entry for "virIsDevMapperDevice" in "src/libvirt_private.syms"

Changes from v1 to v3:
  - s/virIsDeviceMapperDevice/virIsDevMapperDevice/g
  - replace "virRun" with "virCommand"
  - sort the list of util functions in "libvirt_private.syms"
  - ATTRIBUTE_NONNULL(1) for virIsDevMapperDevice declaration.

e.g.

Name                 Path
-----------------------------------------
3600a0b80005ad1d7000093604cae912fp1 /dev/mapper/3600a0b80005ad1d7000093604cae912fp1

Vol /dev/mapper/3600a0b80005ad1d7000093604cae912fp1 deleted

Name                 Path
-----------------------------------------

14 years agoRelease of libvirt-0.8.8
Daniel Veillard [Thu, 17 Feb 2011 04:11:03 +0000 (12:11 +0800)]
Release of libvirt-0.8.8

* configure.ac docs/news.html.in libvirt.spec.in: bump version and add docs
* po/*.po*: updated Gujarati, Polish and Dutch localisations and regenerated

14 years agoqemu: Error prompt when saving a shutoff domain
Osier Yang [Thu, 17 Feb 2011 03:18:47 +0000 (11:18 +0800)]
qemu: Error prompt when saving a shutoff domain

"qemudDomainSaveFlag" goto wrong label "endjob", which will cause
error when security manager trying to restore label (regression).

As it's more reasonable to check if vm is shutoff immediately, and
return right away if it is, remove the checking in "qemudDomainSaveFlag",
and add checking in "qemudDomainSave".

* src/qemu/qemu_driver.c

14 years agomaint: delete unused 'make install' step
Eric Blake [Wed, 16 Feb 2011 17:21:21 +0000 (10:21 -0700)]
maint: delete unused 'make install' step

Libxml2-Logo-90x34.gif was removed from the repository in Sep 2009
(commit d6d528c) because our docs no longer reference it.

* docs/Makefile.am (install-data-local): Don't install missing file.

14 years agocgroup: preserve correct errno on failure
Eric Blake [Tue, 15 Feb 2011 23:50:34 +0000 (16:50 -0700)]
cgroup: preserve correct errno on failure

* src/util/cgroup.c (virCgroupSetValueStr, virCgroupGetValueStr)
(virCgroupRemoveRecursively): VIR_DEBUG can clobber errno.
(virCgroupRemove): Use VIR_DEBUG rather than DEBUG.

14 years agoUpdate czech localization
Zdenek Styblik [Wed, 16 Feb 2011 13:40:44 +0000 (21:40 +0800)]
Update czech localization

14 years agoqemu: Fix command line generation with faked host CPU
Jiri Denemark [Tue, 15 Feb 2011 14:23:17 +0000 (15:23 +0100)]
qemu: Fix command line generation with faked host CPU

The code expected that host CPU architecture matches the architecture on
which libvirt runs. This is normally true but not in tests, where host
CPU is faked to produce consistent results.

14 years agotests: Fake host capabilities properly
Jiri Denemark [Tue, 15 Feb 2011 14:24:39 +0000 (15:24 +0100)]
tests: Fake host capabilities properly

Since we fake host CPU we should also fake host arch instead of taking
the real architecture tests are running on.

14 years agodocs: fix typos
Eric Blake [Tue, 15 Feb 2011 20:50:28 +0000 (13:50 -0700)]
docs: fix typos

* docs/drvopenvz.html.in: Spell administrator correctly.
* docs/drvuml.html.in: Likewise.
* src/qemu/qemu.conf: Likewise.  Fix other typos, too.

14 years agoAvoid empty strings when --with-packager(-version) is not specified
Matthias Bolte [Tue, 15 Feb 2011 18:48:44 +0000 (19:48 +0100)]
Avoid empty strings when --with-packager(-version) is not specified

Make with_packager and with_packager_version default to "no". This way
--without-packager-version (as shorthand for --with-packager(-version)=no)
works correctly too.

Prior to this patch libvirt outputs a line like this when
--with-packager(-version) was not specified

# ./daemon/libvirtd
14:11:15.018: 31796: info : libvirt version: 0.8.8, package:  ()

Now the unspecified parts are correctly omitted.

Reported by Osier Yang.

14 years agobuild: address clang reports about virCommand
Eric Blake [Mon, 14 Feb 2011 22:24:08 +0000 (15:24 -0700)]
build: address clang reports about virCommand

clang had 5 reports against virCommand; three were false positives
(a NULL deref in ProcessIO solved by sa_assert, and two uninitialized
memory operations solved by adding an initializer), but two were real.

* src/util/command.c (virCommandProcessIO): Fix real bug of
possible NULL dereference.  Teach clang that buf is never NULL.
(virCommandRun): Teach clang that infd is only ever accessed when
initialized.

14 years agobuild: silence some clang warnings
Eric Blake [Mon, 14 Feb 2011 23:06:31 +0000 (16:06 -0700)]
build: silence some clang warnings

* tools/virsh.c (cmdHelp): Kill dead variables.

14 years agoqemu: don't mask real error with oom report
Eric Blake [Tue, 15 Feb 2011 16:31:39 +0000 (09:31 -0700)]
qemu: don't mask real error with oom report

* src/qemu/qemu_command.c (qemuBuildCommandLine): Don't report oom
after qemuBuildControllerDevStr, which reported its own errors.

14 years agoqemu: avoid NULL derefs
Eric Blake [Mon, 14 Feb 2011 23:51:59 +0000 (16:51 -0700)]
qemu: avoid NULL derefs

The processWatchdogEvent fix is real, although it can only trigger
on OOM, since bad things happen if doCoreDump is called with a NULL
pathname argument.  The other fixes silence clang, but aren't a real
bug because virReportErrorHelper tolerates a NULL format string even
though *printf does not.

* src/qemu/qemu_driver.c (processWatchdogEvent): Exit on OOM.
(qemuDomainIsActive, qemuDomainIsPersistent, qemuDomainIsUpdated):
Provide valid message.

14 years agovirDomainMemoryStats: avoid null dereference
Eric Blake [Mon, 14 Feb 2011 23:20:39 +0000 (16:20 -0700)]
virDomainMemoryStats: avoid null dereference

* src/libvirt.c (virDomainMemoryStats): Check domain before flags.

14 years agodocs: added link for nimbus to apps page
Justin Clift [Mon, 14 Feb 2011 15:12:56 +0000 (02:12 +1100)]
docs: added link for nimbus to apps page

14 years agoFix leak of mutex attributes in POSIX threads impl
Daniel P. Berrange [Wed, 15 Dec 2010 14:12:30 +0000 (14:12 +0000)]
Fix leak of mutex attributes in POSIX threads impl

* src/util/threads-pthread.c: Fix mutex leak

14 years agoFix leak in SCSI storage backend
Daniel P. Berrange [Fri, 10 Dec 2010 12:26:41 +0000 (12:26 +0000)]
Fix leak in SCSI storage backend

The SCSI storage backend leaks a string containing the pathname
for each block device it discovers

* src/storage/storage_backend_scsi.c: Free the device name

14 years agoOutput commandline on status != 0 in virCommandWait
Matthias Bolte [Tue, 15 Feb 2011 10:46:16 +0000 (11:46 +0100)]
Output commandline on status != 0 in virCommandWait

This helps identifying which command exited with status != 0.

14 years agoadd missing error handling to virGetDomain
Christophe Fergeau [Tue, 15 Feb 2011 03:05:38 +0000 (11:05 +0800)]
add missing error handling to virGetDomain

When creating the virDomain::snapshots hash table, virGetDomain
wasn't checking if the creation was successful. This would then
lead to failures in the vir*DomainSnapshot functions. Better to
report this error early and make virGetDomain fail if the
snapshots hash couldn't be created.
* src/datatypes.c: report failure to make a hash table

14 years agocall virReportOOMError when appropriate in hash.c
Christophe Fergeau [Tue, 15 Feb 2011 02:59:01 +0000 (10:59 +0800)]
call virReportOOMError when appropriate in hash.c

A couple of allocation were not calling virReportOOMError on allocation
errors

* src/util/hash.c: add the needed call in virHashCreate and
  virHashAddOrUpdateEntry

14 years agostorage: Create enough volumes for mpath pool
Osier Yang [Tue, 15 Feb 2011 02:12:24 +0000 (10:12 +0800)]
storage: Create enough volumes for mpath pool

"virStorageBackendCreateVols":
  "names->next" serves as condition expression for "do...while",
however, "names" was shifted before, it then results in one less
loop, and thus, one less volume will be created for mpath pool,
the patch is to fix it.

* src/storage/storage_backend_mpath.c

14 years agomaint: kill dead assignments
Eric Blake [Tue, 15 Feb 2011 00:34:14 +0000 (17:34 -0700)]
maint: kill dead assignments

* src/network/bridge_driver.c (networkStartNetworkDaemon): Delete
unused assignments.

14 years agoqemu: avoid NULL deref on error
Eric Blake [Tue, 15 Feb 2011 00:34:05 +0000 (17:34 -0700)]
qemu: avoid NULL deref on error

* src/qemu/qemu_command.c (qemuParseCommandLineDisk): Report error
before cleaning def.

14 years agobuild: silence false positive clang report
Eric Blake [Mon, 14 Feb 2011 21:23:11 +0000 (14:23 -0700)]
build: silence false positive clang report

clang complained that STREQ(group->controllers[i].mountPoint,...)  was
a NULL dereference when i==VIR_CGROUP_CONTROLLER_CPUSET, because it
assumes the worst about virCgroupPathOfController.  Marking the
argument const doesn't yet have an effect, per this clang bug:
http://llvm.org/bugs/show_bug.cgi?id=7758

So, we use sa_assert, which was designed to shut up false positives
from tools like clang.

* src/util/cgroup.c (virCgroupMakeGroup): Teach clang that there
is no NULL dereference.

14 years agoqemu: ignore failure of qemu -M ? on older qemu
Eric Blake [Mon, 14 Feb 2011 20:00:22 +0000 (13:00 -0700)]
qemu: ignore failure of qemu -M ? on older qemu

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

Regression introduced in commit 2211518.

* src/qemu/qemu_capabilities.c (qemuCapsProbeMachineTypes): Allow
non-zero exit status.

14 years agoxml: avoid compiler warning
Eric Blake [Mon, 14 Feb 2011 20:38:55 +0000 (13:38 -0700)]
xml: avoid compiler warning

Detected by clang.

* src/util/xml.c (virXPathStringLimit): Use %zd, not obsolete %Zd.

14 years agonwfilter: reorder match extensions relative to state match
Stefan Berger [Mon, 14 Feb 2011 19:10:24 +0000 (14:10 -0500)]
nwfilter: reorder match extensions relative to state match

This patch reorders the connlimit and comment match extensions relative to the state match (-m state); connlimit being most useful if found after a -m state --state NEW and not before it.

14 years agoconf: Fix XML generation for smartcards
Jiri Denemark [Mon, 14 Feb 2011 10:49:28 +0000 (11:49 +0100)]
conf: Fix XML generation for smartcards

When formatting XML for smartcard device with mode=host, libvirt
generates invalid XML if the device has address info associated:

<smartcard mode='host' <address type='ccid' controller='0' slot='1'/>

14 years agoFix cleanup on VM state after failed QEMU startup
Daniel P. Berrange [Mon, 14 Feb 2011 09:35:47 +0000 (09:35 +0000)]
Fix cleanup on VM state after failed QEMU startup

Commit 9962e406c664ed5521f5aca500c860a331cb3979 introduced a
problem where if the VM failed to startup, it would not be
correctly cleaned up. Amongst other things the SELinux
security label would not be removed, which prevents the VM
from ever starting again.

The virDomainIsActive() check at the start of qemudShutdownVMDaemon
checks for vm->def->id not being -1. By moving the assignment of the
VM id to the start of qemudStartVMDaemon, we can ensure cleanup will
occur on failure

* src/qemu/qemu_driver.c: Move initialization of 'vm->def->id'
  so that qemudShutdownVMDaemon() will process the shutdown

14 years agolibvirt-qemu: Fix enum type declaration
Jiri Denemark [Mon, 14 Feb 2011 11:04:00 +0000 (12:04 +0100)]
libvirt-qemu: Fix enum type declaration

14 years agofix OOM handling in hash routines
Christophe Fergeau [Mon, 14 Feb 2011 05:36:06 +0000 (13:36 +0800)]
fix OOM handling in hash routines

* src/util/hash.c: virHashAddEntry and virHashUpdateEntry were missing NULL
  checks on strdup
* AUTHORS: add Christophe Fergeau

14 years agoUpdate src/README
Matthias Bolte [Sat, 12 Feb 2011 16:09:28 +0000 (17:09 +0100)]
Update src/README

Add missing subdirectories.

14 years agovirsh: avoid mingw compiler warnings
Eric Blake [Sat, 12 Feb 2011 00:17:12 +0000 (17:17 -0700)]
virsh: avoid mingw compiler warnings

Compilation on mingw was warning about %lld use in fprintf, and
in the gnulib strptime module about dead labels.

* tools/virsh.c (vshPrint): Change redirect.
(vshPrintExtra): Allow use within vshPrint.  Avoid fprintf on
arbitrary formats, since we aren't using gnulib module; instead,
use virVasprintf to pre-format.
(vshError): Likewise.
* .gnulib: Update to latest, for mingw strptime warning fix.
Reported by Matthias Bolte.

14 years agobuild: avoid problems with autogen.sh runs from tarball
Eric Blake [Fri, 11 Feb 2011 17:35:54 +0000 (10:35 -0700)]
build: avoid problems with autogen.sh runs from tarball

Introduced by commit fac97c65c distributing cfg.mk, which
previously could blindly assume it was in a git checkout.

* cfg.mk (_update_required): Also check for .git.
* autogen.sh: Don't run bootstrap from a tarball.
Reported by Daniel Veillard.

14 years agodocs: Distribute XSLT files to generate HACKING
Matthias Bolte [Fri, 11 Feb 2011 10:03:31 +0000 (11:03 +0100)]
docs: Distribute XSLT files to generate HACKING

14 years agoqemu: Report a more informative error for missing cgroup controllers
Matthias Bolte [Fri, 11 Feb 2011 10:02:39 +0000 (11:02 +0100)]
qemu: Report a more informative error for missing cgroup controllers

Also use VIR_ERR_OPERATION_INVALID instead of VIR_ERR_NO_SUPPORT, as
the operation could succeed when the cgroup controller was mounted.

14 years agoxen: Prevent updating device when attaching a device
Osier Yang [Sat, 12 Feb 2011 06:29:09 +0000 (14:29 +0800)]
xen: Prevent updating device when attaching a device

When attaching a device that already exists, xend driver updates
the device with "device_configure", it causes problems (e.g. for
disk device, 'device_configure' only can be used to update device
like CDROM), on the other hand, we provide additional API
(virDomainUpdateDevice) to update device, this fix is to raise up
errors instead of updating the existed device which is not CDROM
device.

Changes from v1 to v2:
  - allow to update CDROM

* src/xen/xend_internal.c

14 years agobuild: fix cygwin strerror_r failure
Eric Blake [Fri, 11 Feb 2011 19:32:17 +0000 (12:32 -0700)]
build: fix cygwin strerror_r failure

Building the 0.8.8 release candidate on cygwin produced this compiler
warning, which is indicative of catastrophic failure on any attempt to
print an error message with errno turned to a string:

  CC       strerror_r.lo
strerror_r.c: In function 'rpl_strerror_r':
strerror_r.c:67: warning: assignment makes integer from pointer without a cast

This has been fixed in gnulib.

* .gnulib: Update to latest, for strerror_r fix.
* src/util/memory.c (includes): Satisfy 'make syntax-check'.

14 years agoqemu: Fix escape_monitor(escape_shell(command))
Philipp Hahn [Fri, 11 Feb 2011 12:59:11 +0000 (13:59 +0100)]
qemu: Fix escape_monitor(escape_shell(command))

Suspending a VM which contains shell meta characters doesn't work with
libvirt-0.8.7:
/var/log/libvirt/qemu/andreas_231-ne\ doch\ nicht.log:
  sh: -c: line 0: syntax error near unexpected token `doch'
  sh: -c: line 0: `cat | { dd bs=4096 seek=1 if=/dev/null && dd bs=1048576; }

Although target="andreas_231-ne doch nicht" contains shell meta
characters (here: blanks), they are not properly escaped by
src/qemu/qemu_monitor_{json,text}.c#qemuMonitor{JSON,Text}MigrateToFile()

First, the filename needs to be properly escaped for the shell, than
this command line has to be properly escaped for qemu again.

For this to work, remove the old qemuMonitorEscapeArg() wrapper, rename
qemuMonitorEscape() to it removing the handling for shell=TRUE, and
implement a new qemuMonitorEscapeShell() returning strings using single
quotes.

Using double quotes or escaping special shell characters with backslashes
would also be possible, but the set of special characters heavily
depends on the concrete shell (dsh, bash, zsh) and its setting (history
expansion, interactive use, ...)

Signed-off-by: Philipp Hahn <hahn@univention.de>
14 years agoImprint all logs with version + package build information
Daniel P. Berrange [Thu, 27 Jan 2011 18:11:16 +0000 (18:11 +0000)]
Imprint all logs with version + package build information

The logging functions are enhanced so that immediately prior to
the first log message being printed to any output channel, the
libvirt package version will be printed.

eg

 $ LIBVIRT_DEBUG=1 virsh
 18:13:28.013: 17536: info : libvirt version: 0.8.7
 18:13:28.013: 17536: debug : virInitialize:361 : register drivers
 ...

The 'configure' script gains two new arguments which can be
used as

   --with-packager="Fedora Project, x86-01.phx2.fedoraproject.org, 01-27-2011-18:00:10"
   --with-packager-version="1.fc14"

to allow distros to append a custom string with package specific
data.

The RPM specfile is modified so that it appends the RPM version,
the build host, the build date and the packager name.

eg

 $ LIBVIRT_DEBUG=1 virsh
 18:14:52.086: 17551: info : libvirt version: 0.8.7, package: 1.fc13 (Fedora Project, x86-01.phx2.fedoraproject.org, 01-27-2011-18:00:10)
 18:14:52.086: 17551: debug : virInitialize:361 : register drivers

Thus when distro packagers receive bug reports they can clearly
see what version was in use, even if the bug reporter mistakenly
or intentionally lies about version/builds

* src/util/logging.c: Output version data prior to first log message
* libvirt.spec.in: Include RPM release, date, hostname & packager
* configure.ac: Add --with-packager & --with-packager-version args

14 years agoqemu: fix attach-interface regression
Wen Congyang [Thu, 10 Feb 2011 02:19:38 +0000 (10:19 +0800)]
qemu: fix attach-interface regression

QEMUD_CMD_FLAG_PCI_MULTIBUS should be set in the function
qemuCapsExtractVersionInfo()

The flag QEMUD_CMD_FLAG_PCI_MULTIBUS is used in the function
qemuBuildDeviceAddressStr(). All callers get qemuCmdFlags
by the function qemuCapsExtractVersionInfo() except that
testCompareXMLToArgvFiles() in qemuxml2argvtest.c.

So we should set QEMUD_CMD_FLAG_PCI_MULTIBUS in the function
qemuCapsExtractVersionInfo() instead of qemuBuildCommandLine()
because the function qemuBuildCommandLine() does not be called
when we attach a pci device.

tests: set QEMUD_CMD_FLAG_PCI_MULTIBUS in testCompareXMLToArgvFiles()

set QEMUD_CMD_FLAG_PCI_MULTIBUS before calling qemuBuildCommandLine()
as the flags is not set by qemuCapsExtractVersionInfo().

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
14 years agoAvoid pthread_sigmask on Win32 platforms
Daniel P. Berrange [Thu, 10 Feb 2011 12:46:29 +0000 (12:46 +0000)]
Avoid pthread_sigmask on Win32 platforms

Win32 doesn't have a concept of signal masks so disable that
code. It is unclear how SIGINT is delivered (if at all) on
Win32, so this might further work to provide an alternative
to pthread_sigmask

* tools/virsh.c: Avoid pthread_sigmask on Win32

14 years agoReduce log level when cgroups aren't mounted
Daniel P. Berrange [Thu, 10 Feb 2011 10:47:46 +0000 (10:47 +0000)]
Reduce log level when cgroups aren't mounted

Quite a few hosts don't have cgroups mounted and so see warnings
from libvirt logged, which then cause bug reports, etc. Reduce
the log level to INFO so they're not visible by default

* src/qemu/qemu_driver.c: Reduce log level for cgroups

14 years agoAvoid warnings from nwfilter driver when run non-root
Daniel P. Berrange [Thu, 10 Feb 2011 10:46:21 +0000 (10:46 +0000)]
Avoid warnings from nwfilter driver when run non-root

When run non-root the nwfilter driver logs error messages about
being unable to find iptables/ebtables commands (they are in
/sbin which isn't in $PATH). The nwfilter driver can't ever work
as non-root, so simply skip it entirely thus avoiding the error
messages

* src/conf/nwfilter_conf.h, src/nwfilter/nwfilter_driver.c,
  src/nwfilter/nwfilter_gentech_driver.c,
  src/nwfilter/nwfilter_gentech_driver.h: Pass 'bool privileged'
  flag down to final driver impl
* src/nwfilter/nwfilter_ebiptables_driver.c: Skip initialization
  if not privileged

14 years agoFix typo in parsing of spice 'auth' data
Michal Privoznik [Thu, 10 Feb 2011 10:50:10 +0000 (10:50 +0000)]
Fix typo in parsing of spice 'auth' data

A typo s/spice/vnc/ caused parsing of the spice 'auth' data
to write into the wrong part of the struct, blowing away
other unrelated data.

* src/conf/domain_conf.c: s/vnc/spice/ in parsing spice auth

14 years agobuild: distribute 'make syntax-check' tweaks
Eric Blake [Tue, 1 Feb 2011 22:33:44 +0000 (15:33 -0700)]
build: distribute 'make syntax-check' tweaks

* Makefile.am (EXTRA_DIST): Distribute cfg.mk.

14 years agodocs: Add information about libvirt-php new location
Michal Novotny [Wed, 9 Feb 2011 18:44:03 +0000 (19:44 +0100)]
docs: Add information about libvirt-php new location

Signed-off-by: Michal Novotny <minovotn@redhat.com>
14 years agomaint: whitespace cleanup
Eric Blake [Fri, 4 Feb 2011 18:16:35 +0000 (11:16 -0700)]
maint: whitespace cleanup

* .dir-locals.el (html-mode): Let emacs help out.
* cfg.mk (sc_TAB_in_indentation): Check more files.
* docs/internals/command.html.in: Fix offenders.
* docs/formatdomain.html.in: Likewise.
* docs/internals.html.in: Likewise.
Reported by Jiri Denemark.

14 years agoAdjust some log levels in udev driver
Daniel P. Berrange [Wed, 9 Feb 2011 16:41:30 +0000 (16:41 +0000)]
Adjust some log levels in udev driver

Most of te VIR_INFO calls in the udev driver are only relevant
to developers so can switch to VIR_DEBUG. Failure to initialize
libpciaccess though is a fatal error

* src/node_device/node_device_udev.c: Adjust log levels

14 years agoAdd check for binary existing in machine type probe
Daniel P. Berrange [Wed, 2 Feb 2011 12:35:31 +0000 (12:35 +0000)]
Add check for binary existing in machine type probe

When probing machine types if the QEMU binary does not exist
we get a hard to diagnose error, due to the execve() in the
child failing

error: internal error Child process exited with status 1.

Add an explicit check so that we get

error: Cannot find QEMU binary /usr/libexec/qem3u-kvm: No such file or directory

* src/qemu/qemu_capabilities.c: Check for QEMU binary

14 years agoAdd a little more debugging for async events
Daniel P. Berrange [Thu, 27 Jan 2011 15:06:05 +0000 (15:06 +0000)]
Add a little more debugging for async events

To make it easier to investigate problems with async event
delivery, add two more debugging lines

* daemon/remote.c: Debug when an event is queued for dispatch
* src/remote/remote_driver.c: Debug when an event is received
  for processing

14 years agoMove connection driver modules directory
Daniel P. Berrange [Fri, 21 Jan 2011 17:42:07 +0000 (17:42 +0000)]
Move connection driver modules directory

When built as modules, the connection drivers live
in $LIBDIR/libvirt/drivers. Now we add lock manager
drivers, we need to distinguish. So move the existing
modules to 'connection-driver'

* src/Makefile.am: Move module install dir
* src/driver.c: Move module search dir

14 years agoReset logging filter function when forking
Daniel P. Berrange [Mon, 24 Jan 2011 12:07:21 +0000 (12:07 +0000)]
Reset logging filter function when forking

To ensure child processes will log all error messages, reset
the logging filter function when forking

* src/util/util.c: Reset log filter in fork

14 years agoBlock SIGPIPE around virExec hook functions
Daniel P. Berrange [Fri, 21 Jan 2011 17:48:48 +0000 (17:48 +0000)]
Block SIGPIPE around virExec hook functions

Some functionality run in virExec hooks may do I/O which
can trigger SIGPIPE. Renable SIGPIPE blocking around the
hook function

* src/util/util.c: Block SIGPIPE around hooks

14 years agoSupport SCSI RAID type & lower log level for unknown types
Daniel P. Berrange [Mon, 7 Feb 2011 17:25:06 +0000 (17:25 +0000)]
Support SCSI RAID type & lower log level for unknown types

The Linux kernel headers don't have a value for SCSI type 12,
but HAL source code shows this to be a 'raid'. Add workaround
for this type. Lower log level for unknown types since
this is not a fatal error condition. Include the device sysfs
path in the log output to allow identification of which device
has problems.

* src/node_device/node_device_udev.c: Add SCSI RAID type

14 years agoOnly initialize/cleanup libpciaccess once
Daniel P. Berrange [Mon, 7 Feb 2011 17:04:35 +0000 (17:04 +0000)]
Only initialize/cleanup libpciaccess once

libpciaccess has many bugs in its pci_system_init/cleanup
functions that makes calling them multiple times unwise.
eg it will double close() FDs, and leak other FDs.

* src/node_device/node_device_udev.c: Only initialize
  libpciaccess once

14 years agoDon't use CLONE_NEWUSER for now
Serge E. Hallyn [Wed, 9 Feb 2011 02:58:24 +0000 (20:58 -0600)]
Don't use CLONE_NEWUSER for now

Until now, user namespaces have not done much, but (for that
reason) have been innocuous to glob in with other CLONE_
flags.  Upcoming userns development, however, will make tasks
cloned with CLONE_NEWUSER far more restricted.  In particular,
for some time they will be unable to access files with anything
other than the world access perms.

This patch assumes that noone really needs the user namespaces
to be enabled.  If that is wrong, then we can try a more
baroque patch where we create a file owned by a test userid with
700 perms and, if we can't access it after setuid'ing to that
userid, then return 0.  Otherwise, assume we are using an
older, 'harmless' user namespace implementation.

Comments appreciated.  Is it ok to do this?

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
14 years agosysinfo: implement qemu support
Eric Blake [Mon, 7 Feb 2011 23:16:04 +0000 (16:16 -0700)]
sysinfo: implement qemu support

* src/qemu/qemu_driver.c (qemuGetSysinfo): New function.
(qemuDriver): Install it.

14 years agosysinfo: refactor xml formatting
Eric Blake [Mon, 7 Feb 2011 23:16:04 +0000 (16:16 -0700)]
sysinfo: refactor xml formatting

* src/util/sysinfo.h (virSysinfoFormat): New prototype.
* src/conf/domain_conf.c (virDomainSysinfoDefFormat): Move guts...
* src/util/sysinfo.c (virSysinfoFormat): ...into new function.
* src/libvirt_private.syms: Export it.

14 years agosysinfo: implement virsh support
Eric Blake [Mon, 7 Feb 2011 22:13:48 +0000 (15:13 -0700)]
sysinfo: implement virsh support

* tools/virsh.c (cmdSysinfo): New function.
(hostAndHypervisorCmds): Add it.
* tools/virsh.pod: Document it.

14 years agosysinfo: implement the remote protocol
Eric Blake [Mon, 7 Feb 2011 22:04:17 +0000 (15:04 -0700)]
sysinfo: implement the remote protocol

Done by editing the first three files, then running
'make -C src rpcgen', then editing src/remote_protocol-structs
to match.

* daemon/remote.c (remoteDispatchGetSysinfo): New function.
* src/remote/remote_driver.c (remoteGetSysinfo, remote_driver):
Client side serialization.
* src/remote/remote_protocol.x (remote_get_sysinfo_args)
(remote_get_sysinfo_ret): New types.
(REMOTE_PROC_GET_SYSINFO): New enum value.
* daemon/remote_dispatch_args.h: Regenerate.
* daemon/remote_dispatch_prototypes.h: Likewise.
* daemon/remote_dispatch_ret.h: Likewise.
* daemon/remote_dispatch_table.h: Likewise.
* src/remote/remote_protocol.c: Likewise.
* src/remote/remote_protocol.h: Likewise.
* src/remote_protocol-structs: Likewise.

14 years agosysinfo: implement the public API
Eric Blake [Mon, 7 Feb 2011 21:48:24 +0000 (14:48 -0700)]
sysinfo: implement the public API

* src/libvirt.c (virConnectGetSysinfo): New function.
* docs/formatdomain.html.in: Mention it.

14 years agosysinfo: define internal driver API
Eric Blake [Mon, 7 Feb 2011 21:14:56 +0000 (14:14 -0700)]
sysinfo: define internal driver API

* src/driver.h (virDrvGetSysinfo): New typedef.
(_virDriver): New callback member.
* src/esx/esx_driver.c (esxDriver): Add stub for driver.
* src/lxc/lxc_driver.c (lxcDriver): Likewise.
* src/opennebula/one_driver.c (oneDriver): Likewise.
* src/openvz/openvz_driver.c (openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemuDriver): Likewise.
* src/remote/remote_driver.c (remote_driver): Likewise.
* src/test/test_driver.c (testDriver): Likewise.
* src/uml/uml_driver.c (umlDriver): Likewise.
* src/vbox/vbox_tmpl.c (Driver): Likewise.
* src/vmware/vmware_driver.c (vmwareDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDriver): Likewise.

14 years agosysinfo: expose new API
Eric Blake [Mon, 7 Feb 2011 19:52:29 +0000 (12:52 -0700)]
sysinfo: expose new API

The new virConnectGetSysinfo() API allows one to get the system
information associated to a connection host, providing the same
data as a guest that uses <os><smbios mode='host'/></os>, and in
a format that can be pasted into the guest and edited when using
<os><smbios mode='sysinfo'/></os>.

* include/libvirt/libvirt.h.in (virConnectGetSysinfo): Declare.
* src/libvirt_public.syms: Export new symbol.

14 years agoAdding Michal Novotny for previous patch
Daniel Veillard [Wed, 9 Feb 2011 02:05:19 +0000 (10:05 +0800)]
Adding Michal Novotny for previous patch

14 years agoAdd libvirt-php information page
Michal Novotny [Wed, 9 Feb 2011 01:43:09 +0000 (09:43 +0800)]
Add libvirt-php information page

This adds a ibvirt-php information page with some
basic information on libvirt-php project compilation, contribution
and other useful information.

14 years agocgroup: Add documentation for blkiotune elements.
Gui Jianfeng [Tue, 8 Feb 2011 07:02:15 +0000 (15:02 +0800)]
cgroup: Add documentation for blkiotune elements.

Add documentation for blkiotune elements.

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agoLXC: LXC Blkio weight configuration support.
Gui Jianfeng [Tue, 8 Feb 2011 07:00:24 +0000 (15:00 +0800)]
LXC: LXC Blkio weight configuration support.

LXC Blkio weight configuration support.

Reviewed-by: "Nikunj A. Dadhania" <nikunj@linux.vnet.ibm.com>
Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agoqemu: Implement blkio tunable XML configuration and parsing.
Gui Jianfeng [Tue, 8 Feb 2011 06:59:38 +0000 (14:59 +0800)]
qemu: Implement blkio tunable XML configuration and parsing.

Implement blkio tunable XML configuration and parsing.

Reviewed-by: "Nikunj A. Dadhania" <nikunj@linux.vnet.ibm.com>
Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agocgroup: Update XML Schema for new entries.
Gui Jianfeng [Tue, 8 Feb 2011 06:58:25 +0000 (14:58 +0800)]
cgroup: Update XML Schema for new entries.

Update XML Schema for new entries.

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agocgroup: Implement blkio.weight tuning API.
Gui Jianfeng [Tue, 8 Feb 2011 06:56:39 +0000 (14:56 +0800)]
cgroup: Implement blkio.weight tuning API.

Implement blkio.weight tuning API.

Acked-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agocgroup: Enable cgroup hierarchy for blkio cgroup
Gui Jianfeng [Tue, 8 Feb 2011 17:41:17 +0000 (10:41 -0700)]
cgroup: Enable cgroup hierarchy for blkio cgroup

Enable cgroup hierarchy for blkio cgroup

Acked-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
14 years agomaint: update AUTHORS
Eric Blake [Tue, 8 Feb 2011 17:30:03 +0000 (10:30 -0700)]
maint: update AUTHORS

* AUTHORS: Adjust for recent commits.

14 years agoUpdate Dutch and Polish localizations
Daniel Veillard [Tue, 8 Feb 2011 13:01:38 +0000 (21:01 +0800)]
Update Dutch and Polish localizations

14 years agoRevert "Czech translation updates"
Daniel Veillard [Tue, 8 Feb 2011 12:38:02 +0000 (20:38 +0800)]
Revert "Czech translation updates"

This reverts commit 9169c0eeb4b68a0001b57d35d11e41f9c1bc6148.
The patch didn't applied cleanly and completely broke po regeneration

14 years agoCzech translation updates
Zdenek Styblik [Tue, 8 Feb 2011 11:23:18 +0000 (19:23 +0800)]
Czech translation updates

14 years agoVietnamese translations for libvirt
Hero Phương [Tue, 8 Feb 2011 10:37:35 +0000 (18:37 +0800)]
Vietnamese translations for libvirt

14 years agodocs/index.html.in: update KVM url
Niels de Vos [Sat, 5 Feb 2011 18:22:40 +0000 (18:22 +0000)]
docs/index.html.in: update KVM url

Signed-off-by: Niels de Vos <ndevos@redhat.com>
14 years agospicevmc: support older -device spicevmc of qemu 0.13.0
Eric Blake [Fri, 4 Feb 2011 15:43:32 +0000 (08:43 -0700)]
spicevmc: support older -device spicevmc of qemu 0.13.0

qemu 0.13.0 (at least as built for Fedora 14, and also backported to
RHEL 6.0 qemu) supported an older syntax for a spicevmc channel; it's
not as flexible (it has an implicit name and hides the chardev
aspect), but now that we support spicevmc, we might as well target
both variants.

* src/qemu/qemu_capabilities.h (QEMUD_CMD_FLAG_DEVICE_SPICEVMC):
New flag.
* src/qemu/qemu_capabilities.c (qemuCapsParseDeviceStr): Set it
correctly.
* src/qemu/qemu_command.h (qemuBuildVirtioSerialPortDevStr): Drop
declaration.
* src/qemu/qemu_command.c (qemuBuildVirtioSerialPortDevStr): Alter
signature, check flag.
(qemuBuildCommandLine): Adjust caller and check flag.
* tests/qemuhelptest.c (mymain): Update test.
* tests/qemuxml2argvtest.c (mymain): New test.
* tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc-old.xml:
New file.
* tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc-old.args:
Likewise.

14 years agosmartcard: add spicevmc support
Eric Blake [Fri, 4 Feb 2011 02:23:31 +0000 (19:23 -0700)]
smartcard: add spicevmc support

Adds <smartcard mode='passthrough' type='spicevmc'/>, which uses the
new <channel name='smartcard'/> of <graphics type='spice'>.

* docs/schemas/domain.rng: Support new XML.
* docs/formatdomain.html.in: Document it.
* src/conf/domain_conf.h (virDomainGraphicsSpiceChannelName): New
enum value.
(virDomainChrSpicevmcName): New enum.
(virDomainChrSourceDef): Distinguish spicevmc types.
* src/conf/domain_conf.c (virDomainGraphicsSpiceChannelName): Add
smartcard.
(virDomainSmartcardDefParseXML): Parse it.
(virDomainChrDefParseXML, virDomainSmartcardDefParseXML): Set
spicevmc name.
(virDomainChrSpicevmc): New enum conversion functions.
* src/libvirt_private.syms: Export new functions.
* src/qemu/qemu_command.c (qemuBuildChrChardevStr): Conditionalize
name.
* tests/qemuxml2argvtest.c (domain): New test.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.args:
New file.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.xml:
Likewise.

14 years agospicevmc: support new qemu chardev
Daniel P. Berrange [Thu, 3 Feb 2011 04:09:44 +0000 (21:09 -0700)]
spicevmc: support new qemu chardev

Inspired by https://bugzilla.redhat.com/show_bug.cgi?id=615757

Add a new character device backend for virtio serial channels that
activates the QEMU spice agent on the main channel using the vdagent
spicevmc connection.  The <target> must be type='virtio', and supports
an optional name that specifies how the guest will see the channel
(for now, name must be com.redhat.spice.0).

<channel type='spicevmc'>
  <target type='virtio'/>
  <address type='virtio-serial' controller='1' bus='0' port='3'/>
</channel>

* docs/schemas/domain.rng: Support new XML.
* docs/formatdomain.html.in: Document it.
* src/conf/domain_conf.h (virDomainChrType): New enum value.
* src/conf/domain_conf.c (virDomainChr): Add spicevmc.
(virDomainChrDefParseXML, virDomainChrSourceDefParseXML)
(virDomainChrDefParseTargetXML): Parse and enforce proper use.
(virDomainChrSourceDefFormat, virDomainChrDefFormat): Format.
* src/qemu/qemu_command.c (qemuBuildChrChardevStr)
(qemuBuildCommandLine): Add qemu support.
* tests/qemuxml2argvtest.c (domain): New test.
* tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml: New
file.
* tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args:
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
14 years agosmartcard: turn on qemu support
Eric Blake [Thu, 13 Jan 2011 00:09:45 +0000 (17:09 -0700)]
smartcard: turn on qemu support

* src/qemu/qemu_command.c (qemuBuildCommandLine): Emit smartcard
options.
(qemuAssignDeviceAliases): Assign an alias for smartcards.
(qemuBuildControllerDevStr): Manage the usb-ccid controller.
* tests/qemuxml2argvtest.c (mymain): Add new tests.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args: New
file.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args:
Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough.args:
Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args:
Likewise.

14 years agosmartcard: enable SELinux support
Eric Blake [Fri, 14 Jan 2011 19:17:17 +0000 (12:17 -0700)]
smartcard: enable SELinux support

* src/security/security_selinux.c
(SELinuxRestoreSecuritySmartcardCallback)
(SELinuxSetSecuritySmartcardCallback): New helper functions.
(SELinuxRestoreSecurityAllLabel, SELinuxSetSecurityAllLabel): Use
them.

14 years agosmartcard: check for qemu capability
Eric Blake [Thu, 13 Jan 2011 15:54:33 +0000 (08:54 -0700)]
smartcard: check for qemu capability

Qemu smartcard/spicevmc support exists on branches (such as
http://cgit.freedesktop.org/~alon/qemu/commit/?h=usb_ccid.v15&id=024a37b)
but is not yet upstream.  The added -help output matches a scratch build
that will be close to the RHEL 6.1 qemu-kvm.

* src/qemu/qemu_capabilities.h (QEMUD_CMD_FLAG_CCID_EMULATED)
(QEMUD_CMD_FLAG_CCID_PASSTHRU, QEMUD_CMD_FLAG_CHARDEV_SPICEVMC):
New flags.
* src/qemu/qemu_capabilities.c (qemuCapsComputeCmdFlags)
(qemuCapsParseDeviceStr): Check for smartcard capabilities.
(qemuCapsExtractVersionInfo): Tweak comment.
* tests/qemuhelptest.c (mymain): New test.
* tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel61: New file.
* tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel61-device: Likewise.

14 years agosmartcard: add domain conf support
Eric Blake [Mon, 10 Jan 2011 16:41:33 +0000 (09:41 -0700)]
smartcard: add domain conf support

* src/conf/domain_conf.h (virDomainSmartcardType): New enum.
(virDomainSmartcardDef, virDomainDeviceCcidAddress): New structs.
(virDomainDef): Include smartcards.
(virDomainSmartcardDefIterator): New typedef.
(virDomainSmartcardDefFree, virDomainSmartcardDefForeach): New
prototypes.
(virDomainControllerType, virDomainDeviceAddressType): Add ccid
enum values.
(virDomainDeviceInfo): Add ccid address type.
* src/conf/domain_conf.c (virDomainSmartcard): Convert between
enum and string.
(virDomainSmartcardDefParseXML, virDomainSmartcardDefFormat)
(virDomainSmartcardDefFree, virDomainDeviceCcidAddressParseXML)
(virDomainDefMaybeAddSmartcardController): New functions.
(virDomainDefParseXML): Parse the new XML.
(virDomainDefFormat): Convert back to XML.
(virDomainDefFree): Clean up.
(virDomainDeviceInfoIterate): Iterate over passthrough aliases.
(virDomainController, virDomainDeviceAddress)
(virDomainDeviceInfoParseXML, virDomainDeviceInfoFormat)
(virDomainDefAddImplicitControllers): Support new values.
* src/libvirt_private.syms (domain_conf.h): New exports.
* cfg.mk (useless_free_options): List new function.

14 years agosmartcard: add XML support for <smartcard> device
Eric Blake [Thu, 6 Jan 2011 01:02:20 +0000 (18:02 -0700)]
smartcard: add XML support for <smartcard> device

Assuming a hypervisor that supports multiple smartcard devices in the
guest, this would be a valid XML description:

<devices>
  <smartcard mode='host'/>
  <smartcard mode='host-certificates'>
    <certificate>/path/to/cert1</certificate>
    <certificate>/path/to/cert2</certificate>
    <certificate>/path/to/cert3</certificate>
  </smartcard>
  <smartcard mode='passthrough' type='tcp'>
    <source mode='bind' host='127.0.0.1' service='2001'/>
    <protocol type='raw'/>
  </smartcard>
</devices>

(As of this commit, the qemu hypervisor will be the first
implementation, but it only supports one smartcard.)

* docs/formatdomain.html.in (Smartcard devices): New section.
* docs/schemas/domain.rng (smartcard): New define, used in
devices.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.xml: New file
to test schema.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.xml:
Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.xml:
Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.xml:
Likewise.

14 years agodocs/index.html.in: update QEMU url
Alon Levy [Thu, 3 Feb 2011 23:40:46 +0000 (01:40 +0200)]
docs/index.html.in: update QEMU url

14 years agoqemu: Support booting from hostdev PCI devices
Jiri Denemark [Thu, 3 Feb 2011 14:09:17 +0000 (15:09 +0100)]
qemu: Support booting from hostdev PCI devices

14 years agoSupport booting from hostdev devices
Jiri Denemark [Thu, 3 Feb 2011 12:06:21 +0000 (13:06 +0100)]
Support booting from hostdev devices

14 years agoqemu: Add shortcut for HMP pass through
Jiri Denemark [Wed, 2 Feb 2011 15:37:10 +0000 (16:37 +0100)]
qemu: Add shortcut for HMP pass through

Currently users who want to use virDomainQemuMonitorCommand() API or
it's virsh equivalent has to use the same protocol as libvirt uses for
communication to qemu. Since the protocol is QMP with current qemu and
HMP much more usable for humans, one ends up typing something like the
following:

    virsh qemu-monitor-command DOM \
'{"execute":"human-monitor-command","arguments":{"command-line":"info kvm"}}'

which is not a very convenient way of debugging qemu.

This patch introduces --hmp option to qemu-monitor-command, which says
that the provided command is in HMP. If libvirt uses QMP to talk with
qemu, the command will automatically be converted into QMP. So the
example above is simplified to just

    virsh qemu-monitor-command --hmp DOM "info kvm"

Also the result is converted from

    {"return":"kvm support: enabled\r\n"}

to just plain HMP:

    kvm support: enabled

If libvirt talks to qemu in HMP, --hmp flag is obviously a noop.

14 years agomacvtap: fix 2 nla_put expressions (non-serious bug)
Stefan Berger [Thu, 3 Feb 2011 19:36:27 +0000 (14:36 -0500)]
macvtap: fix 2 nla_put expressions (non-serious bug)

This patch fixes 2 occurrences of nla_put expression with a '!' in
front of them that basically prevented the detection that the buffer
is too small. However, code further below would then detect that the
buffer is too small when further parts are added to the netlink message.

14 years agoqemu: avoid double shutdown
Eric Blake [Wed, 2 Feb 2011 18:16:41 +0000 (11:16 -0700)]
qemu: avoid double shutdown

* src/qemu/qemu_driver.c (qemudShutdownVMDaemon): Check that vm is
still active.
Reported by Wen Congyang as follows:

Steps to reproduce this bug:

1. use gdb to debug libvirtd, and set breakpoint in the function
   qemuConnectMonitor()
2. start a vm, and the libvirtd will be stopped in qemuConnectMonitor()
3. kill -STOP $(cat /var/run/libvirt/qemu/<domain>.pid)
4. continue to run libvirtd in gdb, and libvirtd will be blocked in the
   function qemuMonitorSetCapabilities()
5. kill -9 $(cat /var/run/libvirt/qemu/<domain>.pid)

Here is log of the qemu:
=========
LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin ...
char device redirected to /dev/pts/3
2011-01-27 09:38:48.101: shutting down
2011-01-27 09:41:26.401: shutting down
=========

The vm is shut down twice. I do not know whether this behavior has
side effect, but I think we should shutdown the vm only once.