]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agoqemu: driver: Fix cold-update of removable storage devices
Peter Krempa [Thu, 12 Mar 2015 16:12:12 +0000 (17:12 +0100)]
qemu: driver: Fix cold-update of removable storage devices

Only selected fields from the disk source were copied when cold updating
source in a CDROM drive. When such drive was backed by a network file
this resulted into corruption of the definition:

    <disk type='network' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source protocol='gluster' name='gluster-vol1(null)'>
        <host name='localhost'/>
      </source>
      <target dev='vdc' bus='virtio'/>
      <readonly/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </disk>

Update the whole source instead of cherry-picking elements.

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

10 years agoqemu: hotplug: Use checker function to check if disk is empty
Peter Krempa [Thu, 12 Mar 2015 15:57:56 +0000 (16:57 +0100)]
qemu: hotplug: Use checker function to check if disk is empty

10 years agovirsh: domain: Fix the change-media command
Peter Krempa [Thu, 12 Mar 2015 15:41:21 +0000 (16:41 +0100)]
virsh: domain: Fix the change-media command

The command did not modify the disk type and thus didn't allow to change
media from a file image to a block backed image or vice versa. In
addition when operating on a network backed removable devices the
command would replace the while <source> subelement with an invalid one.

This patch adds the --block option that allows to specify that the new
image is block backed and assumes that without that option all images
are file backed. Since network backends were always mangled it should
not cause problems.

10 years agovirsh: domain: Add --print-xml flag for command change-media
Peter Krempa [Thu, 12 Mar 2015 15:04:00 +0000 (16:04 +0100)]
virsh: domain: Add --print-xml flag for command change-media

Allow printing the XML that would be used mostly for debugging purposes.

10 years agovirsh: domain: Don't use vshPrepareDiskXML for creating XML to detach disk
Peter Krempa [Thu, 12 Mar 2015 10:51:51 +0000 (11:51 +0100)]
virsh: domain: Don't use vshPrepareDiskXML for creating XML to detach disk

Since cmdDetachDisk() calls into vshPrepareDiskXML() with
type == VSH_PREPARE_DISK_XML_NONE && source == NULL this would result
into skipping all the checks and effectively turn the function into a
XML formatter.

This patch changes the code to use the formatter directly so that the
function can be refactored in a easier way.

10 years agoparallels_sdk.c: minor cleanup
Maxim Nestratov [Tue, 17 Mar 2015 15:21:21 +0000 (18:21 +0300)]
parallels_sdk.c: minor cleanup

Fix indentation in prlsdkGetNetInf()o, remove unnecessary error
message in prlsdkDomainChangeState(), remove unnecessary job
freeing in prlsdkLoadDomains().

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agodomifaddr: Add virsh support
Nehal J Wani [Sun, 25 Jan 2015 18:38:49 +0000 (00:08 +0530)]
domifaddr: Add virsh support

tools/virsh-domain-monitor.c
   * Introduce new command : domifaddr
     Usage: domifaddr <domain> [interface] [--full] [--source lease|agent]

     Example outputs:
     virsh # domifaddr f20
     Name       MAC address          Protocol     Address
     -------------------------------------------------------------------------------
     lo         00:00:00:00:00:00    ipv4         127.0.0.1/8
     -          -                    ipv6         ::1/128
     vnet0      52:54:00:2e:45:ce    ipv4         10.1.33.188/24
     -          -                    ipv6         2001:db8:0:f101::2/64
     -          -                    ipv6         fe80::5054:ff:fe2e:45ce/64
     vnet1      52:54:00:b1:70:19    ipv4         192.168.105.201/16
     -          -                    ipv4         192.168.201.195/16
     -          -                    ipv6         fe80::5054:ff:feb1:7019/64
     vnet2      52:54:00:36:2a:e5    N/A          N/A
     vnet3      52:54:00:20:70:3d    ipv4         192.168.105.240/16
     -          -                    ipv6         fe80::5054:ff:fe20:703d/64

     virsh # domifaddr f20 eth1 --source lease
     Name       MAC address          Protocol     Address
     -------------------------------------------------------------------------------
     vnet1      52:54:00:b1:70:19    ipv4         192.168.105.201/16
     -          -                    ipv4         192.168.201.195/16
     -          -                    ipv6         fe80::5054:ff:feb1:7019/64

     virsh # domifaddr f20 eth0 --source agent --full
     Name       MAC address          Protocol     Address
     -------------------------------------------------------------------------------
     eth0       52:54:00:2e:45:ce    ipv4         10.1.33.188/24
     eth0       52:54:00:2e:45:ce    ipv6         2001:db8:0:f101::2/64
     eth0       52:54:00:2e:45:ce    ipv6         fe80::5054:ff:fe2e:45ce/64

tools/virsh.pod
   * Document new command

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
10 years agodomifaddr: Implement the API for qemu
Nehal J Wani [Sun, 25 Jan 2015 18:38:48 +0000 (00:08 +0530)]
domifaddr: Implement the API for qemu

By querying the qemu guest agent with the QMP command
"guest-network-get-interfaces" and converting the received JSON
output to structured objects.

Although "ifconfig" is deprecated, IP aliases created by "ifconfig"
are supported by this API. The legacy syntax of an IP alias is:
"<ifname>:<alias-name>". Since we want all aliases to be clubbed
under parent interface, simply stripping ":<alias-name>" suffices.
Note that IP aliases formed by "ip" aren't visible to "ifconfig",
and aliases created by "ip" do not have any specific name. But
we are lucky, as qemu guest agent detects aliases created by both.

src/qemu/qemu_agent.h:
  * Define qemuAgentGetInterfaces

src/qemu/qemu_agent.c:
  * Implement qemuAgentGetInterface

src/qemu/qemu_driver.c:
  * New function qemuGetDHCPInterfaces
  * New function qemuDomainInterfaceAddresses

src/remote_protocol-sructs:
  * Define new structs

tests/qemuagenttest.c:
  * Add new test: testQemuAgentGetInterfaces
    Test cases for IP aliases, 0 or multiple ipv4/ipv6 address(es)

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
10 years agodomifaddr: Implement the remote protocol
Nehal J Wani [Sun, 25 Jan 2015 18:38:47 +0000 (00:08 +0530)]
domifaddr: Implement the remote protocol

daemon/remote.c
   * Define remoteSerializeDomainInterface, remoteDispatchDomainInterfaceAddresses

src/remote/remote_driver.c
   * Define remoteDomainInterfaceAddresses

src/remote/remote_protocol.x
   * New RPC procedure: REMOTE_PROC_DOMAIN_INTERFACE_ADDRESSES
   * Define structs remote_domain_ip_addr, remote_domain_interface,
     remote_domain_interfaces_addresse_args, remote_domain_interface_addresses_ret
   * Introduce upper bounds (to handle DoS attacks):
     REMOTE_DOMAIN_INTERFACE_MAX = 2048
     REMOTE_DOMAIN_IP_ADDR_MAX = 2048
     Restrictions on the maximum number of aliases per interface were
     removed after kernel v2.0, and theoretically, at present, there
     are no upper limits on number of interfaces per virtual machine
     and on the number of IP addresses per interface.

src/remote_protocol-structs
   * New structs added

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
10 years agodomifaddr: Implement the public APIs
Nehal J Wani [Sun, 25 Jan 2015 18:38:46 +0000 (00:08 +0530)]
domifaddr: Implement the public APIs

Define helper function virDomainInterfaceFree, which allows
the upper layer application to free the domain interface object
conveniently.

The API is going to provide multiple methods by flags, e.g.
  * Query guest agent
  * Parse DHCP lease file

include/libvirt/libvirt-domain.h
  * Define virDomainInterfaceAddresses, virDomainInterfaceFree
  * Define structs virDomainInterface, virDomainIPAddress

src/driver-hypervisor.h:
  * Define domainInterfaceAddresses

src/libvirt-domain.c:
  * Implement virDomainInterfaceAddresses
  * Implement virDomainInterfaceFree

src/libvirt_public.syms:
  * Export the new symbols

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
10 years agoparallels: fix home directory for VMs
Maxim Nestratov [Fri, 13 Mar 2015 15:40:42 +0000 (18:40 +0300)]
parallels: fix home directory for VMs

Failures of parallelsStorageOpen occured because we incorrectly treated
path to VM' configuration file as a directory. Now initialization of
parallels VM domains home directory is fixed.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agoparallels: don't forget to unlock domain if unregister fails
Maxim Nestratov [Fri, 13 Mar 2015 15:40:41 +0000 (18:40 +0300)]
parallels: don't forget to unlock domain if unregister fails

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agoparallels: set cpu mode when applying xml configuration
Mikhail Feoktistov [Fri, 13 Mar 2015 15:40:40 +0000 (18:40 +0300)]
parallels: set cpu mode when applying xml configuration

Otherwise exporting existing domain config and defining a new one like this:
virsh -c parallels:///system dumpxml instance01 > my.xml
virsh -c parallels:///system define my.xml
leads to an error because PCS default x64 mode turns to x32.
Thus, we need to set correct cpuMode in prlsdkDoApplyConfig() explicitly.

Signed-off-by: Mikhail Feoktistov <mfeoktistov@parallels.com>
Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoconf: Use correct type for balloon stats period
Martin Kletzander [Fri, 13 Mar 2015 16:08:15 +0000 (17:08 +0100)]
conf: Use correct type for balloon stats period

We're parsing memballoon status period as unsigned int, but when we're
trying to set it, both we and qemu use signed int.  That means large
values will get wrapped around to negative one resulting in error.
Basically the same problem as commit e3a7b874 was dealing with when
updating live domain.

QEMU changed the accepted value to int64 in commit 1f9296b5, but even
values as INT_MAX don't make sense since the value passed means seconds.
Hence adding capability flag for this change isn't worth it.

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Don't duplicate errors when settings stats period
Martin Kletzander [Fri, 13 Mar 2015 16:05:32 +0000 (17:05 +0100)]
qemu: Don't duplicate errors when settings stats period

In order not to leave old error messages set, this patch refactors the
code so the error is reported only when acted upon.  The only such place
already rewrites any error, so cleaning up all the error reporting in
qemuMonitorSetMemoryStatsPeriod() is enough.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoconf: Reorder elements inside memballoon
Martin Kletzander [Fri, 13 Mar 2015 15:16:57 +0000 (16:16 +0100)]
conf: Reorder elements inside memballoon

All the devices we have format their address as its last sub-element, so
let's change memballoon to follow suit.  Also adjust RNG to allow any
order of them so 'virsh edit' doesn't shout at us.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoutil: Make sure the comment about virBufferAddBuffer is true
Martin Kletzander [Fri, 13 Mar 2015 15:41:42 +0000 (16:41 +0100)]
util: Make sure the comment about virBufferAddBuffer is true

Change it so it really *always* eats the @toadd buffer.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agowireshark: fix VPATH build
Pavel Hrdina [Tue, 17 Mar 2015 10:36:02 +0000 (11:36 +0100)]
wireshark: fix VPATH build

Add $(top_builddir) paths to INCLUDES to fix VPATH build.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu_command: Fix some indentation and a typo
Luyao Huang [Tue, 17 Mar 2015 02:34:26 +0000 (10:34 +0800)]
qemu_command: Fix some indentation and a typo

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agorpm-build: use pkg-config to detect wireshark presence
Pavel Hrdina [Mon, 16 Mar 2015 11:52:13 +0000 (12:52 +0100)]
rpm-build: use pkg-config to detect wireshark presence

Wireshark supports pkg-config since 1.11.3.  Right now we build
wireshark-dissectior tool as default trough rpm build only on
fedora >= 21 and there is new wireshark that supports pkg-config.
If someone wants to build libvirt with wireshark-dissector against old
wireshark, they should specify the location by hand.

This patch is mainly to fix wrong dependency on wireshark binary as it
doesn't make sense to require that binary file to just get version info
of that package in makefile.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agolibxl: fix regression introduced by commit 4ab8cd77
Jim Fehlig [Sat, 14 Mar 2015 00:36:04 +0000 (18:36 -0600)]
libxl: fix regression introduced by commit 4ab8cd77

Commit 4ab8cd77 added a check requiring input devices to have
a bus type of VIR_DOMAIN_INPUT_BUS_USB, failing to start the
domain otherwise.  But virDomainDefParseXML adds implicit mouse
and keyboard if a graphics device is configured.  See calls to
virDomainDefMaybeAddInput.

The regression is fixed by removing the check requiring USB input
devices, and skipping non-USB input devices when populating USB
'usbdevice' in libxl_domain_build_info struct.

10 years agoqemu: block-commit: Mark disk in block jobs only on successful command
Peter Krempa [Mon, 16 Mar 2015 15:52:44 +0000 (16:52 +0100)]
qemu: block-commit: Mark disk in block jobs only on successful command

Patch 51f9f03a4ca50b070c0fbfb29748d49f583e15e1 introduces a regression
where if a blockCommit operation fails the disk is still marked as being
part of a block job but can't be unmarked later.

10 years agodaemon: avoid memleak when ListAll returns nothing
Eric Blake [Fri, 13 Mar 2015 23:01:43 +0000 (17:01 -0600)]
daemon: avoid memleak when ListAll returns nothing

Commit 4f25146 (v1.2.8) managed to silence Coverity, but at the
cost of a memory leak detected by valgrind:
==24129== 40 bytes in 5 blocks are definitely lost in loss record 355 of 637
==24129==    at 0x4A08B1C: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==24129==    by 0x5084B8E: virReallocN (viralloc.c:245)
==24129==    by 0x514D5AA: virDomainObjListExport (domain_conf.c:22200)
==24129==    by 0x201227DB: qemuConnectListAllDomains (qemu_driver.c:18042)
==24129==    by 0x51CC1B6: virConnectListAllDomains (libvirt-domain.c:6797)
==24129==    by 0x14173D: remoteDispatchConnectListAllDomains (remote.c:1580)
==24129==    by 0x121BE1: remoteDispatchConnectListAllDomainsHelper (remote_dispatch.h:1072)

In short, every time a client calls a ListAll variant and asks
for the resulting list, but there are 0 elements to return, we
end up leaking the 1-entry array that holds the NULL terminator.

What's worse, a read-only client can access these functions in a
tight loop to cause libvirtd to eventually run out of memory; and
this can be considered a denial of service attack against more
privileged clients.  Thankfully, the leak is so small (8 bytes per
call) that you would already have some other denial of service with
any guest calling the API that frequently, so an out-of-memory
crash is unlikely enough that this did not warrant a CVE.

* daemon/remote.c (remoteDispatchConnectListAllDomains)
(remoteDispatchDomainListAllSnapshots)
(remoteDispatchDomainSnapshotListAllChildren)
(remoteDispatchConnectListAllStoragePools)
(remoteDispatchStoragePoolListAllVolumes)
(remoteDispatchConnectListAllNetworks)
(remoteDispatchConnectListAllInterfaces)
(remoteDispatchConnectListAllNodeDevices)
(remoteDispatchConnectListAllNWFilters)
(remoteDispatchConnectListAllSecrets)
(remoteDispatchNetworkGetDHCPLeases): Plug leak.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoRemove virDomainIOThreadsPinDel
John Ferlan [Wed, 11 Mar 2015 20:47:15 +0000 (16:47 -0400)]
Remove virDomainIOThreadsPinDel

This one is no longer necessary since the Vcpu and IOThreads API's share

10 years agoReplace virDomainVcpuPinDel with virDomainPinDel
John Ferlan [Wed, 11 Mar 2015 20:42:44 +0000 (16:42 -0400)]
Replace virDomainVcpuPinDel with virDomainPinDel

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoReplace virDomainIOThreadsPinAdd with virDomainPinAdd
John Ferlan [Wed, 11 Mar 2015 20:22:33 +0000 (16:22 -0400)]
Replace virDomainIOThreadsPinAdd with virDomainPinAdd

This one is no longer necessary since the Vcpu and IOThreads API's share

10 years agoReplace virDomainVcpuPinAdd with virDomainPinAdd
John Ferlan [Wed, 11 Mar 2015 20:17:56 +0000 (16:17 -0400)]
Replace virDomainVcpuPinAdd with virDomainPinAdd

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainVcpuPinFindByVcpu into virDomainPinFindByVcpu
John Ferlan [Wed, 11 Mar 2015 00:31:44 +0000 (20:31 -0400)]
Convert virDomainVcpuPinFindByVcpu into virDomainPinFindByVcpu

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainVcpuPinIsDuplicate into virDomainPinIsDuplicate
John Ferlan [Wed, 11 Mar 2015 00:27:39 +0000 (20:27 -0400)]
Convert virDomainVcpuPinIsDuplicate into virDomainPinIsDuplicate

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainVcpuPinDefCopy into virDomainPinDefCopy
John Ferlan [Wed, 11 Mar 2015 00:24:04 +0000 (20:24 -0400)]
Convert virDomainVcpuPinDefCopy into virDomainPinDefCopy

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainVcpuPinDefArrayFree to virDomainPinDefArrayFree
John Ferlan [Wed, 11 Mar 2015 00:19:35 +0000 (20:19 -0400)]
Convert virDomainVcpuPinDefArrayFree to virDomainPinDefArrayFree

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainVcpuPinDefFree to virDomainPinDefFree
John Ferlan [Wed, 11 Mar 2015 00:15:45 +0000 (20:15 -0400)]
Convert virDomainVcpuPinDefFree to virDomainPinDefFree

Since both Vcpu and IOThreads code use the same API's, alter the naming
of the API's to remove the "Vcpu" specific reference

10 years agoConvert virDomainPinDefPtr->vcpuid to virDomainPinDefPtr->id
John Ferlan [Wed, 11 Mar 2015 00:10:54 +0000 (20:10 -0400)]
Convert virDomainPinDefPtr->vcpuid to virDomainPinDefPtr->id

Since we're not specifically a vcpu related structure anymore...

10 years agoConvert virDomainVcpuPinDefPtr to virDomainPinDefPtr
John Ferlan [Sat, 14 Mar 2015 02:50:26 +0000 (22:50 -0400)]
Convert virDomainVcpuPinDefPtr to virDomainPinDefPtr

As pointed out by jtomko in his review of the IOThreads pinning code:

http://www.redhat.com/archives/libvir-list/2015-March/msg00495.html

there are some comments sprinkled in indicating IOThreads were using
the same structure as the VcpuPin code...

This is the first patch of a few that will change the virDomainVcpuPin*
structures and code to just virDomainPin* - starting with the data
structure naming...

10 years agoqemu: Fix possible memory leak in qemuDomainPinVcpuFlags
John Ferlan [Mon, 9 Mar 2015 22:41:04 +0000 (18:41 -0400)]
qemu: Fix possible memory leak in qemuDomainPinVcpuFlags

During his review of the iothreads pin setting code, Pavel noted that
there was a potential memory leak with respect to how the newVcpuPin
is handled and the goto endjob's in failure paths which would not free
the memory.  For reference, See:

http://www.redhat.com/archives/libvir-list/2015-March/msg00415.html

10 years agoconf: Make specifying <memory> optional
Peter Krempa [Wed, 4 Mar 2015 10:04:27 +0000 (11:04 +0100)]
conf: Make specifying <memory> optional

Now that the size of guest's memory can be inferred from the NUMA
configuration (if present) make it optional to specify <memory>
explicitly.

To make sure that memory is specified add a check that some form of
memory size was specified. One side effect of this change is that it is
no longer possible to specify 0KiB as memory size for the VM, but I
don't think it would be any useful to do so. (I can imagine embedded
systems without memory, just registers, but that's far from what libvirt
is usually doing).

Forbidding 0 memory for guests also fixes a few corner cases where 0 was
not interpreted correctly and caused failures. (Arguments for numad when
using automatic placement, size of the balloon). This fixes problems
described in https://bugzilla.redhat.com/show_bug.cgi?id=1161461

Test case changes are added to verify that the schema change and code
behave correctly.

10 years agoconf: Automatically use NUMA memory size in case NUMA is enabled
Peter Krempa [Wed, 18 Feb 2015 13:02:39 +0000 (14:02 +0100)]
conf: Automatically use NUMA memory size in case NUMA is enabled

Use the NUMA total instead of the configured size both in XML and for
uses in the code once NUMA is enabled for a domain.

One test case change is necessary as the rounding of the individual cell
sizes was not matching the rounding of the total size.

10 years agoqemu: command: Add helper to align memory sizes
Peter Krempa [Wed, 18 Feb 2015 13:31:47 +0000 (14:31 +0100)]
qemu: command: Add helper to align memory sizes

The memory sizes in qemu are aligned up to 1 MiB boundaries. There are
two places where this was done once for the total size and then for
individual NUMA cell sizes.

Add a function that will align the sizes in one place so that it's clear
where the sizes are aligned.

10 years agoconf: Replace access to def->mem.max_balloon with accessor functions
Peter Krempa [Tue, 17 Feb 2015 17:01:09 +0000 (18:01 +0100)]
conf: Replace access to def->mem.max_balloon with accessor functions

As there are two possible approaches to define a domain's memory size -
one used with legacy, non-NUMA VMs configured in the <memory> element
and per-node based approach on NUMA machines - the user needs to make
sure that both are specified correctly in the NUMA case.

To avoid this burden on the user I'd like to replace the NUMA case with
automatic totaling of the memory size. To achieve this I need to replace
direct access to the virDomainMemtune's 'max_balloon' field with
two separate getters depending on the desired size.

The two sizes are needed as:
1) Startup memory size doesn't include memory modules in some
hypervisors.
2) After startup these count as the usable memory size.

Note that the comments for the functions are future aware and document
state that will be present after a few later patches.

10 years agoqemu: Disallow concurrent block jobs on a single disk
Peter Krempa [Fri, 13 Mar 2015 16:22:04 +0000 (17:22 +0100)]
qemu: Disallow concurrent block jobs on a single disk

While qemu may be prepared to do this libvirt is not. Forbid the block
ops until we fix our code.

10 years agoqemu: event: Don't fiddle with disk backing trees without a job
Peter Krempa [Fri, 13 Mar 2015 16:00:03 +0000 (17:00 +0100)]
qemu: event: Don't fiddle with disk backing trees without a job

Surprisingly we did not grab a VM job when a block job finished and we'd
happily rewrite the backing chain data. This made it possible to crash
libvirt when queueing two backing chains tightly and other badness.

To fix it, add yet another handler to the helper thread that handles
monitor events that require a job.

10 years agoqemu: process: Export qemuProcessFindDomainDiskByAlias
Peter Krempa [Fri, 13 Mar 2015 15:59:26 +0000 (16:59 +0100)]
qemu: process: Export qemuProcessFindDomainDiskByAlias

10 years agoqemu: Check for negative port values in network drive configuration
Erik Skultety [Thu, 19 Feb 2015 15:53:13 +0000 (16:53 +0100)]
qemu: Check for negative port values in network drive configuration

We interpret port values as signed int (convert them from char *),
so if a negative value is provided in network disk's configuration,
we accept it as valid, however there's an 'unknown cause' error raised later.
This error is only accidental because we return the port value in the return code.
This patch adds just a minor tweak to the already existing check so we
reject negative values the same way as we reject non-numerical strings.

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

10 years agoAUTHORS: add myself to commiters list
Erik Skultety [Mon, 16 Mar 2015 08:30:02 +0000 (09:30 +0100)]
AUTHORS: add myself to commiters list

10 years agonetwork: avoid memory leak of dnsmasq capabilities
Eric Blake [Fri, 13 Mar 2015 20:55:58 +0000 (14:55 -0600)]
network: avoid memory leak of dnsmasq capabilities

Valgrind detected a leak:

==17820== 102 (56 direct, 46 indirect) bytes in 1 blocks are definitely lost in loss record 479 of 646
==17820==    at 0x4A08946: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17820==    by 0x508521A: virAllocVar (viralloc.c:560)
==17820==    by 0x50D9FCA: virObjectNew (virobject.c:193)
==17820==    by 0x50A4FD9: dnsmasqCapsNewEmpty (virdnsmasq.c:784)
==17820==    by 0x50A514E: dnsmasqCapsNewFromBinary (virdnsmasq.c:830)
==17820==    by 0x1B508287: networkStateInitialize (bridge_driver.c:666)

It looks like commit 172acef introduced the problem, because
networkGetDnsmasqCaps() increments the reference count but an
early exit never does a matching decrement.

* src/network/bridge_driver.c (networkStateCleanup): Plug leak.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agonetdev: silence valgrind warning about ioctl use
Eric Blake [Fri, 13 Mar 2015 20:35:31 +0000 (14:35 -0600)]
netdev: silence valgrind warning about ioctl use

Valgrind complained:

==3770== Syscall param ioctl(SIOCETHTOOL) points to uninitialised byte(s)
==3770==    at 0x919D407: ioctl (syscall-template.S:81)
==3770==    by 0x530FE7E: rpl_ioctl (ioctl.c:42)
==3770==    by 0x50CB433: virNetDevFeatureAvailable (virnetdev.c:2764)
==3770==    by 0x50CB6A7: virNetDevGetFeatures (virnetdev.c:2830)
==3770==    by 0x1F0E5347: udevProcessNetworkInterface (node_device_udev.c:722)
==3770==    by 0x1F0E689F: udevGetDeviceDetails (node_device_udev.c:1300)
==3770==    by 0x1F0E6E06: udevAddOneDevice (node_device_udev.c:1422)
==3770==    by 0x1F0E6FB8: udevProcessDeviceListEntry (node_device_udev.c:1464)
==3770==    by 0x1F0E70CF: udevEnumerateDevices (node_device_udev.c:1494)
==3770==    by 0x1F0E7BB4: nodeStateInitialize (node_device_udev.c:1806)
==3770==    by 0x51B4303: virStateInitialize (libvirt.c:777)
==3770==    by 0x11DEE7: daemonRunStateInit (libvirtd.c:906)
==3770==  Address 0x228e38d4 is on thread 12's stack
==3770==  in frame #2, created by virNetDevFeatureAvailable (virnetdev.c:2750)

* src/util/virnetdev.c (virNetDevFeatureAvailable): Initialize all
bytes of ifr.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agovirsh: fix report of non-active commit completion
Eric Blake [Fri, 13 Mar 2015 15:56:48 +0000 (09:56 -0600)]
virsh: fix report of non-active commit completion

Commit f182da20 (v1.2.6) caused a slight regression in virsh
reporting of a non-active block job; where it used to state
"Commit complete", it now states "Now in synchronized phase".
But the synchronized phase is only possible for an active commit.

For a reproducer, I created a chain 'a <- b <- c <- d <- e' and
ran virsh blockcommit $dom vda --top c --base a --verbose --wait

* tools/virsh-domain.c (cmdBlockCommit): Synchronized phase is
only possible on active commits.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoutil: don't fail if no PortData is found while getting migrateData
zhang bo [Thu, 5 Mar 2015 02:01:50 +0000 (10:01 +0800)]
util: don't fail if no PortData is found while getting migrateData

Introduced by f6a2f97e

Problem Description:
After multiple times of migrating a domain, which has an ovs interface with no portData set,
with non-shared disk, nbd ports got overflowed.

The steps to reproduce the problem:
1 define and start a domain with its network configured as:
    <interface type='bridge'>
          <source bridge='br0'/>
          <virtualport type='openvswitch'>
          </virtualport>
          <model type='virtio'/>
          <driver name='vhost' queues='4'/>
    </interface>
2 do not set the network's portData.
3 migrate(ToURI2) it with flag 91(1011011), which means:
  VIR_MIGRATE_LIVE
  VIR_MIGRATE_PEER2PEER
  VIR_MIGRATE_PERSIST_DEST
  VIR_MIGRATE_UNDEFINE_SOURCE
  VIR_MIGRATE_NON_SHARED_DISK
4 migrate success, but we got an error log in libvirtd.log:
  error : virCommandWait:2423 : internal error: Child process (ovs-vsctl --timeout=5 get Interface
  vnet1 external_ids:PortData) unexpected exit status 1: ovs-vsctl: no key "PortData" in Interface
  record "vnet1" column external_ids
5 migrate it back, migrate it , migrate it back, .......
6 nbd port got overflowed.

The reasons for the problem is :
1 virNetDevOpenvswitchGetMigrateData() takes it as wrong if no portData is available for  the ovs
 interface of a domain. (We think it's not appropriate, as portData is just OPTIONAL)
2 in func qemuMigrationBakeCookie(), it fails in qemuMigrationCookieAddNetwork(), and returns with -1.
 qemuMigrationCookieAddNBD() is not called thereafter, and mig->nbd is still NULL.
3 However, qemuMigrationRun() just *WARN* if qemuMigrationBakeCookie() fails, migration still successes.
 cookie is NULL, it's not baked on the src side.
4 On the destination side, it would alloc a port first and then free the nbd port in COOKIE.
 But the cookie is NULL due to qemuMigrationCookieAddNetwork() failure at src side. thus the nbd port
 is not freed.

In this patch, we add "--if-exists" option to make ovs-vsctl not raise error if there's no portData available.
Further more, because portData may be NULL in the cookie at the dest side, check it before setting portData.

Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agolibxl: prevent attaching multiple netdevs with the same MAC
Marek Marczykowski-Górecki [Fri, 6 Mar 2015 14:36:16 +0000 (15:36 +0100)]
libxl: prevent attaching multiple netdevs with the same MAC

It will not be possible to detach such device later. Also improve
logging in such cases.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
10 years agoconf: add virDomainHasNet
Marek Marczykowski-Górecki [Fri, 6 Mar 2015 14:36:15 +0000 (15:36 +0100)]
conf: add virDomainHasNet

virDomainNetFindIdx no longer returns info whether device was not found,
or there was multiple matches. Additionally it already handle error
reporting. Introduce virDomainHasNet which does a simple task, without
implicit error reporting.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
10 years agotests: xenconfig: test for multiple USB devices and other HVM options
Marek Marczykowski-Górecki [Fri, 6 Mar 2015 14:36:14 +0000 (15:36 +0100)]
tests: xenconfig: test for multiple USB devices and other HVM options

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
10 years agoxenconfig: add support for multiple USB devices syntax
Marek Marczykowski-Górecki [Fri, 6 Mar 2015 14:36:13 +0000 (15:36 +0100)]
xenconfig: add support for multiple USB devices syntax

In Xen>=4.3, libxl supports new syntax for USB devices:
usbdevice=[ "DEVICE", "DEVICE", ... ]
Add support for that in xenconfig driver. When only one device is
defined, keep using old syntax for backward compatibility.

Adjust tests for changed options order.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
10 years agolibxl: add tablet/mouse input device support
Marek Marczykowski [Fri, 6 Mar 2015 14:36:12 +0000 (15:36 +0100)]
libxl: add tablet/mouse input device support

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
10 years agobridge_driver: Use more of networkObjFromNetwork
Michal Privoznik [Mon, 2 Mar 2015 11:22:11 +0000 (12:22 +0100)]
bridge_driver: Use more of networkObjFromNetwork

Now that the network driver lock is ash heap of history,
we can use more of networkObjFromNetwork().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoparallels_network: Drop parallelsDriverLock() from everywhere.
Michal Privoznik [Thu, 26 Feb 2015 13:36:47 +0000 (14:36 +0100)]
parallels_network: Drop parallelsDriverLock() from everywhere.

While in previous commits there were some places that relied on
the big lock, in this file there's no such place and the big
driver lock can be dropped completely. Yay!

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agotest_driver: Drop testDriverLock() from almost everywhere
Michal Privoznik [Thu, 26 Feb 2015 13:25:54 +0000 (14:25 +0100)]
test_driver: Drop testDriverLock() from almost everywhere

Well, if 'everywhere' is defined as that part of the driver code
that serves virNetwork* APIs. Again, we lower layers already have
their locks, so there's no point doing big lock.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agobridge_driver: Drop networkDriverLock() from almost everywhere
Michal Privoznik [Thu, 26 Feb 2015 13:19:53 +0000 (14:19 +0100)]
bridge_driver: Drop networkDriverLock() from almost everywhere

Now that we have fine grained locks, there's no need to
lock the whole driver. We can rely on self-locking APIs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agostruct _virNetworkDriverState: Annotate items
Michal Privoznik [Tue, 10 Mar 2015 14:42:18 +0000 (15:42 +0100)]
struct _virNetworkDriverState: Annotate items

In order to drop network driver lock, lets annotate which
structure items are immutable, which have self-locking
APIs and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonetwork_driver: Use accessor for dnsmasqCaps
Michal Privoznik [Thu, 12 Mar 2015 13:28:15 +0000 (14:28 +0100)]
network_driver: Use accessor for dnsmasqCaps

This is not an immutable pointer and can change during lifetime.
Therefore, in order to drop network driver lock, we must use an
internal accessor which does not lock the network driver yet, but
it will soon. Now it merely returns an referenced object.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agobridge_driver: Don't access global driver randomly
Michal Privoznik [Thu, 12 Mar 2015 12:42:46 +0000 (13:42 +0100)]
bridge_driver: Don't access global driver randomly

Well, network driver code has the driver accessible as a global
variable. This makes any rework hard, as it's unclear where the
variable is accessed and/or modified. Lets just pass the driver
as a parameter to all functions where needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce virBitmapIsBitSet
Ján Tomko [Wed, 11 Mar 2015 15:41:57 +0000 (16:41 +0100)]
Introduce virBitmapIsBitSet

A helper that never returns an error and treats bits out of bitmap range
as false.

Use it everywhere we use ignore_value on virBitmapGetBit, or loop over
the bitmap size.

10 years agoClarify the meaning of version in redirdev filters
Ján Tomko [Thu, 12 Mar 2015 12:13:39 +0000 (13:13 +0100)]
Clarify the meaning of version in redirdev filters

The version attribute in redirdev filters refers to the revision
of the device, not the version of the USB protocol.

Explicitly state that this is not the USB protocol and remove references
to those round version numbers that resemble USB protocol versions.

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

10 years agoparallels: fix prlsdkCheckUnsupportedParams checks
Maxim Nestratov [Thu, 12 Mar 2015 15:43:29 +0000 (18:43 +0300)]
parallels: fix prlsdkCheckUnsupportedParams checks

for memory limits since unset ones are no longer zero

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agovmx: add e1000e to supported NIC models.
Dawid Zamirski [Mon, 9 Mar 2015 15:16:26 +0000 (11:16 -0400)]
vmx: add e1000e to supported NIC models.

This NIC model is supported on hardware version 8 and newer and libvirt
ESX driver does support those.

10 years agovbox: use user cache dir when screenshotting.
Dawid Zamirski [Mon, 9 Mar 2015 15:07:46 +0000 (11:07 -0400)]
vbox: use user cache dir when screenshotting.

For VBOX it's most likely that the connection is vbox:///session and it
runs with local non-root account. This caused permission denied when
LOCALSTATEDIR was used to create temp file. This patch makes use of the
virGetUserCacheDirectory to address this problem for non-root users.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnetdev: fix build with old kernel
Pavel Hrdina [Tue, 10 Mar 2015 16:00:15 +0000 (17:00 +0100)]
virnetdev: fix build with old kernel

Commit c9027d8f added a detection of NIC HW features, but some of them
are not available in old kernel.  Very old kernels lack enum
ethtool_flags and even if this enum is present, not all values are
available for all kernels.  To be sure that we have everything in kernel
that we need, we must check for existence of most of that flags, because
only few of them were defined at first.

Also to successfully build libvirt with older kernel we need to include
<linux/types.h> before <linux/ethtool.h> to have __u32 and friends
defined.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoparallels: add VIR_ARCH_I686 capability to parallels driver
Maxim Nestratov [Tue, 10 Mar 2015 19:32:50 +0000 (22:32 +0300)]
parallels: add VIR_ARCH_I686 capability to parallels driver

as soon as x32 architecture is also supported

10 years agoError out on an address for isa-serial in QEMU driver.
Ján Tomko [Wed, 4 Mar 2015 07:58:02 +0000 (08:58 +0100)]
Error out on an address for isa-serial in QEMU driver.

We've never formatted them on the qemu command line.

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

10 years agoxenapi: Resolve Coverity REVERSE_INULL
John Ferlan [Tue, 10 Mar 2015 23:14:31 +0000 (19:14 -0400)]
xenapi: Resolve Coverity REVERSE_INULL

Coverity notes in xenapiDomainGetXMLDesc that 'vms' is dereferenced
a few times before a "if (vms) xen_vm_set_free(vms);" call is made.
Since we'd exit out much sooner if the fetch of the vms failed, just
remove the unnecessary "if (vms)" check.

10 years agoxenapi: Resolve Coverity REVERSE_INULL
John Ferlan [Tue, 10 Mar 2015 23:10:34 +0000 (19:10 -0400)]
xenapi: Resolve Coverity REVERSE_INULL

Coverity complains that "net_set" is compared to NULL before calling
xen_network_set_free, but used rather liberally before that.  While
I was looking at the code I also noted that if the virAsprintfQuiet
fails, then we leak our structures - so I added those too.

10 years agoxenapi: Resolve Coverity NULL_RETURNS
John Ferlan [Tue, 10 Mar 2015 22:52:07 +0000 (18:52 -0400)]
xenapi: Resolve Coverity NULL_RETURNS

Coverity points out that the return from virDomainDefParseString is
not checked in xenapiDomainCreateXML like it should be which could
end up in a NULL pointer dereference

10 years agoxenapi: Resolve Coverity NO_EFFECT
John Ferlan [Tue, 10 Mar 2015 22:41:18 +0000 (18:41 -0400)]
xenapi: Resolve Coverity NO_EFFECT

Coverity points out that check (def->uuid) has no effect since it's not
a pointer, rather an array of characters.   Just remove the extranous check.

10 years agoxenapi: Resolve Coverity FORWARD_NULL
John Ferlan [Tue, 10 Mar 2015 22:33:59 +0000 (18:33 -0400)]
xenapi: Resolve Coverity FORWARD_NULL

Since inception.  Coverity complains that the code checks "(record ==
NULL && !session->ok)", but doesn't check (record != NULL) before
dereferencing at "record->is_a_template"

10 years agoconf: Resolve Coverity RESOURCE_LEAK
John Ferlan [Tue, 10 Mar 2015 22:24:49 +0000 (18:24 -0400)]
conf: Resolve Coverity RESOURCE_LEAK

Commit id 'c9027d8f' added parsing of the CapNet for offload SRIOV NIC
discovery, but forgot to free the nodes

10 years agovirsh: Add iothreadpin command
John Ferlan [Fri, 6 Mar 2015 00:08:04 +0000 (19:08 -0500)]
virsh: Add iothreadpin command

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

$ virsh iothread --help

  NAME
    iothreadpin - control domain IOThread affinity

  SYNOPSIS
    iothreadpin <domain> <iothread> <cpulist> [--config] [--live] [--current]

  DESCRIPTION
    Pin domain IOThreads to host physical CPUs.

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    [--iothread] <number>  IOThread ID number
    [--cpulist] <string>  host cpu number(s) to set
    --config         affect next boot
    --live           affect running domain
    --current        affect current domain

Using the output from iothreadsinfo, allow changing the pinned CPUs for
a single IOThread.

$ virsh iothreadsinfo $dom
 IOThread ID    CPU Affinity
---------------------------------------------------
 1               2
 2               3
 3               0-1

$ virsh iothreadpin $dom 3 0-2

Then view the change

$ virsh iothreadsinfo $dom
 IOThread ID    CPU Affinity
---------------------------------------------------
 1               2
 2               3
 3               0-2

If an invalid value is supplied or require option missing,
then an error will be displayed:

$ virsh iothreadpin $dom 4 3
error: invalid argument: iothread value out of range 4 > 3

$ virsh iothreadpin $dom 3
error: command 'iothreadpin' requires <cpulist> option

10 years agoqemu: Add support to pin IOThreads to specific CPU
John Ferlan [Fri, 6 Mar 2015 00:07:51 +0000 (19:07 -0500)]
qemu: Add support to pin IOThreads to specific CPU

Add qemuDomainPinIOThread to handle setting the CPU affinity
for a specific IOThread

10 years agodomain: Introduce virDomainIOThreadsPin{Add|Del}
John Ferlan [Tue, 17 Feb 2015 17:22:48 +0000 (12:22 -0500)]
domain: Introduce virDomainIOThreadsPin{Add|Del}

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

More or less a virtual copy of the existing virDomainVcpuPin{Add|Del} API's.

NB: The IOThreads implementation "reused" the virDomainVcpuPinDefPtr
since it provided everything necessary - an "id" and a "map" for each
thread id configured.

10 years agoremote: Implement the plumbing for virDomainPinIOThread
John Ferlan [Thu, 5 Mar 2015 19:28:39 +0000 (14:28 -0500)]
remote: Implement the plumbing for virDomainPinIOThread

Implement the remote plumbing.

10 years agoImplement public API for virDomainPinIOThread
John Ferlan [Thu, 5 Mar 2015 19:14:27 +0000 (14:14 -0500)]
Implement public API for virDomainPinIOThread

Add virDomainPinIOThread to allow setting the CPU affinity for a specific
IOThread based on the output generated from virDomainGetIOThreadsInfo

The API supports updating both the --live domain and the --config data

10 years agovirNetworkObjFindBy*: Return an reference to found object
Michal Privoznik [Thu, 26 Feb 2015 12:45:05 +0000 (13:45 +0100)]
virNetworkObjFindBy*: Return an reference to found object

This patch turns both virNetworkObjFindByUUID() and
virNetworkObjFindByName() to return an referenced object so that
even if caller unlocks it, it's for sure that object won't
disappear meanwhile. Especially if the object (in general) is
locked and unlocked during the caller run.
Moreover, this commit is nicely small, since the object unrefing
can be done in virNetworkObjEndAPI().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNetworkObjListPtr: Make APIs self-locking
Michal Privoznik [Thu, 26 Feb 2015 07:51:55 +0000 (08:51 +0100)]
virNetworkObjListPtr: Make APIs self-locking

Every API that touches internal structure of the object must lock
the object first. Not every API that has the object as an
argument needs to do that though. Some APIs just pass the object
to lower layers which, however, must lock the object then. Look
at the code, you'll get my meaning soon.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonetwork_conf: Introduce locked versions of lookup functions
Michal Privoznik [Wed, 4 Mar 2015 12:28:07 +0000 (13:28 +0100)]
network_conf: Introduce locked versions of lookup functions

This is going to be needed later, when some functions already
have the virNetworkObjList object already locked and need to
lookup a object to work on. As an example of such function is
virNetworkAssignDef(). The other use case might be in
virNetworkObjListForEach() callback.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNetworkObjList: Derive from virObjectLockableClass
Michal Privoznik [Wed, 25 Feb 2015 13:58:16 +0000 (14:58 +0100)]
virNetworkObjList: Derive from virObjectLockableClass

Later we can turn APIs to lock the object if needed instead of
relying on caller to mutually exclude itself (probably done by
locking a big lock anyway).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoparallels_network: Use virNetworkObjEndAPI
Michal Privoznik [Wed, 25 Feb 2015 16:38:54 +0000 (17:38 +0100)]
parallels_network: Use virNetworkObjEndAPI

So far, this is pure code replacement. But once we introduce
reference counting to virNetworkObj this will be more handy as
there'll be only one function to change: virNetworkObjEndAPI().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agotest_driver: Use virNetworkObjEndAPI
Michal Privoznik [Wed, 25 Feb 2015 16:38:54 +0000 (17:38 +0100)]
test_driver: Use virNetworkObjEndAPI

So far, this is pure code replacement. But once we introduce
reference counting to virNetworkObj this will be more handy as
there'll be only one function to change: virNetworkObjEndAPI().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agobridge_driver: Use virNetworkObjEndAPI
Michal Privoznik [Wed, 25 Feb 2015 16:01:52 +0000 (17:01 +0100)]
bridge_driver: Use virNetworkObjEndAPI

So far, this is pure code replacement. But once we introduce
reference counting to virNetworkObj this will be more handy as
there'll be only one function to change: virNetworkObjEndAPI().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonetwork_conf: Introduce virNetworkObjEndAPI
Michal Privoznik [Wed, 25 Feb 2015 15:49:19 +0000 (16:49 +0100)]
network_conf: Introduce virNetworkObjEndAPI

This is practically copy of qemuDomObjEndAPI. The reason why is
it so widely available is to avoid code duplication, since the
function is going to be called from our bridge driver, test
driver and parallels driver too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonetwork_conf: Make virNetworkObj actually virObject
Michal Privoznik [Wed, 25 Feb 2015 13:08:19 +0000 (14:08 +0100)]
network_conf: Make virNetworkObj actually virObject

So far it's just a structure which happens to have 'Obj' in its
name, but otherwise it not related to virObject at all. No
reference counting, not virObjectLock(), nothing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNetworkObjListPtr: Turn list into a hash table
Michal Privoznik [Mon, 9 Mar 2015 11:16:12 +0000 (12:16 +0100)]
virNetworkObjListPtr: Turn list into a hash table

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: monitor: Kill qemuMonitorGetBlockStats(Info,ParamsNumber)
Peter Krempa [Tue, 10 Mar 2015 15:56:53 +0000 (16:56 +0100)]
qemu: monitor: Kill qemuMonitorGetBlockStats(Info,ParamsNumber)

The functions and their QMP and HMP implementations are no longer needed
since everything is now done via the *AllStats functions.

10 years agotest: qemu: json: Avoid using the now obsolete functions
Peter Krempa [Tue, 10 Mar 2015 16:11:22 +0000 (17:11 +0100)]
test: qemu: json: Avoid using the now obsolete functions

Use the new single function instead of calling
qemuMonitorJSONGetBlockStatsInfo and
qemuMonitorJSONGetBlockStatsParamsNumber. This will allow to delete the
functions later while still maintaining coverage.

10 years agoqemu: blockstats: Refactor qemuDomainBlockStatsFlags
Peter Krempa [Tue, 10 Mar 2015 15:52:08 +0000 (16:52 +0100)]
qemu: blockstats: Refactor qemuDomainBlockStatsFlags

Now that qemuDomainBlocksStatsGather provides functions of both
qemuMonitorGetBlockStatsParamsNumber and qemuMonitorGetBlockStatsInfo we
can reuse it and kill a lot of code.

Additionally as a bonus qemuDomainBlockStatsFlags will now support
summary statistics so add a statement to the virsh man page about that.

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

10 years agoqemu: blockstats: Add support for totalled block statistics
Peter Krempa [Tue, 10 Mar 2015 14:54:17 +0000 (15:54 +0100)]
qemu: blockstats: Add support for totalled block statistics

In the LXC driver, if the disk path is not provided the API returns
total statistics for all disks of the domain. With the new text monitor
implementation this can be now done in the qemu driver too.

Add code that wil total the stats for all disks if the path is not
provided.

10 years agoqemu: Split out working code qemuDomainBlockStats
Peter Krempa [Tue, 10 Mar 2015 14:37:31 +0000 (15:37 +0100)]
qemu: Split out working code qemuDomainBlockStats

Extract the code to look up the disk alias and return the block stats
struct so that it can be reused later in qemuDomainBlockStatsFlags.

The function uses qemuMonitorGetAllBlockStatsInfo instead of
qemuMonitorGetBlockStatsInfo.

10 years agoqemu: monitor: Count block stats fields in qemuMonitorGetAllBlockStatsInfo
Peter Krempa [Tue, 10 Mar 2015 13:40:58 +0000 (14:40 +0100)]
qemu: monitor: Count block stats fields in qemuMonitorGetAllBlockStatsInfo

Our virDomainBlockStatsFlags API uses the old approach where, when it's
called without the typed parameter array, returns the count of parameters
supported by qemu.

The supported parameter count is obtained via separate monitor calls
which is a waste since we can calculate it when gathering the data.

This patch adds code to the qemuMonitorGetAllBlockStatsInfo workers that
allows to track the count of supported fields reported by qemu and will
allow to remove the old duplicate code.

10 years agoqemu: monitor: Convert common code to a macro
Peter Krempa [Tue, 10 Mar 2015 13:32:46 +0000 (14:32 +0100)]
qemu: monitor: Convert common code to a macro

The function that is extracting block stats data from the QMP monitor
reply contains a lot of repeated code. Since I'd be changing each of the
copies in the next patch, lets convert it to a macro right away.

10 years agoqemu: monitor: Implement HMP version for listing all block device stats
Peter Krempa [Mon, 9 Mar 2015 16:23:49 +0000 (17:23 +0100)]
qemu: monitor: Implement HMP version for listing all block device stats

Add a different version of parser for "info blockstats" that basically
parses the same information as the existing copy of the function.

This will allow us to remove the single device version
qemuMonitorGetBlockStatsInfo in the future.

The new implementation uses few new helpers so it should be more
understandable and provides a test case to verify that it works.

10 years agotest: qemu: Fix qemu monitor test utils to allow testing HMP
Peter Krempa [Tue, 10 Mar 2015 12:10:20 +0000 (13:10 +0100)]
test: qemu: Fix qemu monitor test utils to allow testing HMP

qemu HMP commands sent by libvirt are terminated just by a '\r'. The
fake monitor used in tests wasn't prepared to handle this and the
communication would hang on an attempt to do a HMP conversation.

Add a special case for handling commands separated by \r in case HMP is
used.

10 years agoqemu: blockstats: Switch to caller allocated hash table
Peter Krempa [Tue, 10 Mar 2015 09:02:40 +0000 (10:02 +0100)]
qemu: blockstats: Switch to caller allocated hash table

Allocate the hash table in the monitor wrapper function instead of the
worker itself so that the text monitor impl that will be added in the
next patch doesn't have to duplicate it.

10 years agoqemu: monitor: Drop parsing of 'errs' from block info
Peter Krempa [Mon, 9 Mar 2015 14:25:17 +0000 (15:25 +0100)]
qemu: monitor: Drop parsing of 'errs' from block info

The error count statistic is not supported by qemu, so there's no need
to pass the variables around if the result is ignored anyways.