]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
10 years agonet: merge virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC
Peter Krempa [Thu, 26 Jun 2014 14:08:34 +0000 (16:08 +0200)]
net: merge virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC

Instead of maintaining two very similar APIs, add the "@mac" parameter
to virNetworkGetDHCPLeases and kill virNetworkGetDHCPLeasesForMAC. Both
of those functions would return data the same way, so making @mac an
optional filter simplifies a lot of stuff.

10 years agoAdd test for type none model dac seclabel
Ján Tomko [Tue, 10 Jun 2014 08:19:40 +0000 (10:19 +0200)]
Add test for type none model dac seclabel

10 years agotest: add user_xattr check for securityselinuxlabeltest
Jincheng Miao [Mon, 9 Jun 2014 11:36:07 +0000 (19:36 +0800)]
test: add user_xattr check for securityselinuxlabeltest

libvirt unit test used setxattr with "user.libvirt.selinux" name to
emulate setfilecon of selinux. But for some old kernel filesystem
(like 2.6.32-431.el6.x86_64), if the filesystem is not mounted with
user_xattr flag, the setxattr with "user.libvirt.selinux" will fail.

So adding testUserXattrEnabled() in securityselinuxlabeltest.c,
if user_xattr is not enabled, skip this case.

The user_xattr is departed in newer kernel, therefore this commit is
only for the compatablity for old kernel.

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Tested-by: Scott Sullivan <ssullivan@liquidweb.com>
10 years agodocs: publish correct enum values
Eric Blake [Wed, 25 Jun 2014 20:54:36 +0000 (14:54 -0600)]
docs: publish correct enum values

We publish libvirt-api.xml for others to use, and in fact, the
libvirt-python bindings use it to generate python constants that
correspond to our enum values.  However, we had an off-by-one bug
that any enum that relied on C's rules for implicit initialization
of the first enum member to 0 got listed in the xml as having a
value of 1 (and all later members of the enum were equally
botched).

The fix is simple - since we add one to the previous value when
encountering an enum without an initializer, the previous value
must start at -1 so that the first enum member is assigned 0.

The python generator code has had the off-by-one ever since DV
first wrote it years ago, but most of our public enums were immune
because they had an explicit = 0 initializer.  The only affected
enums are:
- virDomainEventGraphicsAddressType (such as
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4), since commit 987e31e
(libvirt v0.8.0)
- virDomainCoreDumpFormat (such as VIR_DOMAIN_CORE_DUMP_FORMAT_RAW),
since commit 9fbaff0 (libvirt v1.2.3)
- virIPAddrType (such as VIR_IP_ADDR_TYPE_IPV4), since commit
03e0e79 (not yet released)

Thanks to Nehal J Wani for reporting the problem on IRC, and
for helping me zero in on the culprit function.

* docs/apibuild.py (CParser.parseEnumBlock): Fix implicit enum
values.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agolibxl: detect support for save and restore
Jim Fehlig [Tue, 24 Jun 2014 17:10:49 +0000 (11:10 -0600)]
libxl: detect support for save and restore

libxl does not support save, restore, or migrate on all architectures,
notably ARM.  Detect whether libxl supports these operations using
LIBXL_HAVE_NO_SUSPEND_RESUME.  If not supported, drop advertisement of
<migration_features>.

Found by Ian Campbell while improving Xen's OSSTEST infrastructure

http://lists.xen.org/archives/html/xen-devel/2014-06/msg02171.html

10 years agoqemu: fix guestfwd chardev option back how it was
Martin Kletzander [Thu, 26 Jun 2014 14:09:46 +0000 (16:09 +0200)]
qemu: fix guestfwd chardev option back how it was

Since commit d86c876a66e320b55220d00113027c9ad6199cff we are using
guestfwd=tcp:IP:PORT,chardev=ID for guestfwd specification, however,
that has not changed in qemu, so guestfwd does not work since.

Apart from that, guestfwd is not working with older qemu that doesn't
have QEMU_CAPS_DEVICE.

Both regressions exist since late 2009 and nobody found that (until
now), so I'm only fixing the first one.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoAdd PKG_CONFIG_PATH to run.in script.
Daniel P. Berrange [Thu, 26 Jun 2014 10:53:20 +0000 (11:53 +0100)]
Add PKG_CONFIG_PATH to run.in script.

Allow people to build external bindings using the 'run' script
by defining the PKG_CONFIG_PATH var in it. eg to build Python
you could do

   ../libvirt/run python setup.py build

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoFix typo s/SASL_CONF_DIR/SASL_CONF_PATH/ in QEMU VNC code
Daniel P. Berrange [Thu, 17 Oct 2013 15:05:03 +0000 (16:05 +0100)]
Fix typo s/SASL_CONF_DIR/SASL_CONF_PATH/ in QEMU VNC code

The QEMU VNC client arg code has a long standing typo
of SASL_CONF_DIR when it should be SASL_CONF_PATH for
the env variable name.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoqemu: blockcopy: Don't remove existing disk mirror info
Peter Krempa [Wed, 25 Jun 2014 16:11:17 +0000 (18:11 +0200)]
qemu: blockcopy: Don't remove existing disk mirror info

When creating a new disk mirror the new struct is stored in a separate
variable until everything went well. The removed hunk would actually
remove existing mirror information for example when the api would be run
if a mirror still exists.

10 years agosecurity: nop: Avoid very long lines
Peter Krempa [Mon, 23 Jun 2014 14:41:31 +0000 (16:41 +0200)]
security: nop: Avoid very long lines

The function headers contain type on the same line as the name. When
combined with usage of ATTRIBUTE_UNUSED, the function headers were very
long. Shorten them by breaking the line after the type.

10 years agosecurity: Fix header formatting of a few functions
Peter Krempa [Mon, 23 Jun 2014 13:38:24 +0000 (15:38 +0200)]
security: Fix header formatting of a few functions

Some of the functions in the storage driver had their headers formatted
incorrectly.

10 years agosecurity: manager: Document behavior of disk label manipulation funcs
Peter Krempa [Thu, 19 Jun 2014 15:18:02 +0000 (17:18 +0200)]
security: manager: Document behavior of disk label manipulation funcs

virSecurityManagerSetDiskLabel and virSecurityManagerRestoreDiskLabel
don't have complementary semantics. Document the semantics to avoid
possible problems.

10 years agosecurity: manager: Unify function header format
Peter Krempa [Thu, 19 Jun 2014 15:09:59 +0000 (17:09 +0200)]
security: manager: Unify function header format

10 years agosecurity: manager: Avoid forward decl of virSecurityManagerDispose
Peter Krempa [Thu, 19 Jun 2014 15:01:10 +0000 (17:01 +0200)]
security: manager: Avoid forward decl of virSecurityManagerDispose

10 years agosecurity: Rename virSecurityManagerRestoreImageLabel to *Disk*
Peter Krempa [Wed, 18 Jun 2014 12:46:27 +0000 (14:46 +0200)]
security: Rename virSecurityManagerRestoreImageLabel 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 agoutil: s/virStorageSourceClearBackingStore/virStorageSourceBackingStoreClear
Peter Krempa [Fri, 20 Jun 2014 08:40:45 +0000 (10:40 +0200)]
util: s/virStorageSourceClearBackingStore/virStorageSourceBackingStoreClear

Rename them to comply with the naming policy.

10 years agoFix a typo in a localized string
Daniel Veillard [Thu, 26 Jun 2014 07:47:16 +0000 (15:47 +0800)]
Fix a typo in a localized string

As pointed by Yuri Chornoivan in transifex:
https://fedora.transifex.com/projects/p/libvirt/translate/#uk/strings/27026506

10 years agovirConnectCompareCPU: Introduce FAIL_INCOMPATIBLE flag
Jiri Denemark [Wed, 28 May 2014 13:12:59 +0000 (15:12 +0200)]
virConnectCompareCPU: Introduce FAIL_INCOMPATIBLE flag

The new VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE flag for
virConnectCompareCPU can be used to get an error
(VIR_ERR_CPU_INCOMPATIBLE) describing the incompatibility instead of the
usual VIR_CPU_COMPARE_INCOMPATIBLE return code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agocpuCompare*: Add support for reporting failure on incompatible CPUs
Jiri Denemark [Wed, 28 May 2014 13:11:57 +0000 (15:11 +0200)]
cpuCompare*: Add support for reporting failure on incompatible CPUs

When CPU comparison APIs return VIR_CPU_COMPARE_INCOMPATIBLE, the caller
has no clue why the CPU is considered incompatible with host CPU. And in
some cases, it would be nice to be able to get such info in a client
rather than having to look in logs.

To achieve this, the APIs can be told to return VIR_ERR_CPU_INCOMPATIBLE
error for incompatible CPUs and the reason will be described in the
associated error message.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agocpu: Cleanup coding style in generic CPU driver
Jiri Denemark [Wed, 28 May 2014 12:49:45 +0000 (14:49 +0200)]
cpu: Cleanup coding style in generic CPU driver

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoRemove redundant docs from libvirt.h
Jiri Denemark [Wed, 28 May 2014 12:46:49 +0000 (14:46 +0200)]
Remove redundant docs from libvirt.h

Only types and macros are documented in libvirt.h, APIs are documented
in the *.c file they are implemented in.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agovirsh: Remove bogus stat on log file
Jiri Denemark [Tue, 24 Jun 2014 08:50:10 +0000 (10:50 +0200)]
virsh: Remove bogus stat on log file

Let's just open the file right away and deal with errors. Moreover,
there's no reason to forbid logging to, e.g., a pipe.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoconf: whitespace tweak
Chen Fan [Wed, 25 Jun 2014 08:45:32 +0000 (16:45 +0800)]
conf: whitespace tweak

Fix missing whitespace when parsing 'managed' attribute.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoenhance hostdev mode 'capabilities' process
Jincheng Miao [Wed, 25 Jun 2014 06:45:59 +0000 (14:45 +0800)]
enhance hostdev mode 'capabilities' process

Currently, only LXC has hostdev mode 'capabilities' support,
so the other drivers should forbid to define it in XML.
The hostdev mode check is added to devicesPostParseCallback()
for each hypervisor driver.

But there are some drivers lack function devicesPostParseCallback(),
so only add check for qemu, libxl, openvz, uml, xen, xenapi.

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
10 years agostorage: Don't store parent directory of an image explicitly
Peter Krempa [Tue, 27 May 2014 13:32:21 +0000 (15:32 +0200)]
storage: Don't store parent directory of an image explicitly

The parent directory doesn't necessarily need to be stored after we
don't mangle the path stored in the image. Remove it and tweak the code
to avoid using it.

10 years agostorage: Don't canonicalize paths unnecessarily
Peter Krempa [Tue, 27 May 2014 12:49:41 +0000 (14:49 +0200)]
storage: Don't canonicalize paths unnecessarily

Store backing chain paths as non-canonical. The canonicalization step
will be already taken. This will allow to avoid storing unnecessary
amounts of data.

10 years agotests: virstoragetest: Remove unneeded relative test plumbing
Peter Krempa [Tue, 27 May 2014 12:15:31 +0000 (14:15 +0200)]
tests: virstoragetest: Remove unneeded relative test plumbing

After we don't test relative paths, remove even more unnecessary cruft
from the test code.

10 years agotests: virstoragetest: Don't test relative start of backing chains
Peter Krempa [Tue, 27 May 2014 11:43:08 +0000 (13:43 +0200)]
tests: virstoragetest: Don't test relative start of backing chains

libvirt always uses an absolute path to address the top image of an
image chain. Our storage test tests also the relative path which won't
ever be used. Additionally it makes the test more complicated.

10 years agoutil: storage: Remove now redundant backingRelative from virStorageSource
Peter Krempa [Tue, 27 May 2014 08:40:59 +0000 (10:40 +0200)]
util: storage: Remove now redundant backingRelative from virStorageSource

Now that we store only relative names in virStorageSource's member
relPath the backingRelative member is obsolete. Remove it and adapt the
code to the removal.

10 years agotests: virstoragetest: Remove now unused pathAbs
Peter Krempa [Tue, 27 May 2014 08:15:06 +0000 (10:15 +0200)]
tests: virstoragetest: Remove now unused pathAbs

Separately remove the now unused variable.

10 years agostorage: Store relative path only for relatively backed storage
Peter Krempa [Tue, 27 May 2014 08:05:57 +0000 (10:05 +0200)]
storage: Store relative path only for relatively backed storage

Due to various refactors and compatibility with the virstoragetest the
relPath field of the virStorageSource structure was always filled either
with the relative name or the full path in case of absolutely backed
storage. Return its original purpose to store only the relative name of
the disk if it is backed relatively and tweak the tests.

10 years agotests: virstoragetest: Remove "expBackingStore" field
Peter Krempa [Mon, 26 May 2014 14:05:44 +0000 (16:05 +0200)]
tests: virstoragetest: Remove "expBackingStore" field

Now that we changed ordering of the stored metadata so that the backing
store is described by the child element the test should reflect this
change too.

Remove the expected backing store field as it's actually described by
the next element in the backing chain, so there's no need for
duplication.

10 years agoutil: storage: Add helper to resolve relative path difference
Peter Krempa [Tue, 13 May 2014 08:10:56 +0000 (10:10 +0200)]
util: storage: Add helper to resolve relative path difference

This patch introduces a function that will allow us to resolve a
relative difference between two elements of a disk backing chain. This
function will be used to allow relative block commit and block pull
where we need to specify the new relative name of the image to qemu.

This patch also adds unit tests for the function to verify that it works
correctly.

10 years agoLXC: check whether we get MemSwap[Total|Usage]
Chen Hanxiao [Wed, 25 Jun 2014 01:57:32 +0000 (09:57 +0800)]
LXC: check whether we get MemSwap[Total|Usage]

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agoqemu: enum cleanups in "src/qemu/*"
Julio Faracco [Sun, 15 Jun 2014 16:32:56 +0000 (13:32 -0300)]
qemu: enum cleanups in "src/qemu/*"

As we are doing with the enum structures, a cleanup in "src/qemu/"
directory was done now. All the enums that were defined in the
header files were converted to typedefs in this directory. This
patch includes all the adjustments to remove conflicts when you do
this kind of change. "Enum-to-typedef"'s conversions were made in
"src/qemu/qemu_{capabilities, domain, migration, hotplug}.h".

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
10 years agolibxl: fix version annotation of migration functions
Jim Fehlig [Tue, 24 Jun 2014 17:12:21 +0000 (11:12 -0600)]
libxl: fix version annotation of migration functions

Commit 9b8d6e1e missed updating the libvirt version which
introduced support for domainMigrate*3Params functions.

10 years agobridge: leases: Fix potential crash caused by use after free
Peter Krempa [Tue, 24 Jun 2014 11:52:57 +0000 (13:52 +0200)]
bridge: leases: Fix potential crash caused by use after free

Don't free individual JSON array members as the array will be freed at
the end. This may potentially lead to a crash although it didn't crash
on my setup.

10 years agoFree DHCP leases file in networkGetDHCPLeasesHelper
Ján Tomko [Tue, 24 Jun 2014 12:40:14 +0000 (14:40 +0200)]
Free DHCP leases file in networkGetDHCPLeasesHelper

Introduced by commit ba51398

10 years agoRework remoteSerializeDHCPLease
Ján Tomko [Tue, 24 Jun 2014 12:37:55 +0000 (14:37 +0200)]
Rework remoteSerializeDHCPLease

Don't leak the temporary variables on success if NULL is returned
for that field.

Don't dereference NULL on failure to allocate some of the temporaries.

Introduced by commit 990c3b6

10 years agoFree file header in virStorageFileGetMetadataRecurse
Ján Tomko [Tue, 24 Jun 2014 12:35:59 +0000 (14:35 +0200)]
Free file header in virStorageFileGetMetadataRecurse

Introduced by commit 2bdb8b9

10 years agoChange 'interface' to 'iface' in virNetworkDHCPLease
Daniel P. Berrange [Tue, 24 Jun 2014 12:23:59 +0000 (13:23 +0100)]
Change 'interface' to 'iface' in virNetworkDHCPLease

Variables/fields named 'interface' clash with system
header symbols on some platforms.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agographics: remember graphics not auto allocated ports
Giuseppe Scrivano [Tue, 24 Jun 2014 11:34:18 +0000 (13:34 +0200)]
graphics: remember graphics not auto allocated ports

When looking for a port to allocate, the port allocator didn't take in
consideration ports that are statically set by the user.  Defining
these two graphics elements in the XML would cause an error, as the
port allocator would try to use the same port for the spice graphics
element:

    <graphics type='spice' autoport='yes'/>
    <graphics type='vnc' port='5900' autoport='no'/>

The new *[pP]ortReserved variables keep track of the ports that were
successfully tracked as used by the port allocator but that weren't
bound.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1081881
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
10 years agovirtportallocator: new function "virPortAllocatorSetUsed"
Giuseppe Scrivano [Tue, 24 Jun 2014 11:34:17 +0000 (13:34 +0200)]
virtportallocator: new function "virPortAllocatorSetUsed"

virPortAllocatorSetUsed permits to set a port as already used and
prevent the port allocator to use it without any attempt to bind it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonet-dhcp-leases: Add virsh support
Nehal J Wani [Mon, 23 Jun 2014 21:01:52 +0000 (02:31 +0530)]
net-dhcp-leases: Add virsh support

Use virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC in virsh.

The new feature supports the follwing methods:

1. Retrieve leases info for a given virtual network

2. Retrieve leases info for given network interface

tools/virsh-domain-monitor.c
   * Introduce new command : net-dhcp-leases
     Example Usage: net-dhcp-leases <network> [mac]

   virsh # net-dhcp-leases --network default6
   Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID
   -------------------------------------------------------------------------------------------------------------------
   2014-06-16 03:40:14  52:54:00:85:90:e2  ipv4      192.168.150.231/24        fedora20-test   01:52:54:00:85:90:e2
   2014-06-16 03:40:17  52:54:00:85:90:e2  ipv6      2001:db8:ca2:2:1::c0/64   fedora20-test   00:04:b1:d8:86:42:e1:6a:aa:cf:d5:86:94:23:6f:94:04:cd
   2014-06-16 03:34:42  52:54:00:e8:73:eb  ipv4      192.168.150.181/24        ubuntu14-vm     -
   2014-06-16 03:34:46  52:54:00:e8:73:eb  ipv6      2001:db8:ca2:2:1::5b/64   -               00:01:00:01:1b:30:c6:aa:52:54:00:e8:73:eb

tools/virsh.pod
   * Document new command

src/internal.h
   * Introduce new macro: EMPTYSTR

10 years agonet-dhcp-leases: Private implementation inside network
Nehal J Wani [Mon, 23 Jun 2014 21:01:51 +0000 (02:31 +0530)]
net-dhcp-leases: Private implementation inside network

Query the network driver for the path of the custom leases file for the given
virtual network and parse it to retrieve info.

src/network/bridge_driver.c:
* Implement networkGetDHCPLeases
* Implement networkGetDHCPLeasesForMAC
* Implement networkGetDHCPLeasesHelper

10 years agonet-dhcp-leases: Implement the remote protocol
Nehal J Wani [Mon, 23 Jun 2014 21:01:50 +0000 (02:31 +0530)]
net-dhcp-leases: Implement the remote protocol

Implement RPC calls for virNetworkGetDHCPLeases, virNetworkGetDHCPLeasesForMAC

daemon/remote.c
   * Define remoteSerializeNetworkDHCPLeases,
            remoteDispatchNetworkGetDHCPLeases
   * Define remoteDispatchNetworkGetDHCPLeasesForMAC
   * Define helper function remoteSerializeDHCPLease

src/remote/remote_driver.c
   * Define remoteNetworkGetDHCPLeases
   * Define remoteNetworkGetDHCPLeasesForMAC
   * Define helper function remoteSerializeDHCPLease

src/remote/remote_protocol.x
   * New RPC procedure: REMOTE_PROC_NETWORK_GET_DHCP_LEASES
   * Define structs remote_network_dhcp_leases, remote_network_get_dhcp_leases_args,
                    remote_network_get_dhcp_leases_ret
   * New RPC procedure: REMOTE_PROC_NETWORK_GET_DHCP_LEASES_FOR_MAC
   * Define structs remote_network_dhcp_leases_for_mac, remote_network_get_dhcp_leases_for_mac_args,
                    remote_network_get_dhcp_leases_for_mac_ret

src/remote_protocol-structs
   * New structs added

src/rpc/gendispatch.pl
   * Add exception (s/Dhcp/DHCP) for auto-generating names of the remote functions
     in daemon/remote_dispatch.h

10 years agonet-dhcp-leases: Implement the public APIs
Nehal J Wani [Mon, 23 Jun 2014 21:01:49 +0000 (02:31 +0530)]
net-dhcp-leases: Implement the public APIs

Introduce 3 new APIs, virNetworkGetDHCPLeases, virNetworkGetDHCPLeasesForMAC
and virNetworkDHCPLeaseFree.

* virNetworkGetDHCPLeases: returns the dhcp leases information for a given
     virtual network.

  For DHCPv4, the information returned:
  - Network Interface Name
  - Expiry Time
  - MAC address
  - IAID (NULL)
  - IPv4 address (with type and prefix)
  - Hostname (can be NULL)
  - Client ID (can be NULL)

  For DHCPv6, the information returned:
  - Network Interface Name
  - Expiry Time
  - MAC address
  - IAID (can be NULL, only in rare cases)
  - IPv6 address (with type and prefix)
  - Hostname (can be NULL)
  - Client DUID

  Note: @mac, @iaid, @ipaddr, @clientid are in ASCII form, not raw bytes.
  Note: @expirytime can 0, in case the lease is for infinite time.

* virNetworkGetDHCPLeasesForMAC: returns the dhcp leases information for a
     given virtual network and specified MAC Address.

* virNetworkDHCPLeaseFree: allows the upper layer application to free the
     network interface object conveniently.

There is no support for flags, so user is expected to pass 0 for
both the APIs.

include/libvirt/libvirt.h.in:
  * Define virNetworkGetDHCPLeases
  * Define virNetworkGetDHCPLeasesForMAC
  * Define virNetworkDHCPLeaseFree

src/driver.h:
  * Define networkGetDHCPLeases
  * Define networkGetDHCPLeasesForMAC

src/libvirt.c:
  * Implement virNetworkGetDHCPLeases
  * Implement virNetworkGetDHCPLeasesForMAC
  * Implement virNetworkDHCPLeaseFree

src/libvirt_public.syms:
  * Export the new symbols

10 years agoFix shadowed variable with older gcc
Ján Tomko [Tue, 24 Jun 2014 10:53:44 +0000 (12:53 +0200)]
Fix shadowed variable with older gcc

Commit 2cff94c fixed the shadowed 'link' added by commit 975f0e2,
but forgot the 'link' added by commit 08aa22e.

10 years agoLXC: trivially support flag VIR_DRV_FEATURE_TYPED_PARAM_STRING
Chen Hanxiao [Tue, 24 Jun 2014 09:44:18 +0000 (17:44 +0800)]
LXC: trivially support flag VIR_DRV_FEATURE_TYPED_PARAM_STRING

Fix lxcDomainGetMemoryParameters and lxcDomainGetSchedulerParametersFlags:
virsh -c lxc:/// memtune DOMAIN
error: Unable to get number of memory parameters
error: unsupported flags (0x4) in function lxcDomainGetMemoryParameters

Introduced by commit 399394.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agovirNumaGetPages: Don't fail on huge page-less systems
Michal Privoznik [Mon, 23 Jun 2014 13:46:31 +0000 (15:46 +0200)]
virNumaGetPages: Don't fail on huge page-less systems

If we are running on a system that is not capable of huge pages (e.g.
because the kernel is not configured that way) we still try to open
"/sys/kernel/mm/hugepages/" which however does not exist. We should
be tolerant to this specific use case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNumaGetPageInfo: Take huge pages into account
Michal Privoznik [Mon, 23 Jun 2014 13:04:11 +0000 (15:04 +0200)]
virNumaGetPageInfo: Take huge pages into account

On the Linux kernel, if huge pages are allocated the size they cut off
from memory is accounted under the 'MemUsed' in the meminfo file.
However, we want the sum to be subtracted from 'MemTotal'. This patch
implements this feature. After this change, we can enable reporting
of the ordinary system pages in the capability XML:

<capabilities>

  <host>
    <uuid>01281cda-f352-cb11-a9db-e905fe22010c</uuid>
    <cpu>
      <arch>x86_64</arch>
      <model>Haswell</model>
      <vendor>Intel</vendor>
      <topology sockets='1' cores='1' threads='1'/>
      <feature/>
      <pages unit='KiB' size='4'/>
      <pages unit='KiB' size='2048'/>
      <pages unit='KiB' size='1048576'/>
    </cpu>
    <power_management/>
    <migration_features/>
    <topology>
      <cells num='4'>
        <cell id='0'>
          <memory unit='KiB'>4048248</memory>
          <pages unit='KiB' size='4'>748382</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>
        ...
      </cells>
    </topology>
  </host>
</capabilities>

You can see the beautiful thing about this: if you sum up all the
<pages/> you'll get <memory/>.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
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>