]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agoqemu: Build command line for the new address format
Osier Yang [Tue, 28 Feb 2012 03:39:43 +0000 (11:39 +0800)]
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.

13 years agoqemu: New cap flag to indicate if channel is supported by scsi-disk
Osier Yang [Mon, 27 Feb 2012 10:20:21 +0000 (18:20 +0800)]
qemu: New cap flag to indicate if channel is supported by scsi-disk

13 years agoconf: Introduce new attribute for device address format
Osier Yang [Mon, 27 Feb 2012 10:19:54 +0000 (18:19 +0800)]
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.

13 years agoconf: Add helper function to look up disk controller model
Osier Yang [Mon, 27 Feb 2012 09:20:11 +0000 (17:20 +0800)]
conf: Add helper function to look up disk controller model

13 years agoqemu: add virtio-scsi controller model
Paolo Bonzini [Mon, 27 Feb 2012 09:16:20 +0000 (17:16 +0800)]
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>
13 years agoqemu: add ibmvscsi controller model
Paolo Bonzini [Mon, 27 Feb 2012 09:08:23 +0000 (17:08 +0800)]
qemu: add ibmvscsi controller model

KVM will be able to use a PCI SCSI controller even on POWER.  Let
the user specify the vSCSI controller by other means than a default.

After this patch, the QEMU driver will actually look at the model
and reject anything but auto, lsilogic and ibmvscsi.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Osier Yang <jyang@redhat.com>
13 years agoqemu: fix cleanup of bridge during failure of qemuDomainAttachNetDevice
Laine Stump [Tue, 28 Feb 2012 03:43:23 +0000 (22:43 -0500)]
qemu: fix cleanup of bridge during failure of qemuDomainAttachNetDevice

In qemuDomainAttachNetDevice, the guest's tap interface has only been
attached to the bridge if iface_connected is true. It's possible for
an error to occur prior to that happening, and previously we would
attempt to remove the tap interface from the bridge even if it hadn't
been attached.

13 years agoqemu: unescape HMP commands before converting them to json
Josh Durgin [Sun, 26 Feb 2012 00:48:02 +0000 (16:48 -0800)]
qemu: unescape HMP commands before converting them to json

QMP commands don't need to be escaped since converting them to json
also escapes special characters. When a QMP command fails, however,
libvirt falls back to HMP commands. These fallback functions
(qemuMonitorText*) do their own escaping, and pass the result directly
to qemuMonitorHMPCommandWithFd. If the monitor is in json mode, these
pre-escaped commands will be escaped again when converted to json,
which can result in the wrong arguments being sent.

For example, a filename test\file would be sent in json as
test\\file.

This prevented attaching an image file with a " or \ in its name in
qemu 1.0.50, and also broke rbd attachment (which uses backslashes to
escape some internal arguments.)

Reported-by: Masuko Tomoya <tomoya.masuko@gmail.com>
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoqemu: Add ability to abort existing console while creating new one
Peter Krempa [Thu, 6 Oct 2011 10:24:47 +0000 (12:24 +0200)]
qemu: Add ability to abort existing console while creating new one

This patch fixes console corruption, that happens if two concurrent
sessions are opened for a single console on a domain. Result of this
corruption was that each of the console streams recieved just a part
of the data written to the pipe so every console rendered unusable.

New helper function for safe console handling is used to establish the
console stream connection. This function ensures that no other libvirt
client is using the console (with the ability to disconnect consoles of
libvirt clients) and that no UUCP style lockfile is placed on the PTY
device.

* src/qemu/qemu_domain.h
        - add data structure to domain's private data dealing with
          console connections
* src/qemu/qemu_domain.c:
        - allocate/free domain's console data structure
* src/qemu/qemu_driver.c
        - use the new helper function for console handling

13 years agoutil: Add helpers for safe domain console operations
Peter Krempa [Fri, 25 Nov 2011 15:25:14 +0000 (16:25 +0100)]
util: Add helpers for safe domain console operations

This patch adds a set of functions used in creating console streams for
domains using PTYs and ensures mutually exclusive access to the PTYs.

If mutually exclusive access is not used, two clients may open the same
console, which results in corruption on both clients as both of them
race to read data from the PTY.

Two approaches are used to ensure this:
1) Internal data structure holding open PTYs.
        This is used internally and enables the user to forcibly
        terminate another console connection eg. when somebody leaves
        the console open on another host.

2) UUCP style lock files:
        This uses UUCP lock files according to the  FHS
        ( http://www.pathname.com/fhs/pub/fhs-2.3.html#VARLOCKLOCKFILES )
        to check if other programs (like minicom) are not using the pty
        device of the console.

        This feature is disabled by default and may be enabled using
        configure parameter
        --with-console-lock-files=/path/to/lock/file/directory
        or --with-console-lock-files=auto (which tries to infer the
        location from OS used (currently only linux).

        On usual linux systems, normal users may not write to the
        /var/lock directory containing the locks. This poses problems
        while in session mode. If the current user has no access to the
        lockfile directory, check for presence of the file is still
        done, but no lock file is created. This does NOT result in an
        error.

13 years agofdstream: Add internal callback on stream close
Peter Krempa [Thu, 23 Feb 2012 12:45:25 +0000 (13:45 +0100)]
fdstream: Add internal callback on stream close

This patch adds another callback to a FDstream object. The original
callback is used by the daemon stream driver to handle events.

This callback is called if and only if the stream is about to be closed.
This might be used to handle cleanup steps after a fdstream exits. This
will be used later on in ensuring mutually exclusive access to consoles.

* src/fdstream.c:
        - emit the callback, when stream is being closed
        - add data structures needed to handle the callback
        - add function to register callback
* src/fdstream.h:
        - define function prototypes for the callback

13 years agofdstream: Emit stream abort callback even if poll() doesnt.
Peter Krempa [Thu, 23 Feb 2012 11:54:18 +0000 (12:54 +0100)]
fdstream: Emit stream abort callback even if poll() doesnt.

This patch causes the fdstream driver to call the stream event callback
if virStreamAbort() is called on a stream using this driver.

A remote handler for a stream can only detect changes via stream events,
so this event callback is necessary in order to enable a daemon to abort
a stream in such a way that the client will see the change.

* src/fdstream.c:
        - modify close function to call stream event callback

13 years agovirsh: add support for VIR_DOMAIN_CONSOLE_* flags
Peter Krempa [Wed, 12 Oct 2011 10:59:15 +0000 (12:59 +0200)]
virsh: add support for VIR_DOMAIN_CONSOLE_* flags

This patch adds support for the newly introduced
VIR_DOMAIN_CONSOLE_FORCE and VIR_DOMAIN_CONSOLE_SAFE flags. The console
command now has an optional parameter --force that specifies that the
user wants to forcibly interrupt an ongoing console session and create
a new one. Flag --safe requests that the console should be opened only
if the hypervisor driver supports safe console handling.

The behaviour to this point was that the daemon opened two streams to
the console, that competed for data from the pipe, and the result was
that both of the consoles ended up scrambled.

This patch doesn't modify operation of other commands dealing with
console connections (start, create) as those open connections to newly
started domains making it virtually impossible for another client to race
for the console and steal it.

* tools/console.c:
        - add support for flag passthrough
* tools/console.h:
        - modify function prototypes to match impl.
* tools/virsh.c:
        - add flag --force for the console command

13 years agoAdd flags for virDomainOpenConsole
Peter Krempa [Wed, 12 Oct 2011 11:19:48 +0000 (13:19 +0200)]
Add flags for virDomainOpenConsole

This patch adds a set of flags to be used with the virDomainOpenConsole
API call to specify if the user wishes to interrupt an existing console
session or just to try open a new one.

VIR_DOMAIN_CONSOLE_SAFE - specifies that the console connection should
                          be opened only if the hypervisor supports
                          mutually exclusive access to console devices

VIR_DOMAIN_CONSOLE_FORCE - specifies that the caller wishes to interrupt
                           existing session and force a creation of a
                           new one.

13 years agopidfile: Make checking binary path in virPidFileRead optional
Peter Krempa [Thu, 26 Jan 2012 15:25:38 +0000 (16:25 +0100)]
pidfile: Make checking binary path in virPidFileRead optional

This patch changes behavior of virPidFileRead to enable passing NULL as
path to the binary the pid file should be checked against to skip this
check. This enables using this function for reading files that have same
semantics as pid files, but belong to unknown processes.

13 years agoqemu: Implement virDomainPMWakeup API
Michal Privoznik [Fri, 10 Feb 2012 12:33:52 +0000 (13:33 +0100)]
qemu: Implement virDomainPMWakeup API

using 'system-wakeup' monitor command. It is supported only in JSON,
as we are enabling it if possible. Moreover, this command is available
in qemu-1.1+ which definitely has JSON.

13 years agovirsh: Expose virDomainPMWakeup
Michal Privoznik [Fri, 10 Feb 2012 12:07:24 +0000 (13:07 +0100)]
virsh: Expose virDomainPMWakeup

13 years agoIntroduce virDomainPMWakeup API
Michal Privoznik [Fri, 10 Feb 2012 11:40:52 +0000 (12:40 +0100)]
Introduce virDomainPMWakeup API

This API allows a domain which previously called
virDomainPMSuspendForDuration() to be woken up.

13 years agoFixed URI parsing
Martin Kletzander [Fri, 24 Feb 2012 18:48:55 +0000 (19:48 +0100)]
Fixed URI parsing

Function xmlParseURI does not remove square brackets around IPv6
address when parsing. One of the solutions is making wrappers around
functions working with xmlURI*. This assures that uri->server will be
always properly assigned and it doesn't have to be changed when used
on some new place in the code.
For this purpose, functions virParseURI and virSaveURI were
added. These function are wrappers around xmlParseURI and xmlSaveUri
respectively.
Also there is one new syntax check function to prohibit these functions
anywhere else.

File changes:
 - src/util/viruri.h        -- declaration
 - src/util/viruri.c        -- definition
 - src/libvirt_private.syms -- symbol export
 - src/Makefile.am          -- added source and header files
 - cfg.mk                   -- added sc_prohibit_xmlURI
 - all others               -- ID name and include fixes

13 years agoFixed service handling in specfile
Martin Kletzander [Fri, 24 Feb 2012 11:28:58 +0000 (12:28 +0100)]
Fixed service handling in specfile

After adding the libvirt-guests service into usual runlevels, we used
to start the libvirt-guests service. However this is usually not a
good practice. As mentioned on fedoraproject wiki, the installations
can be in changeroots, in an installer context, or in other situations
where we don't want the services autostarted.

13 years agovirsh: fix informational message in iface-bridge command
Laine Stump [Fri, 24 Feb 2012 19:32:33 +0000 (14:32 -0500)]
virsh: fix informational message in iface-bridge command

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

The position of the bridge name and ethernet device name were
accidentally swapped in the message informing of success creating the
bridge.

13 years agoWorkaround python header file insanity
Daniel P. Berrange [Fri, 24 Feb 2012 15:10:53 +0000 (15:10 +0000)]
Workaround python header file insanity

The /usr/include/python/pyconfig.h file pollutes the global
namespace with a huge number of HAVE_XXX and WITH_XXX
defines. These change what we detected in our own config.h
In particular if you try to build without DTrace, python's
headers turn it back on with predictable fail.

THe hack to workaround this is to rename WITH_DTRACE to
WITH_DTRACE_PROBES to avoid the namespace clash

13 years agoImprove error reporting when virsh console is run without a TTY
Daniel P. Berrange [Wed, 15 Feb 2012 13:12:11 +0000 (13:12 +0000)]
Improve error reporting when virsh console is run without a TTY

If attempting to run

  ssh root@somehost virsh console someguest

You'll get an error

  2012-02-15 13:11:47.683+0000: 4765: info : libvirt version: 0.9.10, package: 1.fc18 (Unknown, 2012-02-15-11:48:57, lettuce.camlab.fab.redhat.com)
  2012-02-15 13:11:47.683+0000: 4765: error : vshRunConsole:320 : unable to get tty attributes: Invalid argument
  Connected to domain f16x86_64
  Escape character is ^]

There are several problems here

 - The actual error message is bad for users
 - We shouldn't rely on VIR_ERROR for this case
 - The prompt makes it look like we still connected
   because we didn't flush stdout.

* virsh.c: Flush stdout before starting console and check
  for a valid tty

13 years agoError out when using SPICE TLS with spice_tls=0
Christophe Fergeau [Fri, 24 Feb 2012 10:34:45 +0000 (11:34 +0100)]
Error out when using SPICE TLS with spice_tls=0

It's possible to disable SPICE TLS in qemu.conf. When this happens,
libvirt ignores any SPICE TLS port or x509 directory that may have
been set when it builds the qemu command line to use. However, it's
not ignoring the secure channels that may have been set and adds
tls-channel arguments to qemu command line.
Current qemu versions don't report an error when this happens, and try to use
TLS for the specified channels.

Before this patch

<domain type='kvm'>
  <name>auto-tls-port</name>
  <memory>65536</memory>
  <os>
    <type arch='x86_64' machine='pc'>hvm</type>
  </os>
  <devices>
    <graphics type='spice' port='5900' tlsPort='-1' autoport='yes' listen='0' ke
      <listen type='address' address='0'/>
      <channel name='main' mode='secure'/>
      <channel name='inputs' mode='secure'/>
    </graphics>
  </devices>
</domain>

generates

-spice port=5900,addr=0,disable-ticketing,tls-channel=main,tls-channel=inputs

and starts QEMU.

After this patch, an error is reported if a TLS port is set in the XML
or if secure channels are specified but TLS is disabled in qemu.conf.
This is the behaviour the oVirt people (where I spotted this issue) said
they would expect.

This fixes bug #790436

13 years agovmx: Better Workstation vmx handling
Jean-Baptiste Rouault [Thu, 23 Feb 2012 09:34:45 +0000 (10:34 +0100)]
vmx: Better Workstation vmx handling

This patch adds support for vmx files with empty networkName
values (which is the case for vmx generated by Workstation).
It also adds support for vmx containing NATed network interfaces.

Update test suite accordingly

13 years agovirterror: Misleading error message when name is missing
Benjamin Cama [Thu, 23 Feb 2012 16:37:30 +0000 (17:37 +0100)]
virterror: Misleading error message when name is missing

[forwarding this here from RH bug #796732]

When creating a network (virsh net-create) with an erroneous XML
containing an empty <name> element, the error message is misleading:

error: Failed to create network from foo.xml
error: missing domain name information

It took me a bit of time to figure out that it was the *network* name
that was missing (I generate this xml and didn't look at it, first).

I realized that the same message is used for missing name when creating
a domain, network, or device node.

13 years agoUpdate bug reporting page
Dave Allan [Thu, 23 Feb 2012 22:49:25 +0000 (17:49 -0500)]
Update bug reporting page

Remove suggestion that people file bugs against RHEL 5 and add a
suggestion that people increase the visibility of their bugs by
mentioning them on libvir-list.

13 years agoqemu: nicer error message on failed graceful destroy
Eric Blake [Wed, 22 Feb 2012 18:41:17 +0000 (11:41 -0700)]
qemu: nicer error message on failed graceful destroy

https://bugzilla.redhat.com/show_bug.cgi?id=795656 mentions
that a graceful destroy request can time out, meaning that the
error message is user-visible and should be more appropriate
than just internal error.

* src/qemu/qemu_driver.c (qemuDomainDestroyFlags): Swap error type.

13 years agoqemu: Forbid migration with cache != none
Jiri Denemark [Tue, 21 Feb 2012 12:20:06 +0000 (13:20 +0100)]
qemu: Forbid migration with cache != none

Migrating domains with disks using cache != none is unsafe unless the
disk images are stored on coherent clustered filesystem. Thus we forbid
migrating such domains unless VIR_MIGRATE_UNSAFE flags is used.

13 years agoIntroduce virStorageFileIsClusterFS
Jiri Denemark [Tue, 21 Feb 2012 21:58:50 +0000 (22:58 +0100)]
Introduce virStorageFileIsClusterFS

13 years agovirsh: Add --unsafe option to migrate command
Jiri Denemark [Tue, 21 Feb 2012 12:19:46 +0000 (13:19 +0100)]
virsh: Add --unsafe option to migrate command

13 years agoAdd support for unsafe migration
Jiri Denemark [Mon, 20 Feb 2012 08:16:23 +0000 (09:16 +0100)]
Add support for unsafe migration

This patch adds VIR_MIGRATE_UNSAFE flag for migration APIs and new
VIR_ERR_MIGRATION_UNSAFE error code.  The error code should be returned
whenever migrating a domain is considered unsafe (e.g., it's configured
in a way that does not ensure data integrity once it is migrated).
VIR_MIGRATE_UNSAFE flag may be used to force migration even though it
would normally be considered unsafe and forbidden.

13 years agoconfigure: Define program name if not found
Michal Privoznik [Wed, 22 Feb 2012 10:18:59 +0000 (11:18 +0100)]
configure: Define program name if not found

AC_CHECK_PROG checks for program in given path. However, if it doesn't
exists, [variable] is set to [value-if-not-found]. We don't want this
to be the empty string in case of 'modprobe' and 'scrub' as we want to
fallback to runtime detection.

13 years agoutil: Fix virFileAccessibleAs return path from parent
Michal Privoznik [Wed, 22 Feb 2012 08:55:27 +0000 (09:55 +0100)]
util: Fix virFileAccessibleAs return path from parent

Despite documentation, if we do fork() parent always returns -1
even if file is accessible. Which is wrong obviously.

13 years agovirsh: Enhance list command to ease creation of shell scripts
Peter Krempa [Tue, 21 Feb 2012 14:02:23 +0000 (15:02 +0100)]
virsh: Enhance list command to ease creation of shell scripts

This patch adds new options to the "virsh list" command enabling
filtering of persistent and transient domains along with the option to
print only UUIDs or names of domains instead of printing the table.

Option --name prints domain names (one per line) instead of the default
table. Similarly --uuid prints domain's UUID. The option --table is
an alias for the default behavior.

Aditionally --persistent and/or --transient may be specified to filter
the output of domains.

13 years agovmware: implement domainXMLFromNative
Jean-Baptiste Rouault [Wed, 22 Feb 2012 09:28:06 +0000 (10:28 +0100)]
vmware: implement domainXMLFromNative

13 years agolib: Fix function documentation for virConnectListDomains
Peter Krempa [Tue, 21 Feb 2012 14:00:33 +0000 (15:00 +0100)]
lib: Fix function documentation for virConnectListDomains

Clarify the documentation of virConnectListDomains.

13 years agoesx: Correctly disable HTTP Expect header usage of libcurl
Matthias Bolte [Mon, 20 Feb 2012 21:34:52 +0000 (22:34 +0100)]
esx: Correctly disable HTTP Expect header usage of libcurl

Adding "Expect:" to the header list stops libcurl from sending a
Expect header at all.

Before, a dummy Expect header was added that might confuse HTTP
proxies and result in HTTP error code 417 being reported.

13 years agovirsh: Fix docs for list command
Peter Krempa [Tue, 21 Feb 2012 14:05:49 +0000 (15:05 +0100)]
virsh: Fix docs for list command

Commit fad5cd210899dfde4afe36712754dc921c3f3051 introduced option to
display domain's title in the list command output. There was a mistake
in the virsh man page example for this command stating --note instead of
--title.

13 years agocaps: Improve error if passed an unknown arch
Cole Robinson [Mon, 20 Feb 2012 18:40:30 +0000 (13:40 -0500)]
caps: Improve error if passed an unknown arch

Previously we would have:

"os type 'hvm' & arch 'idontexist' combination is not supported"

Now we get

"No guest options available for arch 'idontexist'"

or if options available but guest OS type not applicable:

"No os type 'xen' available for arch 'x86_64'"

13 years agospec: use ix86 macros
Peter Robinson [Mon, 20 Feb 2012 16:27:11 +0000 (09:27 -0700)]
spec: use ix86 macros

* libvirt.spec.in: Use %{ix86} rather than open-coded list.

13 years agoFix compilation on MacOS X
Lincoln Myers [Mon, 20 Feb 2012 03:21:00 +0000 (11:21 +0800)]
Fix compilation on MacOS X

* src/util/virfile.h: the virFileWrapperFdFlags being defined as
  a globa variable instead of a type ended up generating a duplicate
  symbol error.
* AUTHORS: added Lincoln Myers

13 years agonwfilter: improved logging during driver initialization
Stefan Berger [Thu, 16 Feb 2012 23:56:39 +0000 (18:56 -0500)]
nwfilter: improved logging during driver initialization

Improve the logging during driver initialization when testing the command
line tools.

13 years agoqemu: Prevent crash of libvirtd without guest agent
Alex Jia [Thu, 16 Feb 2012 02:32:03 +0000 (10:32 +0800)]
qemu: Prevent crash of libvirtd without guest agent

* src/qemu/qemu_process.c (qemuFindAgentConfig): avoid crash libvirtd due to
deref a NULL pointer.

* How to reproduce?
1. virsh edit the following xml into guest configuration:
    <channel type='pty'>
      <target type='virtio'/>
    </channel>
2. virsh start <domain>

or
% virt-install -n foo -r 1024 --disk path=/var/lib/libvirt/images/foo.img,size=1 \
--channel pty,target_type=virtio -l <installation tree>

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: Unlock monitor when connecting to dest qemu fails
Jiri Denemark [Wed, 15 Feb 2012 15:48:54 +0000 (16:48 +0100)]
qemu: Unlock monitor when connecting to dest qemu fails

When migrating a qemu domain, we enter the monitor, send some commands,
try to connect to destination qemu, send other commands, end exit the
monitor. However, if we couldn't connect to destination qemu we forgot
to exit the monitor.

Bug introduced by commit d9d518b1c8ef3b65658cc91f85ba33a63c0959a4.

13 years agoqemu: Fix segfault when host CPU is empty
Jiri Denemark [Wed, 15 Feb 2012 11:18:25 +0000 (12:18 +0100)]
qemu: Fix segfault when host CPU is empty

In case libvirtd cannot detect host CPU model (which may happen if it
runs inside a virtual machine), the daemon is likely to segfault when
starting a new qemu domain. It segfaults when domain XML asks for host
(either model or passthrough) CPU or does not ask for any specific CPU
model at all.

13 years agostorage: Allow runtime detection of scrub
Michal Privoznik [Tue, 14 Feb 2012 10:09:42 +0000 (11:09 +0100)]
storage: Allow runtime detection of scrub

Currently, if scrub (used for wiping algorithms) is not present
at compile time, we don't support any other wiping algorithms than
zeroing, even if it was installed later. Switch to runtime detection
instead.

13 years agoFix polkit0 authentication
Jim Fehlig [Wed, 15 Feb 2012 17:01:50 +0000 (10:01 -0700)]
Fix polkit0 authentication

Commit 7033c5f2 introduced some bugs in polkit0 authentication.

Fix libvirtd segfault in remoteDispatchAuthPolkit().

Fix polkit authentication bypass when caller UID = 0.

13 years agoFix build with polkit0
Jim Fehlig [Thu, 16 Feb 2012 04:34:13 +0000 (21:34 -0700)]
Fix build with polkit0

Commit 8dd623b9 introduced a build error with --enable-compile-warnings=error

  remote.c:2593: error: unused variable 'rv' [-Wunused-variable]

Pushing under build-breaker rule.

13 years agopython: Expose virDomain{G,S}etInterfaceParameters APIs in python binding
Alex Jia [Tue, 14 Feb 2012 02:46:23 +0000 (10:46 +0800)]
python: Expose virDomain{G,S}etInterfaceParameters APIs in python binding

The v4 patch corrects indentation issues.

The v3 patch follows latest python binding codes and change 'size'
type from int to Py_ssize_t.

An simple example to show how to use it:

#!/usr/bin/env python

import libvirt

conn = libvirt.open(None)
dom = conn.lookupByName('foo')

print dom.interfaceParameters('vnet0', 0)

params = {'outbound.peak': 10,
          'inbound.peak': 10,
          'inbound.burst': 20,
          'inbound.average': 20,
          'outbound.average': 30,
          'outbound.burst': 30}

print dom.setInterfaceParameters('vnet0', params, 0)
print dom.interfaceParameters('vnet0', 0)

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agosnapshot: fix snapshot deletion use-after-free
Eric Blake [Tue, 14 Feb 2012 20:08:56 +0000 (13:08 -0700)]
snapshot: fix snapshot deletion use-after-free

Bug introduced in commit 35abced.  On an inactive domain,
$ virsh snapshot-create-as dom snap
$ virsh snapshot-create dom
$ virsh snapshot-create dom
$ virsh snapshot-delete --children dom snap
could crash libvirtd, due to a use-after-free that results
when the callback freed the current element in the iteration.

* src/conf/domain_conf.c (virDomainSnapshotForEachChild)
(virDomainSnapshotActOnDescendant): Allow iteration to delete
current child.

13 years agodaemon: fix logic bug with virAsprintf
Eric Blake [Tue, 14 Feb 2012 23:00:28 +0000 (16:00 -0700)]
daemon: fix logic bug with virAsprintf

Regression introduced in commit 7033c5f2, due to improper conversion
from snprintf to virAsprintf.

* daemon/remote.c (remoteDispatchAuthList): Check return value
correctly.

13 years agodaemon: plug memory leak
Eric Blake [Tue, 14 Feb 2012 22:51:01 +0000 (15:51 -0700)]
daemon: plug memory leak

Leak introduced in commit bb2eddc6.

* daemon/remote.c (remoteDispatchAuthPolkit): Also free pkout on
success.

13 years agonetwork: support Open vSwitch
Ansis Atteka [Fri, 10 Feb 2012 21:09:00 +0000 (23:09 +0200)]
network: support Open vSwitch

This patch allows libvirt to add interfaces to already
existing Open vSwitch bridges. The following syntax in
domain XML file can be used:

    <interface type='bridge'>
      <mac address='52:54:00:d0:3f:f2'/>
      <source bridge='ovsbr'/>
      <virtualport type='openvswitch'>
        <parameters interfaceid='921a80cd-e6de-5a2e-db9c-ab27f15a6e1d'/>
      </virtualport>
      <address type='pci' domain='0x0000' bus='0x00'
                          slot='0x03' function='0x0'/>
    </interface>

or if libvirt should auto-generate the interfaceid use
following syntax:

    <interface type='bridge'>
      <mac address='52:54:00:d0:3f:f2'/>
      <source bridge='ovsbr'/>
      <virtualport type='openvswitch'>
      </virtualport>
      <address type='pci' domain='0x0000' bus='0x00'
                          slot='0x03' function='0x0'/>
    </interface>

It is also possible to pass an optional profileid. To do that
use following syntax:

   <interface type='bridge'>
     <source bridge='ovsbr'/>
     <mac address='00:55:1a:65:a2:8d'/>
     <virtualport type='openvswitch'>
       <parameters interfaceid='921a80cd-e6de-5a2e-db9c-ab27f15a6e1d'
                   profileid='test-profile'/>
     </virtualport>
   </interface>

To create Open vSwitch bridge install Open vSwitch and
run the following command:

    ovs-vsctl add-br ovsbr

13 years agoconf: rename virDomainNetGetActualDirectVirtPortProfile
Laine Stump [Wed, 15 Feb 2012 19:19:32 +0000 (14:19 -0500)]
conf: rename virDomainNetGetActualDirectVirtPortProfile

An upcoming patch will add a <virtualport> element to interfaces of
type='bridge', so it makes sense to give this function a more generic
name.

13 years agoqemu: increase the timeout before sending SIGKILL to qemu process
Laine Stump [Thu, 2 Feb 2012 17:09:44 +0000 (12:09 -0500)]
qemu: increase the timeout before sending SIGKILL to qemu process

The current default method of terminating the qemu process is to send
a SIGTERM, wait for up to 1.6 seconds for it to cleanly shutdown, then
send a SIGKILL and wait for up to 1.4 seconds more for the process to
terminate. This is problematic because occasionally 1.6 seconds is not
long enough for the qemu process to flush its disk buffers, so the
guest's disk ends up in an inconsistent state.

Since this only occasionally happens when the timeout prior to SIGKILL
is 1.6 seconds, this patch increases that timeout to 10 seconds. At
the very least, this should reduce the occurrence from "occasionally"
to "extremely rarely". (Once SIGKILL is sent, it waits another 5
seconds for the process to die before returning).

Note that in the cases where it takes less than this for qemu to
shutdown cleanly, libvirt will *not* wait for any longer than it would
without this patch - qemuProcessKill polls the process and returns as
soon as it is gone.

13 years agoqemu: drop driver lock while trying to terminate qemu process
Laine Stump [Tue, 7 Feb 2012 16:13:57 +0000 (11:13 -0500)]
qemu: drop driver lock while trying to terminate qemu process

This patch is based on an earlier patch by Eric Blake which was never
committed:

https://www.redhat.com/archives/libvir-list/2011-November/msg00243.html

Aside from rebasing, this patch only drops the driver lock once (prior
to the first time the function sleeps), then leaves it dropped until
it returns (Eric's patch would drop and re-acquire the lock around
each call to sleep).

At the time Eric sent his patch, the response (from Dan Berrange) was
that, while it wasn't a good thing to be holding the driver lock while
sleeping, we really need to rethink locking wrt the driver object,
switching to a finer-grained approach that locks individual items
within the driver object separately to allow for greater concurrency.

This is a good plan, and at the time it made sense to not apply the
patch because there was no known bug related to the driver lock being
held in this function.

However, we now know that the length of the wait in qemuProcessKill is
sometimes too short to allow the qemu process to fully flush its disk
cache before SIGKILL is sent, so we need to lengthen the timeout (in
order to improve the situation with management applications until they
can be updated to use the new VIR_DOMAIN_DESTROY_GRACEFUL flag added
in commit 72f8a7f19753506ed957b78ad800c0f3892c9304). But, if we
lengthen the timeout, we also lengthen the amount of time that all
other threads in libvirtd are essentially blocked from doing anything
(since just about everything needs to acquire the driver lock, if only
for long enough to get a pointer to a domain).

The solution is to modify qemuProcessKill to drop the driver lock
while sleeping, as proposed in Eric's patch. Then we can increase the
timeout with a clear conscience, and thus at least lower the chances
that someone running with existing management software will suffer the
consequence's of qemu's disk cache not being flushed.

In the meantime, we still should work on Dan's proposal to make
locking within the driver object more fine grained.

(NB: although I couldn't find any instance where qemuProcessKill() was
called with no jobs active for the domain (or some other guarantee
that the current thread had at least one refcount on the domain
object), this patch still follows Eric's method of temporarily adding
a ref prior to unlocking the domain object, because I couldn't
convince myself 100% that this was the case.)

13 years agoFix typos in API XML file paths
Daniel P. Berrange [Wed, 15 Feb 2012 11:29:38 +0000 (11:29 +0000)]
Fix typos in API XML file paths

* libvirt.pc.in: Add missing '/api/' in path
* libvirt.spec.in, mingw32-libvirt.spec.in: s/apis/api/

13 years agoqemu: Implement DomainPMSuspendForDuration
Michal Privoznik [Mon, 13 Feb 2012 11:27:25 +0000 (12:27 +0100)]
qemu: Implement DomainPMSuspendForDuration

via user agent. Allow targets mem & hybrid iff system_wakeup
monitor command is available.

13 years agoqemu: Set capabilities based on supported monitor commands
Michal Privoznik [Mon, 13 Feb 2012 11:19:24 +0000 (12:19 +0100)]
qemu: Set capabilities based on supported monitor commands

In the future (my next patch in fact) we may want to make
decisions depending on qemu having a monitor command or not.
Therefore, we want to set qemuCaps flag instead of querying
on the monitor each time we are about to make that decision.

13 years agoInstall API XML desc to a standard location
Daniel P. Berrange [Mon, 13 Feb 2012 16:46:29 +0000 (16:46 +0000)]
Install API XML desc to a standard location

Language bindings may well want to use the libvirt-api.xml and
libvirt-qemu-api.xml files to either auto-generate themselves,
or sanity check the manually written bindings for completeness.
Currently these XML files are not installed as standard, merely
ending up as a %doc file in the RPM.

This changes them to be installed into $prefix/share/libvirt/apis/
The *-refs.xml files are not installed, since those are only
useful during generation of the online API doc files.

The pkg-config file is enhanced so that you can query the install
location of the API files. eg

  # pkg-config --variable=libvirt_qemu_api libvirt
  /home/berrange/builder/i686-pc-mingw32/sys-root/mingw/share/libvirt/libvirt-qemu-api.xml

* docs/Makefile.am: Install libvirt-api.xml & libvirt-qemu-api.xml
* libvirt.pc.in: Add vars for querying API install location
* libvirt.spec.in, mingw32-libvirt.spec.in: Include API XML files

13 years agoqemu: make block io tuning smarter
Eric Blake [Fri, 10 Feb 2012 21:53:49 +0000 (14:53 -0700)]
qemu: make block io tuning smarter

When blkdeviotune was first committed in 0.9.8, we had the limitation
that setting one value reset all others.  But bytes and iops should
be relatively independent.  Furthermore, setting tuning values on
a live domain followed by dumpxml did not output the new settings.

* src/qemu/qemu_driver.c (qemuDiskPathToAlias): Add parameter, and
update callers.
(qemuDomainSetBlockIoTune): Don't lose previous unrelated
settings.  Make live changes reflect to dumpxml output.
* tools/virsh.pod (blkdeviotune): Update documentation.

13 years agoRelease of libvirt-0.9.10
Daniel Veillard [Mon, 13 Feb 2012 14:31:31 +0000 (22:31 +0800)]
Release of libvirt-0.9.10

* configure.ac docs/news.html.in libvirt.spec.in: updated for the release
* po/*.po*: update ja, it and uk localization, fixed the ja one

13 years agovirsh: Fix name of domain suspend command
Michal Privoznik [Mon, 13 Feb 2012 13:37:09 +0000 (14:37 +0100)]
virsh: Fix name of domain suspend command

It's dompmsuspend, not suspend-duration.

13 years agovirpidfile: Allow whitespace character at the end of pidfile
Michal Privoznik [Mon, 13 Feb 2012 13:27:15 +0000 (14:27 +0100)]
virpidfile: Allow whitespace character at the end of pidfile

Some programs, notably dnsmasq, which are writing pidfiles on their
own do append a whitespace character after pid, e.g. '\n'.

13 years agoRevert "qemu: add ibmvscsi controller model"
Daniel Veillard [Mon, 13 Feb 2012 13:37:03 +0000 (21:37 +0800)]
Revert "qemu: add ibmvscsi controller model"

This reverts commit 7b345b69f28eb112238b941b743c5f6d57bd4a04.

Conflicts:

tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.xml

13 years agoRevert "qemu: add virtio-scsi controller model"
Daniel Veillard [Mon, 13 Feb 2012 13:36:02 +0000 (21:36 +0800)]
Revert "qemu: add virtio-scsi controller model"

This reverts commit c9abfadf3721505e8eaffbf56ef1e53202c1db3c.

Conflicts:

tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.xml

13 years agopython: make other APIs share common {get, set}PyVirTypedParameter
Guannan Ren [Fri, 10 Feb 2012 10:17:26 +0000 (18:17 +0800)]
python: make other APIs share common {get, set}PyVirTypedParameter

        *libvirt_virDomainBlockStatsFlags
        *libvirt_virDomainGetSchedulerParameters
        *libvirt_virDomainGetSchedulerParametersFlags
        *libvirt_virDomainSetSchedulerParameters
        *libvirt_virDomainSetSchedulerParametersFlags
        *libvirt_virDomainSetBlkioParameters
        *libvirt_virDomainGetBlkioParameters
        *libvirt_virDomainSetMemoryParameters
        *libvirt_virDomainGetMemoryParameters
        *libvirt_virDomainSetBlockIoTune
        *libvirt_virDomainGetBlockIoTune

13 years agovirpidfile: replace fopen/fwrite/fscanf with more portable version
Marc-André Lureau [Thu, 2 Feb 2012 00:28:30 +0000 (01:28 +0100)]
virpidfile: replace fopen/fwrite/fscanf with more portable version

Replace calls to fwrite() and fscanf() with more portable-friendly
version, such as snprintf() and virStrToLong().

13 years agoutil: Do not use PRIx64 macro
Osier Yang [Fri, 10 Feb 2012 11:21:53 +0000 (19:21 +0800)]
util: Do not use PRIx64 macro

It breaks the build on Mingw32,  because PRIx64 is coming
from the Win32 headers, but virAsprintf uses the gnulib printf.

13 years agorpc: Plug memory leaks on doRemoteOpen() failure path
Alex Jia [Fri, 10 Feb 2012 05:26:29 +0000 (13:26 +0800)]
rpc: Plug memory leaks on doRemoteOpen() failure path

Detected by valgrind. Leaks are introduced in commit c1b2264.

* src/remote/remote_driver.c (doRemoteOpen): free client program memory in failure path.

* How to reproduce?
% valgrind -v --leak-check=full virsh -c qemu:

* Actual result

==3969== 40 bytes in 1 blocks are definitely lost in loss record 8 of 28
==3969==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
    ==3969==    by 0x4C89C41: virAlloc (memory.c:101)
    ==3969==    by 0x4D5A236: virNetClientProgramNew (virnetclientprogram.c:60)
    ==3969==    by 0x4D47AB4: doRemoteOpen (remote_driver.c:658)
    ==3969==    by 0x4D49FFF: remoteOpen (remote_driver.c:871)
    ==3969==    by 0x4D13373: do_open (libvirt.c:1196)
    ==3969==    by 0x4D14535: virConnectOpenAuth (libvirt.c:1422)
    ==3969==    by 0x425627: main (virsh.c:18537)
    ==3969==
    ==3969== 40 bytes in 1 blocks are definitely lost in loss record 9 of 28
    ==3969==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
    ==3969==    by 0x4C89C41: virAlloc (memory.c:101)
    ==3969==    by 0x4D5A236: virNetClientProgramNew (virnetclientprogram.c:60)
    ==3969==    by 0x4D47AD7: doRemoteOpen (remote_driver.c:664)
    ==3969==    by 0x4D49FFF: remoteOpen (remote_driver.c:871)
    ==3969==    by 0x4D13373: do_open (libvirt.c:1196)
    ==3969==    by 0x4D14535: virConnectOpenAuth (libvirt.c:1422)
    ==3969==    by 0x425627: main (virsh.c:18537)
    ==3969==
    ==3969== LEAK SUMMARY:
    ==3969==    definitely lost: 80 bytes in 2 blocks

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agonpiv: Auto-generate WWN if it's not specified
Osier Yang [Fri, 10 Feb 2012 04:51:47 +0000 (12:51 +0800)]
npiv: Auto-generate WWN if it's not specified

The auto-generated WWN comply with the new addressing schema of WWN:

<quote>
the first nibble is either hex 5 or 6 followed by a 3-byte vendor
identifier and 36 bits for a vendor-specified serial number.
</quote>

We choose hex 5 for the first nibble. And for the 3-bytes vendor ID,
we uses the OUI according to underlying hypervisor type, (invoking
virConnectGetType to get the virt type). e.g. If virConnectGetType
returns "QEMU", we use Qumranet's OUI (00:1A:4A), if returns
ESX|VMWARE, we use VMWARE's OUI (00:05:69). Currently it only
supports qemu|xen|libxl|xenapi|hyperv|esx|vmware drivers. The last
36 bits are auto-generated.

13 years agoRemove single quotes from audit records
Marcelo Cerri [Thu, 9 Feb 2012 19:06:00 +0000 (17:06 -0200)]
Remove single quotes from audit records

Some audit records generated by libvirt contain fields enclosed by single
quotes. Since those fields are inside the msg field, which is enclosed by
single quotes, these records generated by libvirt are not correctly parsed by
libauparse.

13 years agoGetCPUStats: fix overflow test
Lai Jiangshan [Thu, 9 Feb 2012 10:43:10 +0000 (18:43 +0800)]
GetCPUStats: fix overflow test

Bug introduced in commit c6ec021b.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
13 years agodomain: add implicit USB controller
Marc-André Lureau [Wed, 8 Feb 2012 00:48:25 +0000 (01:48 +0100)]
domain: add implicit USB controller

Some tools, such as virt-manager, prefers having the default USB
controller explicit in the XML document. This patch makes sure there
is one. With this patch, it is now possible to switch from USB1 to
USB2 from the release 0.9.1 of virt-manager.

Fix tests to pass with this change.

13 years agopython: refactoring virTypedParameter conversion for NUMA tuning APIs
Guannan Ren [Wed, 8 Feb 2012 12:20:50 +0000 (20:20 +0800)]
python: refactoring virTypedParameter conversion for NUMA tuning APIs

          *getPyVirTypedParameter
          *setPyVirTypedParameter
          *virDomainSetNumaParameters
          *virDomainGetNumaParameters

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agodocs: fix typo in python bindings
Eric Blake [Thu, 9 Feb 2012 00:19:30 +0000 (17:19 -0700)]
docs: fix typo in python bindings

* docs/python.html.in: Class is virConnect, not virConn.

13 years agoconf: small changes to comments in virDomainDeviceInfo
Laine Stump [Thu, 9 Feb 2012 07:33:29 +0000 (02:33 -0500)]
conf: small changes to comments in virDomainDeviceInfo

romfile wasn't mentioned in the comment, and the fact that rombar is
now supported for network interfaces also wasn't there.

13 years agopython: Correct arguments number for migrateSetMaxSpeed
Osier Yang [Wed, 8 Feb 2012 09:33:22 +0000 (17:33 +0800)]
python: Correct arguments number for migrateSetMaxSpeed

The API definition accepts "flags" argument, however, the
implementation ignores it, though "flags" is unused currently,
we should expose it instead of hard coding, the API
implementation inside hypervisor driver is responsible to check
if the passed "flags" is valid.

13 years agoqemu: fix persistent setting of blkiodevice weights
Eric Blake [Wed, 8 Feb 2012 00:38:41 +0000 (17:38 -0700)]
qemu: fix persistent setting of blkiodevice weights

virsh blkiotune dom --device-weights /dev/sda,400 --config

wasn't working correctly.

* src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters): Use
correct definition.

13 years agoqemu: make blkiodevice weights easier to read
Eric Blake [Wed, 8 Feb 2012 00:38:01 +0000 (17:38 -0700)]
qemu: make blkiodevice weights easier to read

The merge code had too many indirections to easily analyze.

* src/qemu/qemu_driver.c (qemuDomainMergeDeviceWeights): Pick
better variable names.

13 years agosysinfo: simplify function signature
Eric Blake [Tue, 7 Feb 2012 22:35:03 +0000 (15:35 -0700)]
sysinfo: simplify function signature

Now that no one is relying on the return value being a pointer to
somewhere inside of the passed-in argument, we can simplify the
callers to simply return success or failure.  Also wrap some long
lines and add some const-correctness.

* src/util/sysinfo.c (virSysinfoParseBIOS, virSysinfoParseSystem)
(virSysinfoParseProcessor, virSysinfoParseMemory): Change return.
(virSysinfoRead): Adjust caller.

13 years agoPopulate /dev/std{in,out,err} symlinks in LXC containers
Daniel P. Berrange [Wed, 8 Feb 2012 14:21:28 +0000 (14:21 +0000)]
Populate /dev/std{in,out,err} symlinks in LXC containers

Some applications expect /dev/std{in,out,err} to exist. Populate
them during container startup as symlinks to /proc/self/fd

13 years agoReplace truncate() with ftruncate()
Daniel P. Berrange [Wed, 8 Feb 2012 14:03:29 +0000 (14:03 +0000)]
Replace truncate() with ftruncate()

Mingw32 does not have any truncate() API defined, but it does
have ftruncate(). So replace use of the former with the latter

13 years agoUpdate symbols file for virFileDirectFd/virFileWrapperFd rename
Daniel P. Berrange [Wed, 8 Feb 2012 14:03:01 +0000 (14:03 +0000)]
Update symbols file for virFileDirectFd/virFileWrapperFd rename

13 years agovirsh: Fix flag semantics and docs for "desc" command
Peter Krempa [Wed, 8 Feb 2012 10:31:10 +0000 (11:31 +0100)]
virsh: Fix flag semantics and docs for "desc" command

This patch fixes the domain modification impact flags for tie virsh
desc command to match the new semantics and fix the docs to match
actual behavior.

13 years agoqemu: Fix memory leak when building -cpu argument
Jiri Denemark [Wed, 8 Feb 2012 13:35:12 +0000 (14:35 +0100)]
qemu: Fix memory leak when building -cpu argument

Reported by Alex Jia:

==21503== 112 (32 direct, 80 indirect) bytes in 1 blocks are
definitely lost in loss record 37 of 40
==21503==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==21503==    by 0x4A8991: virAlloc (memory.c:101)
==21503==    by 0x505A6C: x86DataCopy (cpu_x86.c:247)
==21503==    by 0x507B34: x86Compute (cpu_x86.c:1225)
==21503==    by 0x43103C: qemuBuildCommandLine (qemu_command.c:3561)
==21503==    by 0x41C9F7: testCompareXMLToArgvHelper
(qemuxml2argvtest.c:183)
==21503==    by 0x41E10D: virtTestRun (testutils.c:141)
==21503==    by 0x41B942: mymain (qemuxml2argvtest.c:705)
==21503==    by 0x41D7E7: virtTestMain (testutils.c:696)

13 years agoqemu: Always use iohelper for domain save
Jiri Denemark [Wed, 8 Feb 2012 13:08:54 +0000 (14:08 +0100)]
qemu: Always use iohelper for domain save

This is probably not strictly needed as save operation is not live but
we may have other reasons to avoid blocking qemu's main loop.

13 years agosecurity: Driver 'none' cannot create confined guests
Jiri Denemark [Tue, 7 Feb 2012 18:54:59 +0000 (19:54 +0100)]
security: Driver 'none' cannot create confined guests

In case the caller specifies that confined guests are required but the
security driver turns out to be 'none', we should return an error since
this driver clearly cannot meet that requirement.  As a result of this
error, libvirtd fails to start when the host admin explicitly sets
confined guests are required but there is no security driver available.

Since security driver 'none' cannot create confined guests, we override
default confined setting so that hypervisor drivers do not thing they
should create confined guests.

13 years agoseclabel: Do not output relabel attribute for type 'none'
Jiri Denemark [Tue, 7 Feb 2012 18:19:01 +0000 (19:19 +0100)]
seclabel: Do not output relabel attribute for type 'none'

Security label type 'none' requires relabel to be set to 'no' so there's
no reason to output this extra attribute.  Moreover, since relabel is
internally stored in a negative from (norelabel), the default value for
relabel would be 'yes' in case there is no <seclabel> element in domain
configuration.  In case VIR_DOMAIN_SECLABEL_DEFAULT turns into
VIR_DOMAIN_SECLABEL_NONE, we would incorrectly output relabel='yes' for
seclabel type 'none'.

13 years agoqemu: Always use iohelper for dumping domain core
Jiri Denemark [Mon, 6 Feb 2012 13:53:24 +0000 (14:53 +0100)]
qemu: Always use iohelper for dumping domain core

Qemu uses non-blocking I/O which doesn't play nice with regular file
descriptors. We need to pass a pipe to qemu instead, which can easily be
done using iohelper.

13 years agoutil: Generalize virFileDirectFd
Jiri Denemark [Mon, 6 Feb 2012 13:40:48 +0000 (14:40 +0100)]
util: Generalize virFileDirectFd

virFileDirectFd was used for accessing files opened with O_DIRECT using
libvirt_iohelper. We will want to use the helper for accessing files
regardless on O_DIRECT and thus virFileDirectFd was generalized and
renamed to virFileWrapperFd.

13 years agovirsh: Plug memory leak on cmdDesc
Alex Jia [Wed, 8 Feb 2012 05:50:06 +0000 (13:50 +0800)]
virsh: Plug memory leak on cmdDesc

13 years agovirsh: Do not check the input XML at virsh layer for cmdDetachDevice
Osier Yang [Tue, 7 Feb 2012 15:56:08 +0000 (23:56 +0800)]
virsh: Do not check the input XML at virsh layer for cmdDetachDevice

Any device XML doesn't use the same order as libvirt generates, or
uses decimal for attributes like "slot" of "<address>" will cause
device detaching to fail, as virsh compares the XML simply earlier
in strict manner before internal parsing.

This is regression introduced by ea7182c.

13 years agopython: drop unused function
Eric Blake [Wed, 8 Feb 2012 00:14:11 +0000 (17:14 -0700)]
python: drop unused function

Gcc warned about an unused static function.

* python/libvirt-qemu-override.c (py_str): Delete.

13 years agoOn systems with dmidecode version 2.10 or older,
Prerna Saxena [Tue, 7 Feb 2012 11:35:37 +0000 (17:05 +0530)]
On systems with dmidecode version 2.10 or older,

 dmidecode displays processor information, followed by BIOS, system and
 memory-DIMM details.
 Calls to virSysinfoParseBIOS(), virSysinfoParseSystem() would update
 the buffer pointer 'base', so the processor information would be lost
 before virSysinfoParseProcessor() was called. Sysinfo would therefore
 not be able to display processor details -- It only described <bios>,
 <system> and <memory_device> details.
 This patch attempts to insulate sysinfo from ordering of dmidecode
 output.

Before the fix:
---------------
virsh # sysinfo
<sysinfo type='smbios'>
  <bios>
    ....
  </bios>
  <system>
    ....
  </system>
  <memory_device>
    ....
  </memory_device>

After the fix:
-------------
virsh # sysinfo
<sysinfo type='smbios'>
  <bios>
    ....
  </bios>
  <system>
    ....
  </system>
  <processor>
    ....
  </processor>
  <memory_device>
    ....
  </memory_device>

13 years agostorage: Don't unsparsify images when cloning
Cole Robinson [Tue, 7 Feb 2012 19:46:30 +0000 (14:46 -0500)]
storage: Don't unsparsify images when cloning

Input to the volume cloning code is a source volume and an XML
descriptor for the new volume. It is possible for the new volume
to have a greater size than source volume, at which point libvirt
will just stick 0s on the end of the new image (for raw format
anyways).

Unfortunately a logic error messed up our tracking of the of the
excess amount that needed to be written: end result is that sparse
clones were made very much non-sparse, and cloning regular disk
images could end up excessively sized (though data unaltered).

Drop the 'remain' variable entriely here since it's redundant, and
track actual allocation directly against the desired 'total'.

13 years agobuild: don't require avahi during install
Laine Stump [Tue, 7 Feb 2012 09:54:59 +0000 (04:54 -0500)]
build: don't require avahi during install

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

The specfile requires avahi during install if libvirt was built with
avahi support, but there are many situations where it is undesirable
to install avahi due to security concerns. This patch requires only
the avahi-libs package, which is needed by libvirt to call the
function that tries to attach to the avahi daemon, but will instead
silently fail because the avahi-daemon is in the main avahi package,
and that package isn't installed.

13 years agoAllow polkit auth for VNC and SSH users
Cole Robinson [Tue, 7 Feb 2012 16:50:29 +0000 (11:50 -0500)]
Allow polkit auth for VNC and SSH users

If you are sitting in front of a physical machine and logged in as
a regular user, you can connect to the system libvirtd instance
by providing a root password to policykit. This is how most
virt-manager users talk to libvirt.

However, if you are launching virt-manager over ssh -X, or over
VNC started from say /etc/sysconfig/vncservers, our policykit policy
rejects the user outright, providing no option to provide the root
password. This is confusing to users and doesn't seem to serve much
point.

Change the policy to allow inactive (VNC) and non-local (SSH, VNC)
to provide root credentials for accessing system libvirtd. We use
auth_admin rather than auth_admin_keep so that credentials aren't
cached at all, and every subsequent reconnection to libvirt requires
auth.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=625115
Similar change to PackageKit policy:
https://bugzilla.redhat.com/show_bug.cgi?id=528511

13 years agopyhton: Don't link against libvirt_util.la
Michal Privoznik [Tue, 7 Feb 2012 12:30:42 +0000 (13:30 +0100)]
pyhton: Don't link against libvirt_util.la

As we already link with libvirt.la which contains libvirt_utils.la.
Double linking causes global symbols to be presented twice and
thus confusion. This partially reverts c700613b8d463212d142c97108b7a2352e23e559