Commit Graph

24588 Commits

Author SHA1 Message Date
Kothapally Madhu Pavan
011935457a vsh: Using VSH_REQUIRE_OPTION rather than virReportError
Correcting the error reporting method by using VSH_REQUIRE_OPTION
instead of virReportError

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
2016-10-28 14:19:41 -04:00
Laine Stump
bbb333e481 network: fix endless loop when starting network with multiple IPs and no dhcp
commit 9065cfaa added the ability to disable DNS services for a
libvirt virtual network. If neither DNS nor DHCP is needed for a
network, then we don't need to start dnsmasq, so code was added to
check for this.

Unfortunately, it was written with a great lack of attention to detail
(I can say that, because I was the author), and the loop that checked
if DHCP is needed for the network would never end if the network had
multiple IP addresses and the first <ip> had no <dhcp> subelement
(which would have contained a <range> or <host> subelement, thus
requiring DHCP services).

This patch rewrites the check to be more compact and (more
importantly) finite.

This bug was present in release 2.2.0 and 2.3.0, so will need to be
backported to any relevant maintainence branches.

Reported here:
  https://www.redhat.com/archives/libvirt-users/2016-October/msg00032.html
  https://www.redhat.com/archives/libvirt-users/2016-October/msg00045.html
2016-10-28 13:59:17 -04:00
Chen Hanxiao
3b782ce572 qemu_driver: unlink new domain cfg file when rollback
If we failed to unlink old dom cfg file, we goto rollback.
But inside rollback, we fogot to unlink the new dom cfg file.
This patch fixes this issue.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-28 04:13:05 -07:00
Michal Privoznik
65462b2944 qemu: Minimalize global driver accesses
Whilst working on another issue, I've noticed that in some
functions we have a local @driver variable among with access to
global @qemu_driver variable. This makes no sense.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-27 18:48:39 -07:00
Nikolay Shirokovskiy
97338eaa7b qemu: Fix crash during qemuStateCleanup
Rather than waiting until we've free'd up all the resources, cause the
'workerPool' thread pool to flush as soon as possible during stateCleanup.
Otherwise, it's possible something waiting to run will SEGV such as is the
case during race conditions of simultaneous exiting libvirtd and qemu process.
Resolves the following crash:

[1] crash backtrace: (bt is shortened a bit):

0  0x00007ffff7282f2b in virClassIsDerivedFrom
   (klass=0xdeadbeef, parent=0x55555581d650) at util/virobject.c:169
1  0x00007ffff72835fd in virObjectIsClass
   (anyobj=0x7fffd024f580, klass=0x55555581d650) at util/virobject.c:365
2  0x00007ffff7283498 in virObjectLock
   (anyobj=0x7fffd024f580) at util/virobject.c:317
3  0x00007ffff722f0a3 in virCloseCallbacksUnset
   (closeCallbacks=0x7fffd024f580, vm=0x7fffd0194db0,
    cb=0x7fffdf1af765 <qemuProcessAutoDestroy>)
   at util/virclosecallbacks.c:164
4  0x00007fffdf1afa7b in qemuProcessAutoDestroyRemove
   (driver=0x7fffd00f3a60, vm=0x7fffd0194db0) at qemu/qemu_process.c:6365
5  0x00007fffdf1adff1 in qemuProcessStop
   (driver=0x7fffd00f3a60, vm=0x7fffd0194db0, reason=VIR_DOMAIN_SHUTOFF_CRASHED,
    asyncJob=QEMU_ASYNC_JOB_NONE, flags=0)
   at qemu/qemu_process.c:5877
6  0x00007fffdf1f711c in processMonitorEOFEvent
   (driver=0x7fffd00f3a60, vm=0x7fffd0194db0) at qemu/qemu_driver.c:4545
7  0x00007fffdf1f7313 in qemuProcessEventHandler
   (data=0x555555832710, opaque=0x7fffd00f3a60) at qemu/qemu_driver.c:4589
8  0x00007ffff72a84c4 in virThreadPoolWorker
   (opaque=0x555555805da0) at util/virthreadpool.c:167

Thread 1 (Thread 0x7ffff7fb1880 (LWP 494472)):
1  0x00007ffff72a7898 in virCondWait
   (c=0x7fffd01c21f8, m=0x7fffd01c21a0) at util/virthread.c:154
2  0x00007ffff72a8a22 in virThreadPoolFree
   (pool=0x7fffd01c2160) at util/virthreadpool.c:290
3  0x00007fffdf1edd44 in qemuStateCleanup ()
   at qemu/qemu_driver.c:1102
4  0x00007ffff736570a in virStateCleanup ()
   at libvirt.c:807
5  0x000055555556f991 in main (argc=1, argv=0x7fffffffe458) at libvirtd.c:1660
2016-10-27 15:58:52 -04:00
Nikolay Shirokovskiy
85c3a1820a daemon: Fix crash during daemon cleanup
Do not dereference the 'dmn' until after the virStateCleanup is completed.

During initialization, virStateInitialize requires/uses the "dmn" as the
argument to/for the daemonInhibitCallback functions. Thus, cleanup cannot
dereference 'dmn' until after calling the virStateCleanup which calls the
the daemonInhibitCallback using 'dmn'; otherwise, the following crash occurs:

backtrace (shortened a bit)

1  0x00007fd3a791b2e6 in virCondWait (c=<optimized out>, m=<optimized out>)
   at util/virthread.c:154
2  0x00007fd3a791bcb0 in virThreadPoolFree (pool=0x7fd38024ee00)
   at util/virthreadpool.c:266
3  0x00007fd38edaa00e in qemuStateCleanup () at qemu/qemu_driver.c:1116
4  0x00007fd3a79abfeb in virStateCleanup () at libvirt.c:808
5  0x00007fd3a85f2c9e in main (argc=<optimized out>, argv=<optimized out>)
    at libvirtd.c:1660

Thread 1 (Thread 0x7fd38722d700 (LWP 32256)):
0  0x00007fd3a7900910 in virClassIsDerivedFrom
   (klass=0xdfd36058d4853, parent=0x7fd3a8f394d0) at util/virobject.c:169
1  0x00007fd3a7900c4e in virObjectIsClass
   (anyobj=anyobj@entry=0x7fd3a8f2f850, klass=<optimized out>)
   at util/virobject.c:365
2  0x00007fd3a7900c74 in virObjectLock (anyobj=0x7fd3a8f2f850)
   at util/virobject.c:317
3  0x00007fd3a7a24d5d in virNetDaemonRemoveShutdownInhibition
   (dmn=0x7fd3a8f2f850) at rpc/virnetdaemon.c:547
4  0x00007fd38ed722cf in qemuProcessStop
   (driver=driver@entry=0x7fd380103810, vm=vm@entry=0x7fd38025b6d0,
    reason=reason@entry=VIR_DOMAIN_SHUTOFF_SHUTDOWN,
    asyncJob=asyncJob@entry=QEMU_ASYNC_JOB_NONE, flags=flags@entry=0)
   at qemu/qemu_process.c:5786
5  0x00007fd38edd9428 in processMonitorEOFEvent
   (vm=0x7fd38025b6d0, driver=0x7fd380103810) at qemu/qemu_driver.c:4588
6  qemuProcessEventHandler (data=<optimized out>, opaque=0x7fd380103810)
   at qemu/qemu_driver.c:4632
7  0x00007fd3a791bb55 in virThreadPoolWorker
   (opaque=opaque@entry=0x7fd3a8f1e4c0) at util/virthreadpool.c:145
2016-10-27 15:58:47 -04:00
Maxim Nestratov
29594f2675 vz: remove Bridged network name and rename Routed
It's funny, but Routed network name was incorrect. We should use
host-routed instead.
2016-10-27 17:25:50 +03:00
Maxim Nestratov
0e094a4495 vz: support type=bridge network interface type correctly
Recently, libprlsdk got a separate flag PNA_BRIDGE corresponding to
type=bridge libvirt network interfaces. Let's use it and get rid of
all workarounds previously added to  support it.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-10-27 17:25:50 +03:00
Chen Hanxiao
8b035c84d8 qemu: Forbid pinning vCPUs for TCG domain
We don't support cpu pinning for TCG domains because QEMU runs them in
one thread only.  But vcpupin command was able to set them, which
resulted in a failed startup, so make sure that doesn't happen.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2016-10-27 15:21:03 +02:00
Ján Tomko
dc67d00cd2 Recreate the USB address cache at reconnect
When starting a new domain, we allocate the USB addresses and keep
an address cache in the domain object's private data.

However this data is lost on libvirtd restart.

Also generate the address cache if all the addresses have been
specified, so that devices hotplugged after libvirtd restart
also get theirs assigned.

https://bugzilla.redhat.com/show_bug.cgi?id=1387666
2016-10-27 13:38:56 +02:00
Ján Tomko
244ebb8f2b Do not try to release virtio serial addresses
Return 0 instead of 1, so that qemuDomainAttachChrDevice does not
assume the address neeeds to be released on error.

No functional change, since qemuDomainReleaseDeviceAddress has been a noop
for virtio serial addresses since the address cache was removed
in commit 19a148b.
2016-10-27 11:16:42 +02:00
Ján Tomko
00c5386c86 Fix crash on usb-serial hotplug
For domains with no USB address cache, we should not attempt
to generate a USB address.

https://bugzilla.redhat.com/show_bug.cgi?id=1387665
2016-10-27 11:15:33 +02:00
Ján Tomko
c11586940c Return directly from qemuDomainAttachChrDeviceAssignAddr
This function should never need a cleanup section.
2016-10-27 11:08:04 +02:00
Ján Tomko
ac518960a6 Introduce virDomainVirtioSerialAddrAutoAssign again
This time do not require an address cache as a parameter.

Simplify qemuDomainAttachChrDeviceAssignAddr to not generate
the virtio serial address cache for devices of other types.

Partially reverts commit 925fa4b.
2016-10-27 11:05:07 +02:00
Ján Tomko
0512dd26ee Add 'FromCache' to virDomainVirtioSerialAddrAutoAssign
Commit 19a148b dropped the cache from QEMU's private domain object.
Assume the callers do not have the cache by default and use
a longer name for the internal ones that do.

This makes the shorter 'virDomainVirtioSerialAddrAutoAssign'
name availabe for a function that will not require the cache.
2016-10-27 11:04:58 +02:00
Martin Kletzander
eacecd7437 virsh: Fix on_shutdown to on_poweroff
The 'on_shutdown' was the name in Xen, there was never such option in
libvirt's domain XML.

Reported-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-10-27 08:45:11 +02:00
Sławek Kapłoński
3e044e6e49 qemu, lxc: Raise error message when resuming running domain
When user tries to resume already running domain (Qemu or LXC)
VIR_ERR_OPERATION_INVALID error should be raised with message that
domain is already running.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1009008
2016-10-26 19:46:44 +02:00
Andrea Bolognani
3cbf054995 wireshark: Rename plugindir to ws_plugindir
Since we're using autoconf to substitute the right value in
Makefile.am now, we can use a less generic name without running
into circular dependencies.
2016-10-26 17:00:21 +02:00
Andrea Bolognani
c587c73549 wireshark: Inject $(prefix) at the right time
Adding $(prefix) in Makefile.am, as we were doing, means that
it would be prepended even when using --with-ws-plugindir,
which is something we don't want to happen.

Instead, we add it beforehand but take care that it doesn't
get expanded until make is called.
2016-10-26 17:00:21 +02:00
Andrea Bolognani
debf2f0b8a wireshark: Strip prefix correctly
Even when we're building $plugindir ourselves because we can't
retrieve it using pkg-config, we still want to strip the prefix,
except in that case it would be the same prefix we're using for
building libvirt.

The fact that $plugindir is missing also doesn't tell us
anything about $ws_prefix, so we have to handle the two variables
separately.
2016-10-26 17:00:21 +02:00
Andrea Bolognani
c64a0a8e32 wireshark: Hoist $ws_prefix declaration
Keep all variable declarations close together.
2016-10-26 17:00:21 +02:00
Andrea Bolognani
182517013e wireshark: Introduce $ws_modversion
Use a separate variable instead of setting it inline for
slightly cleaner code.
2016-10-26 17:00:20 +02:00
Gema Gomez
0701abcb3b qemu: Add support for using AES secret for SCSI hotplug
Support for virtio disks was added in commit id 'fceeeda', but not for
SCSI drives. Add the secret for the server when hotplugging a SCSI drive.
No need to make any adjustments for unplug since that's handled during
the qemuDomainDetachDiskDevice call to qemuDomainRemoveDiskDevice in
the qemuDomainDetachDeviceDiskLive switch.

Added a test to/for the command line processing to show the command line
options when adding a SCSI drive for the guest.
2016-10-26 08:07:15 -04:00
John Ferlan
8550e8585e qemu: Add secret object hotplug for TCP chardev TLS
https://bugzilla.redhat.com/show_bug.cgi?id=1300776

Complete the implementation of support for TLS encryption on
chardev TCP transports by adding the hotplug ability of a secret
to generate the passwordid for the TLS object for chrdev, RNG,
and redirdev.

Fix up the order of object removal on failure to be the inverse
of the attempted attach (for redirdev, chr, rng) - for each the
tls object was being removed before the chardev backend.

Likewise, add the ability to hot unplug that secret object as well
and be sure the order of unplug matches that inverse order of plug.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-26 07:27:48 -04:00
John Ferlan
daf5c651f0 qemu: Add a secret object to/for a char source dev
Add the secret object so the 'passwordid=' can be added if the command line
if there's a secret defined in/on the host for TCP chardev TLS objects.

Preparation for the secret involves adding the secinfo to the char source
device prior to command line processing. There are multiple possibilities
for TCP chardev source backend usage.

Add test for at least a serial chardev as an example.
2016-10-26 07:18:25 -04:00
John Ferlan
68808516fe qemu: Need to remove TLS object in RemoveRNGDevice
Commit id '6e6b4bfc' added the object, but forgot the other end.
2016-10-26 07:04:15 -04:00
John Ferlan
502c747aa1 qemu: Fix depedency order in qemuRemoveDiskDevice
Need to remove the drive first, then the secobj and/or encobj if they exist.
This is because the drive has a dependency on secobj (or the secret for
the networked storage server) and/or the encobj (or the secret for the
LUKS encrypted volume).  Deleting either object first leaves an drive
without it's respective objects.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-26 06:56:00 -04:00
John Ferlan
13022ce430 virsh: Add _length parameters to virsh output
https://bugzilla.redhat.com/show_bug.cgi?id=1349898

Add the duration parameters to the virsh input/output for blkdeviotune
command and describe them in the pod file.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-25 17:20:17 -04:00
John Ferlan
49d01f9e3f virsh: Create macros to add IOTUNE values
Rework the repetitive lines to add iotune values into easier to read macros.
One to handle the SCALED values and one to handle the non scaled values.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-25 17:20:17 -04:00
John Ferlan
2db108c766 qemu: Add the length options to the iotune command line
Add in the block I/O throttling length/duration parameter to the command
line if supported. If not supported, fail command creation.

Add the xml2argvtest for testing.
2016-10-25 17:20:17 -04:00
John Ferlan
8dcf355973 conf: Add support for blkiotune "_length" options
Modify _virDomainBlockIoTuneInfo and rng schema to support the _length
options for bps/iops throttling values. Document the new values.
2016-10-25 17:20:17 -04:00
John Ferlan
223438a245 qemu: Add length for bps/iops throttling parameters to driver
Add support for a duration/length for the bps/iops and friends.

Modify the API in order to add the "blkdeviotune." specific definitions
for the iotune throttling duration/length options

    total_bytes_sec_max_length
    write_bytes_sec_max_length
    read_bytes_sec_max_length
    total_iops_sec_max_length
    write_iops_sec_max_length
    read_iops_sec_max_length
2016-10-25 17:20:13 -04:00
John Ferlan
d379552b41 caps: Add new capability for the bps/iops throttling length
Add the capability to detect if the qemu binary can support the feature
to use bps-max-length and friends.
2016-10-25 17:16:26 -04:00
John Ferlan
2d3377c3a0 include: Add new definitions for duration for bps/iops throttling
Add new options to allow proving a duration/length in seconds to allow the
bps/iops (and friends) to occur:

    total_bytes_sec_max_length
    write_bytes_sec_max_length
    read_bytes_sec_max_length
    total_iops_sec_max_length
    write_iops_sec_max_length
    read_iops_sec_max_length

Add continue for compiler hint to return to for control
2016-10-25 17:16:26 -04:00
John Ferlan
144947ced6 qemu: Introduce qemuDomainSetBlockIoTuneDefaults
Create a helper to set the bytes/iops iotune default values based on
the current qemu setting for both the live and persistent definitions.
NB: This also fixes an unreported bug where the persistent values for
*_max and size_iops_sec would be set back to 0 if unrelated persistent
values were set.
2016-10-25 17:12:11 -04:00
John Ferlan
1f89039ddb qemu: Move setting of conf_disk in qemuDomainSetBlockIoTune
Since persistent_def is the only place that uses it, let's just keep
it closer to where it's used.
2016-10-25 16:09:24 -04:00
John Ferlan
0ac8b70bb3 qemu: Return real error message for block_set_io_throttle
This patch will also adjust the qemuMonitorJSONSetBlockIoThrottle error
procession so that rather than returning/displaying:

    "error: internal error: Unexpected error"

Fetch the actual error message from qemu and display that
2016-10-25 16:09:24 -04:00
John Ferlan
d24835f2ae qemu: Create a macro to handle setting bytes/iops iotune values
Create a macros to hide all the comparisons for each of the fields.

Add a 'continue;' for a compiler hint that we only need to find one
this should be similar enough to the if - elseif - elseif logic.
2016-10-25 16:09:24 -04:00
John Ferlan
1b93def213 qemu: Move TLS object remove from DetachChr to RemoveChr
Commit id '2c32237' added the TLS object removal to the DetachChrDevice
all when it should have been added to the RemoveChrDevice since that's
the norm for similar processing (e.g. disk)

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-25 15:18:17 -04:00
Ján Tomko
1157678f81 virQEMUCapsReset: also clear out hostCPUModel
After succesfully reading an outdated caps cache from disk,
calling virQEMUCapsReset did not properly clear out the calculated
host CPU model. This lead to a memory leak when the host CPU model
pointer was overwritten later in virQEMUCapsNewForBinaryInternal.

Introduced by commit 68c70118.
2016-10-25 13:54:58 +02:00
Jim Fehlig
f830674bf3 libxl: fix leaking of allocated migration ports
Although the migration port is immediately released in the
finish phase of migration, it was never set in the domain
private object when allocated in the prepare phase. So
libxlDomainMigrationFinish() always released a 0-initialized
migrationPort, leaking any allocated port. After enough
migrations to exhaust the migration port pool, migration would
fail with

error: internal error: Unable to find an unused port in range
       'migration' (49152-49216)

Fix it by setting libxlDomainObjPrivate->migrationPort to the
port allocated in the prepare phase. While at it, also fix
leaking an allocated port if the prepare phase fails.
2016-10-24 19:42:10 -06:00
Viktor Mihajlovski
c1be22f971 doc: update virsh domstats documentation for vcpu statistics
Added description for new vcpu.<num>.halted statistics value.
While there, also added a description for vcpu.<num>.wait and
clarified the units displayed for time and wait.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2016-10-24 18:54:25 -04:00
Viktor Mihajlovski
7a51d9ebbd qemu: add vcpu.n.halted to vcpu domain stats
Extended qemuDomainGetStatsVcpu to include the per vcpu halted
indicator if reported by QEMU. The key for new boolean value
has the format "vcpu.<n>.halted".

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2016-10-24 18:52:36 -04:00
Viktor Mihajlovski
08f22976b1 qemu: Add domain support for VCPU halted state
Adding a field to the domain's private vcpu object to hold the halted
state information.
Adding two functions in support of the halted state:
- qemuDomainGetVcpuHalted: retrieve the halted state from a
  private vcpu object
- qemuDomainRefreshVcpuHalted: obtain the per-vcpu halted states
  via qemu monitor and store the results in the private vcpu objects

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Hao QingFeng <haoqf@linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-10-24 18:52:36 -04:00
Viktor Mihajlovski
cc5e695bde qemu: Add monitor support for CPU halted state
Extended the qemuMonitorCPUInfo with a halted flag. Extract the halted
flag for both text and JSON monitor.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-10-24 18:52:36 -04:00
Laine Stump
ab9202e431 qemu: replace calls to virDomainPCIAddressReserveNext*() with static function
An upcoming commit will remove the "flag" argument from all the calls
to reserve the next available address|slot, but I don't want to change
the arguments in the hypervisor-agnostic
virDomainPCIAddressReserveNext*() functions, so this patch places a
simple qemu-specific wrapper around those functions - the new
functions don't take a flags arg, but grab it from the device's
info->pciConnectFlags.
2016-10-24 13:57:02 -04:00
Laine Stump
696929e67f conf: make virDomainPCIAddressGetNextSlot() a local static function
This function is no longer needed outside of domain_addr.c.
2016-10-24 13:55:49 -04:00
Laine Stump
a0bb224cf5 qemu: use virDomainPCIAddressReserveNextAddr in qemuDomainAssignDevicePCISlots
instead of calling virDomainPCIAddressGetNextSlot() (which I want to
turn into a local static in domain_addr.c).
2016-10-24 13:55:19 -04:00
Laine Stump
848e7ff2b3 conf: new function virDomainPCIAddressReserveNextAddr()
There is an existing virDomainPCIAddressReserveNextSlot() which will
reserve all functions of the next available PCI slot. One place in the
qemu PCI address assignment code requires reserving a *single*
function of the next available PCI slot. This patch modifies and
renames virDomainPCIAddressReserveNextSlot() so that it can fulfill
both the original purpose and the need to reserve a single function.

(This is being done so that the abovementioned code in qemu can have
its "kind of open coded" solution replaced with a call to this new
function).
2016-10-24 13:53:24 -04:00
Pavel Hrdina
7c8df1e82f domain: fix migration to older libvirt
Since TLS was introduced hostwide for libvirt 2.3.0 and a domain
configurable haveTLS was implemented for libvirt 2.4.0, we have to
modify the migratable XML for specific case where the 'tls' attribute
is based on setting from qemu.conf.

The "tlsFromConfig" is libvirt internal attribute and is stored only in
status XML to ensure that when libvirtd is restarted this internal flag
is not lost by the restart.

That flag is used to decide whether we should put *tls* attribute to
migratable XML or not.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-24 16:29:26 +02:00