]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agolxc: fix starting a domain with a cpuset but no numatune
Luyao Huang [Fri, 3 Apr 2015 10:11:15 +0000 (18:11 +0800)]
lxc: fix starting a domain with a cpuset but no numatune

 # virsh -c lxc:/// start helloworld
 error: Failed to start domain helloworld
 error: internal error: guest failed to start: Invalid value '1-3'
 for 'cpuset.mems': Invalid argument

Free the cpu mask to avoid reusing it as a mem mask
in virCgroupSetCpusetMems
if virDomainNumatuneMaybeFormatNodeset does not set a mask.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agorng: Move sgio attr definition to a separate block
Erik Skultety [Mon, 20 Apr 2015 07:49:36 +0000 (09:49 +0200)]
rng: Move sgio attr definition to a separate block

it might be worth having sgio attribute defined in a separate block the same way
as rawio attribute.

10 years agorng: Forbid to validate mismatched <disk> 'device' and 'type' attributes
Erik Skultety [Fri, 17 Apr 2015 11:14:12 +0000 (13:14 +0200)]
rng: Forbid to validate mismatched <disk> 'device' and 'type' attributes

According to docs, using 'lun' as a value for device attribute is only valid
with disk types 'block' and 'network'. However current RNG schema also allows
a combination type='file' device='lun' which results in a successfull
xml validation, but fails at qemuBuildCommandLine.
Besides fixing the RNG schema, this patch also adds a qemuxml2argvtest
for this case.

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

10 years agoApparmor: removed duplicate nscd rules
Cédric Bosdonnat [Mon, 20 Apr 2015 07:32:04 +0000 (09:32 +0200)]
Apparmor: removed duplicate nscd rules

10 years agodomcaps: Check for architecture more wisely
Michal Privoznik [Wed, 8 Apr 2015 14:59:36 +0000 (16:59 +0200)]
domcaps: Check for architecture more wisely

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

So we have this bug. The virConnectGetDomainCapabilities() API
performs a couple of checks before it produces any result. One of
the checks is if the architecture requested by user can be run by
the binary (again user provided). However, the check is pretty
dumb. It merely compares if the default binary architecture
matches the one provided by user. However, a qemu binary can run
multiple architectures. For instance: qemu-system-ppc64 can run:
ppc, ppcle, ppc64, ppc64le and ppcemb. The default is ppc64, so
if user requested something else, like ppc64le, the check would
have failed without obvious reason.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoschema: Allow multiple machines for VMs and unite architectures
Martin Kletzander [Thu, 9 Apr 2015 08:49:02 +0000 (10:49 +0200)]
schema: Allow multiple machines for VMs and unite architectures

Use the same pattern for all machine types on all archs and same archs
for hvm and exe types.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemuDomainShutdownFlags: Set fakeReboot more frequently
zhang bo [Fri, 17 Apr 2015 00:43:58 +0000 (08:43 +0800)]
qemuDomainShutdownFlags: Set fakeReboot more frequently

When a qemu domain is to be rebooted, from outside, at libvirt
level it looks like regular shutdown. To really restart the
domain, libvirt needs to issue reset command on the monitor once
SHUTDOWN event appeared. So, in order to differentiate bare
shutdown and reboot libvirt uses a variable within domain private
data. It's called fakeReboot. When the reboot API is called, the
variable is set, but when the shutdown API is called it must be
cleared out. But it was not for every possible case. So if user
called virDomainReboot(), and there was no ACPI daemon running
inside the guest (so guest didn't initiated shutdown sequence)
and then virDomainShutdown(mode=agent) was called bad thing
happened. We remembered the fakeReboot and instead of shutting
the domain down, we just rebooted it.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce virNetDevBandwidthUpdateFilter
Michal Privoznik [Tue, 14 Apr 2015 16:04:30 +0000 (18:04 +0200)]
Introduce virNetDevBandwidthUpdateFilter

This is a simple wrapper around virNetDevBandwidthManipulateFilter() that
will update the desired filter on an interface (usually a network bridge)
with a new MAC address. Although, the MAC address in question usually
refers to some other interface - the one that the filter is constructed
for. Yeah, hard to parse. Thing is, our NATed network has a bridge where
some part of QoS takes place. And vNICs from guests are plugged into
the bridge. However, if a guest decides to change the MAC of its vNIC,
the corresponding qemu process emits an event which we can use to
update the QoS configuration based on the new MAC address.. However,
our QoS hierarchy is currently not notified, therefore it falls apart.
This function (when called in response to the aforementioned event)
will update our QoS hierarchy and duct tape it together again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnetdevbandwidth.c: Separate tc filter creation to a function
Michal Privoznik [Tue, 14 Apr 2015 11:47:22 +0000 (13:47 +0200)]
virnetdevbandwidth.c: Separate tc filter creation to a function

Not only this simplifies the code a bit, it prepares the
environment for upcoming patches. The new
virNetDevBandwidthManipulateFilter() function is capable of both
removing a filter and adding a new one. At the same time! Yeah,
this is not currently used anywhere but look at the next commit
where you'll see it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNetDevBandwidthSet: Add priority to filter
Michal Privoznik [Tue, 14 Apr 2015 13:40:17 +0000 (15:40 +0200)]
virNetDevBandwidthSet: Add priority to filter

Currently, when constructing traffic shaping rules, the ingress
filter is created without any priority specified on the command
line. This makes kernel to make up one. While this works, it
simplifies things a bit if we provide the filter priority. In
this case, since it's the root filter lets give it the highest
priority of number 1.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainActualNetDefContentsFormat: Format class_id more frequently
Michal Privoznik [Tue, 14 Apr 2015 15:59:18 +0000 (17:59 +0200)]
virDomainActualNetDefContentsFormat: Format class_id more frequently

After a360912179 the formatting of virDomainActualNetDefPtr was
changed a bit. However, during the function rewrite, iface's class_id
is not formatted as frequently as it could be. In fact, after rewrite
it's formatted only for iface of type VIR_DOMAIN_NET_TYPE_DIRECT where
it makes no sense and is unused. While where needed (_TYPE_NETWORK) is
not formatted at all. This makes the daemon forget it upon daemon
restart resulting in bad behaviour.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonwfilter: Partly initialize driver even for non-privileged users
Michal Privoznik [Thu, 16 Apr 2015 07:59:22 +0000 (09:59 +0200)]
nwfilter: Partly initialize driver even for non-privileged users

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

This reverts commit b7829f959b33c6e32422222a9ed745c0da7dc696.

The previous fix was not correct. Like everywhere else, a driver is a
global variable allocated in stateInitialize function (or something
similar for stateless drivers). Later, when a driver API is called,
it's possible that the global variable is accessed and dereferenced.
Now, some drivers require root privileges because they undertake some
actions reserved only for the system admin (e.g. manipulating host
firewall). And here's the trouble, the NWFilter state initializer
exited too early when finding out it's running unprivileged, leaving
the global NWFilter driver variable uninitialized. Any subsequent
API call that tried to lock the driver resulted in dereferencing the
driver and thus crash.

On the other hand, in order to not resurrect the bug the original
commit was fixing, Let's forbid the nwfilter define in session mode.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Conflicts:
src/nwfilter/nwfilter_driver.c: Context. Code changed a bit
        since 2013.

10 years agovirNetSocketNewConnectUNIX: Don't unlink(NULL)
Michal Privoznik [Thu, 16 Apr 2015 14:07:15 +0000 (16:07 +0200)]
virNetSocketNewConnectUNIX: Don't unlink(NULL)

There is a possibility that we jump onto error label with @lockpath
still initialized to NULL. Here, the @lockpath should be unlink()-ed,
but passing there a NULL is not a good idea. Don't do that. In fact,
we should call unlink() only if we created the lock file successfully.

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agolxc: move wireless PHYs to a network namespace
Lubomir Rintel [Tue, 14 Apr 2015 16:21:44 +0000 (18:21 +0200)]
lxc: move wireless PHYs to a network namespace

The 802.11 interfaces can not be moved by themselves, their Phy has to move too.

If there are other interfaces, they have to move too -- hopefully it's not too
confusing. This is a less-invasive alternative to defining a new hostdev type
for PHYs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agolibxl: drop virDomainObj lock when destroying a domain
Jim Fehlig [Wed, 4 Mar 2015 00:54:50 +0000 (17:54 -0700)]
libxl: drop virDomainObj lock when destroying a domain

A destroy operation can take considerable time on large memory
domains due to scrubbing the domain's memory.  Unlock the
virDomainObj while libxl_domain_destroy is executing.

Implement libxlDomainDestroyInternal wrapper to handle unlocking,
calling destroy, and locking.  Change all callers of
libxl_domain_destroy to use the wrapper.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: acquire a job when destroying a domain
Jim Fehlig [Sun, 1 Mar 2015 23:22:07 +0000 (16:22 -0700)]
libxl: acquire a job when destroying a domain

A job should be acquired at the beginning of a domain destroy operation,
not at the end when cleaning up the domain.  Fix two occurrences of this
late job acquisition in the libxl driver.  Doing so renders
libxlDomainCleanupJob unused, so it is removed.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: Move job acquisition in libxlDomainStart to callers
Jim Fehlig [Mon, 2 Mar 2015 01:24:26 +0000 (18:24 -0700)]
libxl: Move job acquisition in libxlDomainStart to callers

Let callers of libxlDomainStart decide when it is appropriate to
acquire a job on the associated virDomainObj.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: support HVM direct kernel boot
Jim Fehlig [Fri, 20 Mar 2015 04:16:11 +0000 (22:16 -0600)]
libxl: support HVM direct kernel boot

Add support for HVM direct kernel boot in libxl.  Also add a
test to verify domXML <-> native conversions.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agoxenconfig: don't use "kernel" for hvmloader
Jim Fehlig [Fri, 20 Mar 2015 01:03:08 +0000 (19:03 -0600)]
xenconfig: don't use "kernel" for hvmloader

In xl config, hvmloader is implied for hvm guests.  It is not
specified with the "kernel" option like xm config.  The "kernel"
option, along with "ramdisk" and "extra", is used for HVM direct
kernel boot.  Instead of using "kernel" option to populate
virDomainDef object's os.loader->path, use hvmloader discovered
when gathering capabilities.

This change required fixing initialization of capabilities in
the test utils and removing 'kernel = "/usr/lib/xen/boot/hvmloader"'
from the test config files.

10 years agoxenconfig: move <os> parsing/formating to config-specific files
Jim Fehlig [Fri, 20 Mar 2015 00:28:49 +0000 (18:28 -0600)]
xenconfig: move <os> parsing/formating to config-specific files

xl and xm differ a bit in how <os> configuration is represented.
E.g. xl config supports <os><nvram .../></os> via its "bios"
setting.

Move the xenParseOS and xenFormatOS functions from xen_common.c
and copy to xen_xl.c and xen_xm.c so they can be customized for
xm vs xl config.  An unfortunate fallout is reordering of entries
in the test config files.

10 years agoxenconfig: remove redunant parsing of device_model
Jim Fehlig [Fri, 20 Mar 2015 00:02:28 +0000 (18:02 -0600)]
xenconfig: remove redunant parsing of device_model

device_model is parsed in xenParseOS(), then later in
xenParseConfigCommon().  <emulator> is not part of <os>,
so makes sense to remove the parsing in xenParseOS().

10 years agoxenconfig: export xenConfigCopyString
Jim Fehlig [Thu, 19 Mar 2015 23:29:38 +0000 (17:29 -0600)]
xenconfig: export xenConfigCopyString

Export xenConfigCopyString for use outside of xen_common.c

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agovirbuffer: fix build on rhel-6
Pavel Hrdina [Thu, 16 Apr 2015 16:32:26 +0000 (18:32 +0200)]
virbuffer: fix build on rhel-6

On rhel-6 is broken gcc that reports this warning:

util/virbuffer.c:500: error: logical '&&' with non-zero constant will
    always evaluate as true [-Wlogical-op]

Move the pragma directive before function virBufferEscapeString because
since commit aeb5262e this function uses 'strchr' too.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agostorage: Refactor virStorageBackendSCSINewLun
John Ferlan [Tue, 7 Apr 2015 17:39:01 +0000 (13:39 -0400)]
storage: Refactor virStorageBackendSCSINewLun

Invert the logical of retval and clean up code paths, especially goto's

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agovirCondWaitUntil: calculate timespec correctly
Michael Chapman [Thu, 16 Apr 2015 09:27:36 +0000 (19:27 +1000)]
virCondWaitUntil: calculate timespec correctly

ts.tv_nsec was off by a factor of 1000, making timeouts less than a
second in the future often expiring immediately.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
10 years agoqemu: monitor: Refactor and fix monitor checking
Peter Krempa [Tue, 14 Apr 2015 15:52:48 +0000 (17:52 +0200)]
qemu: monitor: Refactor and fix monitor checking

Among all the monitor APIs some where checking if mon is NULL and some
were not. Since it's possible to have mon equal to NULL in case a second
call is attempted once entered the monitor. This requires that every
single API checks for the monitor.

This patch adds a macro that helps checking the state of the monitor and
either refactors existing checking code to use the macro or adds it in
case it was missing.

10 years agodaemon: Prefix sysctl configuration filename with a number
Jiri Denemark [Wed, 15 Apr 2015 09:49:22 +0000 (11:49 +0200)]
daemon: Prefix sysctl configuration filename with a number

Apparently, files in /usr/lib/sysctl.d are usually prefixed with numbers
for easier ordering. Let's be consistent with this. I chose 60 for
libvirtd so that it goes after 50-default.conf.

https://bugzilla.redhat.com/show_bug.cgi?id=1084876
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: bulk stats: Ignore errors from missing/inaccessible disks
Peter Krempa [Wed, 15 Apr 2015 16:14:30 +0000 (18:14 +0200)]
qemu: bulk stats: Ignore errors from missing/inaccessible disks

Rather than erroring out make the best attempt to retrieve other data if
disks are inaccessible or missing. The failure will still be logged
though.

Since the bulk stats API is called on multiple domains an error like
this makes the API unusable. This regression was introduced by commit
596a13713420e01b20ce3dc3fdbe06d073682675

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

10 years agoRNG schema: allow plain @floor to <bandwidth/>
Michal Privoznik [Tue, 14 Apr 2015 13:54:42 +0000 (15:54 +0200)]
RNG schema: allow plain @floor to <bandwidth/>

The <inbound/> element to <bandwidth/> has several attributes from
which two are mandatory. Well, from two at least one has to be
present: @average or @floor or both. Instead of inventing crazy RNG
schema, let's make all the attributes optional there and rely on our
parsing code to correctly handle the situation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNetDevBandwidthPlug: Update function description
Michal Privoznik [Tue, 14 Apr 2015 11:45:30 +0000 (13:45 +0200)]
virNetDevBandwidthPlug: Update function description

The comment is describing arguments passed to the function.
However, there's no @ifmac argument. In 955af4d4 it was replaced
with @ifmac_ptr.  Unfortunately, the comment wasn't updated.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agotests: fix build on old 32-bit platforms
Eric Blake [Wed, 15 Apr 2015 18:50:23 +0000 (12:50 -0600)]
tests: fix build on old 32-bit platforms

gcc 4.1.2 (hello RHEL 5) on 32-bit platforms complains:

vircgrouptest.c: In function 'testCgroupGetPercpuStats':
vircgrouptest.c:627: warning: integer constant is too large for 'long' type
vircgrouptest.c:628: warning: this decimal constant is unsigned only in ISO C90
vircgrouptest.c:634: warning: integer constant is too large for 'long' type
vircgrouptest.c:635: warning: this decimal constant is unsigned only in ISO C90
vircgrouptest.c:636: warning: this decimal constant is unsigned only in ISO C90
vircgrouptest.c:644: warning: integer constant is too large for 'long' type

* tests/vircgrouptest.c (testCgroupGetPercpuStats): Use ULL suffix.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoStrip control codes in virBufferEscapeString
Ján Tomko [Mon, 30 Mar 2015 10:41:40 +0000 (12:41 +0200)]
Strip control codes in virBufferEscapeString

These cannot be represented in XML.

We have been stripping them, but only if the string had
characters that needed escaping: <>"'&

Extend the strcspn check to include control codes, and strip
them even if we don't do any escaping.

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

10 years agoIgnore storage volumes with control codes in their names
Ján Tomko [Tue, 14 Apr 2015 10:30:55 +0000 (12:30 +0200)]
Ignore storage volumes with control codes in their names

To prevent generating invalid XML.

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

10 years agoStrip control characters from sysfs attributes
Ján Tomko [Tue, 14 Apr 2015 10:30:34 +0000 (12:30 +0200)]
Strip control characters from sysfs attributes

Including them in the XML makes them unparsable.

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

10 years agoAdd functions dealing with control characters in strings
Ján Tomko [Tue, 14 Apr 2015 10:30:16 +0000 (12:30 +0200)]
Add functions dealing with control characters in strings

Add virStringHasControlChars that checks if the string has
any control characters other than \t\r\n,
and virStringStripControlChars that removes them in-place.

10 years agotests: rename testStripIPv6BracketsData to testStripData
Ján Tomko [Tue, 14 Apr 2015 10:06:44 +0000 (12:06 +0200)]
tests: rename testStripIPv6BracketsData to testStripData

For reuse with other Strip* functions.

10 years agoAdd an example for EVENT_ID_DEVICE_ADDED
Ján Tomko [Tue, 14 Apr 2015 12:56:09 +0000 (14:56 +0200)]
Add an example for EVENT_ID_DEVICE_ADDED

10 years agoEmit VIR_DOMAIN_EVENT_ID_DEVICE_ADDED in the QEMU driver
Ján Tomko [Mon, 30 Mar 2015 18:08:47 +0000 (20:08 +0200)]
Emit VIR_DOMAIN_EVENT_ID_DEVICE_ADDED in the QEMU driver

Only for devices that have an alias.

10 years agoAdd VIR_DOMAIN_EVENT_ID_DEVICE_ADDED event
Ján Tomko [Mon, 30 Mar 2015 16:46:21 +0000 (18:46 +0200)]
Add VIR_DOMAIN_EVENT_ID_DEVICE_ADDED event

The counterpart to VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED.

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

10 years agoCleanup "/sys/class/net" usage
Michal Privoznik [Wed, 15 Apr 2015 09:45:47 +0000 (11:45 +0200)]
Cleanup "/sys/class/net" usage

Throughout the code, we have several places need to construct a path
somewhere in /sys/class/net/... They are not consistent and nearly
each code piece invents its own way how to do it. So unify this by:

1) use virNetDevSysfsFile() wherever possible

2) At least use common macro SYSFS_NET_DIR declared in virnetdev.h at
   the rest of places which can't go with 1)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agotests: Add virnetdevtestdata to EXTRA_DIST
Michal Privoznik [Wed, 15 Apr 2015 08:09:52 +0000 (10:09 +0200)]
tests: Add virnetdevtestdata to EXTRA_DIST

In one of my previous commits (49ed6cff9) I've introduced a test
among with some files stored under virnetdevtestdata folder.
While this works perfectly within a git tree, the folder was not
getting into .tar.gz and therefore the dist-check would fail.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agotests: Resolve Coverity RESOURCE_LEAK
John Ferlan [Wed, 15 Apr 2015 14:16:36 +0000 (10:16 -0400)]
tests: Resolve Coverity RESOURCE_LEAK

Commit id 'b77ce18a2' added a new bitmap, but neglected to virBitmapFree it

10 years agovirsh: fix regression in 'virsh event' by domain
Eric Blake [Tue, 14 Apr 2015 22:15:06 +0000 (16:15 -0600)]
virsh: fix regression in 'virsh event' by domain

Commit a0670ae caused a regression in 'virsh event' and
'virsh qemu-monitor-event' - if a user tries to filter the
command to a specific domain, an error message is printed:

$ virsh event dom --loop
error: internal error: virsh qemu-monitor-event: no domain VSH_OT_DATA option

and then the command continues as though no domain had been
supplied (giving events for ALL domains, instead of the
requested one).  This is because the code was incorrectly
assuming that all "domain" options would be supplied via a
mandatory VSH_OT_DATA, even though "domain" is optional for
these two commands, so we had changed them to VSH_OT_STRING
to quit failing for other reasons (ever since it was decided
that VSH_OT_DATA and VSH_OT_STRING should no longer be
synonyms).

In looking at the situation, though, the code for looking up
a domain was making a pointless check for whether the option
exists prior to finding the option's string value, as
vshCommandOptStringReq does just fine at reporting any errors
when looking up a string whether or not the option was present.

So this is a case of regression fixing by pure code deletion :)

* tools/virsh-domain.c (vshCommandOptDomainBy): Drop useless filter.
* tools/virsh-interface.c (vshCommandOptInterfaceBy): Likewise.
* tools/virsh-network.c (vshCommandOptNetworkBy): Likewise.
* tools/virsh-nwfilter.c (vshCommandOptNWFilterBy): Likewise.
* tools/virsh-secret.c (vshCommandOptSecret): Likewise.
* tools/virsh.h (vshCmdHasOption): Drop unused function.
* tools/virsh.c (vshCmdHasOption): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agonode: udev: Remove some redundant error reports
Peter Krempa [Wed, 15 Apr 2015 12:49:14 +0000 (14:49 +0200)]
node: udev: Remove some redundant error reports

All the called functions already report an error.

10 years agovirPidFileConstructPath: Drop useless VIR_FREE()
Michal Privoznik [Wed, 15 Apr 2015 13:01:02 +0000 (15:01 +0200)]
virPidFileConstructPath: Drop useless VIR_FREE()

If a virAsprintf() within the function fails, we call VIR_FREE()
over @rundir variable and jump onto cleanup label, where it is
freed again.  It doesn't hurt, but not make much sense too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: monitor: Fix qemuMonitorGetAllBlockStatsInfo with HMP
Peter Krempa [Tue, 14 Apr 2015 15:08:23 +0000 (17:08 +0200)]
qemu: monitor: Fix qemuMonitorGetAllBlockStatsInfo with HMP

Commit f6563bc3 introduced HMP impl of the function (so that a different
uglier function could be removed). Before the HMP code is called there's
a leftover check that the monitor is JSON which inhibits the code from
working.

10 years agoqemu: monitor: @running in qemuMonitorGetStatus is always non-NULL
Peter Krempa [Tue, 14 Apr 2015 15:00:23 +0000 (17:00 +0200)]
qemu: monitor: @running in qemuMonitorGetStatus is always non-NULL

Add the attribute and remove the check.

10 years agoqemu: monitor: Don't use 'ret' variable where not necessary
Peter Krempa [Tue, 14 Apr 2015 14:19:04 +0000 (16:19 +0200)]
qemu: monitor: Don't use 'ret' variable where not necessary

Quite a lot places set the 'ret' variable just once right before
returning it's value. Remove such usage.

10 years agoqemu: monitor: Ensure that qemuMonitorSetLink is called with non-null name
Peter Krempa [Tue, 14 Apr 2015 13:26:36 +0000 (15:26 +0200)]
qemu: monitor: Ensure that qemuMonitorSetLink is called with non-null name

10 years agoqemu: monitor: Sanitize control flow in qemuMonitorSetCapabilities
Peter Krempa [Tue, 14 Apr 2015 13:17:10 +0000 (15:17 +0200)]
qemu: monitor: Sanitize control flow in qemuMonitorSetCapabilities

10 years agoqemu: monitor: Clean up coding style
Peter Krempa [Tue, 14 Apr 2015 13:14:23 +0000 (15:14 +0200)]
qemu: monitor: Clean up coding style

Fix line spacing between functions, ensure that function return type is
on a separate line and reflow arguments for VIR_DEBUG statements.

10 years agovirNetSocketNewConnectUNIX: Use flocks when spawning a daemon
Michal Privoznik [Thu, 2 Apr 2015 12:41:17 +0000 (14:41 +0200)]
virNetSocketNewConnectUNIX: Use flocks when spawning a daemon

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

Even though we have a mutex mechanism so that two clients don't spawn
two daemons, it's not strong enough. It can happen that while one
client is spawning the daemon, the other one fails to connect.
Basically two possible errors can happen:

  error: Failed to connect socket to '/home/mprivozn/.cache/libvirt/libvirt-sock': Connection refused

or:

  error: Failed to connect socket to '/home/mprivozn/.cache/libvirt/libvirt-sock': No such file or directory

The problem in both cases is, the daemon is only starting up, while we
are trying to connect (and fail). We should postpone the connecting
phase until the daemon is started (by the other thread that is
spawning it). In order to do that, create a file lock 'libvirt-lock'
in the directory where session daemon would create its socket. So even
when called from multiple processes, spawning a daemon will serialize
on the file lock. So only the first to come will spawn the daemon.

Tested-by: Richard W. M. Jones <rjones@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agojson: export non-static functions
Martin Kletzander [Mon, 13 Apr 2015 14:11:03 +0000 (16:11 +0200)]
json: export non-static functions

Two non-static functions in virjson.c were missing their export info in
libvirt_private.syms, so they couldn't be used anywhere it the code (and
that's about to get changed).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoChange virConnectPtr into virObjectLocklable
Martin Kletzander [Thu, 9 Apr 2015 07:43:53 +0000 (09:43 +0200)]
Change virConnectPtr into virObjectLocklable

It already had a virMutex inside, so this is just a cleanup.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agocloseCallback is already lockable, initialize it as such
Martin Kletzander [Tue, 7 Apr 2015 15:18:01 +0000 (17:18 +0200)]
closeCallback is already lockable, initialize it as such

Luckily we are allocating structs as clean memory and
PTHREAD_MUTEX_INITIALIZER is "{ 0 }", so nothing happened, but it should
still be created as lockable object.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoconfigure: Align messages
Martin Kletzander [Tue, 17 Mar 2015 08:45:59 +0000 (09:45 +0100)]
configure: Align messages

The first two were a bit off.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agostorage: Add duplicate devices check for zfs pool def
John Ferlan [Thu, 2 Apr 2015 16:50:07 +0000 (12:50 -0400)]
storage: Add duplicate devices check for zfs pool def

Check proposed pool definitions to ensure they aren't trying to use the
same devices as currently defined definitions - disallow the duplicate

10 years agostorage: Add duplicate source pool for Gluster pool def
John Ferlan [Thu, 2 Apr 2015 16:48:04 +0000 (12:48 -0400)]
storage: Add duplicate source pool for Gluster pool def

Check the proposed pool source host XML definition against existing gluster
pools to ensure the incoming definition doesn't use the same source dir and
soure host XML definition as an existing pool.

10 years agostorage: Add duplicate host check for Sheepdog pool def
John Ferlan [Thu, 2 Apr 2015 16:46:00 +0000 (12:46 -0400)]
storage: Add duplicate host check for Sheepdog pool def

Check the proposed pool source host XML definition against existing sheepdog
pools to ensure the incoming definition doesn't use the same source host XML
definition as an existing pool.

10 years agostorage: Remove default from switch in virStoragePoolSourceFindDuplicate
John Ferlan [Thu, 2 Apr 2015 16:39:27 +0000 (12:39 -0400)]
storage: Remove default from switch in virStoragePoolSourceFindDuplicate

So that we can cover all the cases.

10 years agostorage: Use virStoragePoolSourceMatchSingleHost for NETFS
John Ferlan [Wed, 1 Apr 2015 18:09:05 +0000 (14:09 -0400)]
storage: Use virStoragePoolSourceMatchSingleHost for NETFS

Rather than have duplicate code doing the same check, have the netfs
matching processing code use the new virStoragePoolSourceMatchSingleHost.

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agostorage: Add check for different ports for host duplicate matching
John Ferlan [Mon, 13 Apr 2015 21:11:53 +0000 (17:11 -0400)]
storage: Add check for different ports for host duplicate matching

In virStoragePoolSourceMatchSingleHost, add a comparison for port number
being different prior to checking the 'name' field.

10 years agostorage: Create virStoragePoolSourceMatchSingleHost
John Ferlan [Wed, 1 Apr 2015 18:05:54 +0000 (14:05 -0400)]
storage: Create virStoragePoolSourceMatchSingleHost

Split out the nhost == 1 and hosts[0].name logic into a separate routine

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agostorage: Refactor iSCSI Source matching
John Ferlan [Mon, 30 Mar 2015 23:59:26 +0000 (19:59 -0400)]
storage: Refactor iSCSI Source matching

Create a separate iSCSI Source matching subroutine. Makes the calling
code a bit cleaner as well as sets up for future patches which need to
do better source hosts[0].name processing/checking.

As part of the effort the logic will be inverted from a multi-level
if statement to a series of single level checks for better readability
and further separation

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agosanlock: Use VIR_ERR_RESOURCE_BUSY if sanlock_acquire fails
Jiri Denemark [Tue, 14 Apr 2015 14:27:37 +0000 (16:27 +0200)]
sanlock: Use VIR_ERR_RESOURCE_BUSY if sanlock_acquire fails

When acquiring resource via sanlock fails, we would report it as
VIR_ERR_INTERNAL_ERROR, which is not very friendly to applications using
libvirt. Moreover, the lockd driver would report the same failure as
VIR_ERR_RESOURCE_BUSY, which looks better.

Unfortunately, in sanlock driver we don't really know if acquiring the
resource failed because it was already locked or there was another
reason behind. But the end result is the same and I think using
VIR_ERR_RESOURCE_BUSY reason for all acquire failures is still better
than what we have now.

https://bugzilla.redhat.com/show_bug.cgi?id=1165119
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agobuild: provide virNetDevSysfsFile on non-Linux
Eric Blake [Tue, 14 Apr 2015 19:53:04 +0000 (13:53 -0600)]
build: provide virNetDevSysfsFile on non-Linux

Commit 49ed6cff is broken on mingw and other non-linux platforms:

  CCLD     libvirt.la
  Cannot export virNetDevSysfsFile: symbol not defined
  collect2: error: ld returned 1 exit status

* src/util/virnetdev.c: Provide virNetDevSysfsFile fallback.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agobuild: include correct header for time()
Eric Blake [Tue, 14 Apr 2015 19:15:06 +0000 (13:15 -0600)]
build: include correct header for time()

Found by ./autobuild.sh during a mingw cross-compile:

Commit 8a96e87 was not innocuous - glibc happens to leak the
definition of time() through other headers, so that even without
<sys/select.h>, virrandom.c compiled just fine.  But on mingw,
we were not so lucky; <sys/select.h> was important for its side
effect of dragging in <time.h>, and we now have nothing providing
the declaration of time():

../../src/util/virrandom.c: In function 'virRandomOnceInit':
../../src/util/virrandom.c:65:5: error: implicit declaration of function 'time' [-Werror=implicit-function-declaration]
     unsigned int seed = time(NULL) ^ getpid();
          ^
  ../../src/util/virrandom.c:65:5: error: nested extern declaration of 'time' [-Werror=nested-externs]

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoIntroduce virnetdevtest
Michal Privoznik [Wed, 11 Jun 2014 13:05:00 +0000 (15:05 +0200)]
Introduce virnetdevtest

This is yet another test for check of basic functionality of our
NIC state handling code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agocfg: Disallow usage of 'index' as variable name
John Ferlan [Tue, 14 Apr 2015 11:37:41 +0000 (07:37 -0400)]
cfg: Disallow usage of 'index' as variable name

Since we've run afoul of the Xen-devel build for shadowing a global
declaration of 'index', just disallow using index for a variable name

10 years agonwfilter: Change 'index' to 'idx'
John Ferlan [Tue, 14 Apr 2015 11:36:23 +0000 (07:36 -0400)]
nwfilter: Change 'index' to 'idx'

Forthcoming syntax check rule will disallow usage of 'int index', so
change it for nwfilter

10 years agosnapshot: Change 'index' to 'idx'
John Ferlan [Tue, 14 Apr 2015 11:35:29 +0000 (07:35 -0400)]
snapshot: Change 'index' to 'idx'

Forthcoming syntax check rule will disallow usage of 'int index', so
change it for snapshot

10 years agoutil: Use 'idx' instead of 'index'
John Ferlan [Tue, 14 Apr 2015 11:34:24 +0000 (07:34 -0400)]
util: Use 'idx' instead of 'index'

Impending syntax checker will disallow 'int index', so change it here.

10 years agoqemu: Adjust the prototype to match the function
John Ferlan [Tue, 14 Apr 2015 11:28:57 +0000 (07:28 -0400)]
qemu: Adjust the prototype to match the function

Changing the prototype to not have "int *index" since we'll soon be
disallowing index as a name. Curiously the original commit (a4504ac)
for the function used 'int idx' in the function - so they didn't match.
Now they do.

10 years agoAdd articles to virDomainDeviceDetachFlags docs
Ján Tomko [Tue, 14 Apr 2015 13:29:15 +0000 (15:29 +0200)]
Add articles to virDomainDeviceDetachFlags docs

Reported by John Ferlan.

10 years agoxen: fix build error on rhel-5
Pavel Hrdina [Tue, 14 Apr 2015 12:41:56 +0000 (14:41 +0200)]
xen: fix build error on rhel-5

../../src/xen/block_stats.c:82: warning: dereferencing type-punned
    pointer will break strict-aliasing rules [-Wstrict-aliasing]

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agosparc: Add default PCI root controller
Martin Kletzander [Thu, 9 Apr 2015 08:38:28 +0000 (10:38 +0200)]
sparc: Add default PCI root controller

It is there even with -nodefaults and -no-user-config, so count with
that so we can start sparc domains.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agohostdev: fix loop index error when resetvfnetconfig
Huanle Han [Thu, 2 Apr 2015 15:56:19 +0000 (23:56 +0800)]
hostdev: fix loop index error when resetvfnetconfig

The variable 'last_processed_hostdev_vf' indicates index of the last
successfully configed vf. When resetvfnetconfig because of failure,
hostdevs[last_processed_hostdev_vf] should also be reset.

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
10 years agoqemu: fix index error when clean up vport profile
Huanle Han [Tue, 7 Apr 2015 18:40:15 +0000 (02:40 +0800)]
qemu: fix index error when clean up vport profile

1. 'last_good_net' indicates the index of last successfully configured
net. so def->nets[last_good_net] should also be clean up if error occurs.

2. if error occurs in 'virNetDevMacVLanVPortProfileRegisterCallback'
(second 'goto err_exit' in loop), we should also do
'virNetDevVPortProfileDisassociate' cleanup for the
'virNetDevVPortProfileAssociate'(first code block in loop). So we should
consider the net is successfully configured after first code block in
loop finishes.

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
10 years agovirt-aa-helper: add unix channels (esp for qemu-guest-agent)
Serge Hallyn [Fri, 10 Apr 2015 20:21:03 +0000 (20:21 +0000)]
virt-aa-helper: add unix channels (esp for qemu-guest-agent)

The original bug report was at
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1393842

Also skip abstract unix sockets.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoqemu: save domain status after set memory parameters
Shanzhi Yu [Tue, 14 Apr 2015 10:24:41 +0000 (18:24 +0800)]
qemu: save domain status after set memory parameters

After set memory parameters for running domain, save the change to live
xml is needed otherwise it will disappear after restart libvirtd.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1211548
Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agovirsh: improve the error for wrong memtune parameters
Shanzhi Yu [Tue, 14 Apr 2015 10:24:40 +0000 (18:24 +0800)]
virsh: improve the error for wrong memtune parameters

When set guest memory with a invalid parameter of --soft-limit,
it posts weird error:

$ virsh memtune r7 --hard-limit 20417224 --soft-limit 9007199254740992 \
  --swap-hard-limit 35417224
error: Unable to parse integer parameter 'NAME

Change it to

error: Unable to parse integer parameter soft-limit

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1211550
Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoqemu: Use 'idx' instead of 'index' for variable name
John Ferlan [Tue, 14 Apr 2015 10:41:09 +0000 (06:41 -0400)]
qemu: Use 'idx' instead of 'index' for variable name

Apparently for Xen-devel 'index' is a global and causes a build failure,
so just use the shortened 'idx' instead to avoid the conflict.

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agoqemu: Refactor qemuDomainBlockJobAbort()
Peter Krempa [Wed, 1 Apr 2015 17:17:11 +0000 (19:17 +0200)]
qemu: Refactor qemuDomainBlockJobAbort()

Change few variable names and refactor the code flow. As an additional
bonus the function now fails if the event state is not as expected.

10 years agoqemu: drivePivot: Fix assumption when 'block-job-complete' fails
Peter Krempa [Wed, 1 Apr 2015 17:00:20 +0000 (19:00 +0200)]
qemu: drivePivot: Fix assumption when 'block-job-complete' fails

QEMU does not abandon the mirror. The job carries on in the synchronised
phase and it might be either pivoted again or cancelled. The commit
hints that the described behavior was happening in a downstream version.

If the command returns false there are two possible options:
1) qemu did not reach the point where it would ask the block job to
pivot
2) pivotting failed in the actual qemu coroutine

If either of those would happen we return failure and reset the
condition that waits for the block job to complete. This makes the API
fail but in case where qemu would actually abandon the mirror the fact
is notified via the event and handled asynchronously.

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

10 years agoqemu: blockPull: Refactor the rest of qemuDomainBlockJobImpl
Peter Krempa [Wed, 1 Apr 2015 09:45:35 +0000 (11:45 +0200)]
qemu: blockPull: Refactor the rest of qemuDomainBlockJobImpl

Since it now handles only block pull code paths we can refactor it and
remove tons of cruft.

10 years agoqemu: blockjob: Separate qemuDomainBlockJobAbort from qemuDomainBlockJobImpl
Peter Krempa [Wed, 1 Apr 2015 08:40:06 +0000 (10:40 +0200)]
qemu: blockjob: Separate qemuDomainBlockJobAbort from qemuDomainBlockJobImpl

Sacrifice a few lines of code in favor of the code being more readable.

10 years agoqemu: blockjob: Split qemuDomainBlockJobSetSpeed from qemuDomainBlockJobImpl
Peter Krempa [Wed, 1 Apr 2015 07:47:04 +0000 (09:47 +0200)]
qemu: blockjob: Split qemuDomainBlockJobSetSpeed from qemuDomainBlockJobImpl

qemuDomainBlockJobImpl become an unmaintainable mess over the years of
adding new stuff to it. This patch starts splitting up individual
functions from it until it can be killed entirely.

In bulk this will add lines of code rather than delete them but it will
be traded for maintainability.

10 years agoqemu: monitor: Extract handling of JSON block job error codes
Peter Krempa [Tue, 31 Mar 2015 15:13:21 +0000 (17:13 +0200)]
qemu: monitor: Extract handling of JSON block job error codes

My intention is to split qemuMonitorJSONBlockJob() into simpler separate
functions for every block job type. Since the error handling code is the
same for all block jobs, this patch extracts the code into a separate
function that will later be reused in more places.

With the new helper qemuMonitorJSONErrorIsClass we can save a few
function calls as we can extract the error object once.

10 years agoqemu: monitor: json: Refactor error code class checker
Peter Krempa [Thu, 9 Apr 2015 09:26:43 +0000 (11:26 +0200)]
qemu: monitor: json: Refactor error code class checker

Split out the function that checks the actual error class string into a
separate helper as it will be useful later and refactor
qemuMonitorJSONHasError to return bool type and remove few useless
checks.

Basically virJSONValueObjectHasKey are useless here since the next call
to virJSONValueObjectGet is checking the return value again (which can't
fail at that point). By removing the first check we save a function
call.

10 years agoqemu: Fix condition for checking vcpu when pinning vcpus
Peter Krempa [Tue, 7 Apr 2015 18:44:15 +0000 (20:44 +0200)]
qemu: Fix condition for checking vcpu when pinning vcpus

Previously we checked that the vcpu we are trying to set is in range of
the number of threads presented by qemu. The problem is that if the VM
is offline the count is 0. Since the condition subtracted 1 from the
count the number would overflow and the check would never trigger.

Change the condition for more sensible ones with specific error
messages.

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

10 years agoconf: Refactor virDomainVcpuPinDefParseXML
Peter Krempa [Tue, 7 Apr 2015 18:09:04 +0000 (20:09 +0200)]
conf: Refactor virDomainVcpuPinDefParseXML

Refactor the code to parse the vcpupin in a similar way the iothreadpin
code is now structured. This allows to get rid of some very strange
conditions and error messages.

Additionally since a existing bug
( https://bugzilla.redhat.com/show_bug.cgi?id=1208434 ) allows to add
vcpupin definitions for vcpus that don't exist, this patch makes the
parser to ignore all vcpupins that don't have a matching vCPU in the
definition rather than just offlined ones.

10 years agoconf: Error out if iothread id is missing in iothreadpin
Peter Krempa [Tue, 7 Apr 2015 17:52:02 +0000 (19:52 +0200)]
conf: Error out if iothread id is missing in iothreadpin

Defining a domain with the following config:

<domain ...>
  ...
  <iothreads>1</iothreads>
  <cputune>
    <iothreadpin cpuset='1'/>

will result in the following config formatted back:
<domain type='kvm'>
  ...
  <iothreads>1</iothreads>
  <cputune>
    <iothreadpin iothread='0' cpuset='1'/>

After restart the VM would vanish. Since our schema requires the
@iothread field to be present in <iothreadpin> make it required by the
code too.

10 years agoconf: Split up virDomainVcpuPinDefParseXML
Peter Krempa [Tue, 7 Apr 2015 15:44:12 +0000 (17:44 +0200)]
conf: Split up virDomainVcpuPinDefParseXML

Extract part that parses iothreads into virDomainIothreadPinDefParseXML

10 years agoconf: Split out parsing of emulatorpin
Peter Krempa [Tue, 7 Apr 2015 15:13:07 +0000 (17:13 +0200)]
conf: Split out parsing of emulatorpin

Split up parts of virDomainVcpuPinDefParseXML into
virDomainEmulatorPinDefParseXML.

10 years agolib: snapshot: Explain that only one layer of images is inserted
Peter Krempa [Fri, 10 Apr 2015 08:48:34 +0000 (10:48 +0200)]
lib: snapshot: Explain that only one layer of images is inserted

When creating a snapshot with _REUSE_EXTERNAL when the pre-created image
does not directly link to the current active layer libvirt would
re-detect the backing chain incorrectly and it would not match with
qemu's view. Since the configuration is an operator mistake, document
that only the top layer image gets inserted.

10 years agoqemu: Enforce WWN to be unique among VM's disks
Peter Krempa [Tue, 7 Apr 2015 14:08:32 +0000 (16:08 +0200)]
qemu: Enforce WWN to be unique among VM's disks

Operating systems use the identifier to name the disks. As the name
suggests the ID should be unique.

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

10 years agoconf: ABI: Check WWN in disk abi stability check
Peter Krempa [Tue, 7 Apr 2015 14:00:16 +0000 (16:00 +0200)]
conf: ABI: Check WWN in disk abi stability check

Since the WWN influences guest behavior in naming disks we should treat
this as vm ABI.

10 years agoConvert virDomainPinIsDuplicate into bool return
John Ferlan [Fri, 3 Apr 2015 10:57:32 +0000 (06:57 -0400)]
Convert virDomainPinIsDuplicate into bool return

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agoRename qemuCheckIothreads to qemuCheckIOThreads
John Ferlan [Fri, 3 Apr 2015 00:00:46 +0000 (20:00 -0400)]
Rename qemuCheckIothreads to qemuCheckIOThreads

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agoRewrite vshParseCPUList
Ján Tomko [Wed, 1 Apr 2015 16:46:56 +0000 (18:46 +0200)]
Rewrite vshParseCPUList

Use virBitmap helpers that were added after this function.

Change cpumaplen to int and fill it out by this function.