Commit Graph

21244 Commits

Author SHA1 Message Date
Daniel P. Berrangé
da1ade7a52 remote: remove some __sun conditionals
The libvirtd daemon has some arbitrary logic to drop privileges, but
only on Solaris platforms. This was added during Xen days, when Xen was
the only driver running in libvirtd. There's no expectation or testing
that this works with the new libxl stack, nor whether dropping
privileges breaks any of the secondary drivers. Finally, we'll be
splitting drivers out into their own independant daemons, so this won't
be applicable to libvirtd in future anyway.

The remote driver client meanwhile arbitrarily disables daemon
auto-spawn when connecting as non-root, breaking a key feature of
libvirt unprivileged connections.

Since we've not had any contributions for Solaris since circa 2012
and we don't do any CI testing we should consider this platform
unmaintained and thus reasonable to remove this cruft. If someone steps
forward to maintain Solaris again, this code would need re-evaluating to
come up with something more targetted.

There's various __sun conditionals in the Xen driver code, but those are
not touched. This is all for the legacy Xen driver, which will be
entirely removed at some point in future, so not benefit to hacking out
just the Solaris parts.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-23 15:10:25 +00:00
Michal Privoznik
42900ec622 qemu: Build smartcard command line more wisely
https://bugzilla.redhat.com/show_bug.cgi?id=1558317

Similarly to b133fac356 we need to look up alias of CCID
controller when constructing smartcard command line instead of
relying on broken assumption it will always be 'ccid0'. After
user aliases it can be anything.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-03-23 15:57:06 +01:00
John Ferlan
1706bef617 qemu: Fix virQEMUCapsCommands formatting
Starting with commit id 'fab9d6e1' the formatting of:

{ "command-name", QEMU_CAPS_NAME },

was altered to:

{ "command-name", QEMU_CAPS_NAME},

and then commit id 'e2b05c9a' altered that to:

{ "command-name", QEMU_CAPS_NAME}

So, let's just fix that up to make things consistent with the
rest of the structures.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-23 10:11:17 -04:00
Peter Krempa
9f7373e8c1 qemu: domain: Drop declaration of qemuDomainDefValidateDisk
There is no such function in our code. Commit abca72faa4 added it
spuriously.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 15:02:07 +01:00
Peter Krempa
3283950057 qemu: qapi: Return correct entry in virQEMUQAPISchemaTraverse
virQEMUQAPISchemaTraverse would return previous-to-last queried item on
a query. It would not be a problem if checking if the given path exists
since error reporting works properly but if the caller is interested in
the result, it would be wrong.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
57cd22bc54 util: json: Add accessor for looking up JSON value type
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
38b3b20c66 qemu: monitor: Move processing of QMP schema to the new file
The JSON array was processed to the hash table used by the query apis in
the monitor code. Move it to a new helper in qemu_qapi.c.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
ab8c5fe63f qemu: qapi: Fix naming of moved functions
Change the prefix of the functions to 'virQEMUQapi' and rename the two
public APIs so that the verb is put last.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
367697c54c qemu: caps: Move QAPI schema related code into separate file
Extract the code into qemu_qapi.c/h so that we separate it from various
parts of the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
9be9e26b74 util: buffer: Tolerate NULL 'buf' in virBufferStrcat
Most other buffer APIs tolerate the buffer being NULL.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Prafull
3f9e02b40a lxc: report error message raised by the failing function
The code that calls VIR_WARN after a function fails, doesn't
report the error message raised by the failing function.
Such error messages are now reported in lxc/lxc_driver.c

Signed-off-by: Prafullkumar Tale <talep158@gmail.com>
2018-03-23 13:13:38 +00:00
Daniel P. Berrangé
76e1720c4f rpc: avoid duplicating config in virtlockd/virtlogd augeas tests
Most of the augeas test files use ::CONFIG:: to pull in the master
config file for testing. This ensures that entries added to the config
file are actually tested by augeas.

This identified the missing admin_max_clients example in the virtlogd
config file, which in turn prompted a change in description of the
max_clients parameter, since these daemons don't have separate
readonly & readwrite sockets.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-23 10:44:48 +00:00
Daniel P. Berrangé
65824a7e45 rpc: remove remains of obsolete log_buffer_size config parameter
The global log buffer feature was deleted in:

  commit c0c8c1d7bb
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Mon Mar 3 14:54:33 2014 +0000

    Remove global log buffer feature entirely

    A earlier commit changed the global log buffer so that it only
    records messages that are explicitly requested via the log
    filters setting. This removes the performance burden, and
    improves the signal/noise ratio for messages in the global
    buffer. At the same time though, it is somewhat pointless, since
    all the recorded log messages are already going to be sent to an
    explicit log output like syslog, stderr or the journal. The
    global log buffer is thus just duplicating this data on stderr
    upon crash.

    The log_buffer_size config parameter is left in the augeas
    lens to prevent breakage for users on upgrade. It is however
    completely ignored hereafter.

    Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

This was in the 1.2.3 release, and 4 years is sufficient time for a
graceful upgrade path for augeas, so all remaining traces are now
removed.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-23 10:44:35 +00:00
Katerina Koukiou
094af02b82 test_driver: Add testDomainDestroyFlags
Adding this for completeness

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
2018-03-22 21:48:13 +01:00
Christian Ehrhardt
ac254f342f
virt-aa-helper: generate rules for nvdimm memory
nvdimm memory is backed by a path on the host. This currently works only via
hotplug where the AppArmor label is created via the domain label callbacks.

This adds the virt-aa-helper support for nvdimm memory devices to generate
rules for the needed paths from the initial guest definition as well.

Example in domain xml:
  <memory model='nvdimm'>
    <source>
      <path>/tmp/nvdimm-base</path>
    </source>
    <target>
     <size unit='KiB'>524288</size>
     <node>0</node>
    </target>
  </memory>
Works to start now and creates:
  "/tmp/nvdimm-base" rw,

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1757085

Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2018-03-22 09:42:01 +01:00
Christian Ehrhardt
26bb6d76ec
virt-aa-helper: generate rules for passthrough input devices
Input devices can passthrough an event device. This currently works only via
hotplug where the AppArmor label is created via the domain label callbacks.

This adds the virt-aa-helper support for passthrough input devices to generate
rules for the needed paths from the initial guest definition as well.

Example in domain xml:
  <input type='passthrough' bus='virtio'>
          <source evdev='/dev/input/event0' />
  </input>
Works to start now and creates:
  "/dev/input/event0" rw,

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1757085

Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2018-03-22 09:42:01 +01:00
Christian Ehrhardt
943c1fd9b6
security, apparmor: add (Set|Restore)InputLabel
d8116b5a "security: Introduce functions for input device hot(un)plug"
implemented the code (Set|Restore)InputLabel for several security modules,
this patch adds an AppArmor implementation for it as well.

That fixes hot-plugging event input devices by generating a rule for the
path that needs to be accessed.

Example hot adding:
  <input type='passthrough' bus='virtio'>
     <source evdev='/dev/input/event0' />
  </input>
Creates now:
  "/dev/input/event0" rwk,

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1755153

Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2018-03-22 09:42:01 +01:00
Christian Ehrhardt
999998a792
security, apparmor: add (Set|Restore)MemoryLabel
Recent changes have made implementing this mandatory to hot add any
memory.
Implementing this in apparmor fixes this as well as allows hot-add of nvdimm
tpye memory with an nvdimmPath set generating a AppArmor rule for that
path.

Example hot adding:
  <memory model='nvdimm'>
    <source>
      <path>/tmp/nvdimm-test</path>
    </source>
    <target>
      <size unit='KiB'>524288</size>
      <node>0</node>
    </target>
  </memory>
Creates now:
  "/tmp/nvdimm-test" rwk,

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1755153

Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2018-03-22 09:41:57 +01:00
Michal Privoznik
85666f1314 virCommandFDIsSet: Update documentation
The set of arguments was changed a long time ago (040d996342
which dates back to July 2013)  but the corresponding
documentation was not updated.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-22 07:44:14 +01:00
Michal Privoznik
c02736059a virCommandPassFD: Give name to flags
The flags passed to virCommandPassFD() are unnamed and
documentation to this function doesn't list them either.
Give them name and mention it in documentation to functions
using them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-03-22 07:44:14 +01:00
Jim Fehlig
83edaf4435 libxl: don't hardcode scheduler weight
Long ago in commit dfa1e1dd53 the scheduler weight was accidentally
hardcoded to 1000. Weight is a setting with no unit since it is
relative to the weight of other domains. If no weight is specified,
libxl defaults to 256.

Instead of hardcoding the weight to 1000, honor any <shares> specified
in <cputune>. libvirt's notion of shares is synonomous to libxl's
scheduler weight setting. If shares is unspecified, defer default
weight setting to libxl.

Removing the hardcoded weight required some test fixup. While at it,
add an explicit test for <shares> conversion to scheduler weight.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-21 15:12:24 -06:00
Jim Fehlig
04b4cf5210 libxl: rename migration APIs to include Src or Dst in their name
Inspired by commit ffb7954f to improve readability of the libxl
migration APIs.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-21 12:59:31 -06:00
Jim Fehlig
4f28d7f98c libxl: remove needless 'else' in libxlDomainMigrationPrepare
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-21 12:57:41 -06:00
Jim Fehlig
c66e344e38 libxl: dont dereference NULL libxlDomainObjPrivatePtr
In libxlDomainMigrationPrepare it is possible to dereference a NULL
libxlDomainObjPrivatePtr in early error paths. Check for a valid
'priv' before using it.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-21 12:57:04 -06:00
Jim Fehlig
594b8b996c libxl: convert DefineXMLFlags to use begin/end API pattern
Similar to other uses of virDomainObjListAdd, on success add a ref to the
virDomainObj so that virDomainObjEndAPI can be called as usual.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-21 12:40:50 -06:00
Jim Fehlig
13e81fc6fa libxl: call EndJob in error case
If starting the domain fails in libxlDomainCreateXML, we mistakenly
jumped to cleanup without calling libxlDomainObjEndJob. Remove the
jump to 'cleanup'.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-21 12:40:21 -06:00
Jim Fehlig
3c89868c5f libxl: lock virDomainObj after ListRemove
Most libxl driver API use the pattern of lock and add a ref to
virDomainObj, perform API, then decrement ref and unlock in
virDomainEndAPI. In some cases the API may call
virDomainObjListRemove, which unlocks the virDomainObj. Relock
the object in such cases so EndAPI is called with a locked object.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-21 12:39:18 -06:00
Han Han
ec34c51e9d libvirt: Fix comments for two public APIs.
Fix comments for virConnectListAllNodeDevices and
virConnectListAllSecrets.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-21 08:09:33 -04:00
Michal Privoznik
630c6e3495 virDomainDeviceDefValidateAliasesIterator: Ignore some hostdevs
https://bugzilla.redhat.com/show_bug.cgi?id=1556828

When defining a domain that has <interface type='hostdev'/> our
parser creates two entries in virDomainDef: one for <interface/>
and one for <hostdev/>. However, some info is shared between the
two which makes user alias validation fail because alias belongs
to the set of shared info.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-03-20 15:30:14 +01:00
Cole Robinson
a5d85adb78 hyperv: Sync generator output between python versions
Yet another dependency on dict() hash ordering

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-03-20 09:44:35 -04:00
Radostin Stoyanov
94f417baa9 WmiClass: Don't share "versions" between instances
Lists in Python are mutable and when used as a default value of a
parameter for class constructor, its value will be shared between
all class instances.

Example:

	class Test:
	    def __init__(self, mylist=[]):
	        self.mylist = mylist

	A = Test()
	B = Test()
	A.mylist.append("mylist from instance A")
	print(B.mylist) # Will print ['mylist from instance A']

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-03-20 12:13:35 +00:00
Radostin Stoyanov
5e870cbda4 python: Remove space around = in keyword args
PEP8 recommends not having spaces around = in a keyword argument or
a default parameter value.

https://www.python.org/dev/peps/pep-0008/#other-recommendations

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-03-20 12:13:35 +00:00
Radostin Stoyanov
f3a99869ff esx_vi_generator: Simplify alignment function
Generate whitespace using the standard function ljust() that is
available in both Py3 [1] and Py2 [2].

1: https://docs.python.org/3/library/stdtypes.html?highlight=strip#str.ljust
2: https://docs.python.org/2.7/library/string.html#string.ljust

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-03-20 12:13:35 +00:00
Radostin Stoyanov
b89111afed esx_vi_generator: Simplify get_occurrence_comment
Reduce the number of if-statements and use a single return.
Utilise a dictionary to map between occurrences and values.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-03-20 12:13:35 +00:00
Radostin Stoyanov
25409b2dd3 esx_vi_generator: Simplify generate_helper_header
The function generate_helper_header() only returns a formatted string.
This could be achieved without performing string concatenation.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-03-20 12:13:35 +00:00
Radostin Stoyanov
68106955da esx_vi_generator: Simplify generate_helper_source
The generate_helper_source() function returns a formatted string.
This could be achieved without the use of a local variable "source"
and string concatenation.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-03-20 12:13:35 +00:00
Radostin Stoyanov
28593b5b54 apibuild: Remove whitespace before ', ' and ':'
PEP8 recommends removing whitespace immediately before a comma,
semicolon, or colon [1]. In addition remove multiple spaces after
keyword (PEP8 - E271).

1: https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-03-20 12:13:35 +00:00
Jiri Denemark
1554eafbe6 qemu: Don't assign alias to disabled balloon device
<memballoon model='none'/> is the only way to disable balloon driver
since libvirt will add one automatically if the memballoon element is
missing. In other words, there's no balloon device if model is 'none'
and generating an alias for it makes no sense. The alias will be ignored
when parsing the XML and it will disappear once libvirtd is restarted.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2018-03-19 21:22:43 +01:00
Christian Ehrhardt
77cd862fb5 virt-aa-helper: resolve file symlinks
In a recent change b932ed69: "virt-aa-helper: resolve yet to be created
paths" several cases with symlinks in paths were fixed, but it regressed
cases where the file being last element of the path was the actual link.

In the case of the last element being the symlink realpath can (and shall)
be called on the full path that was passed.

Examples would be zfs/lvm block devices like:
 <disk type='block' device='disk'>
    <driver name='qemu' type='raw'/>
    <source dev='/dev/mapper/testlvm-testvol1'/>
    <target dev='vdd' bus='virtio'/>
 </disk>
With the target being:
 /dev/mapper/testlvm-testvol1 -> ../dm-0

That currently is rendered as
 "/dev/mapper/testlvm-testvol1" rwk,
but instead should be (and is with the fix):
 "/dev/dm-0" rwk,

Fixes: b932ed69: "virt-aa-helper: resolve yet to be created paths"
Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1756394

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2018-03-19 13:06:03 +01:00
Andrea Bolognani
677aaeb128 python: Drop explicit version where possible
Some of our scripts are known to work both with Python 2 and
Python 3, so for them we shouldn't be forcing any specific
version of the interpreter when they're called directly; we
always use $(PYTHON) explicitly in our build rules anyway.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-19 11:22:02 +01:00
Erik Skultety
e02d102bac qemu: hostdev: Fix the error on VM start with an mdev when IOMMU is off
Commit b4c2ac8d56 made a false assumption that IOMMU support necessary
for an mdev device to be assigned to a VM. Unlike direct PCI assignment,
IOMMU support is not needed for mediated devices, as the physical parent
device provides the isolation, therefore, simply checking for VFIO
presence is enough to successfully start a VM.

Luckily, this issue is not serious, since as of yet, libvirt mandates
mdevs to be pre-created prior to a domain's launch - if it is,
everything does work smoothly even with IOMMU disabled, because the
parent device will ensure the iommu groups we try to access exist.
However, if there are *no* IOMMU groups yet, thus no mdev exists yet, one
would see the following error:

"unsupported configuration: Mediated host device assignment requires VFIO
support"

The error msg above is simply wrong and doesn't even reflect the IOMMU
reality, so after applying this patch one would rather see the following
error in such case instead:

"device not found: mediated device '<UUID>' not found"

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-03-19 11:14:40 +01:00
Erik Skultety
3d2e4c3e53 util: mdev: Improve the error msg on non-existent mdev prior to VM start
What one currently gets is:
failed to read '/sys/bus/mdev/devices/<UUID>/mdev_type/device_api': No
such file or directory

This indicates that something is missing within the device's sysfs tree
which likely might be not be the case here because the device simply
doesn't exist yet. So, when creating our internal mdev obj, let's check
whether the device exists first prior to trying to verify the
user-provided model within domain XML.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-03-19 11:14:40 +01:00
Michal Privoznik
29d6bb7045 virNetlinkDumpCommand: Don't leak response buffer
==16451== 32,768 bytes in 2 blocks are definitely lost in loss record 1,007 of 1,013
==16451==    at 0x4C2AF0F: malloc (vg_replace_malloc.c:299)
==16451==    by 0x7CADB40: nl_recv (in /usr/lib64/libnl-3.so.200.23.0)
==16451==    by 0x532DFAC: virNetlinkDumpCommand (virnetlink.c:363)
==16451==    by 0x53236AE: virNetDevIPCheckIPv6Forwarding (virnetdevip.c:641)
==16451==    by 0xE3E4A1A: networkStartNetworkVirtual (bridge_driver.c:2490)
==16451==    by 0xE3E55F5: networkStartNetwork (bridge_driver.c:2832)
==16451==    by 0xE3DFFE5: networkAutostartConfig (bridge_driver.c:531)
==16451==    by 0x53F47E0: virNetworkObjListForEachHelper (virnetworkobj.c:1412)
==16451==    by 0x52FE69F: virHashForEach (virhash.c:606)
==16451==    by 0x53F4857: virNetworkObjListForEach (virnetworkobj.c:1439)
==16451==    by 0xE3E0BF4: networkStateAutoStart (bridge_driver.c:808)
==16451==    by 0x55689CE: virStateInitialize (libvirt.c:758)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-03-19 10:47:08 +01:00
Chen Hanxiao
3ee5a4ddf7 qemu: fix a mem leak
fix a mem leak

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-17 19:21:22 +01:00
Chen Hanxiao
70c67d4a15 virarptable: fix some leaks and format issue
fix some leaks and format issue
Also support virArpTableFree to get NULL.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2018-03-17 13:19:07 +01:00
Jim Fehlig
60b3fcd90c libxl: MigratePrepare: use standard begin and end API pattern
libxlDomainMigrationPrepare adds the incoming domain def to the list
of domains via virDomainObjListAdd, but never adds its own ref to the
returned virDomainObj as other callers of virDomainObjListAdd do.
libxlDomainMigrationPrepareTunnel3 suffers the same discrepancy.

Change both to add a ref to the virDomainObj after a successful
virDomainObjListAdd, similar to other callers. This ensures a consistent
pattern throughout the drivers and allows using the virDomainObjEndAPI
function for cleanup.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-16 14:37:01 -06:00
John Ferlan
fe51dbda56 libxl: Use virDomainObjListFindBy{UUID|ID}Ref
For libxlDomainLookupByID and libxlDomainLookupByUUID let's
return a locked and referenced @vm object so that callers can
then use the common and more consistent virDomainObjEndAPI in
order to handle cleanup rather than needing to know that the
returned object is locked and calling virObjectUnlock.

The LookupByName already returns the ref counted and locked object,
so this will make things more consistent.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2018-03-16 14:26:00 -06:00
John Ferlan
4e6fcdb6fa libxl: Properly cleanup after libxlDomObjFromDomain
Commit id '9ac945078' altered libxlDomObjFromDomain to return
a locked *and* ref counted object for some specific purposes;
however, it neglected to alter all the consumers of the helper
to use virDomainObjEndAPI thus leaving many objects with extra
ref counts.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2018-03-16 14:24:39 -06:00
Jim Fehlig
f5eacf2a9a libxl: MigratePerform: properly cleanup after libxlDomObjFromDomain
libxlDomObjFromDomain to returns locked and ref counted virDomainObj but
libxlDomainMigratePerform3Params only unlocks the object on exit. Convert
it to use the virDomainObjEndAPI function for cleanup.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-16 11:14:58 -06:00
Jim Fehlig
99486799c3 libxl: MigrateConfirm: Dont unlock virDomainObj in helper function
The libxlDomainMigrateConfirm3Params API locks and ref counts the associated
virDomainObj but relies on the helper function libxlDomainMigrationConfirm
to unlock the object. Unref'ing the object is not done in either function.
libxlDomainMigrationConfirm is also used by libxlDomainMigratePerform3Params
for p2p migration, but in that case the lock/ref and unref/unlock are
properly handled in the API entry point.

Remove the unlock from libxlDomainMigrationConfirm and adjust
libxlDomainMigrateConfirm3Params to properly unref/unlock the virDomainObj
on success and error paths.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-16 11:14:57 -06:00