[PULL v2 00/11] Tracing patches
by Stefan Hajnoczi
The following changes since commit c6a5fc2ac76c5ab709896ee1b0edd33685a67ed1:
decodetree: Add --output-null for meson testing (2023-05-31 19:56:42 -0700)
are available in the Git repository at:
https://gitlab.com/stefanha/qemu.git tags/tracing-pull-request
for you to fetch changes up to 367189efae8b53ec2ade37a1c079fd8f69244b9e:
accel/tcg: include cs_base in our hash calculations (2023-06-01 11:05:05 -0400)
----------------------------------------------------------------
Pull request
This pull request contains Alex Bennée's vcpu trace events removal patches.
----------------------------------------------------------------
Alex Bennée (11):
*-user: remove the guest_user_syscall tracepoints
trace-events: remove the remaining vcpu trace events
trace: remove vcpu_id from the TraceEvent structure
scripts/qapi: document the tool that generated the file
docs/deprecated: move QMP events bellow QMP command section
qapi: make the vcpu parameters deprecated for 8.1
trace: remove code that depends on setting vcpu
trace: remove control-vcpu.h
tcg: remove the final vestiges of dstate
hw/9pfs: use qemu_xxhash4
accel/tcg: include cs_base in our hash calculations
docs/about/deprecated.rst | 25 +++++---
qapi/trace.json | 40 ++++++-------
accel/tcg/tb-hash.h | 6 +-
include/exec/exec-all.h | 3 -
include/hw/core/cpu.h | 5 --
include/qemu/xxhash.h | 23 +++++--
include/user/syscall-trace.h | 4 --
trace/control-internal.h | 10 ----
trace/control-vcpu.h | 63 --------------------
trace/control.h | 48 ---------------
trace/event-internal.h | 2 -
accel/tcg/cpu-exec.c | 7 +--
accel/tcg/tb-maint.c | 5 +-
accel/tcg/translate-all.c | 6 --
bsd-user/freebsd/os-syscall.c | 3 -
hw/9pfs/9p.c | 5 +-
hw/core/cpu-common.c | 6 +-
stubs/trace-control.c | 13 ----
trace/control-target.c | 109 +++-------------------------------
trace/control.c | 28 ---------
trace/qmp.c | 76 +++---------------------
trace/trace-hmp-cmds.c | 18 +-----
util/qsp.c | 2 +-
hw/core/trace-events | 3 +
scripts/qapi/gen.py | 9 ++-
scripts/tracetool/format/c.py | 6 --
scripts/tracetool/format/h.py | 16 +----
trace-events | 50 ----------------
28 files changed, 94 insertions(+), 497 deletions(-)
delete mode 100644 trace/control-vcpu.h
--
2.40.1
1 year, 5 months
[PATCH v2] util: basic support for VFIO variant drivers
by Laine Stump
Before a PCI device can be assigned to a guest with VFIO, that device
must be bound to the vfio-pci driver rather than to the device's
normal driver. The vfio-pci driver provides APIs that permit QEMU to
perform all the necessary operations to make the device accessible to
the guest.
There has been kernel work recently to support vendor/device-specific
VFIO variant drivers that provide the basic vfio-pci driver functionality
while adding support for device-specific operations (for example these
device-specific drivers are planned to support live migration of
certain devices). All that will be needed to make this functionality
available will be to bind the new vendor-specific driver to the device
(rather than the generic vfio-pci driver, which will continue to work
just without the extra functionality).
But until now libvirt has required that all PCI devices being assigned
to a guest with VFIO specifically have the "vfio-pci" driver bound to
the device. So even if the user manually binds a shiny new
vendor-specific vfio variant driver to the device (and puts
"managed='no'" in the config to prevent libvirt from changing the
binding), libvirt will just fail during startup of the guest (or
during hotplug) because the driver bound to the device isn't exactly
"vfio-pci".
This patch loosens that restriction a bit - rather than requiring that
the device be bound to "vfio-pci", it also checks if the drivername
contains the string "vfio" at all, and in this case allows the
operation to continue. If the driver is in fact a VFIO variant, then
the assignment will succeed, but if it is not a VFIO variant then QEMU
will fail (and report the error back to libvirt).
In the near future (possibly by kernel 6.0) there will be a
formal method of identifying a VFIO variant driver by looking in
sysfs; in the meantime the inexact, but simple, method in this patch
will allow users of the few existing VFIO variant drivers (and
developers of new VFIO variant drivers) to use their new drivers
without needing to remove libvirt from their setup - they can simply
pre-bind the device to the new driver, then use "managed='no'" in
their libvirt config.
NB: this patch does *not* handle automatically determining the proper
vendor-specific driver and binding to it in the case of
"managed='yes'". This will be implemented later when there is a widely
available driver / device combo we can use for testing.
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
V1 here: https://listman.redhat.com/archives/libvir-list/2022-August/233327.html
Change in V2:
V1 used the output of modinfo to look for "vfio_pci" as an alias for a
driver to see if it was a VFIO variant driver.
As a result of discussion of V1, V2 is much simpler - it just assumes
that any driver with "vfio" in the name is a VFIO variant. This is
okay because 1) QEMU will still catch it and libvirt will properly log
the error if the driver isn't actually a VFIO variant, and 2) it's a
temporary situation, just to enable use of VFIO variant drivers with
libvirt until a standard method of detecting this is added to sysfs
(which, according to the discussion of V1, is coming in the near
future).
(NB: I did implement checking of /lib/modules/`uname -r`/modules.alias
as suggested by Erik, but it turned out that this caused the unit
tests to call uname(3) and open the modules.alias file on the test
host - for a proper unit test I would have also needed to mock these
two functions, and it seemed like too much complexity for a temporary
workaround. I've implemented Jason's suggestion here (accept any
driver with "vfio" in the name), which is similar to danpb's
suggestion (accept specifically the two drivers that are already in
the upstream kernel), but will also allow for new drivers that may be
under development.)
src/hypervisor/virhostdev.c | 26 ++++---------
src/util/virpci.c | 76 ++++++++++++++++++++++++++++++++++---
src/util/virpci.h | 3 ++
3 files changed, 82 insertions(+), 23 deletions(-)
diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index c0ce867596..15b35fa75e 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -747,9 +747,8 @@ virHostdevPreparePCIDevicesImpl(virHostdevManager *mgr,
mgr->inactivePCIHostdevs) < 0)
goto reattachdevs;
} else {
- g_autofree char *driverPath = NULL;
- g_autofree char *driverName = NULL;
- int stub;
+ g_autofree char *drvName = NULL;
+ virPCIStubDriver drvType;
/* Unmanaged devices should already have been marked as
* inactive: if that's the case, we can simply move on */
@@ -769,18 +768,14 @@ virHostdevPreparePCIDevicesImpl(virHostdevManager *mgr,
* information about active / inactive device across
* daemon restarts has been implemented */
- if (virPCIDeviceGetDriverPathAndName(pci,
- &driverPath, &driverName) < 0)
+ if (virPCIDeviceGetDriverNameAndType(pci, &drvName, &drvType) < 0)
goto reattachdevs;
- stub = virPCIStubDriverTypeFromString(driverName);
-
- if (stub > VIR_PCI_STUB_DRIVER_NONE &&
- stub < VIR_PCI_STUB_DRIVER_LAST) {
+ if (drvType > VIR_PCI_STUB_DRIVER_NONE) {
/* The device is bound to a known stub driver: store this
* information and add a copy to the inactive list */
- virPCIDeviceSetStubDriver(pci, stub);
+ virPCIDeviceSetStubDriver(pci, drvType);
VIR_DEBUG("Adding PCI device %s to inactive list",
virPCIDeviceGetName(pci));
@@ -2292,18 +2287,13 @@ virHostdevPrepareOneNVMeDevice(virHostdevManager *hostdev_mgr,
/* Let's check if all PCI devices are NVMe disks. */
for (i = 0; i < virPCIDeviceListCount(pciDevices); i++) {
virPCIDevice *pci = virPCIDeviceListGet(pciDevices, i);
- g_autofree char *drvPath = NULL;
g_autofree char *drvName = NULL;
- int stub = VIR_PCI_STUB_DRIVER_NONE;
+ virPCIStubDriver drvType;
- if (virPCIDeviceGetDriverPathAndName(pci, &drvPath, &drvName) < 0)
+ if (virPCIDeviceGetDriverNameAndType(pci, &drvName, &drvType) < 0)
goto cleanup;
- if (drvName)
- stub = virPCIStubDriverTypeFromString(drvName);
-
- if (stub == VIR_PCI_STUB_DRIVER_VFIO ||
- STREQ_NULLABLE(drvName, "nvme"))
+ if (drvType == VIR_PCI_STUB_DRIVER_VFIO || STREQ_NULLABLE(drvName, "nvme"))
continue;
VIR_WARN("Suspicious NVMe disk assignment. PCI device "
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 7800966963..51ccf4d9fd 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -277,6 +277,71 @@ virPCIDeviceGetDriverPathAndName(virPCIDevice *dev, char **path, char **name)
}
+/**
+ * virPCIDeviceGetDriverNameAndType:
+ * @dev: virPCIDevice object to examine
+ * @drvName: returns name of driver bound to this device (if any)
+ * @drvType: returns type of driver if it is a known stub driver type
+ *
+ * Find the name of the driver bound to @dev (if any) and the type of
+ * the driver if it is a known/recognized "stub" driver (based on the
+ * driver name).
+ *
+ * There are vfio "variant" drivers that provide all the basic
+ * functionality of the standard vfio-pci driver as well as additional
+ * stuff. There is a plan to add info to sysfs that will allow easily
+ * determining if a driver is a vfio variant driver, but that sysfs
+ * entry isn't yet available. In the meantime as a workaround so that
+ * the few existing vfio variant drivers can be used with libvirt, and
+ * so that driver developers can test their new vfio variant drivers
+ * without needing to bypass libvirt, we also check if the driver name
+ * contains the string "vfio"; if it does, then we consider this drier
+ * as type VFIO. This can lead to false positives, but that isn't a
+ * horrible thing, because the problem will still be caught by QEMU as
+ * soon as libvirt makes the request to attach the device.
+ *
+ * Return 0 on success, -1 on failure. If -1 is returned, then an error
+ * message has been logged.
+ */
+int
+virPCIDeviceGetDriverNameAndType(virPCIDevice *dev,
+ char **drvName,
+ virPCIStubDriver *drvType)
+{
+ g_autofree char *drvPath = NULL;
+ int tmpType;
+
+ if (virPCIDeviceGetDriverPathAndName(dev, &drvPath, drvName) < 0)
+ return -1;
+
+ if (!*drvName) {
+ *drvType = VIR_PCI_STUB_DRIVER_NONE;
+ return 0;
+ }
+
+ tmpType = virPCIStubDriverTypeFromString(*drvName);
+
+ if (tmpType > VIR_PCI_STUB_DRIVER_NONE) {
+ *drvType = tmpType;
+ return 0; /* exact match of a known driver name (or no name) */
+ }
+
+ /* Check if the drivername contains "vfio" and count as a VFIO
+ * driver if so - see above for explanation.
+ */
+
+ if (strstr(*drvName, "vfio")) {
+ VIR_DEBUG("Driver %s is a vfio_pci driver", *drvName);
+ *drvType = VIR_PCI_STUB_DRIVER_VFIO;
+ } else {
+ VIR_DEBUG("Driver %s is NOT a vfio_pci driver", *drvName);
+ *drvType = VIR_PCI_STUB_DRIVER_NONE;
+ }
+
+ return 0;
+}
+
+
static int
virPCIDeviceConfigOpenInternal(virPCIDevice *dev, bool readonly, bool fatal)
{
@@ -1004,8 +1069,8 @@ virPCIDeviceReset(virPCIDevice *dev,
virPCIDeviceList *activeDevs,
virPCIDeviceList *inactiveDevs)
{
- g_autofree char *drvPath = NULL;
g_autofree char *drvName = NULL;
+ virPCIStubDriver drvType;
int ret = -1;
int fd = -1;
int hdrType = -1;
@@ -1032,15 +1097,16 @@ virPCIDeviceReset(virPCIDevice *dev,
* reset it whenever appropriate, so doing it ourselves would just
* be redundant.
*/
- if (virPCIDeviceGetDriverPathAndName(dev, &drvPath, &drvName) < 0)
+ if (virPCIDeviceGetDriverNameAndType(dev, &drvName, &drvType) < 0)
goto cleanup;
- if (virPCIStubDriverTypeFromString(drvName) == VIR_PCI_STUB_DRIVER_VFIO) {
- VIR_DEBUG("Device %s is bound to vfio-pci - skip reset",
- dev->name);
+ if (drvType == VIR_PCI_STUB_DRIVER_VFIO) {
+
+ VIR_DEBUG("Device %s is bound to %s - skip reset", dev->name, drvName);
ret = 0;
goto cleanup;
}
+
VIR_DEBUG("Resetting device %s", dev->name);
if ((fd = virPCIDeviceConfigOpenWrite(dev)) < 0)
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 4d9193f24e..0532b90f90 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -280,6 +280,9 @@ int virPCIDeviceRebind(virPCIDevice *dev);
int virPCIDeviceGetDriverPathAndName(virPCIDevice *dev,
char **path,
char **name);
+int virPCIDeviceGetDriverNameAndType(virPCIDevice *dev,
+ char **drvName,
+ virPCIStubDriver *drvType);
int virPCIDeviceIsPCIExpress(virPCIDevice *dev);
int virPCIDeviceHasPCIExpressLink(virPCIDevice *dev);
--
2.37.1
1 year, 5 months
[PATCH] qemu_passt: Format portForward device even without address
by Michal Privoznik
It's almost like we've anticipated this. Our XML parser and
formatter handles @address and @dev attributes of <portForward/>
element completely independent of each other. And as of commit
2023_03_29.b10b983~3 passt allows handling these two separately
too. All that's left is generate the cmd line according to this
new fact.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2210287
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_passt.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c
index 0712ca0b16..99636a3a49 100644
--- a/src/qemu/qemu_passt.c
+++ b/src/qemu/qemu_passt.c
@@ -221,6 +221,7 @@ qemuPasstStart(virDomainObj *vm,
for (i = 0; i < net->nPortForwards; i++) {
virDomainNetPortForward *pf = net->portForwards[i];
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+ bool emitsep = false;
if (pf->proto == VIR_DOMAIN_NET_PROTO_TCP) {
virCommandAddArg(cmd, "--tcp-ports");
@@ -240,12 +241,16 @@ qemuPasstStart(virDomainObj *vm,
return -1;
virBufferAddStr(&buf, addr);
+ emitsep = true;
+ }
- if (pf->dev)
- virBufferAsprintf(&buf, "%%%s", pf->dev);
+ if (pf->dev) {
+ virBufferAsprintf(&buf, "%%%s", pf->dev);
+ emitsep = true;
+ }
+ if (emitsep)
virBufferAddChar(&buf, '/');
- }
if (!pf->nRanges) {
virBufferAddLit(&buf, "all");
--
2.39.3
1 year, 5 months
Release of libvirt-9.4.0
by Jiri Denemark
The 9.4.0 release of both libvirt and libvirt-python is tagged and
signed tarballs and source RPMs are available at
https://download.libvirt.org/
https://download.libvirt.org/python/
Thanks everybody who helped with this release by sending patches,
reviewing, testing, or providing feedback. Your work is greatly
appreciated.
* New features
* qemu: Support compression for parallel migration
QEMU supports parallel migration to be compressed using either zstd or zlib.
* Improvements
* Adapt to musl-1.2.4
The latest version of musl stopped declaring some symbols that libvirt's
test suite used (for redirecting ``stat()`` family of functions), leaving
the tests broken. This is now fixed and the test suite works even with the
latest version of musl.
* conf: Introduce ``<address/>`` for virtio-mem and virtio-pmem
To ensure guest ABI stability, libvirt persists address for memory devices,
now including ``virtio-mem`` and ``virtio-pmem``. The address can be also
specified by user.
* Bug fixes
* qemu: Account for NVMe disks when calculating memlock limit on hotplug
When no ``<hard_limit/>`` is set, libvirt still tries to guess a sensible
limit for memlock for domains. But this limit was not calculated properly
on a hotplug of ``<disk type='nvme'/>``.
* numa: Deny other memory modes than ``restrictive``` if a memnode is ``restrictive``
Due to a missing check it was possible to define a domain with incorrect
``<numatune/>``. For instance it was possible to have a ``<memnode
mode="restrictive"/>`` and ``<memory/>`` of a different mode. This is now
forbidden and if either all ``<memnode/>``-s and ``<memory/>`` have to have
``restrictive`` mode, or none.
* qemu: Start emulator thread with more generous ``cpuset.mems``
To ensure memory is allocated only from configured NUMA nodes, libvirt sets
up cpuset CGgroup controller, even before QEMU is executed. But this may
prevent QEMU from setting affinity of threads that allocate memory. Since
these threads are spawned from the emulator thread, the initial set up must
be more generous and include union of all host NUMA nodes that are allowed
in the domain definition. Once QEMU has allocated all its memory, the
emulator thread is restricted further, as it otherwise would be.
Enjoy.
Jirka
1 year, 5 months
[libvirt PATCH v2] ci: refresh with latest lcitool manifest
by Erik Skultety
Main lcitool changes:
- added Alpine 3.17 and 3.18 targets
- dropped Alpine 3.15 and 3.16
Note that we're not actively testing all Alpine targets due to CI
quota, so only 3.17 is used as a replacement for 3.15 in this patch.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
ci/buildenv/{alpine-315.sh => alpine-317.sh} | 1 +
.../{alpine-315.Dockerfile => alpine-317.Dockerfile} | 3 ++-
ci/gitlab/builds.yml | 12 ++++++------
ci/gitlab/container-templates.yml | 2 +-
ci/gitlab/containers.yml | 4 ++--
ci/manifest.yml | 2 +-
6 files changed, 13 insertions(+), 11 deletions(-)
rename ci/buildenv/{alpine-315.sh => alpine-317.sh} (99%)
rename ci/containers/{alpine-315.Dockerfile => alpine-317.Dockerfile} (97%)
diff --git a/ci/buildenv/alpine-315.sh b/ci/buildenv/alpine-317.sh
similarity index 99%
rename from ci/buildenv/alpine-315.sh
rename to ci/buildenv/alpine-317.sh
index 975914a7c2..e3f36ff8c6 100644
--- a/ci/buildenv/alpine-315.sh
+++ b/ci/buildenv/alpine-317.sh
@@ -60,6 +60,7 @@ function install_buildenv() {
python3 \
qemu-img \
readline-dev \
+ rpcgen \
samurai \
sed \
util-linux-dev \
diff --git a/ci/containers/alpine-315.Dockerfile b/ci/containers/alpine-317.Dockerfile
similarity index 97%
rename from ci/containers/alpine-315.Dockerfile
rename to ci/containers/alpine-317.Dockerfile
index bad7e87c2b..162ae5671b 100644
--- a/ci/containers/alpine-315.Dockerfile
+++ b/ci/containers/alpine-317.Dockerfile
@@ -4,7 +4,7 @@
#
# https://gitlab.com/libvirt/libvirt-ci
-FROM docker.io/library/alpine:3.15
+FROM docker.io/library/alpine:3.17
RUN apk update && \
apk upgrade && \
@@ -61,6 +61,7 @@ RUN apk update && \
python3 \
qemu-img \
readline-dev \
+ rpcgen \
samurai \
sed \
util-linux-dev \
diff --git a/ci/gitlab/builds.yml b/ci/gitlab/builds.yml
index 96f8d3fb43..8910a19c79 100644
--- a/ci/gitlab/builds.yml
+++ b/ci/gitlab/builds.yml
@@ -51,22 +51,22 @@ x86_64-almalinux-8-clang-local-env:
RPM: skip
-x86_64-alpine-315-prebuilt-env:
+x86_64-alpine-317-prebuilt-env:
extends: .native_build_job_prebuilt_env
needs:
- - job: x86_64-alpine-315-container
+ - job: x86_64-alpine-317-container
optional: true
allow_failure: false
variables:
- NAME: alpine-315
+ NAME: alpine-317
-x86_64-alpine-315-local-env:
+x86_64-alpine-317-local-env:
extends: .native_build_job_local_env
needs: []
allow_failure: false
variables:
- IMAGE: docker.io/library/alpine:3.15
- NAME: alpine-315
+ IMAGE: docker.io/library/alpine:3.17
+ NAME: alpine-317
x86_64-alpine-edge-prebuilt-env:
diff --git a/ci/gitlab/container-templates.yml b/ci/gitlab/container-templates.yml
index edb4aba676..adc8a1a312 100644
--- a/ci/gitlab/container-templates.yml
+++ b/ci/gitlab/container-templates.yml
@@ -14,7 +14,7 @@
# Note: never publish from merge requests since they have non-committed code
#
.container_job:
- image: docker:stable
+ image: docker:latest
stage: containers
interruptible: false
needs: []
diff --git a/ci/gitlab/containers.yml b/ci/gitlab/containers.yml
index 3be84a2106..671483813e 100644
--- a/ci/gitlab/containers.yml
+++ b/ci/gitlab/containers.yml
@@ -14,11 +14,11 @@ x86_64-almalinux-8-container:
NAME: almalinux-8
-x86_64-alpine-315-container:
+x86_64-alpine-317-container:
extends: .container_job
allow_failure: false
variables:
- NAME: alpine-315
+ NAME: alpine-317
x86_64-alpine-edge-container:
diff --git a/ci/manifest.yml b/ci/manifest.yml
index 85d699bfae..4504068a64 100644
--- a/ci/manifest.yml
+++ b/ci/manifest.yml
@@ -19,7 +19,7 @@ targets:
RPM: skip
CC: clang
- alpine-315: x86_64
+ alpine-317: x86_64
alpine-edge:
jobs:
--
2.40.1
1 year, 5 months
[PATCH] qemu: add unmap stats to all domain stats
by Oleg Vasilev
From: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
Unmap stats are useful for debugging how efficient qemu is in freeing host
disk space.
Signed-off-by: Oleg Vasilev <oleg.vasilev(a)virtuozzo.com>
---
src/qemu/qemu_driver.c | 3 +++
src/qemu/qemu_monitor.h | 3 +++
src/qemu/qemu_monitor_json.c | 3 +++
3 files changed, 9 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5ee15bab7a..6725bddff9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17451,6 +17451,9 @@ qemuDomainGetStatsBlockExportFrontend(const char *frontendname,
virTypedParamListAddULLong(par, en->wr_req, "block.%zu.wr.reqs", idx) < 0 ||
virTypedParamListAddULLong(par, en->wr_bytes, "block.%zu.wr.bytes", idx) < 0 ||
virTypedParamListAddULLong(par, en->wr_total_times, "block.%zu.wr.times", idx) < 0 ||
+ virTypedParamListAddULLong(par, en->unmap_req, "block.%zu.un.reqs", idx) < 0 ||
+ virTypedParamListAddULLong(par, en->unmap_bytes, "block.%zu.un.bytes", idx) < 0 ||
+ virTypedParamListAddULLong(par, en->unmap_total_times, "block.%zu.un.times", idx) < 0 ||
virTypedParamListAddULLong(par, en->flush_req, "block.%zu.fl.reqs", idx) < 0 ||
virTypedParamListAddULLong(par, en->flush_total_times, "block.%zu.fl.times", idx) < 0)
return -1;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 72db0c0838..0c34319ea2 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -667,6 +667,9 @@ struct _qemuBlockStats {
unsigned long long wr_total_times;
unsigned long long flush_req;
unsigned long long flush_total_times;
+ unsigned long long unmap_req;
+ unsigned long long unmap_bytes;
+ unsigned long long unmap_total_times;
unsigned long long capacity;
unsigned long long physical;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index b2c0b20a11..c0fe4a7554 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2280,6 +2280,9 @@ qemuMonitorJSONBlockStatsCollectData(virJSONValue *dev,
QEMU_MONITOR_BLOCK_STAT_GET("wr_total_time_ns", bstats->wr_total_times, false);
QEMU_MONITOR_BLOCK_STAT_GET("flush_operations", bstats->flush_req, false);
QEMU_MONITOR_BLOCK_STAT_GET("flush_total_time_ns", bstats->flush_total_times, false);
+ QEMU_MONITOR_BLOCK_STAT_GET("unmap_operations", bstats->unmap_req, false);
+ QEMU_MONITOR_BLOCK_STAT_GET("unmap_bytes", bstats->unmap_bytes, false);
+ QEMU_MONITOR_BLOCK_STAT_GET("unmap_total_time_ns", bstats->unmap_total_times, false);
#undef QEMU_MONITOR_BLOCK_STAT_GET
if ((parent = virJSONValueObjectGetObject(dev, "parent")) &&
--
2.40.1
1 year, 5 months
[libvirt PATCHv3 for 9.4.0] conf: node_device: use separate variables for parsing integers
by Ján Tomko
In virNodeDeviceGetSCSIHostCaps, there is a pattern of reusing
a tmp value and stealing the pointer.
But in two case it is not stolen. Use separate variables for them
to avoid mixing autofree with manual free() calls.
This fixes the memory leak of the "max_npiv_vports" string.
(The other gets freed anyway because it was the last use of "tmp"
in the function")
Fixes: 8a0cb5f73ade3900546718eabe70cb064c6bd22c
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
v3: fix "declaration after statement" warning
src/conf/node_device_conf.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index fcee9c027c..172223225f 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2857,29 +2857,32 @@ virNodeDeviceGetSCSIHostCaps(virNodeDevCapSCSIHost *scsi_host)
}
if (virVHBAIsVportCapable(NULL, scsi_host->host)) {
+ g_autofree char *max_vports = NULL;
+ g_autofree char *vports = NULL;
+
scsi_host->flags |= VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS;
- if (!(tmp = virVHBAGetConfig(NULL, scsi_host->host,
+ if (!(max_vports = virVHBAGetConfig(NULL, scsi_host->host,
"max_npiv_vports"))) {
VIR_WARN("Failed to read max_npiv_vports for host%d",
scsi_host->host);
goto cleanup;
}
- if (virStrToLong_i(tmp, NULL, 10, &scsi_host->max_vports) < 0) {
- VIR_WARN("Failed to parse value of max_npiv_vports '%s'", tmp);
+ if (virStrToLong_i(max_vports, NULL, 10, &scsi_host->max_vports) < 0) {
+ VIR_WARN("Failed to parse value of max_npiv_vports '%s'", max_vports);
goto cleanup;
}
- if (!(tmp = virVHBAGetConfig(NULL, scsi_host->host,
+ if (!(vports = virVHBAGetConfig(NULL, scsi_host->host,
"npiv_vports_inuse"))) {
VIR_WARN("Failed to read npiv_vports_inuse for host%d",
scsi_host->host);
goto cleanup;
}
- if (virStrToLong_i(tmp, NULL, 10, &scsi_host->vports) < 0) {
- VIR_WARN("Failed to parse value of npiv_vports_inuse '%s'", tmp);
+ if (virStrToLong_i(vports, NULL, 10, &scsi_host->vports) < 0) {
+ VIR_WARN("Failed to parse value of npiv_vports_inuse '%s'", vports);
goto cleanup;
}
}
--
2.40.1
1 year, 5 months