Commit Graph

23201 Commits

Author SHA1 Message Date
Jiri Denemark
c61360e15b virsh migrate: Fix positional parameters
Thanks to our smart option parser which automatically assigns positional
parameters the following (previously working) command fails:

    virsh migrate test qemu+ssh://1.2.3.4/system tcp://1.2.3.4/
    error: invalid argument: Unsupported compression method
    'tcp://1.2.3.4/'

We need to make sure new options are added at the end of the list rather
than where they logically belong.

Reported by Brian Rak.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-06-21 10:11:03 +02:00
Ján Tomko
a1e1679c8a Mark virsh-optparse as expensive 2016-06-20 18:16:50 +02:00
Ján Tomko
031b477b16 Drop virrandomtest
This test only checks if mocking of virRandomBytes works correctly.

Drop it to avoid infinite recursion by testing the test suite.
2016-06-20 18:16:50 +02:00
Ján Tomko
79d3fc855c Remove virsh-synopsis
This tests checks that the first word after SYNOPSIS
in virsh help ${command} output is ${command}.

This was only good to check that the command option structures
are valid, which is now served by 'virsh self-test'.
2016-06-20 18:16:50 +02:00
Ján Tomko
920ab8bdce Introduce virsh self-test
A new hidden command for virsh that will iterate over
all command groups and commands and print help for every single one.

This involves running vshCmddefOptParse so we can get an error if
one of the command's option structure is invalid.
2016-06-20 18:16:33 +02:00
Ján Tomko
743bda062b tests: mock gnutls_dh_params_generate2
This function generates some big random numbers.

Cache the result and supply it to any subsequent generate2 calls.
2016-06-20 18:12:53 +02:00
Ján Tomko
9f95593d60 Remove virsh-all
Since e8ac4a7 this test wastes some CPU cycles by blindly trying to
run almost every virsh command, blindly throwing away the output
and the return value and returning success if 'virsh help' successfully
returned at least one command.

Drop it completely.
2016-06-20 18:04:44 +02:00
Peter Krempa
832f160247 util: Make failure to get supplementary group list for a uid non-fatal
Since introduction of the DAC security driver we've documented that
seclabels with a leading + can be used with numerical uid. This would
not work though with the rest of libvirt if the uid was not actually
used in the system as we'd fail when trying to get a list of
supplementary groups for the given uid. Since a uid without entry in
/etc/passwd (or other user database) will not have any supplementary
groups we can treat the failure to obtain them as such.

This patch modifies virGetGroupList to not report the error for missing
users and makes it return an empty list or just the group specified in
@gid.

All callers will grant less permissions to a user in case of failure of
this function and thus this change is safe.
2016-06-20 17:35:55 +02:00
Peter Krempa
c674dcccf1 util: Add option not to report errors in virGetUserEnt
In some cases it will be necessary to ignore errors reported from this
function. This allows suppressing them to avoid spamming logs.
2016-06-20 16:51:10 +02:00
Peter Krempa
e29f557515 tools: virt-login-shell: Fix cut'n'paste mistake in error message
Whine about 'allowed_users' having wrong format rather than 'shell'
2016-06-20 16:51:10 +02:00
Peter Krempa
94f93d7071 tools: virt-login-shell: Fix group list bounds checking
The list certainly isn't zero terminated and it would disallow usage of
group 'root'. Pass in the array size and match against it.
2016-06-20 16:48:55 +02:00
Peter Krempa
0a07bf3dc5 conf: Fix label name in virDomainGraphicsListensParseXML
Use 'cleanup' since it's also used on success.
2016-06-20 16:34:43 +02:00
Peter Krempa
9982758cc5 conf: Fix memory leak in graphics XML parser
When loading status XMLs with following graphics definition:

  <graphics type='spice' port='5900' autoport='yes' listen='127.0.0.1'>
    <listen type='address' address='127.0.0.1' fromConfig='1'/>
    <image compression='off'/>
  </graphics>

libvirtd would leak a few bytes:

10 bytes in 1 blocks are definitely lost in loss record 71 of 1,127
   at 0x4C2C000: malloc (vg_replace_malloc.c:299)
   by 0x6789298: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
   by 0x552AB0A: virXMLPropString (virxml.c:479)
   by 0x5539536: virDomainGraphicsListensParseXML (domain_conf.c:11171)
   by 0x553DD5E: virDomainGraphicsDefParseXMLSpice (domain_conf.c:11414)
   by 0x553DD5E: virDomainGraphicsDefParseXML (domain_conf.c:11749)
   by 0x5566061: virDomainDefParseXML (domain_conf.c:16939)
   by 0x556953F: virDomainObjParseXML (domain_conf.c:17348)
   by 0x556953F: virDomainObjParseNode (domain_conf.c:17513)
   by 0x5569902: virDomainObjParseFile (domain_conf.c:17532)
   by 0x5571E02: virDomainObjListLoadStatus (virdomainobjlist.c:514)
   by 0x5571E02: virDomainObjListLoadAllConfigs (virdomainobjlist.c:596)
   by 0x26E0BDC8: qemuStateInitialize (qemu_driver.c:911)
   by 0x55B1FDB: virStateInitialize (libvirt.c:770)
   by 0x122039: daemonRunStateInit (libvirtd.c:960)
2016-06-20 16:34:43 +02:00
Chen Hanxiao
a7822ba3f6 util: fix a typo
s/succcess/success

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2016-06-20 15:20:09 +02:00
Jaroslav Suchanek
dd14032b39 docs: virsh: Added note for the dump command
Crash dump in a old kvmdump format is being obsolete and cannot be loaded and
processed by crash utility since its version 6.1.0. A --memory-only option is
required in order to produce valid ELF file which can be later processed by the
crash utility. A new note is added to the dump command description.
2016-06-20 14:37:02 +02:00
Ján Tomko
0cd5a726e3 Allow disjunct ranges in VIR_TEST_RANGE
Use virBitmapParseUnlimited to parse the env variable.
2016-06-20 12:09:52 +02:00
Ján Tomko
dc56b3a7ce Introduce virBitmapParseUnlimited
For parsing a bitmap of an unknown size.
2016-06-20 12:09:52 +02:00
Ján Tomko
ff52e9d43a Remove separator argument from virBitmapParse
Most the callers pass 0 in one form or another, including
vircapstest which used VIR_ARCH_NONE.
2016-06-20 12:09:52 +02:00
Ján Tomko
d728689d9b Introduce virBitmapParseSeparator
This will be used for the caller that needs to specify a separator.
Currently identical to virBitmapParse.

Also change one test case to use the new function.
2016-06-20 12:09:39 +02:00
Ján Tomko
ba7c026dab Do not return number of set bits in virBitmapParse
This is only used by one caller.
2016-06-20 12:07:16 +02:00
Andrea Bolognani
dc5821d743 qemu: Don't use legacy USB for aarch64 mach-virt guests
The '-usb' option doesn't have any effect for aarch64 mach-virt
guests, so the fact that it's currently enabled by default is not
really causing any issue.

However, that might change in the future (although unlikely), and
having it as part of the QEMU command line can cause confusion to
someone looking through the process list.

Avoid it completely, like it's already happening for q35.
2016-06-20 09:58:48 +02:00
Tomasz Flendrich
ec3f07f0a7 qemu_hotplug: Use a helper variable consistently 2016-06-19 15:55:37 +02:00
Jovanka Gulicoska
eac167e261 virsh: Introduce pool-event command
Similar to 'event' and 'net-event', this prints info about incoming
storage pool events.
2016-06-18 11:15:31 -04:00
Jim Fehlig
8bab1e7c05 libxl: add USB to hostdev domcapabilities
Commit 2a58ed0b added support for creating guests with USB
hostdevs. Commit fc21d10 later added support for hotplut of
USB hostdevs. Advertise support for USB hostdevs in the
domcapabilities.

In addition add the appropriate caps for USB support on
domaincapstest when libvirt is built on a Xen with
LIBXL_HAVE_PVUSB. Otherwise domaincapstest would fail i.e.
testing the wrong domain capabilities.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-06-17 14:25:02 -06:00
Ján Tomko
22d262c9b0 qemu: restore non-pci hostdev labels after detach
Commit 409de00 changed the logic to only match PCI devices
while moving this before Remove*HostDevice calls.

https://bugzilla.redhat.com/show_bug.cgi?id=1342874
2016-06-17 19:43:22 +02:00
Ján Tomko
d41d18bcdc Remove stray space in cmdHelp 2016-06-17 19:39:25 +02:00
Andrea Bolognani
86a68bdb0c qemu: Permit PCI-free aarch64 mach-virt guests
There has been some progress lately in enabling virtio-pci on
aarch64 guests; however, guest OS support is still spotty at best,
so most guests are going to be using virtio-mmio instead.

Currently, mach-virt guests are closely modeled after q35 guests,
and that includes always adding a dmi-to-pci-bridge that's just
impossible to get rid of. While that's acceptable (if suboptimal)
for q35, where you will always need some kind of PCI device anyway,
mach-virt guests should be allowed to avoid it.
2016-06-17 18:30:04 +02:00
Michal Privoznik
9e155e1d8a qemuDomainDetachDeviceConfig: Allow cold unplug of redirdevs
This is fairly simple. We lookup the device in the array of
devices and remove it. No magic.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-06-17 18:12:43 +02:00
Michal Privoznik
3441274016 qemuDomainAttachDeviceConfig: Allow redirdev coldplug
This is really simple, we just need to append the device into the
domain def and that's it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-06-17 18:12:43 +02:00
Michal Privoznik
87bbb6eb2f virDomainDeviceInfoIterateInternal: Iterate through redirdevs too
This is going to be important later when we received
DEVICE_DELETED event on the qemu monitor. If we do,
virDomainDefFindDevice() is called to find the device for given
device alias in the virDomainDef tree. When we enable removal for
redirdevs we need to include them in the lookup process too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-06-17 18:12:43 +02:00
Michal Privoznik
e30dbb9f98 virDomainRedirdevDef: Introduce find & remove routines
Basically, there are just two functions introduced here:
virDomainRedirdevDefFind which looks up given redirdev in domain
definition, and virDomainRedirdevDefRemove which removes the
device at given index in the array of devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-06-17 18:12:43 +02:00
Michal Privoznik
9f20b3b45e domain_conf: Validate redirdev after parsing
There's currently just one limitation: redirdevs that want to go
on USB bus require a USB controller, surprisingly.
At the same time, since I'm using virDomainDefHasUSB() in this
new validator function, it has to be moved a few lines up and
also its header needed to be changed a bit: it is now taking a
const pointer to domain def since it's not changing anything in
there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-06-17 18:12:43 +02:00
Ján Tomko
b7c70a0ba0 configure: remove definition of HAVE_GLIBC_RPCGEN
Unused since commit fb1e8d9 in May 2011.
2016-06-17 15:35:46 +02:00
Ján Tomko
c5be15ef42 configure: error out when asked for mpath on non-Linux 2016-06-17 15:35:46 +02:00
Ján Tomko
7303e7079c configure: define preprocessor macros for SCSI and MPATH
This fixes building these backends when explicitly enabled
on the command line.

Exposed by commit a659559 which started adding
--with-storage-mpath in the spec file.

https://bugzilla.redhat.com/show_bug.cgi?id=1346724
2016-06-17 15:35:46 +02:00
Andrea Bolognani
b31b3eee85 qemu: Fix alignment in virDomainDefAddController() call 2016-06-17 13:06:52 +02:00
Peter Krempa
95f4328e33 tests: schema: Remove useless perf schema data
We have a test case that excercises the parser and formatter now which
takes part in schema checking so remove the schema-only test.
2016-06-17 12:51:08 +02:00
Peter Krempa
3110363d06 docs: virsh: Add minimal documentation for 'mbmt' and 'mbml' perf events 2016-06-17 12:48:45 +02:00
Jiri Denemark
5a9221b9af cpu_x86: Use signature in CPU detection code
Our current detection code uses just the number of CPU features which
need to be added/removed from the CPU model to fully describe the CPUID
data. The smallest number wins. But this may sometimes generate wrong
results as one can see from the fixed test cases. This patch modifies
the algorithm to prefer the CPU model with matching signature even if
this model results in a longer list of additional features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-06-17 11:46:31 +02:00
Jiri Denemark
2f3ccdf01b cpu: Add Skylake-Client x86 CPU model
The CPU model was implemented in QEMU by commit f6f949e929.

The change to i7-5600U is wrong since it's a 5th generation CPU, i.e.,
Broadwell rather than Skylake, but that's just the result of our CPU
detection code (which is fixed by the following commit).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-06-17 11:40:58 +02:00
Martin Kletzander
ddc99f11ac spec: Make driver-qemu require driver-storage
Without that we might get similar messages in the log:

  error : virDriverLoadModule:73 : failed to load module
  /usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
  /usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so: undefined
  symbol: virStorageFileCreate

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-06-17 11:15:43 +02:00
Peter Krempa
f8d565bf86 conf: Rename virDomainDefGetMemoryActual to virDomainDefGetMemoryTotal 2016-06-17 10:39:40 +02:00
Peter Krempa
a877a1635b conf: Remove pre-calculation of initial memory size
While we need to know the difference between the total memory stored in
<memory> and the actual size not included in the possible memory modules
we can't pre-calculate it reliably. This is due to the fact that
libvirt's XML is copied via formatting and parsing the XML and the
initial memory size can be reliably calculated only when certain
conditions are met due to backwards compatibility.

This patch removes the storage of 'initial_memory' and fixes the helpers
to recalculate the initial memory size all the time from the total
memory size. This conversion is possible when we also make sure that
memory hotplug accounts properly for the update of the total memory size
and thus the helpers for inserting and removing memory devices need to
be tweaked too.

This fixes a bug where a cold-plug and cold-remove of a memory device
would increase the size reported in <memory> in the XML by the size of
the memory device. This would happen as the persistent definition is
copied before attaching the device and this would lead to the loss of
data in 'initial_memory'.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1344892
2016-06-17 10:36:41 +02:00
Peter Krempa
23690e1d74 conf: Fix perf event parser
The parser was totaly broken. Fix it by rewriting it. Add tests so that
it doesn't happen.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1346723
2016-06-17 09:35:14 +02:00
Peter Krempa
c22dad33c2 docs: Add at least some docs and fix schema entry for perf events
There was no documentation at all for the XML part. I added at least
some. The 2.0.0 introduction date is deliberate as the parser for the
XML is broken.

The schema file was missing entries for 'mbml' and 'mbmt'.
2016-06-17 09:35:14 +02:00
Peter Krempa
da8285c44a qemu: perf: Don't set state of first event for every other event
A bug in the code used the value of the first perf event as state for
all the mentioned one rather than extracting individual ones.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1346730
2016-06-17 09:35:14 +02:00
Jim Fehlig
e33cd67a9b xenconfig: fix conversion of <driver> to backendtype
When converting domXML to xen xl.cfg, backendtype should
not be emitted if <driver> is not specified. Moreover,
<driver name='file'/> should be converted to backendtype
qdisk, similar to handling of <driver> in libxlMakeDisk()
in libxl_conf.c.

Prior to this change, connectDomainXMLToNative would
produce incorrect xl.cfg when the input domXML contained
<driver name='file'/>

domXML:

  <disk type="file" device="disk">
    <driver name="file"/>
    <source file="/image/file/path"/>
    <target dev="xvda" bus="xen"/>
  </disk>

virsh domxml-to-native xen-xl domXML

disk = [ "format=raw,vdev=xvda,access=rw,backendtype=target=/image/file/path" ]

xl create xl.cfg
config parsing error in disk specification: unknown value
for backendtype: near `target=/image/file/path' in
`format=raw,vdev=xvda,access=rw,backendtype=target=/image/file/path'
2016-06-16 12:31:04 -06:00
Laine Stump
bf913385ae util: fix missing broadcast address in bridge and tap device IP addresses
Commit b3d069872c added peer address setting to the low level
virNetDevSetIPAddress() function, but ended up causing a segfault in
cases where the caller passed NULL for peer address.

Commit a3510e33d3 fixed the segfault, but managed to cause us to
skip setting the broadcast address when setting an interface's IP
address. The result is that the broadcast address is 0.0.0.0 for all
libvirt-created bridges (and interfaces in lxc containers with IP
addresses set by libvirt).

This was reported on the mailing list:

  https://www.redhat.com/archives/libvir-list/2016-June/msg00027.html

but I was too busy to investigate at the time. I found it by accident
today while refactoring virNetDevSetIPAddress(). Since this regression
is present in the 1.3.5 release, I'm sending the bugfix as a separate
patch from my larger refactoring patchset.
2016-06-16 14:27:40 -04:00
Laine Stump
d5fb8f4564 qemu: don't add pci-bridge to Q35/arm domains unless it's needed
Until now, a Q35 domain (or arm/virt, or any other domain that has a
pcie-root bus) would always have a pci-bridge added, so that there
would be a hotpluggable standard PCI slot available to plug in any PCI
devices that might be added. This patch removes the explicit add,
instead relying on the pci-bridge being auto-added during PCI address
assignment (it will add a pci-bridge if there are no free slots).

This doesn't eliminate the dmi-to-pci-bridge controller that is
explicitly added whether or not a standard PCI slot is required (and
that is almost never used as anything other than a converter between
pcie.0's PCIe slots and standard PCI). That will be done separately.
2016-06-16 13:48:25 -04:00
Laine Stump
97b215a450 qemu: don't be as insistent about adding dmi-to-pci-bridge or pci-bridge
Previously there was no way to have a Q35 domain that didn't have
these two controllers. This patch skips their creation as long as
there are some other kinds of pci controllers at index 1 and 2
(e.g. some pcie-root-port controllers).

I'm hoping that soon we won't add them at all, plugging all devices
into auto-added pcie-*-port ports instead, but in the meantime this
makes it easier to experiment with alternative bus hierarchies.
2016-06-16 13:32:11 -04:00