[libvirt] [PATCH RFC 0/4]] nwfilter: don't reinstantiate filters if they are not changed
by Nikolay Shirokovskiy
The series adds optimization in network filters instantiation as suggested
in [1]. Applied on top of [2].
However this approach has drawback I'm unfortunately discovered too late)
Next steps will left us with no network filters after this series applied:
systemctl stop libvirtd
systemctl restart firewalld
systemctl start libvirtd
In case of system update libvirt binaries ctime will change and filters will be
reinstalled.
[1] https://www.redhat.com/archives/libvir-list/2018-October/msg00657.html
[2] https://www.redhat.com/archives/libvir-list/2018-October/msg00787.html
Nikolay Shirokovskiy (4):
nwfilter: add nwfilter hash
nwfilter: don't reinstantiate filters if they are not changed
nwfilter: force filters reinstantiation on firewalld reload
nwfilter: force filters reinstantiation on binary update
src/conf/virnwfilterbindingobj.c | 40 +++++++++
src/conf/virnwfilterbindingobj.h | 10 +++
src/conf/virnwfilterobj.c | 145 +++++++++++++++++++++++++++++++++
src/conf/virnwfilterobj.h | 9 ++
src/libvirt_private.syms | 6 ++
src/nwfilter/nwfilter_driver.c | 11 ++-
src/nwfilter/nwfilter_gentech_driver.c | 67 +++++++++++++--
src/nwfilter/nwfilter_gentech_driver.h | 6 +-
8 files changed, 283 insertions(+), 11 deletions(-)
--
1.8.3.1
6 years, 1 month
[libvirt] [PATCHv6 00/18] Introduce x86 Cache Monitoring Technology (CMT)
by Wang Huaqiang
This series of patches and the series already been merged introduce
the x86 Cache Monitoring Technology (CMT) to libvirt by interacting
with kernel resource control (resctrl) interface. CMT is one of the
Intel(R) x86 CPU feature which belongs to the Resource Director
Technology (RDT). CMT reports the occupancy of the last level cache,
which is shared by all CPU cores.
In the v1 series, an original and complete feature for CMT was introduced
The v2 and v3 patches address the feature for the host capability of CMT.
v4 is addressing the feature for monitoring VM vcpu thread set cache
occupancy and reporting it through a virsh command.
We have serval discussion about the enabling of CMT, please refer to
following links for the RFCs.
RFCv3
https://www.redhat.com/archives/libvir-list/2018-August/msg01213.html
RFCv2
https://www.redhat.com/archives/libvir-list/2018-July/msg00409.html
https://www.redhat.com/archives/libvir-list/2018-July/msg01241.html
RFCv1
https://www.redhat.com/archives/libvir-list/2018-June/msg00674.html
And the merged commits are list as below, for host capability of CMT.
6af8417415508c31f8ce71234b573b4999f35980
8f6887998bf63594ae26e3db18d4d5896c5f2cb4
58fcee6f3a2b7e89c21c1fb4ec21429c31a0c5b8
12093f1feaf8f5023dcd9d65dff111022842183d
a5d293c18831dcf69ec6195798387fbb70c9f461
1. About reason why CMT is necessary in libvirt?
The perf events of 'CMT, MBML, MBMT' have been phased out since Linux
kernel commit c39a0e2c8850f08249383f2425dbd8dbe4baad69, in libvirt
the perf based cmt,mbm will not work with the latest linux kernel. These
patches add CMT feature to libvirt through kernel resctrlfs interface.
2 Create cache monitoring group (cache monitor).
The main interface for creating monitoring group is through XML file. The
proposed configuration is like:
<cputune>
<cachetune vcpus='1'>
<cache id='0' level='3' type='code' size='7680' unit='KiB'/>
<cache id='1' level='3' type='data' size='3840' unit='KiB'/>
+ <monitor level='3' vcpus='1'/>
</cachetune>
<cachetune vcpus='4-7'>
+ <monitor level='3' vcpus='4-6'/>
</cachetune>
</cputune>
In above XML, created 2 cache resctrl allocation groups and 2 resctrl
monitoring groups.
The changes of cache monitor will be effective in next booting of VM.
2 Show CMT result through command 'domstats'
Adding the interface in qemu to report this information for resource
monitor group through command 'virsh domstats --cpu-total'.
Below is a typical output:
# virsh domstats 1 --cpu-total
Domain: 'ubuntu16.04-base'
...
cpu.cache.monitor.count=2
cpu.cache.monitor.0.name=vcpus_1
cpu.cache.monitor.0.vcpus=1
cpu.cache.monitor.0.bank.count=2
cpu.cache.monitor.0.bank.0.id=0
cpu.cache.monitor.0.bank.0.bytes=4505600
cpu.cache.monitor.0.bank.1.id=1
cpu.cache.monitor.0.bank.1.bytes=5586944
cpu.cache.monitor.1.name=vcpus_4-6
cpu.cache.monitor.1.vcpus=4,5,6
cpu.cache.monitor.1.bank.count=2
cpu.cache.monitor.1.bank.0.id=0
cpu.cache.monitor.1.bank.0.bytes=17571840
cpu.cache.monitor.1.bank.1.id=1
cpu.cache.monitor.1.bank.1.bytes=29106176
Changes in v6:
- Addressing John's review comments for v5.
- Removed and cleaned the concepts of 'default allocation' and
'default monitor'.
- qemu: virsh domstats --cpu-total output for CMT, add identifier
'monitor' for each itm.
Changes in v5:
- qemu: Setting up vcpu and adding pids to resctrl monitor groups during
re-connection.
- Add the document for domain configuration related to resctrl monitor.
Changes in v4:
v4 is addressing the feature for monitoring VM vcpu
thread set cache occupancy and reporting it through a
virsh command.
- Introduced resctrl default allocation
- Introduced resctrl monitor and default monitor
Changes in v3:
- Addressed John Ferlan's review.
- Typo fixed.
- Removed VIR_ENUM_DECL(virMonitor);
Changes in v2:
- Introduced MBM capability.
- Capability layout changed
* Moved <monitor> from cahe <bank> to <cache>
* Renamed <Threshold> to <reuseThreshold>
- Document for 'reuseThreshold' changed.
- Introduced API virResctrlInfoGetMonitorPrefix
- Added more tests, covering standalone CMT, fake new
feature.
- Creating CMT resource control group will be
subsequent job.
Wang Huaqiang (18):
docs,util: Refactor schemas and virresctrl to support optional cache
util: Introduce resctrl monitor for CMT
util: Refactor code for determining allocation path
util: Add interface to determine monitor path
util: Refactor code for adding PID to the resource group
util: Add interface for adding PID to the monitor
util: Refactor code for creating resctrl group
util: Add interface for creating monitor group
util: Add more interfaces for resctrl monitor
conf: Remove virDomainResctrlAppend and introduce virDomainResctrlNew
conf: move virResctrlAllocIsEmpty to a place a litter lower
conf: Introduce cache monitor element in cachetune
qemu: enable resctrl monitor in qemu
util: Add function for checking if monitor is running
conf: Add 'id' to virDomainResctrlDef
qemu: refactor qemuDomainGetStatsCpu
qemu: Report cache occupancy (CMT) with domstats
qemu: Setting up vcpu and adding pids to resctrl monitor groups during
reconnection
docs/formatdomain.html.in | 30 +-
docs/schemas/domaincommon.rng | 14 +-
src/conf/domain_conf.c | 310 ++++++++++--
src/conf/domain_conf.h | 12 +
src/libvirt-domain.c | 9 +
src/libvirt_private.syms | 10 +
src/qemu/qemu_driver.c | 270 +++++++++-
src/qemu/qemu_process.c | 69 ++-
src/util/virresctrl.c | 563 +++++++++++++++++++--
src/util/virresctrl.h | 49 ++
tests/genericxml2xmlindata/cachetune-cdp.xml | 3 +
.../cachetune-colliding-monitor.xml | 30 ++
tests/genericxml2xmlindata/cachetune-small.xml | 7 +
tests/genericxml2xmltest.c | 2 +
14 files changed, 1282 insertions(+), 96 deletions(-)
create mode 100644 tests/genericxml2xmlindata/cachetune-colliding-monitor.xml
--
2.7.4
6 years, 1 month
[libvirt] [PULL 00/45] Machine queue, 2018-10-18
by Eduardo Habkost
The following changes since commit 09558375a634e17cea6cfbfec883ac2376d2dc7f:
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20181016-1' into staging (2018-10-16 17:42:56 +0100)
are available in the Git repository at:
git://github.com/ehabkost/qemu.git tags/machine-next-pull-request
for you to fetch changes up to 6d8e1bcc7dd5e819ce81e6a87fffe23e39c700cc:
numa: Clean up error reporting in parse_numa() (2018-10-17 16:33:40 -0300)
----------------------------------------------------------------
Machine queue, 2018-10-18
* sysbus init/realize cleanups
(Cédric Le Goater, Philippe Mathieu-Daudé)
* memory-device refactoring (David Hildenbrand)
* -smp: deprecate incorrect CPUs topology (Igor Mammedov)
* -numa parsing cleanups (Markus Armbruster)
* Fix hostmem-file memory leak (Zhang Yi)
* Typo fix (Li Qiang)
----------------------------------------------------------------
Queue for Machine Core patches
Cédric Le Goater (11):
net: etraxfs_eth: convert SysBus init method to a realize method
net: etraxfs_eth: add a reset method
net: lan9118: convert SysBus init method to a realize method
net: lance: convert SysBus init method to a realize method
net: milkymist_minimac2: convert SysBus init method to a realize
method
net: mipsnet: convert SysBus init method to a realize method
net: opencores_eth: convert SysBus init method to a realize method
net: smc91c111: convert SysBus init method to a realize method
net: stellaris_enet: convert SysBus init method to a realize method
net: stellaris_enet: add a reset method
net: xgmac: convert SysBus init method to a realize method
David Hildenbrand (16):
memory-device: fix alignment error message
memory-device: fix error message when hinted address is too small
memory-device: improve "range conflicts" error message
pc-dimm: pass PCDIMMDevice to pc_dimm_.*plug
memory-device: use memory device terminology in error messages
memory-device: introduce separate config option
memory-device: forward errors in get_region_size()/get_plugged_size()
memory-device: document MemoryDeviceClass
memory-device: add and use memory_device_get_region_size()
memory-device: factor out get_memory_region() from pc-dimm
memory-device: drop get_region_size()
memory-device: add device class function set_addr()
memory-device: complete factoring out pre_plug handling
memory-device: complete factoring out plug handling
memory-device: complete factoring out unplug handling
memory-device: trace when pre_plugging/plugging/unplugging
Igor Mammedov (2):
vl.c deprecate incorrect CPUs topology
vl:c: make sure that sockets are calculated correctly in '-smp X' case
Li Qiang (1):
machine: fix a typo
Markus Armbruster (2):
numa: Fix QMP command set-numa-node error handling
numa: Clean up error reporting in parse_numa()
Philippe Mathieu-Daudé (12):
trace-events: Fix copy/paste typo
hw/timer/sun4v-rtc: Convert from DPRINTF() macro to trace events
hw/timer/sun4v-rtc: Use DeviceState::realize rather than
SysBusDevice::init
hw/ssi/xilinx_spi: Use DeviceState::realize rather than
SysBusDevice::init
hw/sh4/sh_pci: Use DeviceState::realize rather than SysBusDevice::init
hw/pci-host/bonito: Use DeviceState::realize rather than
SysBusDevice::init
hw/mips/gt64xxx_pci: Convert gt64120_reset() function into Device
reset method
hw/mips/gt64xxx_pci: Mark as bridge device
hw/sparc64/niagara: Model the I/O Bridge with the
'unimplemented_device'
hw/alpha/typhoon: Remove unuseful code
hw/hppa/dino: Remove unuseful code
hw/mips/malta: Remove unuseful code
Zhang Yi (1):
hostmem-file: fixed the memory leak while get pmem path.
default-configs/i386-softmmu.mak | 3 +-
default-configs/ppc64-softmmu.mak | 3 +-
default-configs/sparc64-softmmu.mak | 1 -
qapi/misc.json | 2 +-
include/hw/mem/memory-device.h | 74 +++++++++++++++++---
include/hw/mem/pc-dimm.h | 10 +--
include/sysemu/numa.h | 1 -
backends/hostmem-file.c | 10 ++-
hw/alpha/typhoon.c | 13 ----
hw/core/machine.c | 2 +-
hw/hppa/dino.c | 7 --
hw/i386/pc.c | 6 +-
hw/mem/memory-device.c | 103 ++++++++++++++++++++++------
hw/mem/nvdimm.c | 9 ++-
hw/mem/pc-dimm.c | 84 ++++++++---------------
hw/mips/gt64xxx_pci.c | 18 ++---
hw/mips/mips_malta.c | 13 ----
hw/net/etraxfs_eth.c | 44 ++++++++----
hw/net/lan9118.c | 9 +--
hw/net/lance.c | 8 +--
hw/net/milkymist-minimac2.c | 9 +--
hw/net/mipsnet.c | 9 +--
hw/net/opencores_eth.c | 8 +--
hw/net/smc91c111.c | 8 +--
hw/net/stellaris_enet.c | 15 ++--
hw/net/xgmac.c | 9 +--
hw/pci-host/bonito.c | 9 +--
hw/ppc/spapr.c | 29 +++-----
hw/sh4/sh_pci.c | 20 +++---
hw/sparc64/niagara.c | 4 +-
hw/ssi/xilinx_spi.c | 9 +--
hw/timer/sun4v-rtc.c | 23 +++----
numa.c | 21 +++---
vl.c | 12 +++-
hw/Makefile.objs | 2 +-
hw/mem/Makefile.objs | 4 +-
hw/mem/trace-events | 5 +-
hw/timer/trace-events | 6 +-
qemu-deprecated.texi | 12 ++++
39 files changed, 347 insertions(+), 287 deletions(-)
--
2.18.0.rc1.1.g3f1ff2140
6 years, 1 month
[libvirt] [PATCH] qemu: fix device name passed to error report
by Daniel P. Berrangé
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 0a63741b9e..12bef16fd6 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -5814,7 +5814,7 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("cannot hot unplug multifunction PCI device: %s"),
- dev->data.disk->dst);
+ net->ifname);
goto cleanup;
}
--
2.17.2
6 years, 1 month
[libvirt] [PATCH] qemu: Fix IOThread pids lost after qemuProcessReconnect
by Jie Wang
>From fca1732c0e1f691fb25c614349d5486bbc73a109 Mon Sep 17 00:00:00 2001
From: Jie Wang <wangjie88(a)huawei.com>
Date: Wed, 17 Oct 2018 22:55:51 +0800
Subject: [PATCH] qemu: Fix IOThread pids lost after qemuProcessReconnect
IOThread pids info will lost after libvirtd restart, then
if we call pinIOThread, sched_setaffinity will be called with
pid 0, not IOThread pid. So pinIOThread cannot work normally.
Signed-off-by: Jie Wang <wangjie88.huawei.com>
---
src/qemu/qemu_process.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 40d35cbe6b..5bf55721d2 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7650,6 +7650,9 @@ qemuProcessReconnect(void *opaque)
qemuDomainVcpuPersistOrder(obj->def);
+ if (qemuProcessDetectIOThreadPIDs(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
+ goto error;
+
if (qemuSecurityReserveLabel(driver->securityManager, obj->def, obj->pid) < 0)
goto error;
--
2.16.2.windows.1
6 years, 1 month
[libvirt] [PATCH v4 0/5] libxl: PVHv2 support
by Marek Marczykowski-Górecki
This is a respin of my old PVHv1 patch[1], converted to PVHv2. The actual code
use "PVH" name.
The guest ostype reuse VIR_DOMAIN_OSTYPE_XEN, but to request PVH machine,
machine="xenpvh" attribute is used.
Since PVHv2 relies on features in newer Xen versions, I needed to convert also
some older code. For example b_info->u.hvm.nested_hvm was deprecated in favor
of b_info->nested_hvm. While the code do handle both old and new versions
(obviously refusing PVHv2 if Xen is too old), this isn't the case for tests.
How it should be handled, if at all?
To test this with all supported Xen versions (4.6, 4.7, 4.8, 4.9, 4.10, 4.11,
unstable), I've extended travis configuration for that[2]. It isn't exactly
trivial to build Xen 4.6-4.8 on recent system, mostly thanks to -Werror and new
warnings, but also other toolchain changes. Because of this, the configuration
is rather hacky. But it may be a good idea to include multiple pre-built Xen
versions in the base docker image and choose one using ./configure options (maybe
together with some symlink or environment variable like PKG_CONFIG_PATH).
[1] https://www.redhat.com/archives/libvir-list/2016-August/msg00376.html
[2] https://github.com/marmarek/libvirt/tree/travis-xen-pvh
Changes in v2:
- drop "docs: don't refer to deprecated 'linux' ostype in example" patch -
migrating further away from "linux" os type is offtopic to this series and
apparently is a controversial thing
- drop "docs: update domain schema for machine attribute" patch -
already applied
- apply review comments from Jim
- rebase on master
Changes in v3:
- rebase on master, drop already applied patches
- use #ifdef LIBXL_DOMAIN_TYPE_PVH to detect PVH support, fix compilation
failure on older Xen
- exclude PVH from VIR_DOMAIN_OSTYPE_XEN <-> VIR_DOMAIN_OSTYPE_LINUX conversion
- fix reported capabilities for PVH
Changes in v4:
- change PVH support detection method
Marek Marczykowski-Górecki (5):
libxl: reorder libxlMakeDomBuildInfo for upcoming PVH support
libxl: add support for PVH
tests: add basic Xen PVH test
xenconfig: add support for parsing type= xl config entry
xenconfig: add support for type="pvh"
docs/formatcaps.html.in | 4 +-
docs/schemas/domaincommon.rng | 1 +-
m4/virt-driver-libxl.m4 | 3 +-
src/conf/domain_conf.c | 6 +-
src/libxl/libxl_capabilities.c | 38 +++++++++--
src/libxl/libxl_conf.c | 76 ++++++++++++++++------
src/libxl/libxl_driver.c | 6 +-
src/xenconfig/xen_common.c | 27 ++++++--
src/xenconfig/xen_xl.c | 5 +-
tests/libxlxml2domconfigdata/basic-pvh.json | 49 ++++++++++++++-
tests/libxlxml2domconfigdata/basic-pvh.xml | 28 ++++++++-
tests/libxlxml2domconfigtest.c | 3 +-
tests/testutilsxen.c | 3 +-
tests/xlconfigdata/test-fullvirt-type.cfg | 21 ++++++-
tests/xlconfigdata/test-fullvirt-type.xml | 27 ++++++++-
tests/xlconfigdata/test-paravirt-type.cfg | 13 ++++-
tests/xlconfigdata/test-paravirt-type.xml | 25 +++++++-
tests/xlconfigdata/test-pvh-type.cfg | 13 ++++-
tests/xlconfigdata/test-pvh-type.xml | 25 +++++++-
tests/xlconfigtest.c | 3 +-
20 files changed, 341 insertions(+), 35 deletions(-)
create mode 100644 tests/libxlxml2domconfigdata/basic-pvh.json
create mode 100644 tests/libxlxml2domconfigdata/basic-pvh.xml
create mode 100644 tests/xlconfigdata/test-fullvirt-type.cfg
create mode 100644 tests/xlconfigdata/test-fullvirt-type.xml
create mode 100644 tests/xlconfigdata/test-paravirt-type.cfg
create mode 100644 tests/xlconfigdata/test-paravirt-type.xml
create mode 100644 tests/xlconfigdata/test-pvh-type.cfg
create mode 100644 tests/xlconfigdata/test-pvh-type.xml
base-commit: 199eee6aae7af3d813fbe98660c7e0fa1a8ae7b7
--
git-series 0.9.1
6 years, 1 month
[libvirt] [PATCH v2 00/12] Allow modification of IOThread polling values (redux)
by John Ferlan
v1: https://www.redhat.com/archives/libvir-list/2018-October/msg00456.html
Changes since v1 (from code review)
Patch 2: Move the job back into qemuDomainGetIOThreadsLive
Patch 3: Add check for ActiveJob before allowing, use true for
*StatsWorker, and print 'iothread' in output not 'block'
Patch 5: Use virCheckPositiveArgGoto(nparams, error) instead of using
virCheckNonNegativeArgGoto(nparams, error). And then remove
the if (nparams) before the virCheckNonNullArgGoto(params, error);
Patch 6: Add ability to determine which parameter was set via bool
set_poll_{max_ns|grow|shrink} values. Then use those in
the macro that sets the value to determine whether or not
the value will be set based on whether it was changed.
Patch 10: Use bool's to set_ when the value is found in the incoming
params list. Remove the check that says poll_max_ns needs
to be set. Testing proves that if it's set to 0, then the
grow and shrink values can be changed (although they do
nothing)
Patch 12: (NEW) - News article
John Ferlan (12):
qemu: Check for and return IOThread polling values if available
qemu: Split qemuDomainGetIOThreadsLive
qemu: Implement the ability to return IOThread stats
virsh: Add ability to display IOThread stats
lib: Introduce virDomainSetIOThreadParams
qemu: Add monitor functions to set IOThread params
qemu: Alter qemuDomainChgIOThread to take enum instead of bool
qemu: Alter qemuDomainChgIOThread to take qemuMonitorIOThreadInfo
qemu: Detect whether iothread polling is supported
qemu: Introduce qemuDomainSetIOThreadParams
tools: Add virsh iothreadset command
docs: Add news article for IOThread polling
docs/news.xml | 13 +
include/libvirt/libvirt-domain.h | 45 ++
src/driver-hypervisor.h | 8 +
src/libvirt-domain.c | 108 +++++
src/libvirt_public.syms | 5 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_driver.c | 384 ++++++++++++++++--
src/qemu/qemu_monitor.c | 19 +
src/qemu/qemu_monitor.h | 9 +
src/qemu/qemu_monitor_json.c | 50 +++
src/qemu/qemu_monitor_json.h | 4 +
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 21 +-
src/remote_protocol-structs | 10 +
.../caps_2.10.0.aarch64.xml | 1 +
.../caps_2.10.0.ppc64.xml | 1 +
.../caps_2.10.0.s390x.xml | 1 +
.../caps_2.10.0.x86_64.xml | 1 +
.../caps_2.11.0.s390x.xml | 1 +
.../caps_2.11.0.x86_64.xml | 1 +
.../caps_2.12.0.aarch64.xml | 1 +
.../caps_2.12.0.ppc64.xml | 1 +
.../caps_2.12.0.s390x.xml | 1 +
.../caps_2.12.0.x86_64.xml | 1 +
.../qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 +
.../qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 +
.../caps_2.9.0.x86_64.xml | 1 +
.../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 1 +
.../caps_3.0.0.riscv32.xml | 1 +
.../caps_3.0.0.riscv64.xml | 1 +
.../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 1 +
.../caps_3.0.0.x86_64.xml | 1 +
tools/virsh-domain-monitor.c | 7 +
tools/virsh-domain.c | 110 +++++
tools/virsh.pod | 47 ++-
36 files changed, 825 insertions(+), 37 deletions(-)
--
2.17.2
6 years, 1 month
[libvirt] [PATCH] virFileInData: Preserve errno on error
by Michal Privoznik
The virFileInData() function should return to the caller if the
current position the passed file is in is a data section or a
hole (and also how long the current section is). At any rate,
upon return from this function (be it successful or not) the
original position in the file is restored. This may mess up with
errno which might have been set earlier. Save the errno into a
local variable so it can be restored for the caller's sake.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virfile.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index e09992e41a..f6f01ec1e1 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -4072,11 +4072,18 @@ virFileInData(int fd,
ret = 0;
cleanup:
/* At any rate, reposition back to where we started. */
- if (cur != (off_t) -1 &&
- lseek(fd, cur, SEEK_SET) == (off_t) -1) {
- virReportSystemError(errno, "%s",
- _("unable to restore position in file"));
- ret = -1;
+ if (cur != (off_t) -1) {
+ int theerrno = errno;
+
+ if (lseek(fd, cur, SEEK_SET) == (off_t) -1) {
+ virReportSystemError(errno, "%s",
+ _("unable to restore position in file"));
+ ret = -1;
+ if (theerrno == 0)
+ theerrno = errno;
+ }
+
+ errno = theerrno;
}
return ret;
}
--
2.18.1
6 years, 1 month
[libvirt] [PATCH] virfile: Take symlink into account in virFileIsSharedFixFUSE
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1640465
Weirdly enough, there can be symlinks in the path we are trying
to fix. If it is the case our clever algorithm that finds matches
against mount table won't work. Canonicalize path at the
beginning then.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
cfg.mk | 2 +-
src/util/virfile.c | 17 ++++++++++++++---
tests/virfilemock.c | 33 ++++++++++++++++++++++++++++++++-
tests/virfiletest.c | 1 +
4 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 4790d0b7e7..d0183c02ff 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1229,7 +1229,7 @@ exclude_file_name_regexp--sc_prohibit_select = \
^cfg\.mk$$
exclude_file_name_regexp--sc_prohibit_canonicalize_file_name = \
- ^cfg\.mk$$
+ ^(cfg\.mk|tests/virfilemock\.c)$$
exclude_file_name_regexp--sc_prohibit_raw_allocation = \
^(docs/hacking\.html\.in|src/util/viralloc\.[ch]|examples/.*|tests/(securityselinuxhelper|(vircgroup|nss)mock|commandhelper)\.c|tools/wireshark/src/packet-libvirt\.c)$$
diff --git a/src/util/virfile.c b/src/util/virfile.c
index e09992e41a..4747a26ad3 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3473,9 +3473,19 @@ virFileIsSharedFixFUSE(const char *path,
char mntbuf[1024];
char *mntDir = NULL;
char *mntType = NULL;
+ char *canonPath = NULL;
size_t maxMatching = 0;
int ret = -1;
+ if (!(canonPath = virFileCanonicalizePath(path))) {
+ virReportSystemError(errno,
+ _("unable to canonicalize %s"),
+ path);
+ return -1;
+ }
+
+ VIR_DEBUG("Path %s after canonicalization %s", path, canonPath);
+
if (!(f = setmntent(PROC_MOUNTS, "r"))) {
virReportSystemError(errno,
_("Unable to open %s"),
@@ -3487,7 +3497,7 @@ virFileIsSharedFixFUSE(const char *path,
const char *p;
size_t len = strlen(mb.mnt_dir);
- if (!(p = STRSKIP(path, mb.mnt_dir)))
+ if (!(p = STRSKIP(canonPath, mb.mnt_dir)))
continue;
if (*(p - 1) != '/' && *p != '/' && *p != '\0')
@@ -3504,13 +3514,14 @@ virFileIsSharedFixFUSE(const char *path,
}
if (STREQ_NULLABLE(mntType, "fuse.glusterfs")) {
- VIR_DEBUG("Found gluster FUSE mountpoint=%s for path=%s. "
- "Fixing shared FS type", mntDir, path);
+ VIR_DEBUG("Found gluster FUSE mountpoint=%s for canonPath=%s. "
+ "Fixing shared FS type", mntDir, canonPath);
*f_type = GFS2_MAGIC;
}
ret = 0;
cleanup:
+ VIR_FREE(canonPath);
VIR_FREE(mntType);
VIR_FREE(mntDir);
endmntent(f);
diff --git a/tests/virfilemock.c b/tests/virfilemock.c
index 822c757380..ae5c8d025a 100644
--- a/tests/virfilemock.c
+++ b/tests/virfilemock.c
@@ -28,11 +28,14 @@
#endif
#include "virmock.h"
+#include "virstring.h"
+#include "viralloc.h"
#define VIR_FROM_THIS VIR_FROM_NONE
static FILE *(*real_setmntent)(const char *filename, const char *type);
static int (*real_statfs)(const char *path, struct statfs *buf);
+static char *(*real_canonicalize_file_name)(const char *path);
static void
@@ -43,6 +46,7 @@ init_syms(void)
VIR_MOCK_REAL_INIT(setmntent);
VIR_MOCK_REAL_INIT(statfs);
+ VIR_MOCK_REAL_INIT(canonicalize_file_name);
}
@@ -94,6 +98,7 @@ statfs_mock(const char *mtab,
FILE *f;
struct mntent mb;
char mntbuf[1024];
+ char *canonPath = NULL;
int ret = -1;
if (!(f = real_setmntent(mtab, "r"))) {
@@ -101,10 +106,16 @@ statfs_mock(const char *mtab,
return -1;
}
+ /* We don't need to do this in callers because real statfs(2)
+ * does that for us. However, in mocked implementation we
+ * need to do this. */
+ if (!(canonPath = canonicalize_file_name(path)))
+ return -1;
+
while (getmntent_r(f, &mb, mntbuf, sizeof(mntbuf))) {
int ftype;
- if (STRNEQ(mb.mnt_dir, path))
+ if (STRNEQ(mb.mnt_dir, canonPath))
continue;
if (STREQ(mb.mnt_type, "nfs") ||
@@ -136,6 +147,7 @@ statfs_mock(const char *mtab,
}
endmntent(f);
+ VIR_FREE(canonPath);
return ret;
}
@@ -152,3 +164,22 @@ statfs(const char *path, struct statfs *buf)
return real_statfs(path, buf);
}
+
+
+char *
+canonicalize_file_name(const char *path)
+{
+ if (getenv("LIBVIRT_MTAB")) {
+ const char *p;
+ char *ret;
+
+ if ((p = STRSKIP(path, "/some/symlink")))
+ ignore_value(virAsprintfQuiet(&ret, "/gluster%s", p));
+ else
+ ignore_value(VIR_STRDUP_QUIET(ret, path));
+
+ return ret;
+ }
+
+ return real_canonicalize_file_name(path);
+}
diff --git a/tests/virfiletest.c b/tests/virfiletest.c
index 1f2be74c8d..f7b263f2e9 100644
--- a/tests/virfiletest.c
+++ b/tests/virfiletest.c
@@ -456,6 +456,7 @@ mymain(void)
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/nfs/blah", false);
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gluster/file", true);
DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/gluster/sshfs/file", false);
+ DO_TEST_FILE_IS_SHARED_FS_TYPE("mounts3.txt", "/some/symlink/file", true);
return ret != 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
--
2.18.1
6 years, 1 month
[libvirt] [tck PATCH 0/3] a few minor TCK bugfixes
by Laine Stump
Laine Stump (3):
reduce required libvirt version in rpm spec
fix selinux/100-static-relabel-no test
double timeout on nwfilter 060-concurrency test
perl-Sys-Virt-TCK.spec.PL | 2 +-
scripts/nwfilter/nwfilter_concurrent.sh | 2 +-
scripts/selinux/100-static-relabel-no.t | 13 ++++++++++++-
3 files changed, 14 insertions(+), 3 deletions(-)
--
2.14.5
6 years, 1 month