]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
10 years agostorage: gluster: Avoid name shadow on older compilers
Peter Krempa [Tue, 24 Jun 2014 09:22:17 +0000 (11:22 +0200)]
storage: gluster: Avoid name shadow on older compilers

s/link/linkpath/g in virStorageFileBackendGlusterReadlinkCallback as
older gcc complains.

10 years agostorage: gluster: Add backend to return unique storage file path
Peter Krempa [Mon, 5 May 2014 16:04:16 +0000 (18:04 +0200)]
storage: gluster: Add backend to return unique storage file path

Use virStorageFileSimplifyPathInternal to canonicalize gluster paths
via a callback and use it for the unique volume path retrieval API.

10 years agoutil: storagefile: Introduce universal function to canonicalize paths
Peter Krempa [Fri, 2 May 2014 17:22:17 +0000 (19:22 +0200)]
util: storagefile: Introduce universal function to canonicalize paths

Introduce a common function that will take a callback to resolve links
that will be used to canonicalize paths on various storage systems and
add extensive tests.

10 years agoutil: string: Add helper to free non-NULL terminated string arrays
Peter Krempa [Mon, 19 May 2014 12:20:09 +0000 (14:20 +0200)]
util: string: Add helper to free non-NULL terminated string arrays

To free string lists with some strings stolen from the middle we need to
walk the complete array. Introduce a new helper that takes the string
list size to free such string lists.

10 years agolibxl: prefer qdisk for <driver name='file'>
Jim Fehlig [Fri, 20 Jun 2014 05:36:25 +0000 (23:36 -0600)]
libxl: prefer qdisk for <driver name='file'>

The libxl driver currently sets the disk backend to
LIBXL_DISK_BACKEND_TAP when <driver name='file'> is specified
in the <disk> config.  qdisk should be prefered with this
configuration, otherwise existing configuration such as the
following, which worked with the old Xen driver, will not work
with the libxl driver

  <disk type='file' device='cdrom'>
    <driver name='file'/>
    <source file='/path/to/some/iso'/>
    <target dev='hdc' bus='ide'/>
    <readonly/>
  </disk>

In addition, tap performs poorly compared to qdisk.

10 years agocmdFreepages: initialize @tmp
Michal Privoznik [Mon, 23 Jun 2014 18:25:22 +0000 (20:25 +0200)]
cmdFreepages: initialize @tmp

In the 404bac14 the @tmp variable was introduced. It's purpose is to
avoid typecasting when parsing --pagesize argument. However, if the
argument is not presented, tmp may be used uninitialized resulting in
bogus virNodeGetFreePages() API call:

virsh freepages --cellno 2
error: Failed to open file '/sys/devices/system/node/node2/hugepages/hugepages-4294967295kB/free_hugepages': No such file or directory

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix closedir usage in virNumaGetPages
Roman Bogorodskiy [Sat, 21 Jun 2014 15:24:04 +0000 (19:24 +0400)]
Fix closedir usage in virNumaGetPages

virNumaGetPages calls closedir(dir) in cleanup and dir could
be NULL if we jump there from the failed opendir() call.

While it's not harmful on Linux, FreeBSD libc crashes [1], so
make sure that dir is not NULL before calling closedir.

1: http://lists.freebsd.org/pipermail/freebsd-standards/2014-January/002704.html

10 years agoAdd pkg-config files to allow deps to build against source tree
Daniel P. Berrange [Fri, 20 Jun 2014 16:48:12 +0000 (17:48 +0100)]
Add pkg-config files to allow deps to build against source tree

When testing language bindings it is useful to be able to build
them against an uninstalled libvirt source tree. Add a dummy
set of pkg-config files to allow for this. This can be used by
setting

  export PKG_CONFIG_PATH=/path/to/libvirt/git/src

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoAdd pkg-config files for libvirt-qemu & libvirt-lxc
Daniel P. Berrange [Fri, 20 Jun 2014 16:47:15 +0000 (17:47 +0100)]
Add pkg-config files for libvirt-qemu & libvirt-lxc

For some reason there have never been pkg-config files created
for the libvirt-qemu.so and libvirt-lxc.so libraries.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoDon't include @LIBS@ in libvirt.pc.in file
Daniel P. Berrange [Fri, 20 Jun 2014 16:45:05 +0000 (17:45 +0100)]
Don't include @LIBS@ in libvirt.pc.in file

The libvirt.pc file we install is ending up polluted with a
load of compiler flags that should be private to the libvirt
build. eg

Libs: -L${libdir} -lvirt -ldl -O2 -g -pipe -Wall \
      -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \
      -fstack-protector-strong --param=ssp-buffer-size=4 \
      -grecord-gcc-switches  -m64 -mtune=generic

this is caused by including @LIBS@ in the Libs: line of the
pkgconfig.pc.in file.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agovirnuma: Actually build huge page code
Michal Privoznik [Mon, 23 Jun 2014 13:56:46 +0000 (15:56 +0200)]
virnuma: Actually build huge page code

One of previous commits (e6258a33) tried to build the huge page code
only on Linux since it's Linux centric indeed. But it failed miserably
as it used 'WITH_LINUX' which is an automake conditional not a gcc
one. In the sources we need to use __linux__.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: parse -device virtio-balloon
Laine Stump [Mon, 9 Jun 2014 08:11:25 +0000 (11:11 +0300)]
qemu: parse -device virtio-balloon

There are no options to parse here other than the name of the device,
and all three possible device names have the same prefix
("virtio-balloon" with "-ccw", "-pci", or "-device" appended), so the
code is fairly simple. It has been implemented such that it will be
easier to add handling for other -device entries that aren't otherwise
recognized - just add another "else if (STRPREFIX(opts, ....)" clause.

qemuParseCommandLineString() previously would always add a <memballoon
model='virtio'/> to every result (the comments erroneously say that it
is adding a <memballoon model='none'/>) This has been changed to add
model='none', and 84 test case xml's updated accordingly (so that
qemuxml2argvtest won't fail).

Now that the memballoon device is properly parsed, we can safely add a
test for properly ignoring -nodefconfig and -nodefaults. Rather than
adding an entire new test case for this (and memballoon), we just
randomly pick the clock-utc test and modify it slightly to fulfill the
purpose.

10 years agoReport correct error in virNetDevTapCreate
Ján Tomko [Mon, 23 Jun 2014 10:03:05 +0000 (12:03 +0200)]
Report correct error in virNetDevTapCreate

ioctl returns -1, not the errno value

10 years agoDo not call closedir with NULL argument
Ján Tomko [Mon, 23 Jun 2014 06:58:27 +0000 (08:58 +0200)]
Do not call closedir with NULL argument

Only three other callers possibly call closedir on a NULL argument.
Even though these probably won't be used on FreeBSD where this crashes,
let's be nice and only call closedir on an actual directory stream.

10 years agoFix invalid write in virNumaGetDistances
Ján Tomko [Mon, 23 Jun 2014 09:49:02 +0000 (11:49 +0200)]
Fix invalid write in virNumaGetDistances

==== Invalid write of size 4
====    at 0x52E678C: virNumaGetDistances (virnuma.c:479)
====    by 0x5396890: nodeCapsInitNUMA (nodeinfo.c:1796)
====    by 0x203C2B: virQEMUCapsInit (qemu_capabilities.c:960)
====  Address 0xe10a1e0 is 0 bytes after a block of size 0 alloc'd
====    at 0x4C2A6D0: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
====    by 0x52A10D6: virAllocN (viralloc.c:191)
====    by 0x52E674D: virNumaGetDistances (virnuma.c:470)
====    by 0x5396890: nodeCapsInitNUMA (nodeinfo.c:1796)
====    by 0x203C2B: virQEMUCapsInit (qemu_capabilities.c:960)

10 years agoutil: numa: Stub out hugepage code on non-Linux platforms
Peter Krempa [Mon, 23 Jun 2014 07:25:04 +0000 (09:25 +0200)]
util: numa: Stub out hugepage code on non-Linux platforms

The hugepage sizing and counting code gathers the information from sysfs
and thus isn't portable. Stub it out for non-Linux so that we can report
a better error. This patch also avoids calling sysinfo() on Mingw where
it isn't supported.

10 years agoutil: numa: Catch readdir errors in virNumaGetPages
Peter Krempa [Mon, 23 Jun 2014 07:10:04 +0000 (09:10 +0200)]
util: numa: Catch readdir errors in virNumaGetPages

Don't return possibly incomplete result if virDirRead fails.

10 years agotests: Fix syntax-check after cdd11151791bc9e61538988438980f41c0185681
Peter Krempa [Mon, 23 Jun 2014 11:56:12 +0000 (13:56 +0200)]
tests: Fix syntax-check after cdd11151791bc9e61538988438980f41c0185681

makefile_conditionals
tests/Makefile.am:293:endif
maint.mk: match "if FOO" with "endif FOO" in Makefiles
make: *** [sc_makefile_conditionals] Error 1

10 years agotest: Disable storage test when FS backend isn't compiled in
Peter Krempa [Mon, 23 Jun 2014 10:02:04 +0000 (12:02 +0200)]
test: Disable storage test when FS backend isn't compiled in

'virstoragetest' accesses backing chains of files on local storage with
the help of the storage driver. Disable the test on builds without the
storage driver as the test is crashing otherwise.

Reported by: Roman Bogorodskiy

10 years agoProperly check the return value of CCWAddressAsString
Ján Tomko [Mon, 23 Jun 2014 06:31:53 +0000 (08:31 +0200)]
Properly check the return value of CCWAddressAsString

It returns NULL on failure. Checking if the negation of it
is less than zero makes no sense. (Found by coverity after moving
the code)

In another case, the return value wasn't checked at all.

10 years agoSplit out CCW address allocation
Ján Tomko [Tue, 17 Jun 2014 14:17:41 +0000 (16:17 +0200)]
Split out CCW address allocation

Just code movement and rename.

10 years agolibxl: Use cooperative resume for migration
Jason Andryuk [Fri, 20 Jun 2014 13:10:03 +0000 (09:10 -0400)]
libxl: Use cooperative resume for migration

Migration code specifies the problematic non-cooperative resume mode
which is a known issue with Xen's libxl [1].  Instead, use the better
supported cooperative mode.

Without this, guests BUG() in xen_irq_resume after failing to bind
still-bound event channels.

[1] http://bugs.xenproject.org/xen/bug/30

10 years agocpu_arm: Support all ARM processors we know about
Michal Privoznik [Tue, 17 Jun 2014 13:27:17 +0000 (15:27 +0200)]
cpu_arm: Support all ARM processors we know about

So far three ARM processor families are known to libvirt,
however the cpu driver knows only about one of them. This
make host initialization on the other two fail:

2014-06-17 13:35:41.419+0000: 6840: info : libvirt version: 1.2.6
2014-06-17 13:35:41.419+0000: 6840: error : cpuNodeData:342 : this function is not supported by the connection driver: cannot get node CPU data for armv6l architecture
2014-06-17 13:35:41.433+0000: 6840: warning : virQEMUCapsInit:943 : Failed to get host CPU

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNodeParseSocket: Take ARM into account
Michal Privoznik [Tue, 17 Jun 2014 09:22:05 +0000 (11:22 +0200)]
virNodeParseSocket: Take ARM into account

The virNodeParseSocket() function tries to get socked ID from
'topology/physical_package_id' file. However, on some architectures
the file contains the -1 constant which makes in turn libvirt think
the info extraction was unsuccessful. If that's the case, we need to
overwrite the obtained integer with zero like we are doing for other
architectures.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonodeinfotest: Print error if cpuinfo file can't be opened
Michal Privoznik [Tue, 17 Jun 2014 11:22:02 +0000 (13:22 +0200)]
nodeinfotest: Print error if cpuinfo file can't be opened

Currently, we are opening the cpuinfo file via fopen() which if fails
doesn't print any error message. We should do that instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNodeParseNode: Propagate host architecture
Michal Privoznik [Tue, 17 Jun 2014 11:58:48 +0000 (13:58 +0200)]
virNodeParseNode: Propagate host architecture

As in previous commit, there are again some places where we can do
runtime decision instead of compile time. This time it's whether the
'topology/physical_package_id' is allowed to have '-1' within or not.
Then, core ID is pared differently on s390(x) than on the rest of
architectures.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonodeinfo: Introduce @arch to linuxNodeInfoCPUPopulate
Michal Privoznik [Tue, 17 Jun 2014 10:25:23 +0000 (12:25 +0200)]
nodeinfo: Introduce @arch to linuxNodeInfoCPUPopulate

So far, we are doing compile time decisions on which architecture is
used. However, for testing purposes it's much easier if we pass host
architecture as parameter and then let the function decide which code
snippet for extracting host CPU info will be used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agointerface: clean up virInterfaceDefDevFormat
Laine Stump [Thu, 19 Jun 2014 09:58:56 +0000 (12:58 +0300)]
interface: clean up virInterfaceDefDevFormat

This modifies the formatting function of virInterface to be a proper
mirror of the parse function, including the addition of a
"parentIfType" arg so that we can decide whether or not it is
appropriate to emit the elements that are only in toplevel interfaces,
as well as the <link> element (which isn't allowed for bridge
interfaces).

Since the restructuring of the code necessarily changes the order of
some of the elements, some test case data had to be updated.

10 years agointerface: clean up virInterfaceDefParseXML
Laine Stump [Thu, 19 Jun 2014 09:51:38 +0000 (12:51 +0300)]
interface: clean up virInterfaceDefParseXML

the switch cases for the 4 different interface types had repetitive
code which has now been pulled out as common. While touching those
lines, some extra usage of "!= NULL" etc has been eliminated to make
things more compact and inline with current coding practices.

NB: parentIfType == VIR_INTERFACE_TYPE_LAST means that this is a
toplevel interface (not a subordinate of a bridge or bond). Only
toplevel interfaces can have a start mode, mtu, or IP address element.

10 years agointerface: move parsing of bridge attributes into appropriate function
Laine Stump [Thu, 19 Jun 2014 09:47:26 +0000 (12:47 +0300)]
interface: move parsing of bridge attributes into appropriate function

For some reason the bridge stp mode and delay were put directly into
the "bridge" case of the switch in virInterfaceDefParseXML(), although
they are inside the <bridge> element, and so should be parsed in the
function created for that purpose - virInterfaceBridgeDefFormat().

10 years agointerface: report link state for bonds and vlans too
Laine Stump [Fri, 13 Jun 2014 14:07:05 +0000 (17:07 +0300)]
interface: report link state for bonds and vlans too

The interface state for bonds and vlans does seem to reflect the state
of the underlying physical devices, at least in some cases, so it
makes sense to allow reporting it (netcf now does).

The link state/speed for bridge devices is meaningless though, so we
don't even look for it.

10 years agosecurity: Rename virSecurityManagerSetImageLabel to *Disk*
Peter Krempa [Wed, 18 Jun 2014 12:46:27 +0000 (14:46 +0200)]
security: Rename virSecurityManagerSetImageLabel to *Disk*

I'm going to add functions that will deal with individual image files
rather than whole disks. Rename the security function to make room for
the new one.

10 years agosecurity: Sanitize type of @migrated in virSecurityManagerRestoreAllLabel
Peter Krempa [Wed, 18 Jun 2014 16:54:48 +0000 (18:54 +0200)]
security: Sanitize type of @migrated in virSecurityManagerRestoreAllLabel

Also remove one spurious ATTRIBUTE_UNUSED guarding the @migrated
argument.

10 years agoutil: Don't require full disk definition when getting imagelabels
Peter Krempa [Wed, 18 Jun 2014 16:39:47 +0000 (18:39 +0200)]
util: Don't require full disk definition when getting imagelabels

The image labels are stored in the virStorageSource struct. Convert the
virDomainDiskDefGetSecurityLabelDef helper not to use the full disk def
and move it appropriately.

10 years agoutil: storagefile: Introduce helper to free storage source perms
Peter Krempa [Thu, 12 Jun 2014 14:11:43 +0000 (16:11 +0200)]
util: storagefile: Introduce helper to free storage source perms

It will also be reused later.

10 years agoutil: seclabel: Add deep copy function for device labels
Peter Krempa [Thu, 12 Jun 2014 14:03:06 +0000 (16:03 +0200)]
util: seclabel: Add deep copy function for device labels

10 years agostorage: encryption: Add deep copy function for storage encryption
Peter Krempa [Thu, 12 Jun 2014 13:26:18 +0000 (15:26 +0200)]
storage: encryption: Add deep copy function for storage encryption

10 years agolibxl: limit support for specifying an interface script
Jim Fehlig [Tue, 10 Jun 2014 20:53:55 +0000 (14:53 -0600)]
libxl: limit support for specifying an interface script

Generally, <interface> ... <script> is only supported for
type='ethernet'.  Due to the long and pervasive use of

  <interface type='bridge'>
    ...
    <script path='foo'/>
  </interface>

in Xen domain configuration, it was agreed to allow the use
of <script> with type='bridge' for backwards compatibility.  See
the following discussion thread

http://www.redhat.com/archives/libvir-list/2013-April/msg00755.html

This patch limits the use of <script> to interface types ethernet
and bridge, raising an unsupported config error if <script> is
specified for all other interface types.

While at it, use VIR_ERR_CONFIG_UNSUPPORTED instead of
VIR_ERR_INTERNAL_ERROR when reporting unsupported interface types.

10 years agolibxl: support interface type=network
Jim Fehlig [Tue, 10 Jun 2014 20:28:07 +0000 (14:28 -0600)]
libxl: support interface type=network

Add support for <interface type='network'> in the libxl driver.

10 years agovirsh: fix broken code in freepages
Eric Blake [Thu, 19 Jun 2014 15:21:08 +0000 (09:21 -0600)]
virsh: fix broken code in freepages

Commit 9e3efe53 broke the build under valgrind or clang, by writing
8 bytes through an allocation of 4 bytes.  It also risks multiplication
overflow when mallocing (that's a pervasive problem that needs an
audit in the rest of the code, but we might as well fix this one while
we are here), and had a typo.

* tools/virsh-host.c (cmdFreepages): Avoid integer overflow and
undefined behavior.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agointerface: allow reordering of elements in xml
Laine Stump [Thu, 19 Jun 2014 10:48:31 +0000 (13:48 +0300)]
interface: allow reordering of elements in xml

The interface xml schema was written with strict rules about the
ordering of the elements. This was never intentional, but just due to
omission of <interleave> in the appropriate places. This patch just
adds in <interleave> wherever there is more than one element, and
re-indents everything else appropriately.

10 years agodocs: fix some typos in formatdomain.html
Jincheng Miao [Thu, 19 Jun 2014 09:45:13 +0000 (17:45 +0800)]
docs: fix some typos in formatdomain.html

In section "Block / character devices" of "Host device assignment",
the description of hostdev element has some error:

For a block device, the type should be "storage", not "block";
For a character device, the type should be "misc", not "char".

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
10 years agonodeinfo: Implement nodeGetFreePages
Michal Privoznik [Tue, 10 Jun 2014 14:16:44 +0000 (16:16 +0200)]
nodeinfo: Implement nodeGetFreePages

And add stubs to other drivers like: lxc, qemu, uml and vbox.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh: Expose virNodeGetFreePages
Michal Privoznik [Mon, 9 Jun 2014 15:56:43 +0000 (17:56 +0200)]
virsh: Expose virNodeGetFreePages

The new API is exposed under 'freepages' command.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce virNodeGetFreePages
Michal Privoznik [Mon, 9 Jun 2014 15:14:47 +0000 (17:14 +0200)]
Introduce virNodeGetFreePages

The aim of the API is to get information on number of free pages
on the system. The API behaves similar to the
virNodeGetCellsFreeMemory(). User passes starting NUMA cell, the
count of nodes that he's interested in, pages sizes (yes,
multiple sizes can be queried at once) and the counts are
returned in an array.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirCaps: expose pages info
Michal Privoznik [Fri, 6 Jun 2014 16:12:51 +0000 (18:12 +0200)]
virCaps: expose pages info

There are two places where you'll find info on page sizes. The first
one is under <cpu/> element, where all supported pages sizes are
listed. Then the second one is under each <cell/> element which refers
to concrete NUMA node. At this place, the size of page's pool is
reported. So the capabilities XML looks something like this:

<capabilities>

  <host>
    <uuid>01281cda-f352-cb11-a9db-e905fe22010c</uuid>
    <cpu>
      <arch>x86_64</arch>
      <model>Westmere</model>
      <vendor>Intel</vendor>
      <topology sockets='1' cores='1' threads='1'/>
      ...
      <pages unit='KiB' size='4'/>
      <pages unit='KiB' size='2048'/>
      <pages unit='KiB' size='1048576'/>
    </cpu>
    ...
    <topology>
      <cells num='4'>
        <cell id='0'>
          <memory unit='KiB'>4054408</memory>
          <pages unit='KiB' size='4'>1013602</pages>
          <pages unit='KiB' size='2048'>3</pages>
          <pages unit='KiB' size='1048576'>1</pages>
          <distances/>
          <cpus num='1'>
            <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
          </cpus>
        </cell>
        <cell id='1'>
          <memory unit='KiB'>4071072</memory>
          <pages unit='KiB' size='4'>1017768</pages>
          <pages unit='KiB' size='2048'>3</pages>
          <pages unit='KiB' size='1048576'>1</pages>
          <distances/>
          <cpus num='1'>
            <cpu id='1' socket_id='0' core_id='0' siblings='1'/>
          </cpus>
        </cell>
        ...
      </cells>
    </topology>
    ...
  </host>

  <guest/>

</capabilities>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnuma: Introduce pages helpers
Michal Privoznik [Fri, 6 Jun 2014 16:09:01 +0000 (18:09 +0200)]
virnuma: Introduce pages helpers

For future work we need two functions that fetches total number of
pages and number of free pages for given NUMA node and page size
(virNumaGetPageInfo()).

Then we need to learn pages of what sizes are supported on given node
(virNumaGetPages()).

Note that system page size is disabled at the moment as there's one
issue connected. If you have a NUMA node with huge pages allocated the
kernel would return the normal size of memory for that node. It
basically ignores the fact that huge pages steal size from the system
memory. Until we resolve this, it's safer to not confuse users and
hence not report any system pages yet.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonodeinfo: Rename nodeGetFreeMemory to nodeGetMemory
Michal Privoznik [Mon, 16 Jun 2014 12:02:34 +0000 (14:02 +0200)]
nodeinfo: Rename nodeGetFreeMemory to nodeGetMemory

For future work we want to get info for not only the free memory
but overall memory size too. That's why the function must have
new signature too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnuma: Introduce virNumaNodeIsAvailable
Michal Privoznik [Mon, 16 Jun 2014 12:29:15 +0000 (14:29 +0200)]
virnuma: Introduce virNumaNodeIsAvailable

Not on all hosts the set of NUMA nodes IDs is continuous. This is
critical, because our code currently assumes the set doesn't contain
holes. For instance in nodeGetFreeMemory() we can see the following
pattern:

    if ((max_node = virNumaGetMaxNode()) < 0)
        return 0;

    for (n = 0; n <= max_node; n++) {
        ...
    }

while it should be something like this:

    if ((max_node = virNumaGetMaxNode()) < 0)
        return 0;

    for (n = 0; n <= max_node; n++) {
        if (!virNumaNodeIsAvailable(n))
            continue;
        ...
    }

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh: expose new active commit controls
Eric Blake [Wed, 21 May 2014 04:11:29 +0000 (22:11 -0600)]
virsh: expose new active commit controls

Add knobs to virsh to manage a 2-phase active commit of the top
layer, similar to knobs already present on blockcopy.  While this
code will fail until later patches actually implement the new
knobs in the qemu driver, doing it now proves that the API is
usable and also makes it easier for testing the qemu changes as
they are made.

* tools/virsh-domain.c (cmdBlockCommit): Add --active, --pivot,
and --keep-overlay options, modeled after blockcopy.
(blockJobImpl): Support --active flag.
* tools/virsh.pod (blockcommit): Document new flags.
(blockjob): Mention 2-phase commit interaction.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoblockjob: use stable disk string in job event
Eric Blake [Sat, 14 Jun 2014 13:18:04 +0000 (07:18 -0600)]
blockjob: use stable disk string in job event

When the block job event was first added, it was for block pull,
where the active layer of the disk remains the same name.  It was
also in a day where we only cared about local files, and so we
always had a canonical absolute file name.  But two things have
changed since then: we now have network disks, where determining
a single absolute string does not really make sense; and we have
two-phase jobs (copy and active commit) where the name of the
active layer changes between the first event (ready, on the old
name) and second (complete, on the pivoted name).

Adam Litke reported that having an unstable string between events
makes life harder for clients.  Furthermore, all of our API that
operate on a particular disk of a domain accept multiple strings:
not only the absolute name of the active layer, but also the
destination device name (such as 'vda').  As this latter name is
stable, even for network sources, it serves as a better string
to supply in block job events.

But backwards-compatibility demands that we should not change the
name handed to users unless they explicitly request it.  Therefore,
this patch adds a new event, BLOCK_JOB_2 (alas, I couldn't think of
any nicer name - but at least Migrate2 and Migrate3 are precedent
for a number suffix).  We must double up on emitting both old-style
and new-style events according to what clients have registered for
(see also how IOError and IOErrorReason emits double events, but
there the difference was a larger struct rather than changed
meaning of one of the struct members).

Unfortunately, adding a new event isn't something that can easily
be broken into pieces, so the commit is rather large.

* include/libvirt/libvirt.h.in (virDomainEventID): Add a new id
for VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2.
(virConnectDomainEventBlockJobCallback): Document new semantics.
* src/conf/domain_event.c (_virDomainEventBlockJob): Rename field,
to ensure we catch all clients.
(virDomainEventBlockJobNew): Add parameter.
(virDomainEventBlockJobDispose)
(virDomainEventBlockJobNewFromObj)
(virDomainEventBlockJobNewFromDom)
(virDomainEventDispatchDefaultFunc): Adjust clients.
(virDomainEventBlockJob2NewFromObj)
(virDomainEventBlockJob2NewFromDom): New functions.
* src/conf/domain_event.h: Add new prototypes.
* src/libvirt_private.syms (domain_event.h): Export new functions.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Generate two
different events.
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Likewise.
* src/remote/remote_protocol.x
(remote_domain_event_block_job_2_msg): New struct.
(REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB_2): New RPC.
* src/remote/remote_driver.c
(remoteDomainBuildEventBlockJob2): New handler.
(remoteEvents): Register new event.
* daemon/remote.c (remoteRelayDomainEventBlockJob2): New handler.
(domainEventCallbacks): Register new event.
* tools/virsh-domain.c (vshEventCallbacks): Likewise.
(vshEventBlockJobPrint): Adjust client.
* src/remote_protocol-structs: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoFix xmconfigtest
Jim Fehlig [Thu, 19 Jun 2014 05:47:41 +0000 (23:47 -0600)]
Fix xmconfigtest

Commit ac63014c introduced a regression in the conversion of Xen
xm config to XML by emitting an empty <cmdline>.  Prior to this
commit, <cmdline> was omitted if the xm config was missing (or
contained an empty) 'extra='.

10 years agoxen: handle root= in xen-xm configuration files.
Ian Campbell [Wed, 18 Jun 2014 08:58:45 +0000 (09:58 +0100)]
xen: handle root= in xen-xm configuration files.

In addition to extra= xm supported a root= option which was supposed
to be incorporated into the final command line. Handle that for "virsh
domxml-from-native xen-xm". Tested with the libxl backend.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
10 years agovbox_snapshot_conf: fix wrong use of 'xmlSaveFormatFileEnc'
Pavel Hrdina [Wed, 18 Jun 2014 12:13:26 +0000 (14:13 +0200)]
vbox_snapshot_conf: fix wrong use of 'xmlSaveFormatFileEnc'

The function 'xmlSaveFormatFileEnc' has a last option to set
if you want to format dumped xml with whitespaces or not.

Older libxml2, the one used in RHEL6, take this option as it is
but newer libxml2 check this option if it's true or not. This
small difference somehow makes things messy on RHEL6 and generated
xml had extra new line and extra whitespaces.

We should pass 1 instead if -1 because the -1 confuses the libxml2.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agotests: fix vbox snapshot xmls
Pavel Hrdina [Tue, 17 Jun 2014 16:27:37 +0000 (18:27 +0200)]
tests: fix vbox snapshot xmls

On RHEL6 the vboxsnapshotxmltest fails because of wrong xml that
is generated by libvirt. However the core issue is in the xml data
itself with the wrong indentation.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agovirsh: man: Correctly spell QEMU
Peter Krempa [Wed, 18 Jun 2014 09:19:12 +0000 (11:19 +0200)]
virsh: man: Correctly spell QEMU

s/QEemu/QEMU/g

10 years agovirsh: man: Fix examples and docs for virsh version
Peter Krempa [Wed, 18 Jun 2014 09:16:33 +0000 (11:16 +0200)]
virsh: man: Fix examples and docs for virsh version

The version command now takes the --daemon parameter for a while and the
output example was pretty outdated.

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

10 years agovirt-aa-helper: allow access to /dev/vhost-net if needed
Serge Hallyn [Wed, 18 Jun 2014 03:20:59 +0000 (03:20 +0000)]
virt-aa-helper: allow access to /dev/vhost-net if needed

Only allow the access if it is a KVM domain which has a NIC which wants
non-userspace networking.

This addresses https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1322568

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoAdded example script on how to convert LXC container config
Cédric Bosdonnat [Tue, 17 Jun 2014 07:26:22 +0000 (09:26 +0200)]
Added example script on how to convert LXC container config

10 years agovbox: fix a segfault when taking a snapshot
Yohan BELLEGUIC [Tue, 17 Jun 2014 08:28:41 +0000 (10:28 +0200)]
vbox: fix a segfault when taking a snapshot

there is a segfault in the vbox driver when taking a snapshot in the
following functions:
- vboxDomainGetXMLDesc
- vboxSnapshotGetReadWriteDisks
- vboxSnapshotGetReadOnlyDisks

The virStorageSourcePtr in virDomainDiskDef was not correctly allocated.

(The problem stems from the fact that commit 4dc5d8f and commit bc3f5f1
were written in one order but applied in another; so each tested in
isolation passed, but the combination introduces the problem due to
changed semantics).

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agovbox: snapshot: Avoid memleaks in functions dealing with disk arrays
Peter Krempa [Tue, 17 Jun 2014 09:09:29 +0000 (11:09 +0200)]
vbox: snapshot: Avoid memleaks in functions dealing with disk arrays

In virVBoxSnapshotConfRemoveFakeDisks and
virVBoxSnapshotConfDiskIsInMediaRegistry the disk array constructed from
all the disks would be leaked at the end of the function and on
allocation errors. Also the temporary disk list would be leaked.

Add a cleanup section and free the memory properly.

Found by coverity.

10 years agovbox: snapshot: Avoid memleak in virVBoxSnapshotConfAllChildren
Peter Krempa [Tue, 17 Jun 2014 09:02:54 +0000 (11:02 +0200)]
vbox: snapshot: Avoid memleak in virVBoxSnapshotConfAllChildren

On re-allocation failure the function would leak already allocated
memory.

10 years agouuid: Fix coverity warning of unchecked return value
Peter Krempa [Wed, 11 Jun 2014 09:40:44 +0000 (11:40 +0200)]
uuid: Fix coverity warning of unchecked return value

Coverity checks for patterns of handling return values of functions.
Some recent addition must have tripped a threshold where coverity now
complains that we usually check the return value of virUUIDGenerate but
don't do it in one place. Add a check to make coverity happy.

10 years agonetwork: bridge: Avoid freeing uninitialized pointer on cleanup path
Peter Krempa [Tue, 17 Jun 2014 08:03:53 +0000 (10:03 +0200)]
network: bridge: Avoid freeing uninitialized pointer on cleanup path

The cleanup path in networkBuildDhcpDaemonCommandLine could cause a
crash by freeing uninitialized pointer.

10 years agonet: leaseshelper: Refactor copying of old entries to avoid double free
Peter Krempa [Mon, 16 Jun 2014 15:18:07 +0000 (17:18 +0200)]
net: leaseshelper: Refactor copying of old entries to avoid double free

When copying entries from the old lease file into the new array the old
code would copy the pointer of the json object into the second array
without removing it from the first. Afterwards when both arrays were
freed this might lead to a crash due to access of already freed memory.

Refactor the code to use the new array item stealing helper added to the
json code so that the entry resides just in one array.

10 years agonet: leaseshelper: Ignore corrupted lease file and rewrite it
Peter Krempa [Mon, 16 Jun 2014 14:53:42 +0000 (16:53 +0200)]
net: leaseshelper: Ignore corrupted lease file and rewrite it

Instead of reporting an error and terminating, rewrite the file with
the newly learned info.

10 years agonet: leaseshelper: Don't crash if DNSMASQ doesn't provide lease expiry
Peter Krempa [Mon, 16 Jun 2014 14:03:01 +0000 (16:03 +0200)]
net: leaseshelper: Don't crash if DNSMASQ doesn't provide lease expiry

The value is provided via environment and causes a crash if not defined.

10 years agoutil: json: Add helpers for manipulating json arrays
Peter Krempa [Mon, 16 Jun 2014 13:48:11 +0000 (15:48 +0200)]
util: json: Add helpers for manipulating json arrays

Add a checker to determine whether a JSON object is an array and a
helper to steal objects from a JSON array.

10 years agoutil: json: Unify function header formatting
Peter Krempa [Mon, 16 Jun 2014 13:24:26 +0000 (15:24 +0200)]
util: json: Unify function header formatting

Use consistent formatting of function headers:
- two newlines separating functions
- function return type on separate line
- one argument per line

10 years agoblockjob: don't remove older-style mirror XML
Eric Blake [Mon, 16 Jun 2014 19:34:36 +0000 (13:34 -0600)]
blockjob: don't remove older-style mirror XML

Commit 7c6fc39 introduced a regression in the XML produced for older
clients.  The argument at the time was that clients shouldn't be
depending on output-only data for something that is only going to
be triggered for a transient guest; but John Ferlan reported that
the automated testsuite was such a client.  It's better to be safe
than sorry by guaranteeing back-compat cruft.  Note that later
patches will be using <mirror> for active block commit, but there
we don't have to worry about back-compat.

* src/conf/domain_conf.c (virDomainDiskDefFormat): Restore old
style output when necessary.
* docs/schemas/domaincommon.rng: Validate back-compat style.
* docs/formatdomain.html.in: Update the documentation.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml:
Update tests.
* tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoblockjob: avoid compiler uncertainty in info sizing
Eric Blake [Sat, 14 Jun 2014 12:42:41 +0000 (06:42 -0600)]
blockjob: avoid compiler uncertainty in info sizing

We have a policy of avoiding enum types in structs in our public
API, because it is possible for a client to choose compiler options
that can change the in-memory ABI of that struct based on whether
the enum value occupies an int or a minimal size.  But we missed
this for virDomainBlockJobInfo.  We got lucky on little-endian
machines - if the enum fits minimal size (a char), we still end
up padding to the next long before the next field; but on
big-endian, a client interpreting the enum as a char would always
see 0 when the server supplies contents as an int.

* include/libvirt/libvirt.h.in (virDomainBlockJobInfo): Enforce
particular sizing.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoblockjob: document recent job addition
Eric Blake [Sat, 14 Jun 2014 12:42:41 +0000 (06:42 -0600)]
blockjob: document recent job addition

I noticed that the web page lacked documentation on block jobs:
http://libvirt.org/html/libvirt-libvirt.html#virDomainBlockJobType
not only for the recently added active commit, but also for all
the other job types.

* include/libvirt/libvirt.h.in (virDomainBlockJobType): Document
recent addition.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoIncrease the size of REMOTE_MIGRATE_COOKIE_MAX to REMOTE_STRING_MAX
Shivaprasad G Bhat [Wed, 28 May 2014 12:42:55 +0000 (08:42 -0400)]
Increase the size of REMOTE_MIGRATE_COOKIE_MAX to REMOTE_STRING_MAX

During guest migration, if the domain xml is bigger than 16384 which is
easily possible for a guest with good number of disks, message encode fails
for xdr_remote_domain_migrate_perform3_ret().
So, Increase the COOKIE_MAX to STRING_MAX value.

Signed-off-by: Shivaprasad G Bhat <shivaprasadbhat@gmail.com>
10 years agonodedev: Introduce <pci-express/> to PCI devices
Michal Privoznik [Thu, 15 May 2014 08:13:45 +0000 (10:13 +0200)]
nodedev: Introduce <pci-express/> to PCI devices

This new element is there to represent PCI-Express capabilities
of a PCI devices, like link speed, number of lanes, etc.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirpci: Introduce virPCIDeviceIsPCIExpress and friends
Michal Privoznik [Thu, 15 May 2014 08:04:28 +0000 (10:04 +0200)]
virpci: Introduce virPCIDeviceIsPCIExpress and friends

These functions will handle PCIe devices and their link capabilities
to query some info about it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoblockcommit: require base below top
Eric Blake [Wed, 11 Jun 2014 22:22:57 +0000 (16:22 -0600)]
blockcommit: require base below top

The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
  base <- snap1 <- snap2 <- snap3
and a command of:
  virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'

Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'

But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
  virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found

Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point.  The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.

This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.

* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agostorage: better tests of lookup
Eric Blake [Fri, 13 Jun 2014 15:23:10 +0000 (09:23 -0600)]
storage: better tests of lookup

Add some more tests of what happens when we restrict a lookup
to begin at a point in the middle of a chain.  In particular,
we want to ensure that a parent is not found when starting at
the child.  This commit also demonstrates that we have a slight
difference in behavior on what parent we report when filtering
is in effect; as the determination of the parent affects the
code in block commit, exposing this in the testsuite will help
justify changes in future patches that tweak the semantics of
what lookups are allowed.

* tests/virstoragetest.c (testStorageLookup): Test user input.
(TEST_LOOKUP_TARGET): Add parameter.
(mymain): Add lookup tests.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agostorage: renumber lookup tests
Eric Blake [Fri, 13 Jun 2014 16:01:14 +0000 (10:01 -0600)]
storage: renumber lookup tests

The next patch will be adding tests, including adding a parameter
for testing more conditions.  For ease of review of that patch, I
want to create common context lines that don't change when the new
tests are added (it's easier to visually review additions than it
is to review an entire chunk of tests rewritten into another
larger chunk of tests).

* tests/virstoragetest.c (mymain): Add a parameter and renumber
the lookup tests.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agostorage: add alias for less typing
Eric Blake [Fri, 13 Jun 2014 14:44:09 +0000 (08:44 -0600)]
storage: add alias for less typing

Typing chain->backingStore->backingStore gets old after a while;
introduce some alias variables to make the test more compact.

* tests/virstoragetest.c (mymain): Introduce some shorthand.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: snapshot: Don't mark all block disks for metadata reuse
Peter Krempa [Mon, 16 Jun 2014 12:05:07 +0000 (14:05 +0200)]
qemu: snapshot: Don't mark all block disks for metadata reuse

For block devices used as snapshot source the new snapshot code would
set the reuse flag. This inhibits to take snapshot without specially
preparing the block image before taking the snapshot.

Fortunately this is not a regression as only the new way of specifying
snapshot source is affected.

For the followin snapshot XML:
 <domainsnapshot>
   <disks>
     <disk name='vda' type='block'>
       <driver type='qcow2'/>
       <source dev="/dev/andariel/testsnap" />
     </disk>
   </disks>
 </domainsnapshot>

You'd get:
error: internal error: unable to execute QEMU command 'transaction': Image is not in qcow2 format

After this patch the snapshot is created successfully.

10 years agoleaseshelper: fix another crash
Pavel Hrdina [Mon, 16 Jun 2014 12:16:22 +0000 (14:16 +0200)]
leaseshelper: fix another crash

We create a 'lease_new' when we are adding new lease entry, then later
in the code we add the 'lease_new' into a 'leases_array_new' which
leads into the crash because we double free the 'lease_new'.

To prevent the double free we set the 'lease_new' to NULL after
successful append into the 'leases_array_new'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agobhyve: silent destroy command errors on cleanup
Roman Bogorodskiy [Fri, 13 Jun 2014 18:51:18 +0000 (22:51 +0400)]
bhyve: silent destroy command errors on cleanup

When virBhyveProcessStart() fails, it tries to unload
a guest that could have been already loaded using
bhyveload(8) to make sure not to leave it hanging in memory.

However, we could fail before loading a VM into memory,
so 'bhyvectl --destroy' command will fail and print
an error message that looks confusing to users.

So ignore errors when running this in cleanup.

10 years agobhyve: do not cleanup unallocated networks on fail
Roman Bogorodskiy [Fri, 13 Jun 2014 14:56:59 +0000 (18:56 +0400)]
bhyve: do not cleanup unallocated networks on fail

virBhyveProcessStart() calls bhyveNetCleanup() if it fails. However,
it might fail earlier than networks are allocated, so modify
bhyveNetCleanup() to check if net->ifname is not NULL before
going further with the cleanup.

10 years agobhyve: fix crash in bhyveBuildNetArgStr
Roman Bogorodskiy [Fri, 13 Jun 2014 16:14:53 +0000 (20:14 +0400)]
bhyve: fix crash in bhyveBuildNetArgStr

bhyveBuildNetArgStr() calls virNetDevTapCreateInBridgePort() and
passes tapfd = NULL, but tapfdSize = 1. That is wrong, because
if virNetDevTapCreateInBridgePort() crashes after successfully
creating a TAP device, it'll jump to 'error' label, that
loops over tapfd and calls VIR_FORCE_CLOSE:

   for (i = 0; i < tapfdSize && tapfd[i] >= 0; i++)

In that case we get a segfault.

As the bhyve code doesn't use tapfd, pass NULL and set tapfdSize to 0.

10 years agostorage: report VIR_ERR_NO_STORAGE_VOL when the file doesn't exist
Giuseppe Scrivano [Fri, 13 Jun 2014 14:48:15 +0000 (16:48 +0200)]
storage: report VIR_ERR_NO_STORAGE_VOL when the file doesn't exist

Report VIR_ERR_NO_STORAGE_VOL instead of a system error when lstat
fails because the file doesn't exist.

Fixes this problem in virt-install:

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
10 years agobhyve: implement PCI address allocation
Roman Bogorodskiy [Sat, 12 Apr 2014 19:37:53 +0000 (23:37 +0400)]
bhyve: implement PCI address allocation

Automatically allocate PCI addresses for devices instead
of hardcoding them in the driver code. The current
allocation schema is to dedicate an entire slot for each devices.

Also, allow having arbitrary number of devices.

10 years agovirNetDevGetLinkInfo: Don't report link speed if NIC's not up
Michal Privoznik [Fri, 13 Jun 2014 09:29:48 +0000 (11:29 +0200)]
virNetDevGetLinkInfo: Don't report link speed if NIC's not up

The kernel's more broken than one would think. Various drivers report
various (usually spurious) values if the interface is in other state
than 'up' . While on some we experience -EINVAL when read()-ing the
speed sysfs file, with other drivers we might get anything from 0 to
UINT_MAX. If that's the case it's better to not report link speed.
Well, the interface is not up anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agotests: virstoragetest: Fix output when hitting errors
Peter Krempa [Mon, 26 May 2014 14:39:38 +0000 (16:39 +0200)]
tests: virstoragetest: Fix output when hitting errors

When the test is failing but the debug output isn't enabled the
resulting line would look ugly like and would not contain the actual
difference.

TEST: virstoragetest
      .................chain member 1!chain member 1!chain member 1!

Store the member index in the actual checked string to hide this problem

10 years agoblockcommit: update error messages related to block jobs
Eric Blake [Tue, 3 Jun 2014 22:33:33 +0000 (16:33 -0600)]
blockcommit: update error messages related to block jobs

A future patch will add two-phase block commit jobs; as the
mechanism for managing them is similar to managing a block copy
job, existing errors should be made generic enough to occur
for either job type.

* src/conf/domain_conf.c (virDomainHasDiskMirror): Update
comment.
* src/qemu/qemu_driver.c (qemuDomainDefineXML)
(qemuDomainSnapshotCreateXML, qemuDomainRevertToSnapshot)
(qemuDomainBlockJobImpl, qemuDomainBlockCopy): Update error
message.
* src/qemu/qemu_hotplug.c (qemuDomainDetachDiskDevice): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agovirsh: improve blockcopy UI
Eric Blake [Wed, 11 Jun 2014 15:36:49 +0000 (09:36 -0600)]
virsh: improve blockcopy UI

Peter's review of an early version of my addition of active block
commit pointed out some issues that I was copying from the block
copy code; fix them up now before perpetuating them.

For virsh commands that manage a single API call, it's nice to have
a 1:1 mapping of options to flags, so that we can test that
lower-layer software handles flag combinations correctly.  But where
virsh is introducing syntactic sugar to combine multiple API calls
into a single user interface, we might as well make that interface
compact.  That is, we should allow the shorter command-line of
'blockcopy $dom $disk --pivot' without having to explicitly specify
--wait, because this isn't directly a flag passed to a single
underlying API call.

Also, my use of embedded ?: ternaries bordered on unreadable.

* tools/virsh-domain.c (cmdBlockCopy): Make --pivot, --finish,
and --timeout imply --wait. Drop excess ?: operators.
* tools/virsh.pod (blockcopy): Update documentation.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agovirNodeDevCapPCIDevParseXML: Initialize numa_node variable
Michal Privoznik [Thu, 12 Jun 2014 09:14:20 +0000 (11:14 +0200)]
virNodeDevCapPCIDevParseXML: Initialize numa_node variable

With one of my recent patches (1c70277) libvirt's capable of
reporting NUMA node locality for PCI devices. The node ID is
stored in pci_dev.numa_node variable. However, since zero is
valid NUMA node ID, the default is -1 as it is in kernel too.
So, if the PCI device is not tied to any specific NUMA node, the
default is then NOT printed into XML. Therefore, when parsing
node device XML, the <node/> element is optional. But currently,
if it's not there, we must set sane default, otherwise after
parsing in the memory representation doesn't match the XML. We
are already doing this in other place: udevProcessPCI().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoblockcommit: fix regression with explicit top argument
Eric Blake [Wed, 11 Jun 2014 22:22:57 +0000 (16:22 -0600)]
blockcommit: fix regression with explicit top argument

Commit f586965 accidentally changed the semantics of the
virDomainBlockCommit command; where it previously looked for
an explicit top argument from the top of the chain, it now
starts from the backing file of the top.  Of course, until
we allow active commits, the only difference it makes is in
the quality of the error message, but with code for active
commit coming soon, we need to support an explicit mention
of the active layer.

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Start looking
from top of chain.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agovirsh: forbid negative vcpu argument to vcpupin
Jincheng Miao [Thu, 29 May 2014 03:34:40 +0000 (11:34 +0800)]
virsh: forbid negative vcpu argument to vcpupin

The vcpupin command allowed specifying a negative number for the --vcpu
argument. This would the overflow when the underlying virDomainPinVcpu
API was called.

 $ virsh vcpupin r7 -1 0
 error: numerical overflow: input too large: 4294967295

Switch the vCPU variable to a unsigned int and parse it using the
corresponding function.

Also improve the vcpupin test to cover all the defects.

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

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agovirsh: Reject negative numbers in vshCommandOptULongLong
Peter Krempa [Wed, 4 Jun 2014 09:08:08 +0000 (11:08 +0200)]
virsh: Reject negative numbers in vshCommandOptULongLong

To follow the new semantics of the vshCommandOptToU* functions convert
this one to reject negative numbers too. To allow using -1 for "maximum"
semantics for the vol-*load two bandwidth functions that use this helper
introduce vshCommandOptULongLongWrap.

10 years agovirsh: Reject negative numbers in vshCommandOptUL
Peter Krempa [Wed, 4 Jun 2014 09:08:08 +0000 (11:08 +0200)]
virsh: Reject negative numbers in vshCommandOptUL

To follow the new semantics of the vshCommandOptToU* functions convert
this one to reject negative numbers too. To allow using -1 for "maximum"
semantics for the two bandwidth functions that use this helper introduce
vshCommandOptULWrap. Although currently the migrate-setspeed function
for the qemu driver will reject -1 as maximum.

10 years agovirsh: Reject negative numbers in vshCommandOptUInt
Peter Krempa [Thu, 29 May 2014 11:12:26 +0000 (13:12 +0200)]
virsh: Reject negative numbers in vshCommandOptUInt

Use virStrToLong_uip instead of virStrToLong_ui to reject negative
numbers in the helper. None of the callers expects the wraparound
"feature" for negative numbers.

Also add a function that allows wrapping of negative numbers as it might
be used in the future and be explicit about the new semantics in the
function docs.

10 years agoFix crash when saving a domain with type none dac label
Ján Tomko [Thu, 12 Jun 2014 08:50:43 +0000 (10:50 +0200)]
Fix crash when saving a domain with type none dac label

qemuDomainGetImageIds did not check if there was a label
in the seclabel, thus crashing on
<seclabel type='none' model='dac'/>

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

10 years agovbox_snapshot_conf: Resolve Coverity warnings
John Ferlan [Wed, 11 Jun 2014 13:16:55 +0000 (09:16 -0400)]
vbox_snapshot_conf: Resolve Coverity warnings

Clean up some Coverity warnings from commit id '4dc5d8f1'

10 years agovbox_temp: Resolve Coverity warnings
John Ferlan [Wed, 11 Jun 2014 13:14:50 +0000 (09:14 -0400)]
vbox_temp: Resolve Coverity warnings

Clean up code to resolve Coverity RESOURCE_LEAK's from commit id's
'632b9600' and 'b739f807'.

10 years agosecurity: Don't skip labelling for network disks
Peter Krempa [Thu, 5 Jun 2014 13:56:33 +0000 (15:56 +0200)]
security: Don't skip labelling for network disks

A network disk might actually be backed by local storage. Also the path
iterator actually handles networked disks well now so remove the code
that skips the labelling in dac and selinux security driver.