[libvirt PATCH v3 0/6] ci: helper: Rewrite image listing in Python and add stale Docker image checker
by Erik Skultety
since v2:
- dropped original patch 1 renaming ci-help to help in Makefile
- changed the --quiet cmdline option to be tied to the refresh cmd only
- urrlib imports fixed
- improved on Python type hinting
- improved util functions docstrings
- replaced all tabs in formatted strings with 4 spaces
- moved the list_stale_images method to util as requested
- renamed variables in list_stale_images so that it's more clear at first
glance what they actually hold
- added a hint on where GitLab personal tokens should be generated
- added a patch converting private method naming to reflect the common
Python practice (I did it in a separate patch so that if this is not
accepted I only need to ditch a single patch with no further changes)
v1: https://listman.redhat.com/archives/libvir-list/2021-February/msg00641.ht=
ml
v2: https://listman.redhat.com/archives/libvir-list/2021-March/msg00789.html
EXAMPLE OUTPUT OF THE REGISTRY CHECKER:
The following images can be purged from the registry:
ci-debian-9: (ID: 1154661)
ci-debian-9-cross-aarch64: (ID: 1154667)
ci-debian-9-cross-mipsel: (ID: 1154669)
ci-debian-9-cross-armv7l: (ID: 1154671)
ci-debian-9-cross-armv6l: (ID: 1154676)
ci-debian-9-cross-mips: (ID: 1154678)
ci-debian-9-cross-ppc64le: (ID: 1154682)
ci-debian-9-cross-s390x: (ID: 1154683)
ci-debian-9-cross-mips64el: (ID: 1154686)
ci-fedora-31: (ID: 1154687)
ci-opensuse-151: (ID: 1154724)
You can remove the above images over the API with the following code snippet:
$ for image_id in 1154661 1154667 1154669 1154671 1154676 1154678 1154682=
\
1154683 1154686 1154687 1154724; do \
curl --request DELETE --header "PRIVATE-TOKEN: <access_token>" \
https://gitlab.com/api/v4/projects/libvirt%2Flibvirt/registry/repos=
itories/$image_id \
done
You can generate a personal access token here:
https://gitlab.com/-/profile/personal_access_tokens
Erik Skultety (6):
ci: helper: Use the ArgumentDefaultsHelpFormatter help formatter
ci: helper: Introduce --quiet
ci: Introduce a util module
ci: helper: Rewrite image listing to Python
ci: util: Add a registry checker for stale images
ci: helper: Convert private methods to Python common naming practice
ci/Makefile | 12 ----
ci/helper | 162 ++++++++++++++++++++++++++++++++++++----------
ci/list-images.sh | 14 ----
ci/util.py | 92 ++++++++++++++++++++++++++
4 files changed, 219 insertions(+), 61 deletions(-)
delete mode 100644 ci/list-images.sh
create mode 100644 ci/util.py
--=20
2.29.2
3 years, 8 months
[PULL v2 00/13] misc patches removing deprecated features
by Daniel P. Berrangé
The following changes since commit 571d413b5da6bc6f1c2aaca8484717642255ddb0:
Merge remote-tracking branch 'remotes/mcayland/tags/qemu-openbios-20210316' into staging (2021-03-17 21:02:37 +0000)
are available in the Git repository at:
https://gitlab.com/berrange/qemu tags/dep-many-pull-request
for you to fetch changes up to 8d17adf34f501ded65a106572740760f0a75577c:
block: remove support for using "file" driver with block/char devices (2021-03-18 09:22:55 +0000)
----------------------------------------------------------------
Remove many old deprecated features
The following features have been deprecated for well over the 2
release cycle we promise
``-drive file=json:{...{'driver':'file'}}`` (since 3.0)
``-vnc acl`` (since 4.0.0)
``-mon ...,control=readline,pretty=on|off`` (since 4.1)
``migrate_set_downtime`` and ``migrate_set_speed`` (since 2.8.0)
``query-named-block-nodes`` result ``encryption_key_missing`` (since 2.10.0)
``query-block`` result ``inserted.encryption_key_missing`` (since 2.10.0)
``migrate-set-cache-size`` and ``query-migrate-cache-size`` (since 2.11.0)
``query-named-block-nodes`` and ``query-block`` result dirty-bitmaps[i].status (since 4.0)
``query-cpus`` (since 2.12.0)
``query-cpus-fast`` ``arch`` output member (since 3.0.0)
``query-events`` (since 4.0)
chardev client socket with ``wait`` option (since 4.0)
``acl_show``, ``acl_reset``, ``acl_policy``, ``acl_add``, ``acl_remove`` (since 4.0.0)
``ide-drive`` (since 4.2)
``scsi-disk`` (since 4.2)
----------------------------------------------------------------
Daniel P. Berrangé (13):
ui, monitor: remove deprecated VNC ACL option and HMP commands
monitor: raise error when 'pretty' option is used with HMP
monitor: remove 'query-events' QMP command
migrate: remove QMP/HMP commands for speed, downtime and cache size
machine: remove 'query-cpus' QMP command
machine: remove 'arch' field from 'query-cpus-fast' QMP command
chardev: reject use of 'wait' flag for socket client chardevs
hw/ide: remove 'ide-drive' device
hw/scsi: remove 'scsi-disk' device
block: remove 'encryption_key_missing' flag from QAPI
block: remove dirty bitmaps 'status' field
block: remove 'dirty-bitmaps' field from 'BlockInfo' struct
block: remove support for using "file" driver with block/char devices
block/dirty-bitmap.c | 38 --
block/file-posix.c | 17 +-
block/qapi.c | 6 -
chardev/char-socket.c | 12 +-
docs/devel/migration.rst | 2 +-
docs/qdev-device-use.txt | 2 +-
docs/rdma.txt | 2 +-
docs/system/deprecated.rst | 108 -----
docs/system/removed-features.rst | 108 +++++
docs/xbzrle.txt | 5 -
hmp-commands-info.hx | 13 -
hmp-commands.hx | 121 ------
hw/core/machine-hmp-cmds.c | 8 +-
hw/core/machine-qmp-cmds.c | 120 ------
hw/i386/pc.c | 2 -
hw/ide/qdev.c | 38 --
hw/ppc/mac_newworld.c | 13 -
hw/ppc/mac_oldworld.c | 13 -
hw/scsi/scsi-disk.c | 62 ---
hw/sparc64/sun4u.c | 15 -
include/block/dirty-bitmap.h | 1 -
include/monitor/hmp.h | 4 -
migration/migration.c | 45 ---
migration/ram.c | 2 +-
monitor/hmp-cmds.c | 34 --
monitor/misc.c | 187 ---------
monitor/monitor.c | 4 +-
monitor/qmp-cmds-control.c | 24 --
qapi/block-core.json | 64 +--
qapi/control.json | 45 ---
qapi/machine.json | 181 +--------
qapi/migration.json | 98 -----
qemu-options.hx | 5 +-
scripts/device-crash-test | 2 -
softmmu/vl.c | 1 -
tests/acceptance/pc_cpu_hotplug_props.py | 2 +-
tests/acceptance/x86_cpu_model_versions.py | 2 +-
tests/migration/guestperf/engine.py | 18 +-
tests/qemu-iotests/051 | 4 -
tests/qemu-iotests/051.pc.out | 20 -
tests/qemu-iotests/124 | 4 -
tests/qemu-iotests/181 | 2 +-
tests/qemu-iotests/184.out | 6 +-
tests/qemu-iotests/191.out | 48 +--
tests/qemu-iotests/194 | 4 +-
tests/qemu-iotests/194.out | 4 +-
tests/qemu-iotests/226.out | 10 +-
tests/qemu-iotests/236 | 2 +-
tests/qemu-iotests/236.out | 42 +-
tests/qemu-iotests/246 | 3 +-
tests/qemu-iotests/246.out | 66 +--
tests/qemu-iotests/254 | 2 +-
tests/qemu-iotests/254.out | 9 +-
tests/qemu-iotests/257.out | 378 ++++++------------
tests/qemu-iotests/260 | 5 +-
tests/qemu-iotests/273.out | 15 +-
.../tests/migrate-bitmaps-postcopy-test | 6 +-
tests/qtest/migration-test.c | 48 ---
tests/qtest/numa-test.c | 6 +-
tests/qtest/qmp-test.c | 6 +-
tests/qtest/test-hmp.c | 6 +-
tests/qtest/test-x86-cpuid-compat.c | 4 +-
tests/qtest/vhost-user-test.c | 8 +-
ui/vnc.c | 38 --
64 files changed, 369 insertions(+), 1801 deletions(-)
--
2.30.2
3 years, 8 months
[PATCH v7 00/11] Configurable policy for handling deprecated interfaces
by Markus Armbruster
New option -compat lets you configure what to do when deprecated
interfaces get used. This is intended for testing users of the
management interfaces. It is experimental.
-compat deprecated-input=<in-policy> configures what to do when
deprecated input is received. Available policies:
* accept: Accept deprecated commands and arguments (default)
* reject: Reject them
* crash: Crash
-compat deprecated-output=<out-policy> configures what to do when
deprecated output is sent. Available output policies:
* accept: Emit deprecated command results and events (default)
* hide: Suppress them
For now, -compat covers only deprecated syntactic aspects of QMP. We
may want to extend it to cover semantic aspects, CLI, and experimental
features.
v7:
* Trivially rebased
* PATCH 01: New, bug fix from Paolo
* PATCH 02+11: Since: comments fixed, for real this time [Eric]
* PATCH 03+10: qobject_output_visitor_new_qmp() and
qobject_input_visitor_new_qmp() moved to qmp-dispatch.c to not break
--disable-system --disable-tools builds
* PATCH 05: Minor fallout from changed PATCH 03
* PATCH 06: Commit message typo fixed [Eric]
v6:
* Rebased, with straightforward conflicts
* PATCH 1: More verbose commit message, explaining intent, and the
lack of introspection [Peter], comments updated for 6.0, Eric's R-by
kept anyway
* PATCH 5+6: Split old PATCH 5 [Eric], Eric's R-by lept anyway
* PATCH 7: New, correcting a latent issue so it doesn't break PATCH 8
* PATCH 10: Doc fix [Eric]
v5:
* Old PATCH 01-26 merged in commit f57587c7d47.
* Rebased, non-trivial conflicts in PATCH 1 due to Meson, and in PATCH
7 due to visitor changes
* PATCH 1: Comments updated for 5.2 [Eric]
* PATCH 2: Harmless missing initialization fixed [Eric]
* PATCH 3+4: Harmless missing has_FOO = true fixed [Eric]
* PATCH 6+7: Commit message tweaked
v4:
* PATCH 05+07: Temporary memory leak plugged [Marc-André]
* PATCH 23: Rewritten [Marc-André]
* PATCH 24: Comment typo [Marc-André]
* PATCH 30: Memory leaks plugged
v3:
* Rebased, non-trivial conflicts in PATCH 01+26+27+34 due to RST
conversion and code motion
* PATCH 28-29: Old PATCH 28 split up to ease review
* PATCH 30-31: New
* PATCH 32-33: Old PATCH 29 split up to ease review
Comparison to RFC (24 Oct 2019):
* Cover arguments and results in addition to commands and events
* Half-baked "[RFC PATCH 18/19] qapi: Include a warning in the
response to a deprecated command" dropped
See also last item of
Subject: Minutes of KVM Forum BoF on deprecating stuff
Date: Fri, 26 Oct 2018 16:03:51 +0200
Message-ID: <87mur0ls8o.fsf(a)dusky.pond.sub.org>
https://lists.nongnu.org/archive/html/qemu-devel/2018-10/msg05828.html
Cc: Lukáš Doktor <ldoktor(a)redhat.com>
Cc: libguestfs(a)redhat.com
Cc: libvir-list(a)redhat.com
Cc: Daniel P. Berrange <berrange(a)redhat.com>
Cc: Peter Krempa <pkrempa(a)redhat.com>
Cc: Kevin Wolf <kwolf(a)redhat.com>
Markus Armbruster (10):
qemu-options: New -compat to set policy for deprecated interfaces
qapi: Implement deprecated-output=hide for QMP command results
qapi: Implement deprecated-output=hide for QMP events
qapi: Implement deprecated-output=hide for QMP event data
monitor: Drop query-qmp-schema 'gen': false hack
qapi: Implement deprecated-output=hide for QMP introspection
test-util-sockets: Add stub for monitor_set_cur()
qapi: Implement deprecated-input=reject for QMP commands
qapi: Implement deprecated-input=reject for QMP command arguments
qapi: New -compat deprecated-input=crash
Paolo Bonzini (1):
qemuutil: remove qemu_set_fd_handler duplicate symbol
qapi/compat.json | 52 ++++++++++++
qapi/introspect.json | 2 +-
qapi/qapi-schema.json | 1 +
include/qapi/compat-policy.h | 38 +++++++++
include/qapi/qmp/dispatch.h | 1 +
include/qapi/qobject-input-visitor.h | 4 +
include/qapi/qobject-output-visitor.h | 4 +
include/qapi/visitor-impl.h | 6 ++
include/qapi/visitor.h | 18 +++++
monitor/monitor-internal.h | 3 -
monitor/misc.c | 2 -
monitor/qmp-cmds-control.c | 100 +++++++++++++++++++++---
qapi/qapi-visit-core.c | 18 +++++
qapi/qmp-dispatch.c | 35 +++++++++
qapi/qobject-input-visitor.c | 29 +++++++
qapi/qobject-output-visitor.c | 19 +++++
softmmu/vl.c | 17 ++++
storage-daemon/qemu-storage-daemon.c | 2 -
stubs/set-fd-handler.c | 10 ---
tests/unit/test-qmp-cmds.c | 91 +++++++++++++++++++--
tests/unit/test-qmp-event.c | 41 ++++++++++
tests/unit/test-util-sockets.c | 1 +
qapi/meson.build | 1 +
qapi/trace-events | 2 +
qemu-options.hx | 22 ++++++
scripts/qapi/commands.py | 17 ++--
scripts/qapi/events.py | 21 ++++-
scripts/qapi/visit.py | 15 ++++
stubs/meson.build | 1 -
tests/qapi-schema/qapi-schema-test.json | 20 +++--
tests/qapi-schema/qapi-schema-test.out | 20 ++---
31 files changed, 549 insertions(+), 64 deletions(-)
create mode 100644 qapi/compat.json
create mode 100644 include/qapi/compat-policy.h
delete mode 100644 stubs/set-fd-handler.c
--
2.26.3
3 years, 8 months
[libvirt PATCH 00/38] Refactor XML parsing boilerplate code
by Tim Wiederhake
This series replaces some recurring boilerplate code in src/conf/ regarding
the extraction of a virTristate(Switch|Bool) XML attribute.
The boilerplate code looks roughly like this,
g_autofree char *str = NULL;
if (str = virXMLPropString(node, ...)) {
int val;
if ((val = virTristateBoolTypeFromString(str)) <= 0) {
virReportError(...)
return -1;
}
def->... = val;
}
with some variations regarding how `str` is free'd in case of later re-use,
the exact error message for invalid values, whether or not
`VIR_TRISTATE_(SWITCH|BOOL)_ABSENT` is explicitly checked for (`val < 0` vs.
`val <= 0`), whether an intermediate variable is used or the value is assigned
directly, and in some cases the conditions in the two if-blocks are merged.
As a side effect, this makes the error messages for invalid values in these
attributes much more consistent and catches some instances where e.g.
`<foo bar="default"/>` would incorrectly be accepted.
Patch #11 (virDomainChrSourceReconnectDefParseXML) is a good example of what
this refactoring is about.
Tim Wiederhake (38):
virStorageAdapterFCHost: Fix comment
virxml: Add virXMLPropYesNo
virxml: Add virXMLPropOnOff
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainKeyWrapCipherDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainVirtioOptionsParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainDeviceInfoParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainDiskSourceNetworkParse
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainDiskSourceNVMeParse
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainDiskDefDriverParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainActualNetDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainChrSourceReconnectDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainNetDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainChrSourceDefParseTCP
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainChrSourceDefParseFile
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainChrSourceDefParseLog
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainGraphicsDefParseXMLVNC
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainGraphicsDefParseXMLSDL
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainGraphicsDefParseXMLSpice
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainAudioCommonParse
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainAudioJackParse
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainAudioOSSParse
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainAudioDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainMemballoonDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainShmemDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in
virDomainPerfEventDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainMemoryDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainIOMMUDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainVsockDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainFeaturesDefParse
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainLoaderDefParseXML
domain_conf: Use virXMLProp(OnOff|YesNo) in virDomainVcpuParse
backup_conf: Use virXMLProp(OnOff|YesNo) in
virDomainBackupDiskDefParseXML
backup_conf: Use virXMLProp(OnOff|YesNo) in virDomainBackupDefParse
device_conf: Use virXMLProp(OnOff|YesNo) in
virPCIDeviceAddressParseXML
network_conf: Use virXMLProp(OnOff|YesNo) in
virNetworkForwardNatDefParseXML
numa_conf: Use virXMLProp(OnOff|YesNo) in virDomainNumaDefParseXML
storage_adapter_conf: Use virXMLProp(OnOff|YesNo) in
virStorageAdapterParseXMLFCHost
storage_conf: Use virXMLProp(OnOff|YesNo) in
virStoragePoolDefParseSource
src/conf/backup_conf.c | 32 +-
src/conf/device_conf.c | 10 +-
src/conf/domain_conf.c | 791 +++++++++-----------------------
src/conf/network_conf.c | 15 +-
src/conf/numa_conf.c | 13 +-
src/conf/storage_adapter_conf.c | 17 +-
src/conf/storage_adapter_conf.h | 2 +-
src/conf/storage_conf.c | 16 +-
src/util/virxml.c | 74 +++
src/util/virxml.h | 7 +
10 files changed, 314 insertions(+), 663 deletions(-)
--
2.26.2
3 years, 8 months
[PATCH v6 00/10] Configurable policy for handling deprecated interfaces
by Markus Armbruster
New option -compat lets you configure what to do when deprecated
interfaces get used. This is intended for testing users of the
management interfaces. It is experimental.
-compat deprecated-input=<in-policy> configures what to do when
deprecated input is received. Available policies:
* accept: Accept deprecated commands and arguments (default)
* reject: Reject them
* crash: Crash
-compat deprecated-output=<out-policy> configures what to do when
deprecated output is sent. Available output policies:
* accept: Emit deprecated command results and events (default)
* hide: Suppress them
For now, -compat covers only deprecated syntactic aspects of QMP. We
may want to extend it to cover semantic aspects, CLI, and experimental
features.
v6:
* Rebased, with straightforward conflicts
* PATCH 1: More verbose commit message, explaining intent, and the
lack of introspection [Peter], comments updated for 6.0, Eric's R-by
kept anyway
* PATCH 5+6: Split old PATCH 5 [Eric], Eric's R-by lept anyway
* PATCH 7: New, correcting a latent issue so it doesn't break PATCH 8
* PATCH 10: Doc fix [Eric]
v5:
* Old PATCH 01-26 merged in commit f57587c7d47.
* Rebased, non-trivial conflicts in PATCH 1 due to Meson, and in PATCH
7 due to visitor changes
* PATCH 1: Comments updated for 5.2 [Eric]
* PATCH 2: Harmless missing initialization fixed [Eric]
* PATCH 3+4: Harmless missing has_FOO = true fixed [Eric]
* PATCH 6+7: Commit message tweaked
v4:
* PATCH 05+07: Temporary memory leak plugged [Marc-André]
* PATCH 23: Rewritten [Marc-André]
* PATCH 24: Comment typo [Marc-André]
* PATCH 30: Memory leaks plugged
v3:
* Rebased, non-trivial conflicts in PATCH 01+26+27+34 due to RST
conversion and code motion
* PATCH 28-29: Old PATCH 28 split up to ease review
* PATCH 30-31: New
* PATCH 32-33: Old PATCH 29 split up to ease review
Comparison to RFC (24 Oct 2019):
* Cover arguments and results in addition to commands and events
* Half-baked "[RFC PATCH 18/19] qapi: Include a warning in the
response to a deprecated command" dropped
See also last item of
Subject: Minutes of KVM Forum BoF on deprecating stuff
Date: Fri, 26 Oct 2018 16:03:51 +0200
Message-ID: <87mur0ls8o.fsf(a)dusky.pond.sub.org>
https://lists.nongnu.org/archive/html/qemu-devel/2018-10/msg05828.html
Cc: Lukáš Doktor <ldoktor(a)redhat.com>
Cc: libguestfs(a)redhat.com
Cc: libvir-list(a)redhat.com
Cc: Daniel P. Berrange <berrange(a)redhat.com>
Cc: Peter Krempa <pkrempa(a)redhat.com>
Cc: Kevin Wolf <kwolf(a)redhat.com>
Markus Armbruster (10):
qemu-options: New -compat to set policy for deprecated interfaces
qapi: Implement deprecated-output=hide for QMP command results
qapi: Implement deprecated-output=hide for QMP events
qapi: Implement deprecated-output=hide for QMP event data
monitor: Drop query-qmp-schema 'gen': false hack
qapi: Implement deprecated-output=hide for QMP introspection
test-util-sockets: Add stub for monitor_set_cur()
qapi: Implement deprecated-input=reject for QMP commands
qapi: Implement deprecated-input=reject for QMP command arguments
qapi: New -compat deprecated-input=crash
qapi/compat.json | 52 ++++++++++++
qapi/introspect.json | 2 +-
qapi/qapi-schema.json | 1 +
include/qapi/compat-policy.h | 20 +++++
include/qapi/qmp/dispatch.h | 1 +
include/qapi/qobject-input-visitor.h | 9 +++
include/qapi/qobject-output-visitor.h | 9 +++
include/qapi/visitor-impl.h | 6 ++
include/qapi/visitor.h | 18 +++++
monitor/monitor-internal.h | 3 -
monitor/misc.c | 2 -
monitor/qmp-cmds-control.c | 100 +++++++++++++++++++++---
qapi/qapi-visit-core.c | 18 +++++
qapi/qmp-dispatch.c | 17 ++++
qapi/qobject-input-visitor.c | 29 +++++++
qapi/qobject-output-visitor.c | 19 +++++
softmmu/vl.c | 17 ++++
storage-daemon/qemu-storage-daemon.c | 2 -
tests/test-qmp-cmds.c | 91 +++++++++++++++++++--
tests/test-qmp-event.c | 41 ++++++++++
tests/test-util-sockets.c | 1 +
qapi/meson.build | 1 +
qapi/trace-events | 2 +
qemu-options.hx | 22 ++++++
scripts/qapi/commands.py | 14 ++--
scripts/qapi/events.py | 20 ++++-
scripts/qapi/visit.py | 15 ++++
tests/qapi-schema/qapi-schema-test.json | 20 +++--
tests/qapi-schema/qapi-schema-test.out | 20 ++---
29 files changed, 522 insertions(+), 50 deletions(-)
create mode 100644 qapi/compat.json
create mode 100644 include/qapi/compat-policy.h
--
2.26.2
3 years, 8 months
[PATCH v2 0/2] XML non-virtio video device validation
by Kristina Hanicova
Kristina Hanicova (2):
move virDomainCheckVirtioOptionsAreAbsent a few lines forward
XML validate that non-virtio video devices have none virtio options
src/conf/domain_validate.c | 60 ++++++++++++++++++++------------------
1 file changed, 32 insertions(+), 28 deletions(-)
--
2.29.2
3 years, 8 months
[PATCH 0/2] refactoring conf for virDomainDeviceInfoParseXML to use XPath
by Kristina Hanicova
Kristina Hanicova (2):
conf: Propagate xmlXPathContextPtr into virDomainDeviceInfoParseXML()
refactoring virDomainDeviceInfoParseXML to use XPath
src/conf/domain_conf.c | 116 +++++++++++++++++------------------------
1 file changed, 49 insertions(+), 67 deletions(-)
--
2.29.2
3 years, 8 months
[PATCH v2] bhyve: add <os firmware='efi'> support
by Roman Bogorodskiy
Implement "<os firmware='efi'>" support for bhyve driver.
As there are not really lot of options, try to find
"BHYVE_UEFI.fd" firmware which is installed by the
sysutils/uefi-edk2-bhyve FreeBSD port.
If not found, just use the first found firmware
in the firmwares directory (which is configurable via
config file).
Signed-off-by: Roman Bogorodskiy <bogorodskiy(a)gmail.com>
---
Changes from v1:
- Fixed various leaks,
- Re-implemented testing using opendir() mock.
po/POTFILES.in | 1 +
src/bhyve/bhyve_domain.c | 5 +
src/bhyve/bhyve_firmware.c | 91 +++++++++++++++++++
src/bhyve/bhyve_firmware.h | 30 ++++++
src/bhyve/bhyve_process.c | 15 +++
src/bhyve/bhyve_process.h | 5 +
src/bhyve/bhyve_utils.h | 2 +
src/bhyve/meson.build | 1 +
tests/bhyvefirmwaredata/empty/.keepme | 0
.../three_firmwares/BHYVE_UEFI.fd | 0
.../three_firmwares/BHYVE_UEFI_CSM.fd | 0
.../three_firmwares/refind_x64.efi | 0
.../bhyvexml2argv-firmware-efi.args | 11 +++
.../bhyvexml2argv-firmware-efi.ldargs | 1 +
.../bhyvexml2argv-firmware-efi.xml | 22 +++++
tests/bhyvexml2argvmock.c | 33 +++++++
tests/bhyvexml2argvtest.c | 52 ++++++++---
17 files changed, 257 insertions(+), 12 deletions(-)
create mode 100644 src/bhyve/bhyve_firmware.c
create mode 100644 src/bhyve/bhyve_firmware.h
create mode 100644 tests/bhyvefirmwaredata/empty/.keepme
create mode 100644 tests/bhyvefirmwaredata/three_firmwares/BHYVE_UEFI.fd
create mode 100644 tests/bhyvefirmwaredata/three_firmwares/BHYVE_UEFI_CSM.fd
create mode 100644 tests/bhyvefirmwaredata/three_firmwares/refind_x64.efi
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.xml
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 80c5f145be..413783ee35 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,6 +14,7 @@
@SRCDIR(a)src/bhyve/bhyve_command.c
@SRCDIR(a)src/bhyve/bhyve_domain.c
@SRCDIR(a)src/bhyve/bhyve_driver.c
+@SRCDIR(a)src/bhyve/bhyve_firmware.c
@SRCDIR(a)src/bhyve/bhyve_monitor.c
@SRCDIR(a)src/bhyve/bhyve_parse_command.c
@SRCDIR(a)src/bhyve/bhyve_process.c
diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 8fbc554a0a..209e4d3905 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -64,6 +64,9 @@ bhyveDomainDefNeedsISAController(virDomainDefPtr def)
if (def->os.bootloader == NULL && def->os.loader)
return true;
+ if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI)
+ return true;
+
if (def->nserials || def->nconsoles)
return true;
@@ -230,6 +233,8 @@ virDomainDefParserConfig virBhyveDriverDomainDefParserConfig = {
.domainPostParseCallback = bhyveDomainDefPostParse,
.assignAddressesCallback = bhyveDomainDefAssignAddresses,
.deviceValidateCallback = bhyveDomainDeviceDefValidate,
+
+ .features = VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT,
};
static void
diff --git a/src/bhyve/bhyve_firmware.c b/src/bhyve/bhyve_firmware.c
new file mode 100644
index 0000000000..2055f34288
--- /dev/null
+++ b/src/bhyve/bhyve_firmware.c
@@ -0,0 +1,91 @@
+/*
+ * bhyve_firmware.c: bhyve firmware management
+ *
+ * Copyright (C) 2021 Roman Bogorodskiy
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <config.h>
+#include <dirent.h>
+
+#include "viralloc.h"
+#include "virlog.h"
+#include "virfile.h"
+#include "bhyve_conf.h"
+#include "bhyve_firmware.h"
+
+#define VIR_FROM_THIS VIR_FROM_BHYVE
+
+VIR_LOG_INIT("bhyve.bhyve_firmware");
+
+
+#define BHYVE_DEFAULT_FIRMWARE "BHYVE_UEFI.fd"
+
+int
+bhyveFirmwareFillDomain(bhyveConnPtr driver,
+ virDomainDefPtr def,
+ unsigned int flags)
+{
+ g_autoptr(DIR) dir = NULL;
+ g_autoptr(virBhyveDriverConfig) cfg = virBhyveDriverGetConfig(driver);
+ const char *firmware_dir = cfg->firmwareDir;
+ struct dirent *entry;
+ g_autofree char *matching_firmware = NULL;
+ g_autofree char *first_found = NULL;
+
+ virCheckFlags(0, -1);
+
+ if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_NONE)
+ return 0;
+
+ if (virDirOpenIfExists(&dir, firmware_dir) > 0) {
+ while ((virDirRead(dir, &entry, firmware_dir)) > 0) {
+ if (g_str_has_prefix(entry->d_name, "."))
+ continue;
+
+ if (STREQ(entry->d_name, BHYVE_DEFAULT_FIRMWARE)) {
+ matching_firmware = g_strdup(entry->d_name);
+ break;
+ }
+ if (!first_found)
+ first_found = g_strdup(entry->d_name);
+ }
+ }
+
+ if (!matching_firmware) {
+ if (!first_found) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("no firmwares found in %s"),
+ firmware_dir);
+ return -1;
+ } else {
+ matching_firmware = g_steal_pointer(&first_found);
+ }
+ }
+
+ if (!def->os.loader)
+ def->os.loader = g_new0(virDomainLoaderDef, 1);
+
+ def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
+ def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
+
+ VIR_FREE(def->os.loader->path);
+
+ def->os.loader->path = g_build_filename(firmware_dir, matching_firmware, NULL);
+
+ return 0;
+}
diff --git a/src/bhyve/bhyve_firmware.h b/src/bhyve/bhyve_firmware.h
new file mode 100644
index 0000000000..ae4bc98676
--- /dev/null
+++ b/src/bhyve/bhyve_firmware.h
@@ -0,0 +1,30 @@
+/*
+ * bhyve_firmware.h: bhyve firmware management
+ *
+ * Copyright (C) 2021 Roman Bogorodskiy
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include "domain_conf.h"
+#include "bhyve_utils.h"
+
+int
+bhyveFirmwareFillDomain(bhyveConnPtr driver,
+ virDomainDefPtr def,
+ unsigned int flags);
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index 060018bc70..0cfe69688c 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -33,6 +33,7 @@
#include "bhyve_device.h"
#include "bhyve_driver.h"
#include "bhyve_command.h"
+#include "bhyve_firmware.h"
#include "bhyve_monitor.h"
#include "bhyve_process.h"
#include "datatypes.h"
@@ -251,6 +252,17 @@ virBhyveProcessStartImpl(bhyveConnPtr driver,
return ret;
}
+int
+bhyveProcessPrepareDomain(bhyveConnPtr driver,
+ virDomainObjPtr vm,
+ unsigned int flags)
+{
+ if (bhyveFirmwareFillDomain(driver, vm->def, flags) < 0)
+ return -1;
+
+ return 0;
+}
+
int
virBhyveProcessStart(virConnectPtr conn,
virDomainObjPtr vm,
@@ -268,6 +280,9 @@ virBhyveProcessStart(virConnectPtr conn,
conn, bhyveProcessAutoDestroy) < 0)
return -1;
+ if (bhyveProcessPrepareDomain(driver, vm, flags) < 0)
+ return -1;
+
return virBhyveProcessStartImpl(driver, vm, reason);
}
diff --git a/src/bhyve/bhyve_process.h b/src/bhyve/bhyve_process.h
index d7b4e0bd4e..133863c1e0 100644
--- a/src/bhyve/bhyve_process.h
+++ b/src/bhyve/bhyve_process.h
@@ -23,6 +23,11 @@
#include "bhyve_utils.h"
+int
+bhyveProcessPrepareDomain(bhyveConnPtr driver,
+ virDomainObjPtr vm,
+ unsigned int flags);
+
int virBhyveProcessStart(virConnectPtr conn,
virDomainObjPtr vm,
virDomainRunningReason reason,
diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h
index f3e80b6121..3bf5ae5daf 100644
--- a/src/bhyve/bhyve_utils.h
+++ b/src/bhyve/bhyve_utils.h
@@ -43,6 +43,8 @@ struct _virBhyveDriverConfig {
char *firmwareDir;
};
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virBhyveDriverConfig, virObjectUnref);
+
struct _bhyveConn {
virMutex lock;
diff --git a/src/bhyve/meson.build b/src/bhyve/meson.build
index 2b65eecf5e..b3551477b7 100644
--- a/src/bhyve/meson.build
+++ b/src/bhyve/meson.build
@@ -2,6 +2,7 @@ bhyve_sources = files(
'bhyve_capabilities.c',
'bhyve_command.c',
'bhyve_conf.c',
+ 'bhyve_firmware.c',
'bhyve_parse_command.c',
'bhyve_device.c',
'bhyve_domain.c',
diff --git a/tests/bhyvefirmwaredata/empty/.keepme b/tests/bhyvefirmwaredata/empty/.keepme
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/bhyvefirmwaredata/three_firmwares/BHYVE_UEFI.fd b/tests/bhyvefirmwaredata/three_firmwares/BHYVE_UEFI.fd
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/bhyvefirmwaredata/three_firmwares/BHYVE_UEFI_CSM.fd b/tests/bhyvefirmwaredata/three_firmwares/BHYVE_UEFI_CSM.fd
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/bhyvefirmwaredata/three_firmwares/refind_x64.efi b/tests/bhyvefirmwaredata/three_firmwares/refind_x64.efi
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args b/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args
new file mode 100644
index 0000000000..2f5aa4d783
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.args
@@ -0,0 +1,11 @@
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-l bootrom,fakefirmwaredir/BHYVE_UEFI.fd \
+-s 1:0,lpc \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.ldargs
new file mode 100644
index 0000000000..421376db9e
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.ldargs
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.xml
new file mode 100644
index 0000000000..302326cb26
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-firmware-efi.xml
@@ -0,0 +1,22 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os firmware='efi'>
+ <type>hvm</type>
+ </os>
+ <devices>
+ <disk type='file'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <interface type='bridge'>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c
index 25b97f5e04..af5e0fd4b9 100644
--- a/tests/bhyvexml2argvmock.c
+++ b/tests/bhyvexml2argvmock.c
@@ -1,13 +1,46 @@
#include <config.h>
+#include <dirent.h>
+
#include "viralloc.h"
#include "virstring.h"
#include "virnetdev.h"
#include "virnetdevtap.h"
+#include "virmock.h"
#include "internal.h"
#define VIR_FROM_THIS VIR_FROM_BHYVE
+static DIR * (*real_opendir)(const char *name);
+
+static void
+init_syms(void)
+{
+ VIR_MOCK_REAL_INIT(opendir);
+}
+
+#define FAKEFIRMWAREDIR abs_srcdir "/bhyvefirmwaredata/three_firmwares"
+#define FAKEFIRMWAREEMPTYDIR abs_srcdir "/bhyvefirmwaredata/empty"
+
+DIR *
+opendir(const char *path)
+{
+ init_syms();
+
+ g_autofree char *path_override = NULL;
+
+ if (STREQ(path, "fakefirmwaredir")) {
+ path_override = g_strdup(FAKEFIRMWAREDIR);
+ } else if (STREQ(path, "fakefirmwareemptydir")) {
+ path_override = g_strdup(FAKEFIRMWAREEMPTYDIR);
+ }
+
+ if (!path_override)
+ path_override = g_strdup(path);
+
+ return real_opendir(path_override);
+}
+
void virMacAddrGenerate(const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN],
virMacAddrPtr addr)
{
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index 197334f9c4..34e40a6438 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -7,17 +7,20 @@
# include "datatypes.h"
# include "bhyve/bhyve_capabilities.h"
+# include "bhyve/bhyve_conf.h"
# include "bhyve/bhyve_domain.h"
# include "bhyve/bhyve_utils.h"
# include "bhyve/bhyve_command.h"
+# include "bhyve/bhyve_process.h"
# define VIR_FROM_THIS VIR_FROM_BHYVE
static bhyveConn driver;
typedef enum {
- FLAG_EXPECT_FAILURE = 1 << 0,
- FLAG_EXPECT_PARSE_ERROR = 1 << 1,
+ FLAG_EXPECT_FAILURE = 1 << 0,
+ FLAG_EXPECT_PARSE_ERROR = 1 << 1,
+ FLAG_EXPECT_PREPARE_ERROR = 1 << 2,
} virBhyveXMLToArgvTestFlags;
static int testCompareXMLToArgvFiles(const char *xml,
@@ -29,7 +32,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
g_autofree char *actualargv = NULL;
g_autofree char *actualld = NULL;
g_autofree char *actualdm = NULL;
- g_autoptr(virDomainDef) vmdef = NULL;
+ g_autoptr(virDomainObj) vm = NULL;
g_autoptr(virCommand) cmd = NULL;
g_autoptr(virCommand) ldcmd = NULL;
g_autoptr(virConnect) conn = NULL;
@@ -38,8 +41,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (!(conn = virGetConnect()))
goto out;
- if (!(vmdef = virDomainDefParseFile(xml, driver.xmlopt,
- NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
+ if (!(vm = virDomainObjNew(driver.xmlopt)))
+ return -1;
+
+ if (!(vm->def = virDomainDefParseFile(xml, driver.xmlopt,
+ NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
if (flags & FLAG_EXPECT_PARSE_ERROR) {
ret = 0;
} else if (flags & FLAG_EXPECT_FAILURE) {
@@ -54,11 +60,20 @@ static int testCompareXMLToArgvFiles(const char *xml,
conn->privateData = &driver;
- cmd = virBhyveProcessBuildBhyveCmd(&driver, vmdef, false);
- if (vmdef->os.loader)
+ if (bhyveProcessPrepareDomain(&driver, vm, 0) < 0) {
+ if (flags & FLAG_EXPECT_PREPARE_ERROR) {
+ ret = 0;
+ VIR_TEST_DEBUG("Got expected error: %s",
+ virGetLastErrorMessage());
+ }
+ goto out;
+ }
+
+ cmd = virBhyveProcessBuildBhyveCmd(&driver, vm->def, false);
+ if (vm->def->os.loader)
ldcmd = virCommandNew("dummy");
else
- ldcmd = virBhyveProcessBuildLoadCmd(&driver, vmdef, "<device.map>",
+ ldcmd = virBhyveProcessBuildLoadCmd(&driver, vm->def, "<device.map>",
&actualdm);
if ((cmd == NULL) || (ldcmd == NULL)) {
@@ -94,10 +109,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0;
out:
- if (vmdef &&
- vmdef->ngraphics == 1 &&
- vmdef->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC)
- virPortAllocatorRelease(vmdef->graphics[0]->data.vnc.port);
+ if (vm && vm->def &&
+ vm->def->ngraphics == 1 &&
+ vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC)
+ virPortAllocatorRelease(vm->def->graphics[0]->data.vnc.port);
return ret;
}
@@ -132,6 +147,8 @@ static int
mymain(void)
{
int ret = 0;
+ g_autofree char *fakefirmwaredir = g_strdup("fakefirmwaredir");
+ g_autofree char *fakefirmwareemptydir = g_strdup("fakefirmwareemptydir");
if ((driver.caps = virBhyveCapsBuild()) == NULL)
return EXIT_FAILURE;
@@ -142,6 +159,10 @@ mymain(void)
if (!(driver.remotePorts = virPortAllocatorRangeNew("display", 5900, 65535)))
return EXIT_FAILURE;
+ if (!(driver.config = virBhyveDriverConfigNew()))
+ return EXIT_FAILURE;
+
+ driver.config->firmwareDir = fakefirmwaredir;
# define DO_TEST_FULL(name, flags) \
do { \
@@ -162,6 +183,9 @@ mymain(void)
# define DO_TEST_PARSE_ERROR(name) \
DO_TEST_FULL(name, FLAG_EXPECT_PARSE_ERROR)
+# define DO_TEST_PREPARE_ERROR(name) \
+ DO_TEST_FULL(name, FLAG_EXPECT_PREPARE_ERROR)
+
driver.grubcaps = BHYVE_GRUB_CAP_CONSDEV;
driver.bhyvecaps = BHYVE_CAP_RTC_UTC | BHYVE_CAP_AHCI32SLOT | \
BHYVE_CAP_NET_E1000 | BHYVE_CAP_LPC_BOOTROM | \
@@ -209,6 +233,9 @@ mymain(void)
DO_TEST("sound");
DO_TEST("isa-controller");
DO_TEST_FAILURE("isa-multiple-controllers");
+ DO_TEST("firmware-efi");
+ driver.config->firmwareDir = fakefirmwareemptydir;
+ DO_TEST_PREPARE_ERROR("firmware-efi");
DO_TEST("fs-9p");
DO_TEST("fs-9p-readonly");
DO_TEST_FAILURE("fs-9p-unsupported-type");
@@ -267,6 +294,7 @@ mymain(void)
virObjectUnref(driver.caps);
virObjectUnref(driver.xmlopt);
virPortAllocatorRangeFree(driver.remotePorts);
+ virObjectUnref(driver.config);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
--
2.30.0
3 years, 8 months
[libvirt PATCH] nodedev: Don't crash when exiting before init is done
by Jonathon Jongsma
If libvirtd is terminated before the node driver finishes
initialization, it can crash with a backtrace similar to the following:
Stack trace of thread 1922933:
#0 0x00007f8515178774 g_hash_table_find (libglib-2.0.so.0)
#1 0x00007f851593ea98 virHashSearch (libvirt.so.0)
#2 0x00007f8515a1dd83 virNodeDeviceObjListSearch (libvirt.so.0)
#3 0x00007f84cceb40a1 udevAddOneDevice (libvirt_driver_nodedev.so)
#4 0x00007f84cceb5fae nodeStateInitializeEnumerate (libvirt_driver_nodedev.so)
#5 0x00007f85159840cb virThreadHelper (libvirt.so.0)
#6 0x00007f8511c7d14a start_thread (libpthread.so.0)
#7 0x00007f851442bdb3 __clone (libc.so.6)
Stack trace of thread 1922863:
#0 0x00007f851442651d syscall (libc.so.6)
#1 0x00007f85159842d4 virThreadSelfID (libvirt.so.0)
#2 0x00007f851594e240 virLogFormatString (libvirt.so.0)
#3 0x00007f851596635d vir_object_finalize (libvirt.so.0)
#4 0x00007f8514efe8e9 g_object_unref (libgobject-2.0.so.0)
#5 0x00007f85159667f8 virObjectUnref (libvirt.so.0)
#6 0x00007f851517755f g_hash_table_remove_all_nodes.part.0 (libglib-2.0.so.0)
#7 0x00007f8515177e62 g_hash_table_unref (libglib-2.0.so.0)
#8 0x00007f851596637e vir_object_finalize (libvirt.so.0)
#9 0x00007f8514efe8e9 g_object_unref (libgobject-2.0.so.0)
#10 0x00007f85159667f8 virObjectUnref (libvirt.so.0)
#11 0x00007f84cceb2b42 nodeStateCleanup (libvirt_driver_nodedev.so)
#12 0x00007f8515b37950 virStateCleanup (libvirt.so.0)
#13 0x00005648085348e8 main (libvirtd)
#14 0x00007f8514352493 __libc_start_main (libc.so.6)
#15 0x00005648085350fe _start (libvirtd)
This is because the initial population of the device list is done in a
separate initialization thread. If we attempt to exit libvirtd before
this init thread has completed, we'll try to free the device list while
accessing it from the other thread. In order to guarantee that this
init thread is not accessing the device list when we're cleaning up the
nodedev driver, make it joinable and wait for it to finish before
proceding with the cleanup. This is similar to how we handle the udev
event handler thread.
The separate initialization thread was added in commit
9f0ae0b1.
https://bugzilla.redhat.com/show_bug.cgi?id=1933590
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/node_device/node_device_udev.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index fe25f8235e..010ebf4e74 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -66,6 +66,9 @@ struct _udevEventData {
virCond threadCond;
bool threadQuit;
bool dataReady;
+
+ /* init thread */
+ virThread initThread;
};
static virClassPtr udevEventDataClass;
@@ -1660,6 +1663,7 @@ nodeStateCleanup(void)
priv->threadQuit = true;
virCondSignal(&priv->threadCond);
virObjectUnlock(priv);
+ virThreadJoin(&priv->initThread);
virThreadJoin(&priv->th);
}
@@ -1995,7 +1999,6 @@ nodeStateInitialize(bool privileged,
{
udevEventDataPtr priv = NULL;
struct udev *udev = NULL;
- virThread enumThread;
if (root != NULL) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -2103,7 +2106,7 @@ nodeStateInitialize(bool privileged,
if (udevSetupSystemDev() != 0)
goto cleanup;
- if (virThreadCreateFull(&enumThread, false, nodeStateInitializeEnumerate,
+ if (virThreadCreateFull(&priv->initThread, true, nodeStateInitializeEnumerate,
"nodedev-init", false, udev) < 0) {
virReportSystemError(errno, "%s",
_("failed to create udev enumerate thread"));
--
2.26.2
3 years, 8 months
[PATCH] virxml: Fix possible memory leak in virXMLNodeContentString()
by Kristina Hanicova
Previously, if xml node passed to the virXMLNodeContentString()
was not of type XML_ELEMENT_NODE, @ret could have caused a memory
leak because xmlNodeGetContent() works for other types of nodes
as well.
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/util/virxml.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/util/virxml.c b/src/util/virxml.c
index 060b7530fc..4a6fe09468 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -536,7 +536,7 @@ virXMLPropStringLimit(xmlNodePtr node,
char *
virXMLNodeContentString(xmlNodePtr node)
{
- char *ret = (char *)xmlNodeGetContent(node);
+ char *ret = NULL;
if (node->type != XML_ELEMENT_NODE) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -545,6 +545,8 @@ virXMLNodeContentString(xmlNodePtr node)
return NULL;
}
+ ret = (char *)xmlNodeGetContent(node);
+
if (!ret) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("node '%s' has unexpected NULL content. This could be caused by malformed input, or a memory allocation failure"),
--
2.29.2
3 years, 8 months