[libvirt] [PATCH] virnwfilterbindingobj: Introduce and use virNWFilterBindingObjStealDef
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1686927
When trying to create a nwfilter binding via
nwfilterBindingCreateXML() we may encounter a crash. The sequence
of functions called is as follows:
1) nwfilterBindingCreateXML() parses the XML and calls
virNWFilterBindingObjListAdd() which calls
virNWFilterBindingObjListAddLocked()
2) Here, @binding is not found because binding->remove is set.
3) Therefore, controls continue with creating new @binding,
setting its def to the one from 1) and adding it to the hash
table.
4) This fails, because the binding is still in the hash table
(duplicate key is detected).
5) The control jumps to 'error' label where
virNWFilterBindingObjEndAPI() is called which frees the binding
definition passed.
6) Error is propagated to the caller, which calls
virNWFilterBindingDefFree() over the definition again.
The solution is to unset binding->def in case of failure so it's
not freed in step 5).
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Technically, this is a v2 of:
https://www.redhat.com/archives/libvir-list/2019-March/msg01209.html
But since this one implements different approach than v1 I'm not marking
it as such.
src/conf/virnwfilterbindingobj.c | 10 ++++++++++
src/conf/virnwfilterbindingobj.h | 3 +++
src/conf/virnwfilterbindingobjlist.c | 4 ++++
src/libvirt_private.syms | 1 +
4 files changed, 18 insertions(+)
diff --git a/src/conf/virnwfilterbindingobj.c b/src/conf/virnwfilterbindingobj.c
index 23978d4207..68afb9c434 100644
--- a/src/conf/virnwfilterbindingobj.c
+++ b/src/conf/virnwfilterbindingobj.c
@@ -88,6 +88,16 @@ virNWFilterBindingObjSetDef(virNWFilterBindingObjPtr obj,
}
+virNWFilterBindingDefPtr
+virNWFilterBindingObjStealDef(virNWFilterBindingObjPtr obj)
+{
+ virNWFilterBindingDefPtr def;
+
+ VIR_STEAL_PTR(def, obj->def);
+ return def;
+}
+
+
bool
virNWFilterBindingObjGetRemoving(virNWFilterBindingObjPtr obj)
{
diff --git a/src/conf/virnwfilterbindingobj.h b/src/conf/virnwfilterbindingobj.h
index 8e5fbee35f..b26bb3c8ec 100644
--- a/src/conf/virnwfilterbindingobj.h
+++ b/src/conf/virnwfilterbindingobj.h
@@ -39,6 +39,9 @@ void
virNWFilterBindingObjSetDef(virNWFilterBindingObjPtr obj,
virNWFilterBindingDefPtr def);
+virNWFilterBindingDefPtr
+virNWFilterBindingObjStealDef(virNWFilterBindingObjPtr obj);
+
bool
virNWFilterBindingObjGetRemoving(virNWFilterBindingObjPtr obj);
diff --git a/src/conf/virnwfilterbindingobjlist.c b/src/conf/virnwfilterbindingobjlist.c
index 06ccbf53af..4ee2c1b194 100644
--- a/src/conf/virnwfilterbindingobjlist.c
+++ b/src/conf/virnwfilterbindingobjlist.c
@@ -167,6 +167,7 @@ virNWFilterBindingObjListAddLocked(virNWFilterBindingObjListPtr bindings,
virNWFilterBindingDefPtr def)
{
virNWFilterBindingObjPtr binding;
+ bool stealDef = false;
/* See if a binding with matching portdev already exists */
if ((binding = virNWFilterBindingObjListFindByPortDevLocked(
@@ -181,6 +182,7 @@ virNWFilterBindingObjListAddLocked(virNWFilterBindingObjListPtr bindings,
goto error;
virNWFilterBindingObjSetDef(binding, def);
+ stealDef = true;
if (virNWFilterBindingObjListAddObjLocked(bindings, binding) < 0)
goto error;
@@ -188,6 +190,8 @@ virNWFilterBindingObjListAddLocked(virNWFilterBindingObjListPtr bindings,
return binding;
error:
+ if (stealDef)
+ virNWFilterBindingObjStealDef(binding);
virNWFilterBindingObjEndAPI(&binding);
return NULL;
}
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 26f10bd47f..a33f9e61b1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1101,6 +1101,7 @@ virNWFilterBindingObjParseFile;
virNWFilterBindingObjSave;
virNWFilterBindingObjSetDef;
virNWFilterBindingObjSetRemoving;
+virNWFilterBindingObjStealDef;
# conf/virnwfilterbindingobjlist.h
--
2.19.2
5 years, 9 months
[libvirt] [PATCH] rpm: fix upgrades when RBD is disabled in a new version
by Daniel P. Berrangé
We previously had to disable RBD on 32-bit platforms since Ceph has
dropped all support for 32-bit. Unfortunately anyone with the RPM
libvirt-daemon-driver-storage-rbd installed on 32-bit now has a
broken upgrade path.
To fix this we must make libvirt-daemon-driver-storage-common
have an Obsoletes: libvirt-daemon-driver-storage-rbd < $VER-$REL
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
libvirt.spec.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 1497cad3d2..79f3d31d19 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -550,6 +550,9 @@ Requires: util-linux
# From QEMU RPMs
Requires: /usr/bin/qemu-img
%endif
+%if !%{with_storage_rbd}
+Obsoletes: libvirt-daemon-driver-storage-rbd < %{version}-%{release}
+%endif
%description daemon-driver-storage-core
The storage driver plugin for the libvirtd daemon, providing
--
2.20.1
5 years, 9 months
[libvirt] [PATCH v2 0/3] nodedev: add class info for pci capability
by Nikolay Shirokovskiy
Diff from v1 [1]
===============
- add patch to use/restrict name "klass" in headers instead of class, _class
- add news patch
[1] https://www.redhat.com/archives/libvir-list/2019-February/msg01036.html
Nikolay Shirokovskiy (3):
conf: don't use "class" as name in _virNodeDevCapPCIDev
xml: nodedev: add class info for pci capability
news: update for new class element of PCI nodedev capability
cfg.mk | 8 ++++++++
docs/formatnode.html.in | 5 +++++
docs/news.xml | 5 +++++
docs/schemas/nodedev.rng | 5 +++++
src/conf/node_device_conf.c | 17 +++++++++++++++--
src/conf/node_device_conf.h | 4 ++--
src/node_device/node_device_udev.c | 4 ++--
.../nodedevschemadata/pci_0000_00_02_0_header_type.xml | 1 +
.../nodedevschemadata/pci_0000_00_1c_0_header_type.xml | 1 +
tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml | 1 +
tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml | 1 +
.../pci_0000_02_10_7_sriov_pf_vfs_all.xml | 1 +
.../pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml | 1 +
tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml | 1 +
.../pci_0000_02_10_7_sriov_zero_vfs_max_count.xml | 1 +
tests/nodedevschemadata/pci_1002_71c4.xml | 1 +
tests/nodedevschemadata/pci_8086_0c0c_snd_hda_intel.xml | 1 +
tests/nodedevschemadata/pci_8086_10c9_sriov_pf.xml | 1 +
tests/nodedevschemadata/pci_8086_4238_pcie_wireless.xml | 1 +
tests/nodedevschemadata/pci_82579LM_network_adapter.xml | 1 +
20 files changed, 55 insertions(+), 6 deletions(-)
--
2.16.5
5 years, 9 months
[libvirt] [PATCH] virStoragePoolDefParseSource: Don't leak @port
by Michal Privoznik
In a1c453dc088, during VIR_AUTOFREE() rewrite this wasn't done
properly. @port might be leaked because it's allocated in a for()
loop.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under trivial rule.
src/conf/storage_conf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 7dff566641..3ae0d7ab77 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -588,6 +588,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
goto cleanup;
}
}
+ VIR_FREE(port);
}
}
--
2.19.2
5 years, 9 months
[libvirt] [PATCH] virStoragePoolDefFree: Free @def->refresh
by Michal Privoznik
In 669018bc9cb I've introduced def->refresh which might be
allocated by virStoragePoolDefRefreshParse() but is never freed.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under trivial rule.
src/conf/storage_conf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index b797a405f7..7dff566641 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -509,6 +509,7 @@ virStoragePoolDefFree(virStoragePoolDefPtr def)
VIR_FREE(def->target.path);
VIR_FREE(def->target.perms.label);
+ VIR_FREE(def->refresh);
if (def->namespaceData && def->ns.free)
(def->ns.free)(def->namespaceData);
VIR_FREE(def);
--
2.19.2
5 years, 9 months
[libvirt] [PATCH] nwfilter: Don't crash when trying to add an nwfilter that's already being removed
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1686927
When trying to create a nwfilter binding via
nwfilterBindingCreateXML() we may encounter a crash. The sequence
of functions called is as follows:
1) nwfilterBindingCreateXML() parses the XML and calls
virNWFilterBindingObjListAdd() which calls
virNWFilterBindingObjListAddLocked()
2) Here, @binding is not found because binding->remove is set.
3) Therefore, controls continue with creating new @binding,
setting its def to the one from 1) and adding it to the hash
table.
4) This fails, because the binding is still in the hash table
(duplicate key is detected).
5) The control jumps to 'error' label where
virNWFilterBindingObjEndAPI() is called which frees the binding
definition passed.
6) Error is propagated to the caller, which calls
virNWFilterBindingDefFree() over the definition again.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/virnwfilterbindingobjlist.c | 11 ++++++-----
src/conf/virnwfilterbindingobjlist.h | 2 +-
src/nwfilter/nwfilter_driver.c | 5 ++---
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/conf/virnwfilterbindingobjlist.c b/src/conf/virnwfilterbindingobjlist.c
index 06ccbf53af..87189da642 100644
--- a/src/conf/virnwfilterbindingobjlist.c
+++ b/src/conf/virnwfilterbindingobjlist.c
@@ -164,23 +164,24 @@ virNWFilterBindingObjListAddObjLocked(virNWFilterBindingObjListPtr bindings,
*/
static virNWFilterBindingObjPtr
virNWFilterBindingObjListAddLocked(virNWFilterBindingObjListPtr bindings,
- virNWFilterBindingDefPtr def)
+ virNWFilterBindingDefPtr *def)
{
virNWFilterBindingObjPtr binding;
/* See if a binding with matching portdev already exists */
if ((binding = virNWFilterBindingObjListFindByPortDevLocked(
- bindings, def->portdevname))) {
+ bindings, (*def)->portdevname))) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("binding '%s' already exists"),
- def->portdevname);
+ (*def)->portdevname);
goto error;
}
if (!(binding = virNWFilterBindingObjNew()))
goto error;
- virNWFilterBindingObjSetDef(binding, def);
+ virNWFilterBindingObjSetDef(binding, *def);
+ *def = NULL;
if (virNWFilterBindingObjListAddObjLocked(bindings, binding) < 0)
goto error;
@@ -195,7 +196,7 @@ virNWFilterBindingObjListAddLocked(virNWFilterBindingObjListPtr bindings,
virNWFilterBindingObjPtr
virNWFilterBindingObjListAdd(virNWFilterBindingObjListPtr bindings,
- virNWFilterBindingDefPtr def)
+ virNWFilterBindingDefPtr *def)
{
virNWFilterBindingObjPtr ret;
diff --git a/src/conf/virnwfilterbindingobjlist.h b/src/conf/virnwfilterbindingobjlist.h
index b0fb90f667..4047453634 100644
--- a/src/conf/virnwfilterbindingobjlist.h
+++ b/src/conf/virnwfilterbindingobjlist.h
@@ -35,7 +35,7 @@ virNWFilterBindingObjListFindByPortDev(virNWFilterBindingObjListPtr bindings,
virNWFilterBindingObjPtr
virNWFilterBindingObjListAdd(virNWFilterBindingObjListPtr bindings,
- virNWFilterBindingDefPtr def);
+ virNWFilterBindingDefPtr *def);
void
virNWFilterBindingObjListRemove(virNWFilterBindingObjListPtr bindings,
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index fdfc6f48fa..8c2e987b5d 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -759,7 +759,7 @@ nwfilterBindingCreateXML(virConnectPtr conn,
goto cleanup;
obj = virNWFilterBindingObjListAdd(driver->bindings,
- def);
+ &def);
if (!obj)
goto cleanup;
@@ -775,8 +775,7 @@ nwfilterBindingCreateXML(virConnectPtr conn,
virNWFilterBindingObjSave(obj, driver->bindingDir);
cleanup:
- if (!obj)
- virNWFilterBindingDefFree(def);
+ virNWFilterBindingDefFree(def);
virNWFilterBindingObjEndAPI(&obj);
return ret;
--
2.19.2
5 years, 9 months
[libvirt] [PATCH] conf: Drop unused variable
by Andrea Bolognani
The refresh_volume_allocation variable in
virStoragePoolDefParseXML() has been unused since its
introduction in commit 669018bc9cb1, and Clang rightfully
complains about this fact.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
Pushed under the build breaker rule.
src/conf/storage_conf.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 653602f7be..b797a405f7 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -849,7 +849,6 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
VIR_AUTOFREE(char *) type = NULL;
VIR_AUTOFREE(char *) uuid = NULL;
VIR_AUTOFREE(char *) target_path = NULL;
- VIR_AUTOFREE(char *) refresh_volume_allocation = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
--
2.20.1
5 years, 9 months
[libvirt] [PATCH] spec: Only call ldconfig on RHEL7
by Cole Robinson
Since Fedora 28 (our minimum supported build), ldconfig is called
automatically for us:
https://fedoraproject.org/wiki/Changes/Removing_ldconfig_scriptlets
These changes appear to be implemented for rhel > 7 as well, so only
run ldconfig on rhel7
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
libvirt.spec.in | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 1497cad3d2..445fddc801 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1477,12 +1477,16 @@ exit 0
%post client
+%if 0%{?rhel} == 7
/sbin/ldconfig
+%endif
%systemd_post libvirt-guests.service
%postun client
+%if 0%{?rhel} == 7
/sbin/ldconfig
+%endif
%systemd_postun libvirt-guests.service
%triggerun client -- libvirt < 0.9.4
--
2.21.0
5 years, 9 months
[libvirt] [PATCH v3 0/3] rbd: improvements to actual disk-usage calculation
by jdillama@redhat.com
From: Jason Dillaman <dillaman(a)redhat.com>
The RBD fast-diff feature can vastly reduce the amount of time needed
to calculate actual disk usage of volumes, but it might still be a
slow operation for large RBD pools or pools with large RBD images.
Therefore, this feature should be able to be optionally disabled if
needed.
Additionally, the fast-diff feature can only be used if the fast-diff
map isn't flagged as invalid. Otherwise, librbd will silently perform
a costly block-by-block scan to calculate the disk usage.
since v1:
- Moved RBD-unique refresh volume allocation override to shared storage
pool attribute
sice v2:
- Moved attribute under new "<refresh><volume allocation='...'/></refresh>"
elements.
Jason Dillaman (3):
rbd: do not attempt to use fast-diff if it's marked invalid
storage: optional 'refresh' elemement on pool
rbd: optionally compute volume allocation from capacity
docs/formatstorage.html.in | 27 ++++++++++++
docs/schemas/storagecommon.rng | 7 ++++
docs/schemas/storagepool.rng | 23 ++++++++++
src/conf/storage_conf.c | 27 ++++++++++++
src/conf/storage_conf.h | 9 ++++
src/storage/storage_backend_rbd.c | 42 +++++++++++++++++--
.../pool-rbd-refresh-volume-allocation.xml | 15 +++++++
.../pool-rbd-refresh-volume-allocation.xml | 18 ++++++++
tests/storagepoolxml2xmltest.c | 1 +
9 files changed, 165 insertions(+), 4 deletions(-)
create mode 100644 tests/storagepoolxml2xmlin/pool-rbd-refresh-volume-allocation.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-rbd-refresh-volume-allocation.xml
--
2.20.1
5 years, 9 months
[libvirt] [PATCH 00/34] conf: refactor virStorageSource parsing and formatting (blockdev-add saga)
by Peter Krempa
Simplify parsing and formatting of virStorageSource into/from XML. This
series contains the refactors which unify the various parsers into one
with a neat cleanup.
The plan is to reuse the parser for parsing job backing chains when the
disk frontend will be unplugged by the guest so that we don't lose track
of the backing chain members.
This series adds support for backing chain of the <mirror> subelement
which has a similar reason. If we open a user-formatted file
(--reuse-external) and do a shallow copy into it we will need to keep
around the backing chain for that as well. It feels fitting to format
the backing chain under <mirror> as it might become the disk source
later.
Peter Krempa (34):
conf: Invert 'skipSeclabels' argument of
virDomainDiskSourceFormatInternal
conf: Move formatting of 'index' and 'startupPolicy' for
virStorageSource
conf: Introduce virDomainStorageSourceFormatFull
qemu: domain: Replace qemuDomainObjPrivateXMLFormatNBDMigrationSource
conf: Unexport virDomainStorageSourceFormat
conf: domain: Merge virDomainDiskSourceFormatInternal into the wrapper
conf: Simplify control flow in virDomainDiskSourceFormat
conf: Avoid temporary variable in virDomainDiskBackingStoreFormat
conf: Use virXMLFormatElement in virDomainDiskBackingStoreFormat
conf: Move virDomainDiskBackingStoreFormat up to avoid forward
declarations
conf: Move backingStore formating into virDomainDiskSourceFormat
conf: Add possibility to format full chain with
virDomainStorageSourceFormatFull
conf: Simplify error paths in storage source component parsers
cleanup error path in virDomainStorageSourceParse
util: xml: Introduce VIR_AUTOPTR functions for xmlDoc and
xmlXPathContext
tests: Use full force of our VIR_AUTO* machinery in
testBackingXMLjsonXML
tests: Refactor control flow in testBackingXMLjsonXML
conf: Refactor control flow in virDomainDiskBackingStoreParse
conf: Fold private data parsing into virDomainStorageSourceParse
conf: Introduce modular parser for virStorageSource
qemu: Use virDomainStorageSourceParseFull when parsing NBD migration
data
conf: Unexport virDomainStorageSourceParse
tests: qemublock: Use new source formatter and parser in
testBackingXMLjsonXML
conf: snapshot: Use virDomainStorageSourceParseFull for snapshots
conf: Replace virDomainDiskSourceParse by virDomainStorageSourceParse
conf: Use virDomainStorageSourceParseFull in
virDomainDiskBackingStoreParse
conf: Use virDomainStorageSourceParseFull to parse disk source in
virDomainDiskDefParseXML
conf: Use virDomainStorageSourceParseFull in
virDomainDiskDefMirrorParse
conf: Parse <backingStore> in virDomainStorageSourceParseFull
conf: Parse and format 'backingStore' for disk <mirror>
conf: Add 'index' attribute for <disk><mirror><source>
conf: Format seclabels for <backingStore>
conf: Remove @seclabels from virDomainDiskSourceFormat
conf: Remove @seclabels from virDomainStorageSourceFormat
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 494 ++++++++++--------
src/conf/domain_conf.h | 32 +-
src/conf/snapshot_conf.c | 40 +-
src/libvirt_private.syms | 4 +-
src/qemu/qemu_domain.c | 104 +---
src/util/virxml.h | 3 +
tests/qemublocktest.c | 179 +++----
.../blockjob-mirror-in.xml | 13 +
.../qemuxml2argvdata/disk-backing-chains.xml | 6 +-
tests/qemuxml2argvdata/disk-mirror.xml | 8 +-
.../disk-backing-chains-active.xml | 6 +-
.../disk-backing-chains-inactive.xml | 6 +-
.../qemuxml2xmloutdata/disk-mirror-active.xml | 8 +-
tests/virstoragetest.c | 2 +-
15 files changed, 443 insertions(+), 463 deletions(-)
--
2.20.1
5 years, 9 months