]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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.

10 years agoRewrite vshPrintPinInfo
Ján Tomko [Thu, 26 Mar 2015 14:24:09 +0000 (15:24 +0100)]
Rewrite vshPrintPinInfo

Use virBitmapDataToString instead of constructing the ranges bit
by bit, remove the checking of parameters (that is already done
by the callers).

Let the callers choose the right bitmap, since there's only
one that uses this helper on a matrix-in-an-array.

10 years agoParallels: implemented domainAttachDevice
Alexander Burluka [Thu, 9 Apr 2015 10:42:00 +0000 (13:42 +0300)]
Parallels: implemented domainAttachDevice

That function uses domainAttachDeviceFlags

Signed-off-by: Alexander Burluka <aburluka@parallels.com>
10 years agoParallels: implement domainAttachDeviceFlags
Alexander Burluka [Mon, 13 Apr 2015 14:55:27 +0000 (17:55 +0300)]
Parallels: implement domainAttachDeviceFlags

Parallels Cloud Server supports block devices and virtual NIC
live attachment. I implemented that function for block devices so
OpenStack volume attachment is now works.

Signed-off-by: Alexander Burluka <aburluka@parallels.com>
10 years agoParallels: remove disk serial number check
Alexander Burluka [Thu, 9 Apr 2015 10:42:00 +0000 (13:42 +0300)]
Parallels: remove disk serial number check

OpenStack needs disk serial number setup because
nova boot --block-device-mapping command generates that param in
libvirt xml. I took QEMU libvirt driver behavior as a base.
QEMU driver skips inability to set serial and continues work.
So Parallels driver will ignore this param too and let domain
boot.

10 years agoRemove overengineered loop
Ján Tomko [Fri, 10 Apr 2015 12:28:41 +0000 (14:28 +0200)]
Remove overengineered loop

Do not loop over enum with one value.

10 years agoIntroduce struct _virStorageBackendQemuImgInfo
Ján Tomko [Thu, 31 Jul 2014 16:07:56 +0000 (18:07 +0200)]
Introduce struct _virStorageBackendQemuImgInfo

This will contain the data required for creating the qemu-img
command line without having access to the volume definition.

10 years agoRename virStorageBackendCreateQemuImgCmd
Ján Tomko [Thu, 31 Jul 2014 16:08:33 +0000 (18:08 +0200)]
Rename virStorageBackendCreateQemuImgCmd

Add FromVol at the end. This function will create the qemu-img
command line from volume definitions and check them.

10 years agoUse XPath when parsing snapshot disk definition
Ján Tomko [Fri, 10 Apr 2015 09:55:43 +0000 (11:55 +0200)]
Use XPath when parsing snapshot disk definition

Instead of going through XML nodes in a loop and
having to check if they are duplicate.

10 years agoSplit out storage format 'compat' attribute sanity check
Ján Tomko [Thu, 9 Apr 2015 08:48:49 +0000 (10:48 +0200)]
Split out storage format 'compat' attribute sanity check

For future reuse in the snapshot XML.

10 years agovirBitmap: Place virBitmapIsAllClear check after virBitmapParse calls
Erik Skultety [Fri, 10 Apr 2015 09:11:21 +0000 (11:11 +0200)]
virBitmap: Place virBitmapIsAllClear check after virBitmapParse calls

This patch adds checks for empty bitmaps right after the calls of
virBitmapParse. These only include spots where set API's are called and
where domain's XML is parsed.
Also, it partially reverts commit 983f5a which added a check for
invalid nodeset "0,^0" into virBitmapParse function. This change broke
the logic, as an empty bitmap should not cause an error.

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

10 years agoRemove feature formating funcs from pool-specific options
Ján Tomko [Thu, 9 Apr 2015 12:02:53 +0000 (14:02 +0200)]
Remove feature formating funcs from pool-specific options

We only have one formatting function for the features.

10 years agoVisually separate snapshot disk subelements
Ján Tomko [Fri, 10 Apr 2015 12:25:37 +0000 (14:25 +0200)]
Visually separate snapshot disk subelements

Create four smaller blocks of texts instead of one large one.

10 years agoRewrite usb device version parsing
Ján Tomko [Fri, 10 Apr 2015 13:50:53 +0000 (15:50 +0200)]
Rewrite usb device version parsing

Simplify the function by leaving out the local copy and checking
return values of virStrToLong.

10 years agoFix usb device version parsing issues
Ján Tomko [Fri, 10 Apr 2015 13:49:42 +0000 (15:49 +0200)]
Fix usb device version parsing issues

Request that the number be parsed as decimal, to allow 08
and 09.

Format it with the leading zero, 1.01 and 1.10 are two
different versions.

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

10 years agoDo xml->xml test for usb-redir-filter
Ján Tomko [Fri, 10 Apr 2015 13:03:07 +0000 (15:03 +0200)]
Do xml->xml test for usb-redir-filter

We don't format the default '-1' fields back.

10 years agoDo not require virtio-pci devices when using virtio-mmio
Ján Tomko [Fri, 10 Apr 2015 09:22:05 +0000 (11:22 +0200)]
Do not require virtio-pci devices when using virtio-mmio

On arm, we probe for virtio-*-pci devices, but use their
virtio-*-device variants.

Set the capabilities based on the -device variants as well,
to make them work with qemus with the PCI devices compiled out.

10 years agoqemuMigrationPrecreateStorage: Fix debug message
Michal Privoznik [Thu, 2 Apr 2015 14:34:01 +0000 (16:34 +0200)]
qemuMigrationPrecreateStorage: Fix debug message

When pre-creating storage for domains, we need to find corresponding
disk in the XML on the destination (domain XML may differ there, e.g.
disk is accessible under different path). For better debugging, I'm
printing all info I received on a disk. But there was a typo when
printing the disk capacity: "%lluu" instead of "%llu".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu_migration.c: sleep first before checking for migration status.
Xing Lin [Thu, 9 Apr 2015 22:02:02 +0000 (16:02 -0600)]
qemu_migration.c: sleep first before checking for migration status.

The problem with the previous implementation is,
even when qemuMigrationUpdateJobStatus() detects a migration job
has completed, it will do a sleep for 50 ms (which is unnecessary
and only adds up to the VM pause time).

Signed-off-by: Xing Lin <xinglin@cs.utah.edu>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoconf: Don't output <cpu> tag if it contains no information.
Andrea Bolognani [Fri, 10 Apr 2015 13:09:59 +0000 (15:09 +0200)]
conf: Don't output <cpu> tag if it contains no information.

The tag is already marked as optional in the schema, so no changes
are needed there.

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

10 years agoqemu: qemuDomainHotplugVcpus - separate out pin adjustment code
John Ferlan [Wed, 8 Apr 2015 13:25:47 +0000 (09:25 -0400)]
qemu: qemuDomainHotplugVcpus - separate out pin adjustment code

Future IOThread setting patches would copy the code anyway, so create
and generalize the adding of pindef for the vcpu and the pinning of the
thread into their own APIs.

10 years agoAUTHORS: Add my email address to AUTHORS.in
Dmitry Guryanov [Fri, 10 Apr 2015 15:26:00 +0000 (18:26 +0300)]
AUTHORS: Add my email address to AUTHORS.in

10 years agoSupport IPv6 in networkGetNetworkAddress
Ján Tomko [Wed, 8 Apr 2015 14:36:42 +0000 (16:36 +0200)]
Support IPv6 in networkGetNetworkAddress

We've been explicitly requesting IPv4 for some reason,
even if there were only IPv6 addresses in the network
definition.

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

10 years agoutil: Update virNetDevGetIPAddress to get IPv6 addresses
Luyao Huang [Tue, 10 Mar 2015 00:04:58 +0000 (20:04 -0400)]
util: Update virNetDevGetIPAddress to get IPv6 addresses

Add static virNetDevGetifaddrsAddress to attempt to get the interface
IP address. If getifaddrs is not supported, fall back to
virNetDevGetIPv4AddressIoctl to get the IP address.

This allows IPv6 addresses to be used for <listen type='network>
with device-backed networks.

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoutil: Replace virNetDevGetIPv4Address with virNetDevGetIPAddress
John Ferlan [Tue, 10 Mar 2015 00:04:57 +0000 (20:04 -0400)]
util: Replace virNetDevGetIPv4Address with virNetDevGetIPAddress

Rename it to virNetDevGetIPv4AddressIoctl and make
virNetDevGetIPAddress a wrapper around it, allowing
other ways of getting the address to be implemented,
and still falling back to the old method.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoparallels: fix virDomainDefineXML for domain in saved state
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:13 +0000 (23:35 +0300)]
parallels: fix virDomainDefineXML for domain in saved state

PCS doesn't store domain config in managed save state file.
It's forbidden to change config for VMs in this state.
It's possible to change config for containers, but after
restoring domain will have that new config, not a config,
which domain had at the moment of virDomainManagedSave.

So we need to handle this case differently from other states.
Let's forbid this operation, if config is changed and if it's
not changed - just do nothing.

Openstack/nova calls virDomainDefineXML on resume with
current domain config, so we can't forbid this operation
in managed save state.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoconf: fix virDomainDefFormatInternal for parallels
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:12 +0000 (23:35 +0300)]
conf: fix virDomainDefFormatInternal for parallels

We should add input devices with proper bus,
not VIR_DOMAIN_INPUT_BUS_XEN.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoconf: fix virDomainDefParseXML for parallels
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:11 +0000 (23:35 +0300)]
conf: fix virDomainDefParseXML for parallels

Handle input devices in virDomainDefParseXML properly
in case of parallels containers and VMs.

Parallels containers support only
VIR_DOMAIN_INPUT_BUS_PARALLELS. And if VNC is enabled
we should add implicit mouse and keyboard.

For VMs we should add implicit PS/2 mouse and
keyboard.

BTW, is it worth to refactor code and move
all this code to drivers, to *DomainDefPostParse
functions?

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoparallels: add implicit input devices
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:10 +0000 (23:35 +0300)]
parallels: add implicit input devices

Add implicit input devices in parallelsLoadDomains,
when VNC is enabled.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoconf: add input device type for parallels containers
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:09 +0000 (23:35 +0300)]
conf: add input device type for parallels containers

Add VIR_DOMAIN_INPUT_BUS_PARALLELS device type
to handle domain configuration properly for
parallels containers, when VNC is enabled.

When domain configuration has at least one
'graphics', there should be mouse and keyboard.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoconf: return proper default video type for parallels
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:08 +0000 (23:35 +0300)]
conf: return proper default video type for parallels

Fix function virDomainVideoDefaultType for
parallels VMs and containers. It should return
VGA for VMs and VIR_DOMAIN_VIDEO_TYPE_PARALLELS
for containers.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoconf: add VIR_DOMAIN_VIDEO_TYPE_PARALLELS video type
Dmitry Guryanov [Tue, 7 Apr 2015 20:35:07 +0000 (23:35 +0300)]
conf: add VIR_DOMAIN_VIDEO_TYPE_PARALLELS video type

We support VNC for containers to have the same
interface with VMs. At this moment it just renders
linux text console.

Of course we don't pass any physical devices and
don't emulate virtual devices. Our VNC server
renders text from terminal master and sends
input events from VNC client to terminal.

So add special video type VIR_DOMAIN_VIDEO_TYPE_PARALLELS
for these pseudo-devices.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>