]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
10 years agoqemu: fix the vm deadlock when deleting a nonexistent iothread
Luyao Huang [Mon, 4 May 2015 09:36:16 +0000 (17:36 +0800)]
qemu: fix the vm deadlock when deleting a nonexistent iothread

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

Jump to endjob instead of cleanup to fix this deadlock.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agotools: fix the wrong check when use virsh setvcpus --maximum
Luyao Huang [Fri, 20 Mar 2015 14:39:03 +0000 (15:39 +0100)]
tools: fix the wrong check when use virsh setvcpus --maximum

The --maximum option wasn't properly parsed and the equivalent flag
wasn't set.  Fix this bug and also rewrite the way we check this option
by using new macro.  The new approach is that --maximum requires
--config, no other combination is allowed, because they don't make sense.

The new error will be:

 # virsh setvcpus test --maximum 10
 error: Option --config is required by option --maximum

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agovirsh: introduce new macros to help check flag requirements
Pavel Hrdina [Thu, 26 Mar 2015 10:01:35 +0000 (11:01 +0100)]
virsh: introduce new macros to help check flag requirements

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: use new macros for setvcpus to check flags and cleanup the code
Pavel Hrdina [Wed, 25 Mar 2015 21:33:10 +0000 (22:33 +0100)]
qemu: use new macros for setvcpus to check flags and cleanup the code

Now that we have macros for exclusive flags and flag requirements we can
use them to cleanup the code for setvcpus and error out for all wrong
flag combination.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agouse new macro helpers to check flag requirements
Pavel Hrdina [Tue, 28 Apr 2015 17:24:07 +0000 (19:24 +0200)]
use new macro helpers to check flag requirements

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agouse new macro helpers to check exclusive flags
Pavel Hrdina [Tue, 28 Apr 2015 17:14:07 +0000 (19:14 +0200)]
use new macro helpers to check exclusive flags

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agointernal: introduce macro helpers to check flag requirements
Pavel Hrdina [Wed, 25 Mar 2015 12:11:38 +0000 (13:11 +0100)]
internal: introduce macro helpers to check flag requirements

Similar to VIR_EXLUSIVE_FLAGS, it will error out if flag requirement is
not met.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agointernal: introduce macro helpers to reject exclusive flags
Pavel Hrdina [Fri, 20 Mar 2015 14:38:59 +0000 (15:38 +0100)]
internal: introduce macro helpers to reject exclusive flags

Inspired by commit 7e437ee7 that introduced similar macros for virsh
commands so we don't have to repeat the same code all over.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoRelease of libvirt-1.2.15
Daniel Veillard [Mon, 4 May 2015 03:43:04 +0000 (11:43 +0800)]
Release of libvirt-1.2.15

- docs/news.html.in libvirt.spec.in: update for the release
- po/*.po*: regenerated

10 years agoqemu: Fix bus and lun checks when scsi-disk.channel not present
John Ferlan [Thu, 30 Apr 2015 19:52:03 +0000 (15:52 -0400)]
qemu: Fix bus and lun checks when scsi-disk.channel not present

Found by Laine and discussed a bit on internal IRC.

Commit id c56fe7f1d6 added support for creating a command line to support
scsi-disk.channel.

Series was here:
http://www.redhat.com/archives/libvir-list/2012-February/msg01052.html

Which pointed to a design proposal here:
http://permalink.gmane.org/gmane.comp.emulators.libvirt/50428

Which states (in part):

Libvirt should check for the QEMU "scsi-disk.channel" property.  If it
is unavailable, QEMU will only support channel=lun=0 and 0<=target<=7.

However, the check added was ensuring that bus != lun *and* bus != 0. So
if bus == lun and both were non zero, we'd never make the second check.
Changing this to an *or* check fixes the check, but still is less readable
than the just checking each for 0

10 years agomain: add new generated files to .gitignore
Pavel Hrdina [Thu, 30 Apr 2015 16:32:58 +0000 (18:32 +0200)]
main: add new generated files to .gitignore

This means new libxl-lockd.conf and libxl-sanlock.conf

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agorpm-build: update %files section for libxl
Pavel Hrdina [Thu, 30 Apr 2015 15:18:59 +0000 (17:18 +0200)]
rpm-build: update %files section for libxl

Recent commit 198cc1d3 introduced integration of lockd and sanlock into
libxl, but forget to update libvirt.spec.in to also list new files
distributed via package.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: blockjob: Call qemuDomainSupportsBlockJobs only on online VMs
Peter Krempa [Thu, 30 Apr 2015 14:01:18 +0000 (16:01 +0200)]
qemu: blockjob: Call qemuDomainSupportsBlockJobs only on online VMs

Since the qemu capabilities are not initialized for offline VMs the
caller might get suboptimal error message:

$ virsh blockjob VM PATH --bandwidth 1
error: unsupported configuration: block jobs not supported with this QEMU binary

Move the checks after we make sure that the VM is alive.

10 years agoqemu: Check address type for USB disks
Jiri Denemark [Thu, 30 Apr 2015 12:16:40 +0000 (14:16 +0200)]
qemu: Check address type for USB disks

Only USB addresses are allowed for USB disks. Report an error if another
address is configured.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agocpu: Honor vendor_id override in host-model
Jiri Denemark [Thu, 30 Apr 2015 09:10:16 +0000 (11:10 +0200)]
cpu: Honor vendor_id override in host-model

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoiscsi: do not fail to stop a stopped pool
Ján Tomko [Wed, 29 Apr 2015 12:59:08 +0000 (14:59 +0200)]
iscsi: do not fail to stop a stopped pool

Just as we allow stopping filesystem pools when they were unmounted
externally, do not fail to stop an iscsi pool when someone else
closed the session externally.

Reported at:
https://bugzilla.redhat.com/show_bug.cgi?id=1171984

10 years agolibxl: provide integration with lock manager
Jim Fehlig [Tue, 14 Apr 2015 20:38:46 +0000 (14:38 -0600)]
libxl: provide integration with lock manager

Provide integration with libvirt's lock manager in the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agodomain: conf: Drop unused OSTYPE_AIX
Cole Robinson [Wed, 22 Apr 2015 14:34:38 +0000 (10:34 -0400)]
domain: conf: Drop unused OSTYPE_AIX

The phyp driver stuffed it into a DomainDefPtr during its attachdevice
routine, but the value is never advertised via capabilities so it should
be safe to drop.

Have the phyp driver use OSTYPE_LINUX, which is what it advertises via
capabilities.

10 years agoqemu: migration: use sync block job helpers
Michael Chapman [Thu, 16 Apr 2015 09:24:23 +0000 (19:24 +1000)]
qemu: migration: use sync block job helpers

In qemuMigrationDriveMirror we can start all disk mirrors in parallel.
We wait until they are all ready, or one of them aborts.

In qemuMigrationCancelDriveMirror, we wait until all mirrors are
properly stopped. This is necessary to ensure that destination VM is
fully in sync with the (paused) source VM.

If a drive mirror can not be cancelled, then the destination is not in a
consistent state. In this case it is not safe to continue with the
migration.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
10 years agoqemuDomainBlockJobAbort: use sync block job helpers
Michael Chapman [Thu, 16 Apr 2015 09:24:22 +0000 (19:24 +1000)]
qemuDomainBlockJobAbort: use sync block job helpers

The !modern code path needs to call qemuBlockJobEventProcess directly.
the modern code path will call it via qemuBlockJobSyncWait.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
10 years agoqemuProcessStop: wake up pending sync block jobs
Michael Chapman [Thu, 16 Apr 2015 09:24:21 +0000 (19:24 +1000)]
qemuProcessStop: wake up pending sync block jobs

Other threads may be blocked in qemuBlockJobSyncWait. Ensure that
they're woken up when the domain is stopped.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
10 years agoqemuBlockJobSync*: introduce sync block job helpers
Michael Chapman [Thu, 16 Apr 2015 09:24:20 +0000 (19:24 +1000)]
qemuBlockJobSync*: introduce sync block job helpers

qemuBlockJobSyncBegin and qemuBlockJobSyncEnd delimit a region of code
where block job events are processed "synchronously".
qemuBlockJobSyncWait and qemuBlockJobSyncWaitWithTimeout wait for an
event generated by a block job.

The Wait* functions may be called multiple times while the synchronous
block job is active. Any pending block job event will be processed by
only when Wait* or End is called.  disk->blockJobStatus is reset by
these functions, so if it is needed a pointer to a
virConnectDomainEventBlockJobStatus variable should be passed as the
last argument. It is safe to pass NULL if you do not care about the
block job status.

All functions assume the VM object is locked. The Wait* functions will
unlock the object for as long as they are waiting. They will return -1
and report an error if the domain exits before an event is received.

Typical use is as follows:

  virQEMUDriverPtr driver;
  virDomainObjPtr vm; /* locked */
  virDomainDiskDefPtr disk;
  virConnectDomainEventBlockJobStatus status;

  qemuBlockJobSyncBegin(disk);

  ... start block job ...

  if (qemuBlockJobSyncWait(driver, vm, disk, &status) < 0) {
      /* domain died while waiting for event */
      ret = -1;
      goto error;
  }

  ... possibly start other block jobs
      or wait for further events ...

  qemuBlockJobSyncEnd(driver, vm, disk, NULL);

To perform other tasks periodically while waiting for an event:

  virQEMUDriverPtr driver;
  virDomainObjPtr vm; /* locked */
  virDomainDiskDefPtr disk;
  virConnectDomainEventBlockJobStatus status;
  unsigned long long timeout = 500 * 1000ull; /* milliseconds */

  qemuBlockJobSyncBegin(disk);

  ... start block job ...

  do {
      ... do other task ...

      if (qemuBlockJobSyncWaitWithTimeout(driver, vm, disk,
                                          timeout, &status) < 0) {
          /* domain died while waiting for event */
          ret = -1;
          goto error;
      }
  } while (status == -1);

  qemuBlockJobSyncEnd(driver, vm, disk, NULL);

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
10 years agoqemuBlockJobEventProcess: move to new source file
Michael Chapman [Thu, 16 Apr 2015 09:24:19 +0000 (19:24 +1000)]
qemuBlockJobEventProcess: move to new source file

We will want to use synchronous block jobs from qemu_migration as well,
so split this function out into a new source file.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
10 years agoqemu: Validate available slot count for memory devices
Peter Krempa [Tue, 28 Apr 2015 15:33:54 +0000 (17:33 +0200)]
qemu: Validate available slot count for memory devices

While qemu would reject the configuration we can check whether it makes
sense to plug the device upfront.

10 years agoqemu: command: Validate that memory devices slot ID is in range
Peter Krempa [Tue, 28 Apr 2015 15:15:43 +0000 (17:15 +0200)]
qemu: command: Validate that memory devices slot ID is in range

slot id, if specified, has to be less than the slots count.

10 years agoqemu: conf: Reject memory device if it would exceed configured max size
Peter Krempa [Tue, 28 Apr 2015 14:23:05 +0000 (16:23 +0200)]
qemu: conf: Reject memory device if it would exceed configured max size

If the added memory device would exceed the maximum memory size, reject
it.

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

10 years agoqemu: blockCopy: Allow reuse of raw image for shallow block copy
Peter Krempa [Mon, 27 Apr 2015 11:57:20 +0000 (13:57 +0200)]
qemu: blockCopy: Allow reuse of raw image for shallow block copy

The documentation states that for shallow block copy the image has to
have the same guest visible content as backing file of the current
image if the file is being reused. This condition can be achieved also
with a raw file (or a qcow without a backing file) so remove the
condition that would disallow it.

(This patch additionally fixes crash described in
 https://bugzilla.redhat.com/show_bug.cgi?id=1215569 )

10 years agoparallels: implement domainDetachDevice and domainDetachDeviceFlags
Maxim Nestratov [Thu, 23 Apr 2015 18:37:00 +0000 (21:37 +0300)]
parallels: implement domainDetachDevice and domainDetachDeviceFlags

New functions utilize previosly added prlsdkDelDisk and prlsdkGetDiskIndex
Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agoparallels: add prlsdkDelDisk and prlsdkGetDiskIndex functions
Maxim Nestratov [Thu, 23 Apr 2015 18:37:00 +0000 (21:37 +0300)]
parallels: add prlsdkDelDisk and prlsdkGetDiskIndex functions

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agoFix building virnetserverclientmock with MinGW
Martin Kletzander [Mon, 27 Apr 2015 13:59:18 +0000 (15:59 +0200)]
Fix building virnetserverclientmock with MinGW

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agotests: free ChardevInfo correctly in qemumonitorjsontest
Zhang Bo [Tue, 28 Apr 2015 01:16:13 +0000 (09:16 +0800)]
tests: free ChardevInfo correctly in qemumonitorjsontest

The free callback should be qemuMonitorChardevInfoFree rather
than just 'free' when virHashCreate'ing the chardevInfo hash.

==29959== 24 bytes in 2 blocks are definitely lost in loss record 19 of 53
==29959==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==29959==    by 0xB95C679: strdup (in /lib64/libc-2.20.so)
==29959==    by 0x63C6546: virStrdup (virstring.c:709)
==29959==    by 0x4805ED: qemuMonitorJSONExtractChardevInfo (qemu_monitor_json.c:3429)
==29959==    by 0x4807A5: qemuMonitorJSONGetChardevInfo (qemu_monitor_json.c:3479)
==29959==    by 0x434AEC: testQemuMonitorJSONqemuMonitorJSONGetChardevInfo (qemumonitorjsontest.c:1824)
==29959==    by 0x436F2F: virtTestRun (testutils.c:211)
==29959==    by 0x436932: mymain (qemumonitorjsontest.c:2404)
==29959==    by 0x4382EA: virtTestMain (testutils.c:863)
==29959==    by 0x436B27: main (qemumonitorjsontest.c:2423)

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
10 years agoqemu: make qemuMonitorChardevInfoFree non-static
Zhang Bo [Tue, 28 Apr 2015 01:16:12 +0000 (09:16 +0800)]
qemu: make qemuMonitorChardevInfoFree non-static

It would be used in qemumonitorjsontest, thus we make it non-static.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
10 years agostorage: fs: Ignore volumes that fail to open with EACCESS/EPERM
Cole Robinson [Mon, 27 Apr 2015 15:47:28 +0000 (11:47 -0400)]
storage: fs: Ignore volumes that fail to open with EACCESS/EPERM

Trying to use qemu:///session to create a storage pool pointing at
/tmp will usually fail with something like:

$ virsh pool-start tmp
error: Failed to start pool tmp
error: cannot open volume '/tmp/systemd-private-c38cf0418d7a4734a66a8175996c384f-colord.service-kEyiTA': Permission denied

If any volume in an FS pool can't be opened by the daemon, the refresh
fails, and the pool can't be used.

This causes pain for virt-install/virt-manager though. Imaging a user
downloads a disk image to /tmp. virt-manager wants to import /tmp as
a storage pool, so we can detect what disk format it is, and set the
XML correctly. However this case will likely fail as explained above.

Change the logic here to skip volumes that fail to open. This could
conceivably cause user complaints along the lines of 'why doesn't
libvirt show $ROOT-OWNED-VOLUME-FOO', but figuring that currently
the pool won't even startup, I don't think there are any current
users that care about that case.

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

10 years agostorage: If driver startup state syncing fails, delete statefile
Cole Robinson [Mon, 27 Apr 2015 14:43:22 +0000 (10:43 -0400)]
storage: If driver startup state syncing fails, delete statefile

If you end up with a state file for a pool that no longer starts up
or refreshes correctly, the state file is never removed and adds
noise to the logs everytime libvirtd is started.

If the initial state syncing fails, delete the statefile.

10 years agostorage: Break out storageDriverLoadPoolState
Cole Robinson [Mon, 27 Apr 2015 14:43:22 +0000 (10:43 -0400)]
storage: Break out storageDriverLoadPoolState

Will simplify a future patch

10 years agostorage: Don't leave stale state file if pool startup fails
Cole Robinson [Mon, 27 Apr 2015 14:43:22 +0000 (10:43 -0400)]
storage: Don't leave stale state file if pool startup fails

After pool startup we call refreshPool(). If that fails, we leave
a stale pool state file hanging around.

Hit this trying to create a pool with qemu:///session containing
root owned files.

10 years agostorage: Fix autostart dir for qemu:///session
Cole Robinson [Mon, 27 Apr 2015 14:43:22 +0000 (10:43 -0400)]
storage: Fix autostart dir for qemu:///session

10 years agoqemu: Remove need for qemuMonitorIOThreadInfoFree
John Ferlan [Tue, 28 Apr 2015 10:32:52 +0000 (06:32 -0400)]
qemu: Remove need for qemuMonitorIOThreadInfoFree

Replace with just VIR_FREE.

10 years agoqemu: qemuProcessDetectIOThreadPIDs invert checks
John Ferlan [Mon, 27 Apr 2015 18:24:34 +0000 (14:24 -0400)]
qemu: qemuProcessDetectIOThreadPIDs invert checks

If we received zero iothreads from the monitor, but were perhaps
expecting to receive something, then the code was skipping the check
to ensure what's in the monitor matches our expectations.  So invert
the checks to check that what we get back matches expectations and
then check there are zero iothreads returned.

10 years agoqemu: Remove need for qemuDomainParseIOThreadAlias
John Ferlan [Mon, 27 Apr 2015 18:16:54 +0000 (14:16 -0400)]
qemu: Remove need for qemuDomainParseIOThreadAlias

Rather than have a separate routine to parse the alias of an iothread
returned from qemu in order to get the iothread_id value, parse the alias
when returning and just return the iothread_id in qemuMonitorIOThreadInfoPtr

This set of patches removes the function, changes the "char *name" to
"unsigned int" and handles all the fallout.

10 years agoconf: Resolve some Coverity errors
John Ferlan [Mon, 27 Apr 2015 19:02:42 +0000 (15:02 -0400)]
conf: Resolve some Coverity errors

Resolve some Coverity errors with IOThread changes

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agoconf: explicitly initialize 'cpumask' variable
Roman Bogorodskiy [Tue, 28 Apr 2015 04:26:44 +0000 (08:26 +0400)]
conf: explicitly initialize 'cpumask' variable

Build with clang fails with:

  CC       conf/libvirt_conf_la-domain_conf.lo
  conf/domain_conf.c:13377:9: error: variable 'cpumask' is used
  uninitialized whenever 'if' condition is true
  [-Werror,-Wsometimes-uninitialized]
      if (!(tmp = virXMLPropString(node, "cpuset"))) {
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and many other similar errors regarding the 'cpuset' variable.

Fix by explicitly initializing it with NULL.

10 years agonetwork: check newDef for used bridge names in addition to def
Laine Stump [Fri, 24 Apr 2015 18:15:44 +0000 (14:15 -0400)]
network: check newDef for used bridge names in addition to def

If someone has updated a network to change its bridge name, but the
network is still active (so that bridge name hasn't taken effect yet),
we still want to disallow another network from taking that new name.

10 years agonetwork: check for bridge name conflict with existing devices
Laine Stump [Thu, 23 Apr 2015 18:29:08 +0000 (14:29 -0400)]
network: check for bridge name conflict with existing devices

Since some people use the same naming convention as libvirt for bridge
devices they create outside the context of libvirt, it is much nicer
if we check for those devices when looking for a bridge device name to
auto-assign to a new network.

10 years agonetwork: move auto-assign of bridge name from XML parser to net driver
Laine Stump [Thu, 23 Apr 2015 16:49:59 +0000 (12:49 -0400)]
network: move auto-assign of bridge name from XML parser to net driver

We already check that any auto-assigned bridge device name for a
virtual network (e.g. "virbr1") doesn't conflict with the bridge name
for any existing libvirt network (via virNetworkSetBridgeName() in
conf/network_conf.c).

We also want to check that the name doesn't conflict with any bridge
device created on the host system outside the control of libvirt
(history: possibly due to the ploriferation of references to libvirt's
bridge devices in HOWTO documents all around the web, it is not
uncommon for an admin to manually create a bridge in their host's
system network config and name it "virbrX"). To add such a check to
virNetworkBridgeInUse() (which is called by virNetworkSetBridgeName())
we would have to call virNetDevExists() (from util/virnetdev.c); this
function calls ioctl(SIOCGIFFLAGS), which everyone on the mailing list
agreed should not be done from an XML parsing function in the conf
directory.

To remedy that problem, this patch removes virNetworkSetBridgeName()
from conf/network_conf.c and puts an identically functioning
networkBridgeNameValidate() in network/bridge_driver.c (because it's
reasonable for the bridge driver to call virNetDevExists(), although
we don't do that yet because I wanted this patch to have as close to 0
effect on function as possible).

There are a couple of inevitable changes though:

1) We no longer check the bridge name during
   virNetworkLoadConfig(). Close examination of the code shows that
   this wasn't necessary anyway - the only *correct* way to get XML
   into the config files is via networkDefine(), and networkDefine()
   will always call networkValidate(), which previously called
   virNetworkSetBridgeName() (and now calls
   networkBridgeNameValidate()). This means that the only way the
   bridge name can be unset during virNetworkLoadConfig() is if
   someone edited the config file on disk by hand (which we explicitly
   prohibit).

2) Just on the off chance that somebody *has* edited the file by hand,
   rather than crashing when they try to start their malformed
   network, a check for non-NULL bridge name has been added to
   networkStartNetworkVirtual().

   (For those wondering why I don't instead call
   networkValidateBridgeName() there to set a bridge name if one
   wasn't present - the problem is that during
   networkStartNetworkVirtual(), the lock for the network being
   started has already been acquired, but the lock for the network
   list itself *has not* (because we aren't adding/removing a
   network). But virNetworkBridgeInuse() iterates through *all*
   networks (including this one) and locks each network as it is
   checked for a duplicate entry; it is necessary to lock each network
   even before checking if it is the designated "skip" network because
   otherwise some other thread might acquire the list lock and delete
   the very entry we're examining. In the end, permitting a setting of
   the bridge name during network start would require that we lock the
   entire network list during any networkStartNetwork(), which
   eliminates a *lot* of parallelism that we've worked so hard to
   achieve (it can make a huge difference during libvirtd startup). So
   rather than try to adjust for someone playing against the rules, I
   choose to instead give them the error they deserve.)

3) virNetworkAllocateBridge() (now removed) would leak any "template"
   string set as the bridge name. Its replacement
   networkFindUnusedBridgeName() doesn't leak the template string - it
   is properly freed.

10 years agotest: Fix actual vs. expected in virtTestCompareFiles
Laine Stump [Mon, 27 Apr 2015 17:43:06 +0000 (13:43 -0400)]
test: Fix actual vs. expected in virtTestCompareFiles

Commit ca329299 added a utility function virtTestCompareFiles() to
eliminate repetitive code in several test programs. It unfortunately
calls virtTestDifference() with the arguments in the wrong order -
strcontent is the "actual" output gathered by the test rig, while
filecontent is the "expected", and virtTestDifference() wants expected
(filecontent) followed by actual (strcontent), but
virtTestCompareFiles() does the opposite, which can make the output a
bit confusing when there is a failure.

10 years agoqemu: Resolve Coverity DEADCODE
John Ferlan [Mon, 27 Apr 2015 11:25:22 +0000 (07:25 -0400)]
qemu: Resolve Coverity DEADCODE

Coverity notes that the switch() used to check 'connected' values has
two DEADCODE paths (_DEFAULT & _LAST).  Since 'connected' is a boolean
it can only be one or the other (CONNECTED or DISCONNECTED), so it just
seems pointless to use a switch to get "all" values.  Convert to if-else

10 years agovirsh: Add iothreadadd and iothreaddel commands
John Ferlan [Wed, 18 Mar 2015 13:01:50 +0000 (09:01 -0400)]
virsh: Add iothreadadd and iothreaddel commands

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

Add command to allow adding and removing IOThreads from the domain including
the configuration and live domain.

$ virsh iothreadadd --help
  NAME
    iothreadadd - add an IOThread to the guest domain

  SYNOPSIS
    iothreadadd <domain> <id> [--config] [--live] [--current]

  DESCRIPTION
    Add an IOThread to the guest domain.

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    [--id] <number>  iothread for the new IOThread
    --config         affect next boot
    --live           affect running domain
    --current        affect current domain

$ virsh iothreaddel --help
  NAME
    iothreaddel - delete an IOThread from the guest domain

  SYNOPSIS
    iothreaddel <domain> <id> [--config] [--live] [--current]

  DESCRIPTION
    Delete an IOThread from the guest domain.

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    [--id] <number>  iothread_id for the IOThread to delete
    --config         affect next boot
    --live           affect running domain
    --current        affect current domain

Assuming a running $dom with multiple IOThreads assigned and that
that the $dom has disks assigned to IOThread 1 and IOThread 2:

$ virsh iothreadinfo $dom
 IOThread ID     CPU Affinity
 ---------------------------------------------------
  1               2
  2               3
  3               0-1

$ virsh iothreadadd $dom 1
error: invalid argument: an IOThread is already using iothread_id '1' in iothreadpids

$ virsh iothreadadd $dom 1 --config
error: invalid argument: an IOThread is already using iothread_id '1' in persistent iothreadids

$ virsh iothreadadd $dom 4
$ virsh iothreadinfo $dom
 IOThread ID     CPU Affinity
 ---------------------------------------------------
  1               2
  2               3
  3               0-1
  4               0-3

$ virsh iothreadinfo $dom --config
 IOThread ID     CPU Affinity
 ---------------------------------------------------
  1               2
  2               3
  3               0-1

$ virsh iothreadadd $dom 4 --config
$ virsh iothreadinfo $dom --config
 IOThread ID     CPU Affinity
  ---------------------------------------------------
    1               2
    2               3
    3               0-1
    4               0-3

Assuming the same original configuration

$ virsh iothreaddel $dom 1
error: invalid argument: cannot remove IOThread 1 since it is being used by disk 'vde'

$ virsh iothreaddel $dom 3

$ virsh iothreadinfo $dom
 IOThread ID     CPU Affinity
 ---------------------------------------------------
  1               2
  2               3

$ virsh iothreadinfo $dom --config
 IOThread ID     CPU Affinity
 ---------------------------------------------------
  1               2
  2               3
  3               0-1

10 years agoqemu: Add support to Add/Delete IOThreads
John Ferlan [Wed, 18 Mar 2015 10:51:12 +0000 (06:51 -0400)]
qemu: Add support to Add/Delete IOThreads

Add qemuDomainAddIOThread and qemuDomainDelIOThread in order to add or
remove an IOThread to/from the host either for live or config optoins

The implementation for the 'live' option will use the iothreadpids list
in order to make decision, while the 'config' option will use the
iothreadids list.  Additionally, for deletion each may have to adjust
the iothreadpin list.

IOThreads are implemented by qmp objects, the code makes use of the existing
qemuMonitorAddObject or qemuMonitorDelObject APIs.

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agodomain: Introduce virDomainIOThreadSchedDelId
John Ferlan [Thu, 23 Apr 2015 18:01:48 +0000 (14:01 -0400)]
domain: Introduce virDomainIOThreadSchedDelId

We're about to allow IOThreads to be deleted, but an iothreadid may be
included in some domain thread sched, so add a new API to allow removing
an iothread from some entry.

Then during the writing of the threadsched data and an additional check
to determine whether the bitmap is all clear before writing it out.

10 years agoremote: Add support for AddIOThread and DelIOThread
John Ferlan [Wed, 25 Mar 2015 21:13:07 +0000 (17:13 -0400)]
remote: Add support for AddIOThread and DelIOThread

Add remote support for the add/delete IOThread API's

10 years agoImplement virDomainAddIOThread and virDomainDelIOThread
John Ferlan [Wed, 25 Mar 2015 21:03:49 +0000 (17:03 -0400)]
Implement virDomainAddIOThread and virDomainDelIOThread

Add libvirt API's to manage adding and deleting IOThreads to/from the
domain

10 years agoconf: Adjust the iothreadsched expectations
John Ferlan [Tue, 21 Apr 2015 21:21:28 +0000 (17:21 -0400)]
conf: Adjust the iothreadsched expectations

With iothreadid's allowing any 'id' value for an iothread_id, the
iothreadsched code needs a slight adjustment to allow for "any"
unsigned int value in order to create the bitmap of ids that will
have scheduler adjustments. Adjusted the doc description as well.

10 years agoMove iothreadspin information into iothreadids
John Ferlan [Tue, 21 Apr 2015 19:43:05 +0000 (15:43 -0400)]
Move iothreadspin information into iothreadids

Remove the iothreadspin array from cputune and replace with a cpumask
to be stored in the iothreadids list.

Adjust the test output because our printing goes in order of the iothreadids
list now.

10 years agoconf: Move virDomainPinIsDuplicate and make static
John Ferlan [Tue, 21 Apr 2015 17:35:33 +0000 (13:35 -0400)]
conf: Move virDomainPinIsDuplicate and make static

Since it's only ever referenced in domain_conf.c, make the function
static, but also will need to move it to somewhere before it's referenced
rather than forward referencing it.

10 years agoqemu: Use domain iothreadids to IOThread's 'thread_id'
John Ferlan [Fri, 10 Apr 2015 13:21:23 +0000 (09:21 -0400)]
qemu: Use domain iothreadids to IOThread's 'thread_id'

Add 'thread_id' to the virDomainIOThreadIDDef as a means to store the
'thread_id' as returned from the live qemu monitor data.

Remove the iothreadpids list from _qemuDomainObjPrivate and replace with
the new iothreadids 'thread_id' element.

Rather than use the default numbering scheme of 1..number of iothreads
defined for the domain, use the iothreadid's list for the iothread_id

Since iothreadids list keeps track of the iothread_id's, these are
now used in place of the many places where a for loop would "know"
that the ID was "+ 1" from the array element.

The new tests ensure usage of the <iothreadid> values for an exact number
of iothreads and the usage of a smaller number of <iothreadid> values than
iothreads that exist (and usage of the default numbering scheme).

10 years agoconf: Add new domain XML element 'iothreadids'
John Ferlan [Thu, 2 Apr 2015 23:59:25 +0000 (19:59 -0400)]
conf: Add new domain XML element 'iothreadids'

Adding a new XML element 'iothreadids' in order to allow defining
specific IOThread ID's rather than relying on the algorithm to assign
IOThread ID's starting at 1 and incrementing to iothreads count.

This will allow future patches to be able to add new IOThreads by
a specific iothread_id and of course delete any exisiting IOThread.

Each iothreadids element will have 'n' <iothread> children elements
which will have attribute "id".  The "id" will allow for definition
of any "valid" (eg > 0) iothread_id value.

On input, if any <iothreadids> <iothread>'s are provided, they will
be marked so that we only print out what we read in.

On input, if no <iothreadids> are provided, the PostParse code will
self generate a list of ID's starting at 1 and going to the number
of iothreads defined for the domain (just like the current algorithm
numbering scheme).  A future patch will rework the existing algorithm
to make use of the iothreadids list.

On output, only print out the <iothreadids> if they were read in.

10 years agoCleanup parameters for mock libraries
Martin Kletzander [Mon, 27 Apr 2015 13:31:32 +0000 (15:31 +0200)]
Cleanup parameters for mock libraries

All the libraries use same parameters when building, why not have it in
one place at the begining of the Makefile.

This will also ensure no new mock library will have a problem with
missing e.g. MINGW_EXTRA_LDFLAGS.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoCleanup srcdir usage
Michal Privoznik [Mon, 27 Apr 2015 09:08:59 +0000 (11:08 +0200)]
Cleanup srcdir usage

In a lot places we use path like this:

  $(srcdir)/../src/....

when in fact it can be:

  $(top_srcdir)/src/

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoutil: fix memleak in virStorageSourceClear
zhang bo [Mon, 27 Apr 2015 09:26:31 +0000 (17:26 +0800)]
util: fix memleak in virStorageSourceClear

snapshot and configFile are not freed, free them.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agoAdd missing linker flags for MinGW build
Pavel Fedin [Mon, 27 Apr 2015 10:40:53 +0000 (13:40 +0300)]
Add missing linker flags for MinGW build

This fix should completely close
https://bugzilla.redhat.com/show_bug.cgi?id=1214605

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
10 years agostorage: Resolve Coverity UNINIT
John Ferlan [Fri, 24 Apr 2015 17:57:30 +0000 (13:57 -0400)]
storage: Resolve Coverity UNINIT

commit id '1e13eff4' didn't init found when changed from a bool to
an int in virStoragePoolFCRefreshThread and Coverity...

10 years agoopenvz: Drop useless domain lookup
Michal Privoznik [Sat, 25 Apr 2015 08:06:29 +0000 (10:06 +0200)]
openvz: Drop useless domain lookup

The lookup is just for check whether a domain we are about to add does
not already exists. Well, the virDomainObjListAdd() function does that
for us already so there's no need to duplicate the check.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix check for return value of qemuDomainAgentAvailable()
Martin Kletzander [Mon, 27 Apr 2015 08:11:35 +0000 (10:11 +0200)]
Fix check for return value of qemuDomainAgentAvailable()

Commit dcbb243bbc3470431d15cec4c5bb96d2de89a88b used the return value of
the function as int even though it returns bool.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoconf: fix memleak in virDomainHostdevDefClear
Zhang Bo [Mon, 27 Apr 2015 06:41:45 +0000 (14:41 +0800)]
conf: fix memleak in virDomainHostdevDefClear

use virNetworkRouteDefFree() instead of VIR_FREE to free routes, otherwise
the element 'family' would not be freed.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agoconf: fix memleak in virDomainNetIpParseXML
Zhang Bo [Mon, 27 Apr 2015 06:41:44 +0000 (14:41 +0800)]
conf: fix memleak in virDomainNetIpParseXML

use cleanup instead of error, so that the allocated strings could also get freed
when there's no error.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agoqemu: fix memleak in virCapabilitiesDomainDataLookup
Zhang Bo [Mon, 27 Apr 2015 06:41:43 +0000 (14:41 +0800)]
qemu: fix memleak in virCapabilitiesDomainDataLookup

virBufferContentAndReset() doesn't free buf contents, we should use
virBufferFreeAndReset() to get buf freed.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agoqemu: fix memleaks in qemuBuildCommandLine
Zhang Bo [Mon, 27 Apr 2015 06:41:42 +0000 (14:41 +0800)]
qemu: fix memleaks in qemuBuildCommandLine

free boot_opts_str and boot_order_str both in normal and error paths.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agoutil: fix memleak in virFindSCSIHostByPCI
Zhang Bo [Mon, 27 Apr 2015 06:41:41 +0000 (14:41 +0800)]
util: fix memleak in virFindSCSIHostByPCI

free buf in cleanup.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agotests: fix some memleaks in tests
Zhang Bo [Mon, 27 Apr 2015 06:41:40 +0000 (14:41 +0800)]
tests: fix some memleaks in tests

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agoqemu: Fix comment for timeDelta
Jiri Denemark [Mon, 27 Apr 2015 07:43:27 +0000 (09:43 +0200)]
qemu: Fix comment for timeDelta

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoFix typo in comment about memory binding
zhang bo [Sat, 25 Apr 2015 06:10:00 +0000 (14:10 +0800)]
Fix typo in comment about memory binding

rather then -> rather than

Signed-off-by: YueWenyuan <yuewenyuan@huawei.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoqemu: Connect to guest agent after channel hotplug
Peter Krempa [Fri, 24 Apr 2015 14:48:26 +0000 (16:48 +0200)]
qemu: Connect to guest agent after channel hotplug

If a user hot-attaches the guest agent channel libvirt would ignore it
until the restart of libvirtd or shutdown/destroy and start of the VM
itself.

This patch adds code that opens or closes the guest agent connection
according to the state of the guest agent channel according to
connect/disconnect events.

To allow opening the channel from the event handler qemuConnectAgent
needed to be exported.

10 years agoqemu: agent: Differentiate errors when the agent channel was hotplugged
Peter Krempa [Fri, 24 Apr 2015 14:43:38 +0000 (16:43 +0200)]
qemu: agent: Differentiate errors when the agent channel was hotplugged

When the guest agent channel gets hotplugged to a VM, libvirt would
still report that "QEMU guest agent is not configured" rather than
stating that the connection was not established yet.

Currently the code won't be able to connect to the agent after hotplug
but that will change in a later patch.

As the qemuFindAgentConfig() helper is quite helpful in this case move
it to a more usable place and export it.

10 years agoqemu: Reuse qemuDomainAgentAvailable in qemuDomainInterfaceAddresses
Peter Krempa [Fri, 24 Apr 2015 13:54:08 +0000 (15:54 +0200)]
qemu: Reuse qemuDomainAgentAvailable in qemuDomainInterfaceAddresses

10 years agoqemu: Fix domain object leak in qemuDomainInterfaceAddresses
Peter Krempa [Fri, 24 Apr 2015 13:48:43 +0000 (15:48 +0200)]
qemu: Fix domain object leak in qemuDomainInterfaceAddresses

The API didn't use virDomainObjEndAPI to release the domain object thus
it leaked a reference to it.

10 years agoqemu: agent: Reuse virJSONValueObjectCreateVArgs in qemuAgentMakeCommand
Peter Krempa [Fri, 24 Apr 2015 13:32:15 +0000 (15:32 +0200)]
qemu: agent: Reuse virJSONValueObjectCreateVArgs in qemuAgentMakeCommand

Since the code is now separated into the common helper, we can reuse it
instead of maintaining two copies.

10 years agolibxl: remove duplicate check for pci subsystem type
Olaf Hering [Fri, 24 Apr 2015 16:01:02 +0000 (16:01 +0000)]
libxl: remove duplicate check for pci subsystem type

Both attach and detach functions get called only if the type matches.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: use pci init and dispose functions
Olaf Hering [Fri, 24 Apr 2015 15:56:23 +0000 (15:56 +0000)]
libxl: use pci init and dispose functions

Rearrange code so that the local variable is always initialized and
disposed.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: initialize sdl.opengl defbool in libxlMakeVfb
Jim Fehlig [Fri, 24 Apr 2015 20:11:26 +0000 (14:11 -0600)]
libxl: initialize sdl.opengl defbool in libxlMakeVfb

Commit bf32462b missed initializing sdl.opengl.  Without the
initialization, libvirtd will be terminated by an assert from libxl:

Assertion `!libxl_defbool_is_default(db)' failed.

Reported-by: Olaf Hering <olaf@aepfle.de>
10 years agolibxl: initialize vfb defbools in libxlMakeVfb
Olaf Hering [Fri, 17 Apr 2015 17:19:31 +0000 (17:19 +0000)]
libxl: initialize vfb defbools in libxlMakeVfb

If the domU configu has sdl enabled libvirtd crashes:
libvirtd[5158]: libvirtd: libxl.c:343: libxl_defbool_val:
Assertion `!libxl_defbool_is_default(db)' failed.

Initialize the relevant defbool variables in libxl_device_vfb.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Jim Fehlig <jfehlig@suse.com>
10 years agoparallels: fix crash in prlsdkAddNet in case of CT definition
Maxim Nestratov [Thu, 23 Apr 2015 17:35:00 +0000 (20:35 +0300)]
parallels: fix crash in prlsdkAddNet in case of CT definition

Since net->model is not defined for containers we shouldn't touch it.
In case network adapter model is defined, a warning about ignoring
it is shown.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agovirhostdev: Fix comments for virHostdevReAttachPCIDevices
John Ferlan [Fri, 24 Apr 2015 17:27:25 +0000 (13:27 -0400)]
virhostdev: Fix comments for virHostdevReAttachPCIDevices

Pushed previous patch (commit id 'd45dadae6') too quickly...

The patch just updates the patch from Laine's suggestions.

10 years agobhyve: fix build in tests
Roman Bogorodskiy [Fri, 24 Apr 2015 16:50:08 +0000 (19:50 +0300)]
bhyve: fix build in tests

Commit ca32929 caused build errors in bhyvexml2argvtest.c because of
some undefined variables.

Pushing under the build breaker rule.

10 years agohostdev: fix net config restore error
Huanle Han [Wed, 15 Apr 2015 17:29:43 +0000 (01:29 +0800)]
hostdev: fix net config restore error

Fix for such a case:
1. Domain A and B xml contain the same SRIOV net hostdev(<interface
type='hostdev' /> with same pci address).
2. virsh start A (Successfully, and configure the SRIOV net with
custom mac)
3. virsh start B (Fail because of the hostdev used by domain A or other
reason.)
In step 3, 'virHostdevNetConfigRestore' is called for the hostdev
which is still used by domain A. It makes the mac/vlan of the SRIOV net
change.

Code Change in this fix:
1. As the pci used by other domain have been removed from
'pcidevs' in previous loop, we only restore the nic config for
the hostdev still in 'pcidevs'(used by this domain)
2. update the comments to make it more clear

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
10 years agohostdev: Create virHostdevIsPCINetDevice
Huanle Han [Wed, 22 Apr 2015 11:33:09 +0000 (07:33 -0400)]
hostdev: Create virHostdevIsPCINetDevice

Refactor some code to create a static function virHostdevIsPCINetDevice
which will detect whether the hostdev is a pci net device or not.

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
10 years agoqemu: Build nvram directory at driver startup
Cole Robinson [Fri, 24 Apr 2015 00:01:05 +0000 (20:01 -0400)]
qemu: Build nvram directory at driver startup

Similar to what was done for the channel socket in the previous commit.

10 years agoqemu: Build channel autosocket directory at driver startup
Cole Robinson [Thu, 23 Apr 2015 23:24:50 +0000 (19:24 -0400)]
qemu: Build channel autosocket directory at driver startup

Rather than depend on the RPM to put it in place, since this doesn't
cover the qemu:///session case. Currently auto allocated socket path is
completely busted with qemu:///session

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

And because we chown the directory at driver startup now, this also fixes
autosocket startup failures when using user/group=root

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

10 years agoqemu: chown autoDumpPath on driver startup
Cole Robinson [Fri, 24 Apr 2015 00:21:21 +0000 (20:21 -0400)]
qemu: chown autoDumpPath on driver startup

Not sure if this is required, but it makes things consistent with the
rest of the directories.

10 years agoqemu: conf: Clarify paths that are relative to libDir
Cole Robinson [Fri, 24 Apr 2015 00:16:30 +0000 (20:16 -0400)]
qemu: conf: Clarify paths that are relative to libDir

Rather than duplicate libDir for each new path

10 years agotests: qemu: Couple aarch64 CPU tests
Cole Robinson [Thu, 23 Apr 2015 17:47:06 +0000 (13:47 -0400)]
tests: qemu: Couple aarch64 CPU tests

- Make sure aarch64 host-passthrough works correctly
- Make sure libvirt doesn't choke on cpu model=host, which is what
  virt-install/virt-manager were incorrectly specifying up until recently.

10 years agomigration: Usable time statistics without requiring NTP
Jiri Denemark [Thu, 23 Apr 2015 07:19:12 +0000 (09:19 +0200)]
migration: Usable time statistics without requiring NTP

virDomainGetJobStats is able to report statistics of a completed
migration, however to get usable downtime and total time statistics both
hosts have to keep synchronized time. To provide at least some
estimation of the times even when NTP daemons are not running on both
hosts we can just ignore the time needed to transfer a migration cookie
to the destination host. The result will be also inaccurate but a bit
more predictable. The total/down time will just be at least what we
report.

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

10 years agoFix memory leak in virNetSocketNewConnectUNIX
Jiri Denemark [Fri, 24 Apr 2015 09:56:34 +0000 (11:56 +0200)]
Fix memory leak in virNetSocketNewConnectUNIX

==26726==    by 0x673CD67: __vasprintf_chk (vasprintf_chk.c:80)
==26726==    by 0x5673605: UnknownInlinedFun (stdio2.h:210)
==26726==    by 0x5673605: virVasprintfInternal (virstring.c:476)
==26726==    by 0x56736EE: virAsprintfInternal (virstring.c:497)
==26726==    by 0x5680C37: virGetUserRuntimeDirectory (virutil.c:866)
==26726==    by 0x5783A89: virNetSocketNewConnectUNIX (virnetsocket.c:572)
==26726==    by 0x57751AF: virNetClientNewUNIX (virnetclient.c:344)
==26726==    by 0x57689B3: doRemoteOpen (remote_driver.c:895)
==26726==    by 0x5769F8E: remoteConnectOpen (remote_driver.c:1195)
==26726==    by 0x57092DF: do_open (libvirt.c:1189)
==26726==    by 0x570A7BF: virConnectOpenAuth (libvirt.c:1341)

https://bugzilla.redhat.com/show_bug.cgi?id=1215042
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agobuild: add pragma directive to fix build on some gcc
Pavel Hrdina [Fri, 24 Apr 2015 10:57:10 +0000 (12:57 +0200)]
build: add pragma directive to fix build on some gcc

Commit 1268820a removed obsolete index() function and replaced it by
strchr.  Few versions of gcc has a bug and reports a warning about
strchr:

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agouml: s/virDomainObjListFindByID/virDomainObjListFindByUUID/
Michal Privoznik [Fri, 24 Apr 2015 07:34:10 +0000 (09:34 +0200)]
uml: s/virDomainObjListFindByID/virDomainObjListFindByUUID/

ListFindByID() still requires to step through items in the hash table
(in the worst case scenario through all of them), lock each one and
compare whether we've found what we're looking for. This is suboptimal
as locking a domain object means we need to wait for the current API
running over the object to finish.

Unfortunately, we can't drop the function completely because we have
this public API virDomainLookupByID which we can't drop.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainObjList: Introduce yet another hash table
Michal Privoznik [Thu, 23 Apr 2015 13:31:53 +0000 (15:31 +0200)]
virDomainObjList: Introduce yet another hash table

This hash table will contain the same data as already existing one.
The only difference is that while the first table uses domain uuid as
key, the new table uses domain name. This will allow much faster (and
lockless) lookups by domain name.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainObjListFindByName: Return referenced object
Michal Privoznik [Thu, 23 Apr 2015 16:00:01 +0000 (18:00 +0200)]
virDomainObjListFindByName: Return referenced object

Every domain that grabs a domain object to work over should
reference it to make sure it won't disappear meanwhile.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce virDomainObjEndAPI
Michal Privoznik [Thu, 23 Apr 2015 15:27:58 +0000 (17:27 +0200)]
Introduce virDomainObjEndAPI

This is basically turning qemuDomObjEndAPI into a more general
function. Other drivers which gets a reference to domain objects may
benefit from this function too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainObjListNew: Use virObjectFreeHashData
Michal Privoznik [Thu, 23 Apr 2015 15:10:28 +0000 (17:10 +0200)]
virDomainObjListNew: Use virObjectFreeHashData

There's no point in duplicating virObjectFreeHashData() in a separate
function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainObjListAddLocked: s/false/NULL/ for @oldDef
Michal Privoznik [Thu, 23 Apr 2015 13:27:32 +0000 (15:27 +0200)]
virDomainObjListAddLocked: s/false/NULL/ for @oldDef

It's a pointer after all. We should initialize it to NULL instead of
false.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>