Commit Graph

18422 Commits

Author SHA1 Message Date
Luyao Huang
5035279198 qemu: free priv->origname when qemuMigrationPrepareAny fails
https://bugzilla.redhat.com/show_bug.cgi?id=1181182

When we meet error in qemuMigrationPrepareAny and goto
cleanup with rc < 0, we forget clear the priv->origname and this
will make this vm migrate fail next time because leave a wrong
origname in  priv, and will Generate a wrong cookie when do
migrate next time.

This patch will make priv->origname is NULL when migrate fail
in target host.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-01-15 11:32:50 +01:00
Ján Tomko
c749eda4a2 Fix vmdef usage while in monitor in qemu process
Make local copy of the disk alias in qemuProcessInitPasswords,
instead of referencing the one in domain definition, which
might get freed if the domain crashes while we're in monitor.

Also copy the memballoon period value.
2015-01-14 19:30:32 +01:00
Ján Tomko
3f21398437 Fix vmdef usage while in monitor in BlockStat* APIs
Make a local copy of the disk alias instead of pointing
to the domain definition, which might get freed if
the domain dies while we're in monitor.

Also exit early if that happens.
2015-01-14 19:30:32 +01:00
Ján Tomko
051add2ff9 Fix vmdef usage while in monitor in qemuDomainHotplugVcpus
Exit the monitor right after we've done with it to get
the virDomainObjPtr lock back, otherwise we might be accessing
vm->def while it's being cleaned up by qemuProcessStop.

If the domain crashed while we were in the monitor, exit
early instead of changing vm->def which is now the persistent
definition.
2015-01-14 19:30:32 +01:00
Ján Tomko
a5e5996b91 Mark the domain as active in qemuhotplugtest
This will allow us to call qemuDomainObjIsActive() in
the tested functions to check if the domain has crashed.
2015-01-14 19:30:32 +01:00
Ján Tomko
dc2fd51fd7 Check for domain liveness in qemuDomainObjExitMonitor
The domain might disappear during the time in monitor when
the virDomainObjPtr is unlocked, so the caller needs to check
if it's still alive.

Since most of the callers are going to need it, put the
check inside qemuDomainObjExitMonitor and return -1 if
the domain died in the meantime.
2015-01-14 19:30:32 +01:00
Shivaprasad G Bhat
7e72de49fe check IOMMU group devices usage when preparing device for vfio passthrough
The virsh start <domain> fails with qemu error when the hostdevices of the
same iommu group are used actively by other vms. It is not clear which
hostdev from the same iommu group is used by any of the running guests.
User has to go through every guest xml to figure out who is using the
hostdev of same iommu group.

Solution:
Iterate the iommu group of the hostdev and error our neatly in case a
device in the same iommu group is busy. Reattach code also does the same
kind of check, remove duplicate code as well.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-14 18:01:06 +01:00
Shivaprasad G Bhat
6af9bb3560 virpci: Implement virPCIDeviceGetAddress function
Basically a getter function which is implemented for accessing the
address fields in virPCIDevice.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-14 18:01:06 +01:00
Kiarie Kahurani
cec71a6ba6 libxl: Add support for parsing/formating Xen XL config
Now that xenconfig supports parsing and formatting Xen's
XL config format, integrate it into the libxl driver's
connectDomainXML{From,To}Native functions.

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-14 08:28:51 -07:00
Kiarie Kahurani
4ed5fb9193 tests: Tests for the xen-xl parser
Add disk and spice config tests for the xen_xl config parser

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-14 08:28:50 -07:00
Jim Fehlig
4689cdf779 Introduce support for parsing/formatting Xen xl config format
Introduce a parser/formatter for the xl config format.  Since the
deprecation of xm/xend, the VM config file format has diverged as
new features are added to libxl.  This patch adds support for parsing
and formating the xl config format.  It supports the existing xm config
format, plus adds support for spice graphics and xl disk config syntax.

Disk config is specified a bit differently in xl as compared to xm.  In
xl, disk config consists of comma-separated positional parameters and
keyword/value pairs separated by commas. Positional parameters are
specified as follows

   target, format, vdev, access

Supported keys for key=value options are

  devtype, backendtype

The positional paramters can also be specified in key/value form.  For
example the following xl disk config are equivalent

    /dev/vg/guest-volume,,hda
    /dev/vg/guest-volume,raw,hda,rw
    format=raw, vdev=hda, access=rw, target=/dev/vg/guest-volume

See $xen_sources/docs/misc/xl-disk-configuration.txt for more details.

xl disk config is parsed with the help of xlu_disk_parse() from
libxlutil, libxl's utility library.  Although the library exists
in all Xen versions supported by the libxl virt driver, only
recently has the corresponding header file been included.  A check
for the header is done in configure.ac.  If not found, xlu_disk_parse()
is declared externally.

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-14 08:28:50 -07:00
Pavel Hrdina
ce745914b3 qemu_process: detect updated video ram size values from QEMU
QEMU internally updates the size of video memory if the domain XML had
provided too low memory size or there are some dependencies for a QXL
devices 'vgamem' and 'ram' size. We need to know about the changes and
store them into the status XML to not break migration or managedsave
through different libvirt versions.

The values would be loaded only if the "vgamem_mb" property exists for
the device.  The presence of the "vgamem_mb" also tells that the
"ram_size" and "vram_size" exists for QXL devices.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-01-14 11:55:51 +01:00
Pavel Hrdina
cc41c64878 qemu_monitor: introduce new function to get QOM path
The search is done recursively only through QOM object that has a type
prefixed with "child<" as this indicate that the QOM is a parent for
other QOM objects.

The usage is that you give known device name with starting path where to
search.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-01-14 11:55:51 +01:00
Pavel Hrdina
e105dc9814 qemu_driver: fix setting vcpus for offline domain
Commit e3435caf fixed hot-plugging of vcpus with strict memory pinning
on NUMA hosts, but unfortunately it also broke updating number of vcpus
for offline guests using our API.

The issue is that we try to create a cpu cgroup for non-running guest
which fails as there are no cgroups for that domain. We should create
cgroups and update cpuset.mems only if we are hot-plugging.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-01-14 10:34:20 +01:00
Michal Privoznik
04cf99a6b6 qemu, lxc: Warn if setting QoS on unsupported vNIC types
https://bugzilla.redhat.com/show_bug.cgi?id=1165993

So, there are still plenty of vNIC types that we don't know how to set
bandwidth on. Let's warn explicitly in case user has requested it
instead of pretending everything was set.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-14 08:54:49 +01:00
Shanzhi Yu
9f974858dd qemu: snapshot: inactive external snapshot can't work after libvirtd restart
When create inactive external snapshot, after update disk definitions,
virDomainSaveConfig is needed, if not after restart libvirtd the new snapshot
file definitions in xml will be lost.

Reproduce steps:

1. prepare a shut off guest
$ virsh domstate rhel7 && virsh domblklist rhel7
shut off

Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/rhel7.img

2. create external disk snapshot
$ virsh snapshot-create rhel7 --disk-only && virsh domblklist rhel7
Domain snapshot 1417882967 created
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/rhel7.1417882967

3. restart libvirtd then check guest source file
$ service  libvirtd restart && virsh domblklist rhel7
Redirecting to /bin/systemctl restart  libvirtd.service
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/rhel7.img

This was first reported by Eric Blake
http://www.redhat.com/archives/libvir-list/2014-December/msg00369.html

Signed-off-by: Shanzhi Yu <shyu@redhat.com>
2015-01-13 15:59:06 -05:00
Michal Privoznik
a605025c21 conf: Increase virNetDevBandwidthParse intelligence
There's this function virNetDevBandwidthParse which parses the
bandwidth XML snippet. But it's not clever much. For the
following XML it allocates the virNetDevBandwidth structure even
though it's completely empty:

    <bandwidth>
    </bandwidth>

Later in the code there are some places where we check if
bandwidth was set or not. And since we obtained pointer from the
parsing function we think that it is when in fact it isn't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-13 18:24:15 +01:00
Daniel P. Berrange
0ecd685109 Give virDomainDef parser & formatter their own flags
The virDomainDefParse* and virDomainDefFormat* methods both
accept the VIR_DOMAIN_XML_* flags defined in the public API,
along with a set of other VIR_DOMAIN_XML_INTERNAL_* flags
defined in domain_conf.c.

This is seriously confusing & error prone for a number of
reasons:

 - VIR_DOMAIN_XML_SECURE, VIR_DOMAIN_XML_MIGRATABLE and
   VIR_DOMAIN_XML_UPDATE_CPU are only relevant for the
   formatting operation
 - Some of the VIR_DOMAIN_XML_INTERNAL_* flags only apply
   to parse or to format, but not both.

This patch cleanly separates out the flags. There are two
distint VIR_DOMAIN_DEF_PARSE_* and VIR_DOMAIN_DEF_FORMAT_*
flags that are used by the corresponding methods. The
VIR_DOMAIN_XML_* flags received via public API calls must
be converted to the VIR_DOMAIN_DEF_FORMAT_* flags where
needed.

The various calls to virDomainDefParse which hardcoded the
use of the VIR_DOMAIN_XML_INACTIVE flag change to use the
VIR_DOMAIN_DEF_PARSE_INACTIVE flag.
2015-01-13 16:26:12 +00:00
Daniel P. Berrange
e34473c1da Decouple CPU XML formatting from domain XML public API flags
The virCPUDefFormat* methods were relying on the VIR_DOMAIN_XML_*
flag definitions. It is not desirable for low level internal
functions to be coupled to flags for the public API, since they
may need to be called from several different contexts where the
flags would not be appropriate.
2015-01-13 16:19:56 +00:00
Michal Privoznik
2b8090b701 formatdomaincaps: Correctly format API reference
Well, since the link to the virConnectGetDomainCapabilities API is in
<pre/> section we must take special care about the spaces around the
link.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2015-01-13 16:31:14 +01:00
Eric Blake
e1125cebfc qemu: forbid second blockcommit during active commit
https://bugzilla.redhat.com/show_bug.cgi?id=1135339 documents some
confusing behavior when a user tries to start an inactive block
commit in a second connection while there is already an on-going
active commit from a first connection.  Eventually, qemu will
support multiple simultaneous block jobs, but as of now, it does
not; furthermore, libvirt also needs an overhaul before we can
support simultaneous jobs.  So, the best way to avoid confusing
ourselves is to quit relying on qemu to tell us about the situation
(where we risk getting in weird states) and instead forbid a
duplicate block commit ourselves.

Note that we are still relying on qemu to diagnose attempts to
interrupt an inactive commit (since we only track XML of an active
commit), but as inactive commit is less confusing for libvirt to
manage, there is less that can go wrong by leaving that detection
up to qemu.

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Hoist check for
active commit to occur earlier outside of conditions.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-01-13 08:21:20 -07:00
Daniel P. Berrange
ee043216e6 parallels: don't override error message when XML parsing fails
The virDomainDefParseString method will report a suitable error
on parsing fail, so don't replace that.
2015-01-13 10:43:07 +00:00
Daniel P. Berrange
70948db22a Fix flags passed to virDomainDefParseString by XenAPI driver
The XenAPI driver was passing the flags for
virDomainCreateXML straight into the virDomainDefParseString
method, even though they expect totally different sets of
flags. It should have been using VIR_DOMAIN_XML_INACTIVE
2015-01-13 10:43:07 +00:00
Daniel P. Berrange
4d6ed1bf0b Don't use VIR_DOMAIN_XML_SECURE when parsing XML
The VIR_DOMAIN_XML_SECURE flag only has effect on the formatting
of XML so should not be passed to virDomainDefParseNode
2015-01-13 10:43:07 +00:00
Daniel P. Berrange
4d2ebc71ce Add stub virDomainDefineXMLFlags impls
Make sure every virt driver implements virDomainDefineXMLFlags
by adding a trivial passthrough from the existing impl with
no flags set.
2015-01-13 10:38:56 +00:00
Daniel P. Berrange
2a5ee95441 Add new virDomainDefineXMLFlags public API
The virDomainDefineXML method is one of the few that still lacks
an 'unsigned int flags' parameter. This will be needed for adding
XML validation to this API. virDomainCreateXML fortunately already
has flags.
2015-01-13 10:35:09 +00:00
Luyao Huang
fba7173f72 conf: fix crash when hotplug a channel chr device with no target
https://bugzilla.redhat.com/show_bug.cgi?id=1181408

When we try to hotplug a channel chr device with no target, we
will get success (which should fail) in virDomainChrDefParseXML,
because we use goto cleanup this place and return an incomplete
definition (with no target). In qemuDomainAttachChrDevice,
we add it to the domain definition, but fail to remove it from
there when chardev-add fails, because virDomainChrRemove
matches chardevices according to the target name.
The device definition is then freed in qemuDomainAttachDeviceFlags,
leaving a stale pointer in the domain definition.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-01-13 09:56:56 +01:00
Martin Kletzander
adff345e1e qemu: Allow enabling/disabling features with host-passthrough
QEMU supports feature specification with -cpu host and we just skip
using that.  Since QEMU developers themselves would like to use this
feature, this patch modifies the code to work.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-01-13 08:51:01 +01:00
Jim Fehlig
f7a30375bd Revert "src/xenconfig: Xen-xl parser"
This reverts commit 2c78051a14.

Conflicts:
	src/Makefile.am

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-12 10:15:13 -07:00
Jim Fehlig
cb4befc748 Revert "tests: Tests for the xen-xl parser"
This reverts commit 6b818d3b09.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-12 10:15:09 -07:00
Jim Fehlig
4d77c136f8 Revert "libxl: Add support for parsing/formating Xen XL config"
This reverts commit 4f524212ce.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-12 10:15:04 -07:00
Jim Fehlig
88e34a9479 Revert "src/Makefile.am: fix build breaker for xenconfig"
This reverts commit 703ef9667a.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-12 10:14:59 -07:00
Jim Fehlig
0f2cd69b5a Revert "build: fix xenconfig VPATH builds"
This reverts commit 1b21d30069.

Conflicts:
	src/Makefile.am

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-12 10:14:54 -07:00
Jim Fehlig
3ac24305a8 Revert "Revert "src/Makefile.am: fix build breaker for xenconfig""
This reverts commit e662968fd9.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-12 10:14:48 -07:00
Jim Fehlig
1cb2667c12 Revert "src/Makefile: move the new xen_xl_disk parser code at the correct place"
This reverts commit edacdb3d12.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-12 10:14:42 -07:00
Jim Fehlig
dc8f62a9f9 Revert "src/Makefile: Fix parallel build after xen_xl_disk parser introduction"
This reverts commit 533349ff43.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-12 10:14:37 -07:00
Jim Fehlig
d2f80a772f Revert "bootstrap.conf: add check for flex"
This reverts commit cab767831f.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-12 10:14:30 -07:00
Guido Günther
c1deb7f58c lxc: Move setting ifname_guest_actual to virLXCSetupInterfaces
so it applies to interfaces of type 'direct' too.

Reported and patch provided by Bastian Blank at

    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769600
2015-01-12 18:01:46 +01:00
Michal Privoznik
d776e995e3 qemuxml2argvtest: Fix test after change of qxl vgamem_mb default
Well, apparently it's possible for a patch to sneak in through
review process and break 'make check'. It happened just lately
with 0e502466ac which changed the default of vgamem_mb for
qxl device. However, there were left some domain XMLs within our
test suite relying on the old default. These should be updated to
match the change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-12 15:47:52 +01:00
Daniel Hansel
5940301889 cpu: Bugfix for s390 CPU driver to return a host CPU model
The curent libvirt CPU driver for s390 does not return a host CPU model.
This patch returns 'host' according to the other platforms that would
not decode any CPU model.
This is an intermediate bugfix due to a discussion on OpenStack mailing
list. The final patch introducing the CPU model support for s390x will
exchange the hard-coded decode method.

Signed-off-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
2015-01-12 15:08:29 +01:00
John Ferlan
b789db36ae virconf: Resolve a possible memory leak in virConfSetValue
Found this one by inspection... The API claims to "own" the input
value even in the case of error.  However, in the initial entry
to the API if the value exists, was STRING, but without a str value
it just returned without freeing the 'value' which it claims to now
own.  So I added the virConfFreeValue() call in order to resolve.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-01-12 08:59:55 -05:00
John Ferlan
a267f01532 openvz: Check errors from virSocketAddrFormat
Commit id 'a4e86390' modified the command line to allow --ipadd multiple
times; however, it did not account for the condition where a NULL is
returned which will could lead to some interesting errors with multiple
--ipadd's without parameters.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-01-12 08:59:55 -05:00
John Ferlan
21160a7ac9 openvz: Resolve Coverity RESOURCE_LEAK
Commit id 'a4e86390' modified the command line to allow --ipadd multiple
times, which caused Coverity to notice a latent memory leak with the
'ipAddr' string not being VIR_FREE()'d

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-01-12 08:59:54 -05:00
Pavel Hrdina
0e502466ac qxl: change the default value for vgamem_mb to 16 MiB
The default value should be 16 MiB instead of 8 MiB. Only really old
version of upstream QEMU used the 8 MiB as default for vga framebuffer.

Without this change if you update your libvirt where we introduced the
"vgamem" attribute for QXL video device the value will be set to 8 MiB,
but previously your guest had 16 MiB because we didn't pass any value to
QEMU command line which means QEMU used its own 16 MiB as default.

This will affect all users with guest's display resolution higher than
1920x1080.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-01-12 14:51:13 +01:00
Michal Privoznik
241ab97d7e docs: Document some -boot option limitations on UEFI
It was brought to my attention that some -boot options may not
work with UEFI. For instance, rebootTimeout is very SeaBIOS
specific,splash logo is not implemented yet on OVMF, and so on.
We should document this limitation at least.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-12 14:32:17 +01:00
Hao Liu
a0670aef37 virsh: Emit error for VSH_OT_DATA without VSH_OFLAG_REQ
Commit 6b9964 enforces checking invalid use of VSH_OT_STRING with
VSH_OFLAG_REQ. This commit tries to do the same thing to stop using
VSH_OT_DATA without VSH_OFLAG_REQ and also fix existing misuse.

Signed-off-by: Hao Liu <hliu@redhat.com>
2015-01-12 13:38:42 +01:00
Guido Günther
906a116586 lxc: Don't crash on NULL ifname_guest_actual
Reported and patch provided by Bastian Blank at

    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769600
2015-01-12 10:40:20 +01:00
Luyao Huang
97fac17c77 conf: Correctly format controller's driver
https://bugzilla.redhat.com/show_bug.cgi?id=1179684

The way that we currently generate the <driver/> for <controller/> is
just madness:

    <controller type='scsi' index='0' model='virtio-scsi'>
      <driver queues='12'/>
      <driver cmd_per_lun='123'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>

It's obvious that we should be aiming at the following:

    <controller type='scsi' index='0' model='virtio-scsi'>
      <driver queues='12' cmd_per_lun='123'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-01-09 16:01:55 +01:00
Ján Tomko
1390c26847 safezero: fall back to writing zeroes even when resizing
Remove the resize flag and use the same code path for all callers.
This flag was added by commit 18f0316 to allow virStorageFileResize
use 'safezero' while preserving the behavior.

Explicitly return -2 when a fallback to a different method should
be done, to make the code path more obvious.

Fail immediately when ftruncate fails in the mmap method,
as we did before commit 18f0316.
2015-01-09 13:48:23 +01:00
John Ferlan
a4b0040353 virsh.pod: Update description
The 'pool-build' command description for --overwrite and --no-overwrite
indicated usage for only 'filesystem' pools; however, the 'disk' pool
also supports the flags as of commit id 'afa1029a'. So add a description
for that usage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-01-09 13:43:17 +01:00