[PATCH] qemu: Use virDomainObjCheckActive() more
by Michal Privoznik
Using the following spatch, I've identified two places which
could be switched from explicit virDomainObjIsActive() +
virReportError() to virDomainObjCheckActive():
@@
expression dom;
@@
if (
- !virDomainObjIsActive(dom)
+ virDomainObjCheckActive(dom) < 0
) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not running"));
...
}
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
BTW. if I'm more aggressive and let virReportError() have just any args
then even more places fit the rule (approx. two dozen more).
src/qemu/qemu_driver.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 70d51855b2..e417d358cd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19924,9 +19924,7 @@ qemuDomainGetSEVInfo(virQEMUDriver *driver,
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
return -1;
- if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("domain is not running"));
+ if (virDomainObjCheckActive(vm) < 0) {
goto endjob;
}
@@ -20744,9 +20742,7 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
- if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("domain is not running"));
+ if (virDomainObjCheckActive(vm) < 0) {
goto endjob;
}
--
2.34.1
2 years, 9 months
[PATCH v6 0/8] support mode option for dirtyrate calculation
by huangy81@chinatelecom.cn
From: Hyman Huang(黄勇) <huangy81(a)chinatelecom.cn>
v6:
- rebase on mastr
- drop the commit [PATCH v5 1/9] in this patchset, post an extra
commit if needed in the future.
Please review, thanks !
Regards
Yong
v5:
- [PATCH v5 9/9]: Fix alignment error in qemuDomainGetStatsDirtyRate.
v4:
- Rebase the master
- [PATCH v4 1/9]: Refactor dirty page rate calculation status
implementation, display calc_status as string when
'virsh domstats --dirtyrate' api return.
- [PATCH v4 3/9]: Adjust the 'cap check' block before BeginJob().
- [PATCH v4 5/9]: Drop the virDomainDirtyRateCalcMode and introduce
internal enum qemuMonitorDirtyRateCalcMode instead.
- [PATCH v4 6/9]: Code clean.
- [PATCH v4 7/9]: Split qemu_driver logic of domdirtyrate-calc virsh
api into a separate commit.
- [PATCH v4 8/9]: Change the 'mode' parameter usage as --mode=[xxx|yyy],
code clean in qemuDomainStartDirtyRateCalc.
- [PATCH v4 9/9]: Display calc_mode as string and do code clean in
qemuMonitorJSONExtractDirtyRateInfo.
Thanks Michal and Peter for reviewing the previous versions, please review.
Regards
Yong
v3:
- Rebase the master
- [PATCH v2 2/6]: Fix the usage of virQEMUCapsGet
- [PATCH v2 4/6]: Fix the cleanup missed in qemuDomainStartDirtyRateCalc
- [PATCH v2 4/6]: Move all blocks below ACL check
- [PATCH v2 4/6]: Make the qemuMonitorJSONStartDirtyRateCalc cleaner by
merging the different case of qemuMonitorJSONMakeCommand
- [PATCH v2 4/6]: Code clean, make the error message not be line-broken
- [PATCH v2 5/6]: Abstract the enum definition into a standalone commit
- [PATCH v2 5/6]: Move the validations code above calculating flags block
- [PATCH v2 6/6]: Change the type of 'value' field to unsigned in
struct qemuMonitorDirtyRateVcpu
- [PATCH v2 6/6]: Rename the enum type qemuMonitorDirtyRateCalcMode to
virDomainDirtyRateCalcMode
- [PATCH v2 6/6]: Code clean, align the code in qemuDomainGetStatsDirtyRate
Thanks Peter for quick and precise response, please review.
Regards
Yong
v2:
Rebase master and fix confilicts with commit
"Introduce QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_PREALLOC"
Thanks !
v1:
This patchset introduce mode option as the supplement of
qemuDomainStartDirtyRateCalc api, add calc_mode for dirtyrate
statistics correspondingly.
Qemu add mode parameter for calc-dirty-rate command since >= 6.2.0,
either of these three mode "page-sampling, dirty-bitmap, dirty-ring"
can be specified when calculating dirty page rate.
Page sampling is the original mode and used as default mode.
Dirty bitmap mode use kvm log sync api to fetch the dirty-bitmap
and count the increased 1 bits number during measurement, thus,
calculate the dirty page rate.
Dirty ring mode use the dirty-ring mechanism implemented in Qemu
which can count the increased dirty page on virtual cpu granularity,
thus, calculate the per-vcpu dirty page rate.
These three calculation mode can be used in different scenarios, and
the dirty-bitmap, dirty-ring mode may be more accurate to a certain
degree. So maybe it's time to support the mode option for dirtyrate
calculation.
This series make main modifications as the following:
1. introduce QEMU_CAPS_CALC_DIRTY_RATE capability to probe
calc-dirty-rate command in case of failure since it just
introduced since >= 5.2.0
2. introduce QEMU_CAPS_DIRTYRATE_MODE capability to probe
mode option of calc-dirty-rate command in case of failure, same
as 1.
3. implement mode option support for dirtyrate calculation.
Please review, thanks !
Best Regards !
Hyman Huang(黄勇) (8):
qemu_capabilities: Introduce QEMU_CAPS_CALC_DIRTY_RATE capability
qemu_driver: Probe capability before calculating dirty page rate
qemu_capabilities: Introduce QEMU_CAPS_DIRTYRATE_MODE capability
include: Introduce virDomainDirtyRateCalcFlags
qemu_driver: Add mode parameter to qemuDomainStartDirtyRateCalc
qemu_driver: Extend flags parameter of virDomainStartDirtyRateCalc
virsh: Add mode option to domdirtyrate-calc virsh api
qemu_driver: Add calc_mode for dirtyrate statistics
docs/manpages/virsh.rst | 7 ++-
include/libvirt/libvirt-domain.h | 13 +++++
src/libvirt-domain.c | 18 +++++-
src/qemu/qemu_capabilities.c | 4 ++
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_driver.c | 56 ++++++++++++++++--
src/qemu/qemu_monitor.c | 5 +-
src/qemu/qemu_monitor.h | 27 ++++++++-
src/qemu/qemu_monitor_json.c | 69 ++++++++++++++++++++++-
src/qemu/qemu_monitor_json.h | 3 +-
tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml | 1 +
tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 1 +
tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml | 1 +
tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml | 1 +
tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml | 1 +
tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml | 2 +
tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml | 2 +
tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 2 +
tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml | 2 +
tools/virsh-completer-domain.c | 17 ++++++
tools/virsh-completer-domain.h | 4 ++
tools/virsh-domain.c | 42 +++++++++++++-
tools/virsh-domain.h | 9 +++
28 files changed, 278 insertions(+), 16 deletions(-)
--
1.8.3.1
2 years, 9 months
[PATCH v2 0/4] qemu: Introduce 'virDomainQemuMonitorCommandWithFiles'
by Peter Krempa
I was doing some tests with 'add-fd' and 'getfd' and made this to help
me.
v2:
- add API support for passing FDs back, but for now we don't have
use for it
Peter Krempa (4):
virnetmessage: Introduce virNetMessageClearFDs
lib: Introduce 'virDomainQemuMonitorCommandWithFiles'
virsh: Implement support for virDomainQemuMonitorCommandWithFiles
qemu: Implement qemuDomainQemuMonitorCommandWithFiles
docs/manpages/virsh.rst | 6 +-
include/libvirt/libvirt-qemu.h | 8 +++
src/driver-hypervisor.h | 10 ++++
src/libvirt-qemu.c | 89 +++++++++++++++++++++++++++++
src/libvirt_qemu.syms | 5 ++
src/libvirt_remote.syms | 1 +
src/qemu/qemu_driver.c | 42 ++++++++++++--
src/qemu/qemu_monitor.c | 7 ++-
src/qemu/qemu_monitor.h | 1 +
src/qemu/qemu_monitor_json.c | 6 +-
src/qemu/qemu_monitor_json.h | 2 +
src/qemu/qemu_monitor_text.c | 8 +--
src/qemu_protocol-structs | 9 +++
src/remote/qemu_protocol.x | 20 ++++++-
src/remote/remote_daemon_dispatch.c | 62 ++++++++++++++++++++
src/remote/remote_driver.c | 57 ++++++++++++++++++
src/rpc/virnetmessage.c | 9 ++-
src/rpc/virnetmessage.h | 1 +
tools/virsh-domain.c | 19 +++++-
19 files changed, 345 insertions(+), 17 deletions(-)
--
2.35.1
2 years, 9 months
[PATCH v5 0/9] support mode option for dirtyrate calculation
by huangy81@chinatelecom.cn
From: Hyman Huang(黄勇) <huangy81(a)chinatelecom.cn>
v5:
- [PATCH v5 9/9]: Fix alignment error in qemuDomainGetStatsDirtyRate.
v4:
- Rebase the master
- [PATCH v4 1/9]: Refactor dirty page rate calculation status
implementation, display calc_status as string when
'virsh domstats --dirtyrate' api return.
- [PATCH v4 3/9]: Adjust the 'cap check' block before BeginJob().
- [PATCH v4 5/9]: Drop the virDomainDirtyRateCalcMode and introduce
internal enum qemuMonitorDirtyRateCalcMode instead.
- [PATCH v4 6/9]: Code clean.
- [PATCH v4 7/9]: Split qemu_driver logic of domdirtyrate-calc virsh
api into a separate commit.
- [PATCH v4 8/9]: Change the 'mode' parameter usage as --mode=[xxx|yyy],
code clean in qemuDomainStartDirtyRateCalc.
- [PATCH v4 9/9]: Display calc_mode as string and do code clean in
qemuMonitorJSONExtractDirtyRateInfo.
Thanks Michal and Peter for reviewing the previous versions, please review.
Regards
Yong
v3:
- Rebase the master
- [PATCH v2 2/6]: Fix the usage of virQEMUCapsGet
- [PATCH v2 4/6]: Fix the cleanup missed in qemuDomainStartDirtyRateCalc
- [PATCH v2 4/6]: Move all blocks below ACL check
- [PATCH v2 4/6]: Make the qemuMonitorJSONStartDirtyRateCalc cleaner by
merging the different case of qemuMonitorJSONMakeCommand
- [PATCH v2 4/6]: Code clean, make the error message not be line-broken
- [PATCH v2 5/6]: Abstract the enum definition into a standalone commit
- [PATCH v2 5/6]: Move the validations code above calculating flags block
- [PATCH v2 6/6]: Change the type of 'value' field to unsigned in
struct qemuMonitorDirtyRateVcpu
- [PATCH v2 6/6]: Rename the enum type qemuMonitorDirtyRateCalcMode to
virDomainDirtyRateCalcMode
- [PATCH v2 6/6]: Code clean, align the code in qemuDomainGetStatsDirtyRate
Thanks Peter for quick and precise response, please review.
Regards
Yong
v2:
Rebase master and fix confilicts with commit
"Introduce QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_PREALLOC"
Thanks !
v1:
This patchset introduce mode option as the supplement of
qemuDomainStartDirtyRateCalc api, add calc_mode for dirtyrate
statistics correspondingly.
Qemu add mode parameter for calc-dirty-rate command since >= 6.2.0,
either of these three mode "page-sampling, dirty-bitmap, dirty-ring"
can be specified when calculating dirty page rate.
Page sampling is the original mode and used as default mode.
Dirty bitmap mode use kvm log sync api to fetch the dirty-bitmap
and count the increased 1 bits number during measurement, thus,
calculate the dirty page rate.
Dirty ring mode use the dirty-ring mechanism implemented in Qemu
which can count the increased dirty page on virtual cpu granularity,
thus, calculate the per-vcpu dirty page rate.
These three calculation mode can be used in different scenarios, and
the dirty-bitmap, dirty-ring mode may be more accurate to a certain
degree. So maybe it's time to support the mode option for dirtyrate
calculation.
This series make main modifications as the following:
1. introduce QEMU_CAPS_CALC_DIRTY_RATE capability to probe
calc-dirty-rate command in case of failure since it just
introduced since >= 5.2.0
2. introduce QEMU_CAPS_DIRTYRATE_MODE capability to probe
mode option of calc-dirty-rate command in case of failure, same
as 1.
3. implement mode option support for dirtyrate calculation.
Please review, thanks !
Best Regards !
Hyman Huang(黄勇) (9):
qemu: Refactor dirty page rate calculation status implementation
qemu_capabilities: Introduce QEMU_CAPS_CALC_DIRTY_RATE capability
qemu_driver: Probe capability before calculating dirty page rate
qemu_capabilities: Introduce QEMU_CAPS_DIRTYRATE_MODE capability
include: Introduce virDomainDirtyRateCalcFlags
qemu_driver: Add mode parameter to qemuDomainStartDirtyRateCalc
qemu_driver: Extend flags parameter of virDomainStartDirtyRateCalc
virsh: Add mode option to domdirtyrate-calc virsh api
qemu_driver: Add calc_mode for dirtyrate statistics
docs/manpages/virsh.rst | 7 ++-
include/libvirt/libvirt-domain.h | 21 +++----
src/libvirt-domain.c | 22 ++++++-
src/qemu/qemu_capabilities.c | 4 ++
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_driver.c | 63 ++++++++++++++++---
src/qemu/qemu_monitor.c | 5 +-
src/qemu/qemu_monitor.h | 45 +++++++++++++-
src/qemu/qemu_monitor_json.c | 73 +++++++++++++++++++++--
src/qemu/qemu_monitor_json.h | 3 +-
tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml | 1 +
tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 1 +
tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml | 1 +
tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml | 1 +
tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml | 1 +
tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml | 2 +
tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml | 2 +
tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 2 +
tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml | 2 +
tools/virsh-completer-domain.c | 17 ++++++
tools/virsh-completer-domain.h | 4 ++
tools/virsh-domain.c | 42 ++++++++++++-
tools/virsh-domain.h | 9 +++
28 files changed, 298 insertions(+), 37 deletions(-)
--
1.8.3.1
2 years, 9 months
[libvirt PATCH] docs: Fix template matching in page.xsl
by Martin Kletzander
Our last default template had a match of "node()" which incidentally matched
everything, including text nodes. Since this has the same priority according to
the XSLT spec, section 5.5:
https://www.w3.org/TR/1999/REC-xslt-19991116#conflict
this is an error. Also according to the same spec section, the XSLT processor
may signal the error or pick the last rule.
This was uncovered with libxslt 1.1.35 which contains the following commit:
https://gitlab.gnome.org/GNOME/libxslt/-/commit/b0074eeca3c6b21b4da14fdf7...
which makes the build fail with:
runtime error: file ../docs/page.xsl line 223 element element
xsl:element: The effective name '' is not a valid QName.
because our last rule also matches text nodes and we are trying to extract the
node name out of them.
To fix this we change the match to "*" which only matches elements and not all
the nodes, and to avoid any possible errors with different XSLT processors we
also bump the priority of the match="text()" rule a little higher, just in case
someone needs to use an XSLT processor that chooses signalling the error instead
of the optional recovery.
https://bugs.gentoo.org/833586
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
docs/page.xsl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/page.xsl b/docs/page.xsl
index fd67918d3b08..72a6fa084235 100644
--- a/docs/page.xsl
+++ b/docs/page.xsl
@@ -215,11 +215,11 @@
</xsl:element>
</xsl:template>
- <xsl:template match="text()" mode="copy">
+ <xsl:template match="text()" mode="copy" priority="0">
<xsl:value-of select="."/>
</xsl:template>
- <xsl:template match="node()" mode="copy">
+ <xsl:template match="*" mode="copy">
<xsl:element name="{name()}">
<xsl:copy-of select="./@*"/>
<xsl:apply-templates mode="copy" />
--
2.35.1
2 years, 9 months
[PATCH] libxl: Fix libvirtd crash on domain restore
by Jim Fehlig
Commit cc2a3c2a94 missed one case in the libxl driver where virDomainDef
is returned from libxlDomainSaveImageOpen and a g_steal_pointer is needed.
Without it, the virDomainDef object is freed and the driver crashes later
in the restore process when accessing the object.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index c91e531a9a..ee031267ca 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -811,7 +811,7 @@ libxlDomainSaveImageOpen(libxlDriverPrivate *driver,
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
goto error;
- *ret_def = def;
+ *ret_def = g_steal_pointer(&def);
*ret_hdr = hdr;
return fd;
--
2.35.1
2 years, 9 months
[libvirt PATCH 00/10] Automatic mutex management - part 2
by Tim Wiederhake
Use the recently implemented VIR_LOCK_GUARD and VIR_WITH_MUTEX_LOCK_GUARD
to simplify mutex management.
Tim Wiederhake (10):
vz: Use automatic mutex management
vmware: Use automatic mutex management
secret: Factor out mutex
secret: Use automatic mutex management
virlockspace: Use automatic mutex management
virtpm: Use automatic mutex management
vbox: Use automatic mutex management
tools: Use automatic mutex management
qemusecuritymock: Use automatic mutex management
qemumonitortestutils: Use automatic mutex management
src/secret/secret_driver.c | 62 ++++++++------------
src/util/virfirewall.c | 13 ++---
src/util/virlockspace.c | 106 +++++++++++------------------------
src/util/virtpm.c | 39 ++++---------
src/vbox/vbox_common.c | 18 +-----
src/vmware/vmware_driver.c | 100 ++++++++++-----------------------
src/vz/vz_driver.c | 44 +++++++--------
tests/qemumonitortestutils.c | 65 +++++++++------------
tests/qemusecuritymock.c | 88 ++++++++++-------------------
tools/virsh.c | 12 ++--
tools/virt-admin.c | 12 ++--
tools/vsh.c | 8 +--
12 files changed, 201 insertions(+), 366 deletions(-)
--
2.31.1
2 years, 9 months
[PATCH] virsystemdtest: remove unused 'demo_socket_path'
by Peter Krempa
Commit b56a833243ca7324 removed bunch of old code after which
'demo_socket_path' in 'testActivationFDNames' is no longer used
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
Pushed as a build fix (for clang).
tests/virsystemdtest.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index 9b513697e0..fcd76514e1 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -526,15 +526,12 @@ testActivationFDNames(const void *opaque G_GNUC_UNUSED)
size_t nfds = 0;
g_autoptr(virSystemdActivation) act = NULL;
g_auto(virBuffer) names = VIR_BUFFER_INITIALIZER;
- g_autofree char *demo_socket_path = NULL;
virBufferAddLit(&names, "demo-unix.socket");
if (testActivationCreateFDs(&sockUNIX, &sockIP, &nsockIP) < 0)
return -1;
- demo_socket_path = virNetSocketGetPath(sockUNIX);
-
for (i = 0; i < nsockIP; i++)
virBufferAddLit(&names, ":demo-ip.socket");
--
2.35.1
2 years, 9 months
[PATCH] libsemanage: allow spaces in user/group names
by Vit Mojzis
"semanage login -a" accepts whitespaces in user/group name
(e.g. users/groups from Active Directory), which may lead to issues down
the line since libsemanage doesn't expect whitespaces in
/var/lib/selinux/targeted/active/seusers and other config files.
Fixes:
Artificial but simple reproducer
# groupadd server_admins
# sed -i "s/^server_admins/server admins/" /etc/group
# semanage login -a -s staff_u %server\ admins
# semanage login -l (or "semodule -B")
libsemanage.parse_assert_ch: expected character ':', but found 'a' (/var/lib/selinux/targeted/active/seusers: 6):
%server admins:staff_u:s0-s0:c0.c1023 (No such file or directory).
libsemanage.seuser_parse: could not parse seuser record (No such file or directory).
libsemanage.dbase_file_cache: could not cache file database (No such file or directory).
libsemanage.enter_ro: could not enter read-only section (No such file or directory).
FileNotFoundError: [Errno 2] No such file or directory
Signed-off-by: Vit Mojzis <vmojzis(a)redhat.com>
---
libsemanage/src/booleans_file.c | 2 +-
libsemanage/src/fcontexts_file.c | 6 +++---
libsemanage/src/ibendports_file.c | 4 ++--
libsemanage/src/ibpkeys_file.c | 4 ++--
libsemanage/src/interfaces_file.c | 6 +++---
libsemanage/src/nodes_file.c | 8 ++++----
libsemanage/src/parse_utils.c | 6 +++---
libsemanage/src/parse_utils.h | 11 +++++------
libsemanage/src/ports_file.c | 4 ++--
libsemanage/src/seusers_file.c | 6 +++---
libsemanage/src/users_base_file.c | 7 +++----
libsemanage/src/users_extra_file.c | 4 ++--
12 files changed, 33 insertions(+), 35 deletions(-)
diff --git a/libsemanage/src/booleans_file.c b/libsemanage/src/booleans_file.c
index f79d0b44..6d600bbc 100644
--- a/libsemanage/src/booleans_file.c
+++ b/libsemanage/src/booleans_file.c
@@ -48,7 +48,7 @@ static int bool_parse(semanage_handle_t * handle,
goto last;
/* Extract name */
- if (parse_fetch_string(handle, info, &str, '=') < 0)
+ if (parse_fetch_string(handle, info, &str, '=', 0) < 0)
goto err;
if (semanage_bool_set_name(handle, boolean, str) < 0)
diff --git a/libsemanage/src/fcontexts_file.c b/libsemanage/src/fcontexts_file.c
index 04cd365a..f3579410 100644
--- a/libsemanage/src/fcontexts_file.c
+++ b/libsemanage/src/fcontexts_file.c
@@ -90,7 +90,7 @@ static int fcontext_parse(semanage_handle_t * handle,
goto last;
/* Regexp */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_fcontext_set_expr(handle, fcontext, str) < 0)
goto err;
@@ -100,7 +100,7 @@ static int fcontext_parse(semanage_handle_t * handle,
/* Type */
if (parse_assert_space(handle, info) < 0)
goto err;
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (!strcasecmp(str, "-s"))
semanage_fcontext_set_type(fcontext, SEMANAGE_FCONTEXT_SOCK);
@@ -124,7 +124,7 @@ static int fcontext_parse(semanage_handle_t * handle,
/* Context */
if (parse_assert_space(handle, info) < 0)
goto err;
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
process_context:
diff --git a/libsemanage/src/ibendports_file.c b/libsemanage/src/ibendports_file.c
index bafa8c1d..2fa2a67c 100644
--- a/libsemanage/src/ibendports_file.c
+++ b/libsemanage/src/ibendports_file.c
@@ -75,7 +75,7 @@ static int ibendport_parse(semanage_handle_t *handle,
goto err;
/* IB Device Name */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_ibendport_set_ibdev_name(handle, ibendport, str) < 0)
goto err;
@@ -92,7 +92,7 @@ static int ibendport_parse(semanage_handle_t *handle,
/* context */
if (parse_assert_space(handle, info) < 0)
goto err;
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_context_from_string(handle, str, &con) < 0) {
ERR(handle, "invalid security context \"%s\" (%s: %u)\n%s",
diff --git a/libsemanage/src/ibpkeys_file.c b/libsemanage/src/ibpkeys_file.c
index 929bc31e..edde69f0 100644
--- a/libsemanage/src/ibpkeys_file.c
+++ b/libsemanage/src/ibpkeys_file.c
@@ -80,7 +80,7 @@ static int ibpkey_parse(semanage_handle_t *handle,
goto err;
/* Subnet Prefix */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_ibpkey_set_subnet_prefix(handle, ibpkey, str) < 0)
goto err;
@@ -115,7 +115,7 @@ static int ibpkey_parse(semanage_handle_t *handle,
semanage_ibpkey_set_pkey(ibpkey, low);
}
/* Pkey context */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_context_from_string(handle, str, &con) < 0) {
ERR(handle, "invalid security context \"%s\" (%s: %u)\n%s",
diff --git a/libsemanage/src/interfaces_file.c b/libsemanage/src/interfaces_file.c
index c19c8f94..244f0ae5 100644
--- a/libsemanage/src/interfaces_file.c
+++ b/libsemanage/src/interfaces_file.c
@@ -72,7 +72,7 @@ static int iface_parse(semanage_handle_t * handle,
goto err;
/* Name */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_iface_set_name(handle, iface, str) < 0)
goto err;
@@ -82,7 +82,7 @@ static int iface_parse(semanage_handle_t * handle,
/* Interface context */
if (parse_assert_space(handle, info) < 0)
goto err;
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_context_from_string(handle, str, &con) < 0) {
ERR(handle, "invalid security context \"%s\" (%s: %u)\n%s",
@@ -106,7 +106,7 @@ static int iface_parse(semanage_handle_t * handle,
/* Message context */
if (parse_assert_space(handle, info) < 0)
goto err;
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_context_from_string(handle, str, &con) < 0) {
ERR(handle, "invalid security context \"%s\" (%s: %u)\n%s",
diff --git a/libsemanage/src/nodes_file.c b/libsemanage/src/nodes_file.c
index c3647f2a..2d2b7fe0 100644
--- a/libsemanage/src/nodes_file.c
+++ b/libsemanage/src/nodes_file.c
@@ -77,7 +77,7 @@ static int node_parse(semanage_handle_t * handle,
goto err;
/* Protocol */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (!strcasecmp(str, "ipv4"))
proto = SEMANAGE_PROTO_IP4;
@@ -96,7 +96,7 @@ static int node_parse(semanage_handle_t * handle,
/* Address */
if (parse_assert_space(handle, info) < 0)
goto err;
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_node_set_addr(handle, node, proto, str) < 0)
goto err;
@@ -106,7 +106,7 @@ static int node_parse(semanage_handle_t * handle,
str = NULL;
/* Netmask */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_node_set_mask(handle, node, proto, str) < 0)
goto err;
@@ -116,7 +116,7 @@ static int node_parse(semanage_handle_t * handle,
str = NULL;
/* Port context */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_context_from_string(handle, str, &con) < 0) {
ERR(handle, "invalid security context \"%s\" (%s: %u)\n%s",
diff --git a/libsemanage/src/parse_utils.c b/libsemanage/src/parse_utils.c
index 4fb54fc3..918dee43 100644
--- a/libsemanage/src/parse_utils.c
+++ b/libsemanage/src/parse_utils.c
@@ -239,7 +239,7 @@ int parse_fetch_int(semanage_handle_t * handle,
char *test = NULL;
int value = 0;
- if (parse_fetch_string(handle, info, &str, delim) < 0)
+ if (parse_fetch_string(handle, info, &str, delim, 0) < 0)
goto err;
if (!isdigit((int)*str)) {
@@ -267,7 +267,7 @@ int parse_fetch_int(semanage_handle_t * handle,
}
int parse_fetch_string(semanage_handle_t * handle,
- parse_info_t * info, char **str, char delim)
+ parse_info_t * info, char **str, char delim, int allow_spaces)
{
char *start = info->ptr;
@@ -277,7 +277,7 @@ int parse_fetch_string(semanage_handle_t * handle,
if (parse_assert_noeof(handle, info) < 0)
goto err;
- while (*(info->ptr) && !isspace(*(info->ptr)) &&
+ while (*(info->ptr) && (allow_spaces || !isspace(*(info->ptr))) &&
(*(info->ptr) != delim)) {
info->ptr++;
len++;
diff --git a/libsemanage/src/parse_utils.h b/libsemanage/src/parse_utils.h
index 0f334860..3e44aca1 100644
--- a/libsemanage/src/parse_utils.h
+++ b/libsemanage/src/parse_utils.h
@@ -71,12 +71,11 @@ extern int parse_optional_str(parse_info_t * info, const char *str);
int parse_fetch_int(semanage_handle_t * hgandle,
parse_info_t * info, int *num, char delim);
-/* Extract the next string (delimited by
- * whitespace), and move the read pointer past it.
- * Stop of the optional character delim is encountered,
- * or if whitespace/eof is encountered. Fail if the
- * string is of length 0. */
+/* Extract the next string and move the read pointer past it.
+ * Stop if the optional character delim (or eof) is encountered,
+ * or if whitespace is encountered and allow_spaces is 0.
+ * Fail if the string is of length 0. */
extern int parse_fetch_string(semanage_handle_t * handle,
- parse_info_t * info, char **str_ptr, char delim);
+ parse_info_t * info, char **str_ptr, char delim, int allow_spaces);
#endif
diff --git a/libsemanage/src/ports_file.c b/libsemanage/src/ports_file.c
index ade4102f..1356021a 100644
--- a/libsemanage/src/ports_file.c
+++ b/libsemanage/src/ports_file.c
@@ -77,7 +77,7 @@ static int port_parse(semanage_handle_t * handle,
goto err;
/* Protocol */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (!strcasecmp(str, "tcp"))
semanage_port_set_proto(port, SEMANAGE_PROTO_TCP);
@@ -123,7 +123,7 @@ static int port_parse(semanage_handle_t * handle,
semanage_port_set_port(port, low);
/* Port context */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_context_from_string(handle, str, &con) < 0) {
ERR(handle, "invalid security context \"%s\" (%s: %u)\n%s",
diff --git a/libsemanage/src/seusers_file.c b/libsemanage/src/seusers_file.c
index 910bedf4..21b970ac 100644
--- a/libsemanage/src/seusers_file.c
+++ b/libsemanage/src/seusers_file.c
@@ -53,7 +53,7 @@ static int seuser_parse(semanage_handle_t * handle,
goto last;
/* Extract name */
- if (parse_fetch_string(handle, info, &str, ':') < 0)
+ if (parse_fetch_string(handle, info, &str, ':', 1) < 0)
goto err;
if (semanage_seuser_set_name(handle, seuser, str) < 0)
goto err;
@@ -68,7 +68,7 @@ static int seuser_parse(semanage_handle_t * handle,
goto err;
/* Extract sename */
- if (parse_fetch_string(handle, info, &str, ':') < 0)
+ if (parse_fetch_string(handle, info, &str, ':', 1) < 0)
goto err;
if (semanage_seuser_set_sename(handle, seuser, str) < 0)
goto err;
@@ -83,7 +83,7 @@ static int seuser_parse(semanage_handle_t * handle,
goto err;
/* NOTE: does not allow spaces/multiline */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_seuser_set_mlsrange(handle, seuser, str) < 0)
diff --git a/libsemanage/src/users_base_file.c b/libsemanage/src/users_base_file.c
index 0f0a8fdb..a0f8cd7e 100644
--- a/libsemanage/src/users_base_file.c
+++ b/libsemanage/src/users_base_file.c
@@ -83,7 +83,7 @@ static int user_base_parse(semanage_handle_t * handle,
goto err;
/* Parse user name */
- if (parse_fetch_string(handle, info, &name_str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &name_str, ' ', 0) < 0)
goto err;
if (semanage_user_base_set_name(handle, user, name_str) < 0) {
@@ -150,7 +150,7 @@ static int user_base_parse(semanage_handle_t * handle,
goto err;
/* NOTE: does not allow spaces/multiline */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_user_base_set_mlslevel(handle, user, str) < 0)
goto err;
@@ -165,8 +165,7 @@ static int user_base_parse(semanage_handle_t * handle,
if (parse_assert_space(handle, info) < 0)
goto err;
- /* NOTE: does not allow spaces/multiline */
- if (parse_fetch_string(handle, info, &str, ';') < 0)
+ if (parse_fetch_string(handle, info, &str, ';', 1) < 0)
goto err;
if (semanage_user_base_set_mlsrange(handle, user, str) < 0)
goto err;
diff --git a/libsemanage/src/users_extra_file.c b/libsemanage/src/users_extra_file.c
index 8f2bebd6..7aa9df3c 100644
--- a/libsemanage/src/users_extra_file.c
+++ b/libsemanage/src/users_extra_file.c
@@ -57,7 +57,7 @@ static int user_extra_parse(semanage_handle_t * handle,
goto err;
/* Extract name */
- if (parse_fetch_string(handle, info, &str, ' ') < 0)
+ if (parse_fetch_string(handle, info, &str, ' ', 0) < 0)
goto err;
if (semanage_user_extra_set_name(handle, user_extra, str) < 0)
goto err;
@@ -73,7 +73,7 @@ static int user_extra_parse(semanage_handle_t * handle,
goto err;
/* Extract prefix */
- if (parse_fetch_string(handle, info, &str, ';') < 0)
+ if (parse_fetch_string(handle, info, &str, ';', 1) < 0)
goto err;
if (semanage_user_extra_set_prefix(handle, user_extra, str) < 0)
goto err;
--
2.30.2
2 years, 9 months
[PATCH 0/8] driver: Fix handling of driver feature flags
by Peter Krempa
In a review of code using FD passing I was asked to add the check, so I
wanted to see how it works and found a few issues.
Peter Krempa (8):
driver: Introduce global driver feature flag handling function
virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_REMOTE
virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_PROGRAM_KEEPALIVE
virDriverFeatureIsGlobal: Handle
VIR_DRV_FEATURE_REMOTE_(CLOSE|EVENT)_CALLBACK
virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_TYPED_PARAM_STRING
virDriverFeatureIsGlobal: Handle
VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER
virDriverFeatureIsGlobal: Handle VIR_DRV_FEATURE_FD_PASSING
virDomainCreate(XML)WithFiles: Add check for
VIR_DRV_FEATURE_FD_PASSING
src/ch/ch_driver.c | 5 +++
src/driver.c | 65 +++++++++++++++++++++++++++++++++++++
src/driver.h | 3 ++
src/esx/esx_driver.c | 4 +++
src/libvirt-domain.c | 24 ++++++++++++++
src/libvirt_private.syms | 1 +
src/libxl/libxl_driver.c | 5 +++
src/lxc/lxc_driver.c | 5 +++
src/network/bridge_driver.c | 5 +++
src/openvz/openvz_driver.c | 5 +++
src/qemu/qemu_driver.c | 5 +++
src/test/test_driver.c | 5 +++
src/vz/vz_driver.c | 5 +++
13 files changed, 137 insertions(+)
--
2.35.1
2 years, 9 months