Commit Graph

2968 Commits

Author SHA1 Message Date
Andrea Bolognani
2503e4b03c conf: Copy loadparm in virDomainDeviceInfoCopy()
Commit 54fa1b44af added virDomainDeviceInfo::loadparm
and updated virDomainDeviceInfoClear() accordingly, but
omitted the necessary virDomainDeviceInfoCopy() changes.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-06-27 12:42:41 +02:00
John Ferlan
2065499b60 events: Avoid double free possibility on remote call failure
If a remote call fails during event registration (more than likely from
a network failure or remote libvirtd restart timed just right), then when
calling the virObjectEventStateDeregisterID we don't want to call the
registered @freecb function because that breaks our contract that we
would only call it after succesfully returning.  If the @freecb routine
were called, it could result in a double free from properly coded
applications that free their opaque data on failure to register, as seen
in the following details:

    Program terminated with signal 6, Aborted.
    #0  0x00007fc45cba15d7 in raise
    #1  0x00007fc45cba2cc8 in abort
    #2  0x00007fc45cbe12f7 in __libc_message
    #3  0x00007fc45cbe86d3 in _int_free
    #4  0x00007fc45d8d292c in PyDict_Fini
    #5  0x00007fc45d94f46a in Py_Finalize
    #6  0x00007fc45d960735 in Py_Main
    #7  0x00007fc45cb8daf5 in __libc_start_main
    #8  0x0000000000400721 in _start

The double dereference of 'pyobj_cbData' is triggered in the following way:

    (1) libvirt_virConnectDomainEventRegisterAny is invoked.
    (2) the event is successfully added to the event callback list
        (virDomainEventStateRegisterClient in
        remoteConnectDomainEventRegisterAny returns 1 which means ok).
    (3) when function remoteConnectDomainEventRegisterAny is hit,
        network connection disconnected coincidently (or libvirtd is
        restarted) in the context of function 'call' then the connection
        is lost and the function 'call' failed, the branch
        virObjectEventStateDeregisterID is therefore taken.
    (4) 'pyobj_conn' is dereferenced the 1st time in
        libvirt_virConnectDomainEventFreeFunc.
    (5) 'pyobj_cbData' (refered to pyobj_conn) is dereferenced the
         2nd time in libvirt_virConnectDomainEventRegisterAny.
    (6) the double free error is triggered.

Resolve this by adding a @doFreeCb boolean in order to avoid calling the
freeCb in virObjectEventStateDeregisterID for any remote call failure in
a remoteConnect*EventRegister* API. For remoteConnect*EventDeregister* calls,
the passed value would be true indicating they should run the freecb if it
exists; whereas, it's false for the remote call failure path.

Patch based on the investigation and initial patch posted by
fangying <fangying1@huawei.com>.
2017-06-25 08:16:04 -04:00
Peter Krempa
b910fa8b76 Revert "qemu: Check duplicate WWNs also for hotplugged disks"
Similarly to commit 5da28cc306 this check
actually does not make sense since duplicate WWNs are used e.g. when
multipathing disks.

This reverts commit 780fe4e4ba.
2017-06-23 13:50:19 +02:00
Farhan Ali
54fa1b44af conf: Add loadparm boot option for a boot device
Update the per device boot schema to add an optional loadparm parameter.

eg: <boot order='1' loadparm='2'/>

Extend the virDomainDeviceInfo to support loadparm option.
Modify the appropriate functions to parse loadparm from boot device xml.
Add the xml2xml test to validate the field.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
2017-06-20 07:03:22 -04:00
Pavel Hrdina
1763a2e7e2 conf: move seclabel for chardev source to the correct sturcture
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-06-16 15:42:59 +02:00
Martin Kletzander
cc9f0521cd Report more correct information for cache control
On some platforms the number of bits in the cbm_mask might not be
divisible by 4 (and not even by 2), so we need to properly count the
bits.  Similar file, min_cbm_bits, is properly parsed and used, but if
the number is greater than one, we lose the information about
granularity when reporting the data in capabilities.  For that matter
always report granularity, but if it is not the same as the minimum,
add that information in there as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-06-16 13:09:41 +02:00
Marc Hartmayer
adf846d3c9 Use ATTRIBUTE_FALLTHROUGH
Use ATTRIBUTE_FALLTHROUGH, introduced by commit
5d84f5961b, instead of comments to
indicate that the fall through is an intentional behavior.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-06-12 19:11:30 -04:00
Ján Tomko
cc0933d350 Add virtio-related options to input devices
https://bugzilla.redhat.com/show_bug.cgi?id=1283251

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-08 16:32:53 +02:00
Ján Tomko
f5384fb402 Add virtio-related options to video
https://bugzilla.redhat.com/show_bug.cgi?id=1283251

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-08 16:32:49 +02:00
Ján Tomko
f65db1be12 Add virtio-related options to rng devices
https://bugzilla.redhat.com/show_bug.cgi?id=1283251

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-08 16:32:44 +02:00
Ján Tomko
b10c22d9fa Add virtio-related options to filesystems
https://bugzilla.redhat.com/show_bug.cgi?id=1283251

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-08 16:32:40 +02:00
Ján Tomko
c85217cf8a Add virtio-related options to controllers
https://bugzilla.redhat.com/show_bug.cgi?id=1283251

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-08 16:32:33 +02:00
Ján Tomko
1bc2cb3b32 Add virtio-related options to disks
https://bugzilla.redhat.com/show_bug.cgi?id=1283251

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-08 16:32:27 +02:00
Ján Tomko
82223f9364 add virtio-related options to memballoon
https://bugzilla.redhat.com/show_bug.cgi?id=1283251

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-08 16:32:11 +02:00
Ján Tomko
fd51864340 Add virtio-related options to interfaces
<interface type='user'>
  <mac address='52:54:56:5a:5c:5e'/>
  <model type='virtio'/>
  <driver iommu='on' ats='on'/>
</interface>

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

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-08 16:31:54 +02:00
Ján Tomko
d1feb4773d conf: use a leading space in virDomainVirtioNetDriverFormat
Instead of formatting a space after every option.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-08 16:31:48 +02:00
Ján Tomko
27b187be39 conf: add iotlb attribute to iommu
Add a new iotlb attribute to the iommu device
to control the device IOTLB support for intel-iommu.

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

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-08 16:31:09 +02:00
Ján Tomko
e146264aaa virDomainControllerDefFormat: do not mix attributes and subelements
Move out the PCI controller's subelements formatting out of the switch
handling attributes. This removes the need for a few bool variables.
2017-06-07 18:10:51 +02:00
Ján Tomko
583022e52e conf: eliminate monster condition in virDomainControllerDefFormat
Move most of the subelement formatting out of the giant if.
2017-06-07 18:10:51 +02:00
Michal Privoznik
836f85d13f virDomainNetDefParseXML: Fix typo
In 9cb891141c we've introduced some logic to clearing suggested
macvtap/macvlan ifnames. The logic consists of comparing ifname
string with strings that libvirt would generate. However, due to
a typo only VIR_NET_GENERATED_MACVTAP_PREFIX was compared. Twice.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-06-07 17:55:46 +02:00
Jiri Denemark
25af7e950a conf: Add save cookie callbacks to xmlopt
virDomainXMLOption gains driver specific callbacks for parsing and
formatting save cookies.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 13:36:01 +02:00
Jiri Denemark
e37daa1fb6 conf: Introduce virSaveCookie
The code will be used by snapshots and domain save/restore code to store
additional data for a saved running domain. It is analogous to migration
cookies, but simple and one way only.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 13:36:01 +02:00
Jiri Denemark
957cd268a9 conf: Pass xmlopt to virDomainSnapshotDefFormat
This will be used later when a save cookie will become part of the
snapshot XML using new driver specific parser/formatter functions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 13:36:01 +02:00
Jiri Denemark
00968dca96 conf: Make virDomainSnapshotDefFormat easier to read
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 13:36:01 +02:00
Jiri Denemark
702013f3b3 conf: Refactor virCPUDefParseXML
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 13:36:01 +02:00
Jiri Denemark
25ec7f6fe9 conf: Make error reporting in virCPUDefIsEqual optional
The function will be used in paths where mismatching CPU defs are not an
error.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-06-07 13:36:01 +02:00
John Ferlan
46f5eca4b2 interface: Convert virInterfaceObj to use virObjectLockable
Now that we have a bit more control, let's convert our object into
a lockable object and let that magic handle the create and lock/unlock.

This commit also introduces virInterfaceObjEndAPI in order to handle the
lock unlock and object unref in one call for consumers returning a NULL
obj upon return. This removes the need for virInterfaceObj{Lock|Unlock}
external API's.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-06 12:05:00 -04:00
John Ferlan
92840eb3a7 interface: Consume @def in virInterfaceObjNew
Move the consumption of @def in virInterfaceObjNew and then handle that
in the error path of virInterfaceObjListAssignDef since it's caller expects
to need to free @def when NULL is returned and so would virInterfaceObjFree.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-06 12:05:00 -04:00
John Ferlan
309947375a interface: Introduce virInterfaceObjNew
Create/use a helper to perform the object allocation

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-06 12:05:00 -04:00
Ján Tomko
bb74c66e67 conf: only format <controller> as a pair tag when needed
Make the decision based on the usage of childBuf buffer.

This fixes the oddity in the test case introduced by commit c1c4d0d
where we would format an empty pair tag.
2017-06-05 16:13:50 +02:00
Ján Tomko
5b96f37ff4 conf: use a separate buffer for the subelements of <controller>
We need to decide whether to format <controller> as a single tag
or if it has any subelements.

Rewrite the function to use a separate buffer for subelements,
to make adding new options easier.
2017-06-05 16:13:50 +02:00
Ján Tomko
fe262186dc conf: introduce virDomainControllerDriverFormat
Split out formatting the <driver> subelement of <controller>
to make adding new options easier.
2017-06-05 16:13:50 +02:00
Martin Kletzander
6d12a1cb2f audit: Fix the output message for shmem
After some discussion on and off the linux-audit mailing list, we
should use different fields for the audit messages.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-06-05 15:19:44 +02:00
Eli Qiao
0ab409ccc4 Expose resource control capabilities for caches
Add cache resource control into capabilities for CAT without CDP:

  <cache>
    <bank id='0' level='3' type='unified' size='15360' unit='KiB' cpus='0-5'>
      <control min='768' unit='KiB' scope='both' max_allocation='4'/>
    </bank>
  </cache>

and with CDP:

  <cache>
    <bank id='0' level='3' type='unified' size='15360' unit='KiB' cpus='0-5'>
      <control min='768' unit='KiB' scope='code' max_allocation='4'/>
      <control min='768' unit='KiB' scope='data' max_allocation='4'/>
    </bank>
  </cache>

Also add new test cases for vircaps2xmltest.

Signed-off-by: Eli Qiao <liyong.qiao@intel.com>
2017-06-05 09:50:51 +02:00
Michal Privoznik
4f0aeed871 virDomainXMLOption: Introduce virDomainABIStabilityDomain
While checking for ABI stability, drivers might pose additional
checks that are not valid for general case. For instance, qemu
driver might check some memory backing attributes because of how
qemu works. But those attributes may work well in other drivers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-06-05 09:08:52 +02:00
John Ferlan
5d3994d822 nodedev: Remove privateData from virNodeDeviceObj
It was only ever used in node_device_hal.c which really never used it
anyway since the NODE_DEV_UDI was never referenced.  Remove free_udi()
and @privData as well as the references to obj->privateData & obj->privateFree.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-03 08:34:35 -04:00
John Ferlan
922af89e44 nodedev: Introduce virNodeDeviceObjGetDef
In preparation for privatizing the virNodeDeviceObj - create an accessor
for the @def field and then use it for various callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-03 08:34:35 -04:00
John Ferlan
944b8de83e nodedev: Use switch for virNodeDeviceObjHasCap and virNodeDeviceCapMatch
In order to ensure that whenever something is added to virNodeDevCapType
that both functions are considered for processing of a new capability,
change the if-then-else construct into a switch statement.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-03 08:34:34 -04:00
John Ferlan
51ed8907a3 nodedev: Need to check for vport capable scsi_host for vHBA searches
When searching for an NPIV capable fc_host, not only does there need to
be an "fc_host" capability with the specified wwnn/wwpn or fabric_wwn,
but that scsi_host must be vport capable; otherwise, one could end up
picking an exising vHBA/NPIV which wouldn't be good.

Currently not a problem since scsi_hosts are in an as found forward linked
list and the vport capable scsi_hosts will always appear before a vHBA by
definition. However, in the near term future a hash table will be used to
lookup the devices and that could cause problems for these algorithms.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-03 08:34:34 -04:00
John Ferlan
9c9a12ca31 interface: Clean up virInterfaceObjListFindByMACString
Alter the algorithm to return a list of matching names rather than a
list of match virInterfaceObjPtr which are then just dereferenced
extracting the def->name and def->mac. Since the def->mac would be
the same as the passed @mac, just return a list of names and as long
as there's only one, extract the [0] entry from the passed list.
Also alter the error message on failure to include the mac that wasn't
found.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
e2f3e6c38e interface: Rename some virInterfaceObj* API's
Prefix should have been virInterfaceObjList since the API is operating
on the list of interfaces.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
5374a1ca80 interface: Make _virInterfaceObjList struct private
Move the structs into virinterfaceobj.c, create necessary accessors, and
initializers.

This also includes reworking virInterfaceObjListClone to handle receiving
a source interfaces list pointer, creating the destination interfaces object,
and copying everything from source into dest.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
3b6de6c0cb interface: Make _virInterfaceObj struct private
Move the struct into virinterfaceobj.c, create necessary accessors, and
initializers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
4939f0b25d interface: Use virInterfaceDefPtr rather than deref from virInterfaceObjPtr
We're about to make the obj much more private, so make it easier to
see future changes which will require accessors for the obj->def

This also includes modifying some interfaces->objs[i]->X references to be
obj = interfaces->objs[i]; and then def = obj->def

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
3a18ee91b7 interface: Consistently use 'obj' for a virInterfaceObjPtr
Alter variable names to be obj rather than 'iface' and/or 'obj'.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
Michal Privoznik
6e9e1423e1 virCapabilitiesInitCaches: Don't leak @cpus
The @cpus is allocated by virFileReadValueBitmap() but never
freed:

==21274== 40 (32 direct, 8 indirect) bytes in 1 blocks are definitely lost in loss record 808 of 1,004
==21274==    at 0x4C2E080: calloc (vg_replace_malloc.c:711)
==21274==    by 0x54BA561: virAlloc (viralloc.c:144)
==21274==    by 0x54BC604: virBitmapNewEmpty (virbitmap.c:126)
==21274==    by 0x54BD059: virBitmapParseUnlimited (virbitmap.c:570)
==21274==    by 0x54EECE9: virFileReadValueBitmap (virfile.c:4113)
==21274==    by 0x5563132: virCapabilitiesInitCaches (capabilities.c:1548)
==21274==    by 0x2BB86E59: virQEMUCapsInit (qemu_capabilities.c:1132)
==21274==    by 0x2BBEC067: virQEMUDriverCreateCapabilities (qemu_conf.c:928)
==21274==    by 0x2BC3DEAA: qemuStateInitialize (qemu_driver.c:845)
==21274==    by 0x5625AAC: virStateInitialize (libvirt.c:770)
==21274==    by 0x124519: daemonRunStateInit (libvirtd.c:881)
==21274==    by 0x554C927: virThreadHelper (virthread.c:206)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-29 10:09:38 +02:00
Bjoern Walk
bb2adfe934 node_device: introduce new capability FC_RPORT
Similar to scsi_host and fc_host, there is a relation between a
scsi_target and its transport specific fc_remote_port. Let's expose this
relation and relevant information behind it.

An example for a virsh nodedev-dumpxml:

    virsh # nodedev-dumpxml scsi_target0_0_0
    <device>
      <name>scsi_target0_0_0</name>
      <path>/sys/devices/[...]/host0/rport-0:0-0/target0:0:0</path>
      <parent>scsi_host0</parent>
      <capability type='scsi_target'>
        <target>target0:0:0</target>
        <capability type='fc_remote_port'>
          <rport>rport-0:0-0</rport>
          <wwpn>0x9d73bc45f0e21a86</wwpn>
        </capability>
      </capability>
    </device>

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-05-26 10:44:05 -04:00
Bjoern Walk
c7cfcc57d5 virsh: nodedev: ability to filter CCW capabilities
Now that the node_device driver is aware of CCW devices, let's hook up
virsh so that we can filter them properly.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-05-26 10:44:05 -04:00
Bjoern Walk
b0ffd938d4 node_device: detect CCW devices
Make CCW devices available to the node_device driver. The devices are
already seen by udev so let's implement necessary code for detecting
them properly.

Topologically, CCW devices are similar to PCI devices, e.g.:

    +- ccw_0_0_1a2b
        |
        +- scsi_host0
            |
            +- scsi_target0_0_0
                |
                +- scsi_0_0_0_0

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-05-26 10:44:05 -04:00
Ján Tomko
dc61d92758 conf: add eim attribute to <iommu><driver>
Add an attribute to control extended interrupt mode.

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

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2017-05-26 08:11:25 +02:00