[PATCH] node_device: fix leak of DIR*
by Laine Stump
Commit 53aec799fa31 introduced the function udevGetVDPACharDev(),
which scans a directory using virDirOpenIfExists() and
virDirRead(). It unfortunately forgets to close the DIR* when it is
finished with it. This patch fixes that omission.
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
src/node_device/node_device_udev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index b1b8427c05..ec0bf9192b 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1162,6 +1162,7 @@ udevGetVDPACharDev(const char *sysfs_path,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("vDPA chardev path '%s' does not exist"),
chardev);
+ VIR_DIR_CLOSE(dir);
return -1;
}
VIR_DEBUG("vDPA chardev is at '%s'", chardev);
@@ -1171,6 +1172,8 @@ udevGetVDPACharDev(const char *sysfs_path,
}
}
+ VIR_DIR_CLOSE(dir);
+
if (direrr < 0)
return -1;
--
2.26.2
4 years
[libvirt PATCH v2] libvirt-guests: Sync time for autostarted guests
by Tim Wiederhake
From: Orion Poplawski <orion(a)nwra.com>
Setting SYNC_TIME=1 does not work on autostarted guests.
See https://bugzilla.redhat.com/show_bug.cgi?id=1555398.
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
tools/libvirt-guests.sh.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
index d69df908d2..87f96af14d 100644
--- a/tools/libvirt-guests.sh.in
+++ b/tools/libvirt-guests.sh.in
@@ -206,9 +206,9 @@ start() {
retval run_virsh "$uri" start $bypass "$name" \
>/dev/null && \
gettext "done"; echo
- if "$sync_time"; then
- run_virsh "$uri" domtime --sync "$name" >/dev/null
- fi
+ fi
+ if "$sync_time"; then
+ run_virsh "$uri" domtime --sync "$name" >/dev/null
fi
fi
done
--
2.26.2
4 years
migration/dirtyrate: Introduce APIs for getting domain memory dirty rate
by Hao Wang
V2 -> V3:
reorganize patchset to fix compile warning
V1 -> V2:
replace QEMU_JOB_ASYNC with QEMU_JOB_QUERY
Sometimes domain's memory dirty rate is expected by user in order to
decide whether it's proper to be migrated out or not.
We have already completed the QEMU part of the capability:
https://patchew.org/QEMU/1600237327-33618-1-git-send-email-zhengchuan@hua...
And this serial of patches introduce the corresponding LIBVIRT part --
DomainGetDirtyRateInfo API and corresponding virsh api -- "getdirtyrate".
instructions:
bash# virsh getdirtyrate --help
NAME
getdirtyrate - Get a vm's memory dirty rate
SYNOPSIS
getdirtyrate <domain> [--seconds <number>] [--calculate] [--query]
DESCRIPTION
Get memory dirty rate of a domain in order to decide whether it's proper to be migrated out or not.
OPTIONS
[--domain] <string> domain name, id or uuid
--seconds <number> calculate memory dirty rate within specified seconds, a valid range of values is [1, 60], and would default to 1s.
--calculate calculate dirty rate only, can be used together with --query, either or both is expected, otherwise would default to both.
--query query dirty rate only, can be used together with --calculate, either or both is expected, otherwise would default to both.
example:
bash# virsh getdirtyrate --calculate --query --domain vm0 --seconds 1
status: measured
startTime: 820148
calcTime: 1 s
dirtyRate: 6 MB/s
Hao Wang (7):
migration/dirtyrate: Introduce virDomainDirtyRateInfo structure
migration/dirtyrate: set up framwork of domainGetDirtyRateInfo API
migration/dirtyrate: Implement qemuDomainGetDirtyRateInfo
migration/dirtyrate: Implement qemuDomainCalculateDirtyRate
migration/dirtyrate: Implement qemuDomainCalculateDirtyRate
migration/dirtyrate: Implement qemuMonitorJSONExtractDirtyRateInfo
migration/dirtyrate: Introduce getdirtyrate virsh api
include/libvirt/libvirt-domain.h | 56 ++++++++++++++++
src/driver-hypervisor.h | 7 ++
src/libvirt-domain.c | 46 +++++++++++++
src/libvirt_public.syms | 5 ++
src/qemu/qemu_driver.c | 67 ++++++++++++++++++
src/qemu/qemu_migration.c | 59 ++++++++++++++++
src/qemu/qemu_migration.h | 10 +++
src/qemu/qemu_monitor.c | 24 +++++++
src/qemu/qemu_monitor.h | 8 +++
src/qemu/qemu_monitor_json.c | 97 ++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 8 +++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 21 +++++-
tools/virsh-domain.c | 112 +++++++++++++++++++++++++++++++
14 files changed, 520 insertions(+), 1 deletion(-)
--
2.23.0
4 years
[PULL 06/12] nbd: Update qapi to support exporting multiple bitmaps
by Eric Blake
Since 'block-export-add' is new to 5.2, we can still tweak the
interface; there, allowing 'bitmaps':['str'] is nicer than
'bitmap':'str'. This wires up the qapi and qemu-nbd changes to permit
passing multiple bitmaps as distinct metadata contexts that the NBD
client may request, but the actual support for more than one will
require a further patch to the server.
Note that there are no changes made to the existing deprecated
'nbd-server-add' command; this required splitting the QAPI type
BlockExportOptionsNbd, which fortunately does not affect QMP
introspection.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
Message-Id: <20201027050556.269064-5-eblake(a)redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov(a)virtuozzo.com>
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
---
docs/system/deprecated.rst | 3 ++-
qapi/block-export.json | 41 +++++++++++++++++++++++++++-----------
blockdev-nbd.c | 6 +++++-
nbd/server.c | 19 ++++++++++++------
qemu-nbd.c | 18 ++++++++---------
5 files changed, 58 insertions(+), 29 deletions(-)
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 0ebce37a1919..32a0e620dbb9 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -257,7 +257,8 @@ the 'wait' field, which is only applicable to sockets in server mode
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Use the more generic commands ``block-export-add`` and ``block-export-del``
-instead.
+instead. As part of this deprecation, where ``nbd-server-add`` used a
+single ``bitmap``, the new ``block-export-add`` uses a list of ``bitmaps``.
Human Monitor Protocol (HMP) commands
-------------------------------------
diff --git a/qapi/block-export.json b/qapi/block-export.json
index 480c497690b0..c4125f4d2104 100644
--- a/qapi/block-export.json
+++ b/qapi/block-export.json
@@ -63,10 +63,10 @@
'*max-connections': 'uint32' } }
##
-# @BlockExportOptionsNbd:
+# @BlockExportOptionsNbdBase:
#
-# An NBD block export (options shared between nbd-server-add and the NBD branch
-# of block-export-add).
+# An NBD block export (common options shared between nbd-server-add and
+# the NBD branch of block-export-add).
#
# @name: Export name. If unspecified, the @device parameter is used as the
# export name. (Since 2.12)
@@ -74,15 +74,27 @@
# @description: Free-form description of the export, up to 4096 bytes.
# (Since 5.0)
#
-# @bitmap: Also export the dirty bitmap reachable from @device, so the
-# NBD client can use NBD_OPT_SET_META_CONTEXT with
-# "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0)
-#
# Since: 5.0
##
+{ 'struct': 'BlockExportOptionsNbdBase',
+ 'data': { '*name': 'str', '*description': 'str' } }
+
+##
+# @BlockExportOptionsNbd:
+#
+# An NBD block export (distinct options used in the NBD branch of
+# block-export-add).
+#
+# @bitmaps: Also export each of the named dirty bitmaps reachable from
+# @device, so the NBD client can use NBD_OPT_SET_META_CONTEXT with
+# the metadata context name "qemu:dirty-bitmap:BITMAP" to inspect
+# each bitmap.
+#
+# Since: 5.2
+##
{ 'struct': 'BlockExportOptionsNbd',
- 'data': { '*name': 'str', '*description': 'str',
- '*bitmap': 'str' } }
+ 'base': 'BlockExportOptionsNbdBase',
+ 'data': { '*bitmaps': ['str'] } }
##
# @BlockExportOptionsVhostUserBlk:
@@ -106,19 +118,24 @@
##
# @NbdServerAddOptions:
#
-# An NBD block export.
+# An NBD block export, per legacy nbd-server-add command.
#
# @device: The device name or node name of the node to be exported
#
# @writable: Whether clients should be able to write to the device via the
# NBD connection (default false).
#
+# @bitmap: Also export a single dirty bitmap reachable from @device, so the
+# NBD client can use NBD_OPT_SET_META_CONTEXT with the metadata
+# context name "qemu:dirty-bitmap:BITMAP" to inspect the bitmap
+# (since 4.0).
+#
# Since: 5.0
##
{ 'struct': 'NbdServerAddOptions',
- 'base': 'BlockExportOptionsNbd',
+ 'base': 'BlockExportOptionsNbdBase',
'data': { 'device': 'str',
- '*writable': 'bool' } }
+ '*writable': 'bool', '*bitmap': 'str' } }
##
# @nbd-server-add:
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index cee9134b12eb..d8443d235b73 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -209,8 +209,12 @@ void qmp_nbd_server_add(NbdServerAddOptions *arg, Error **errp)
.has_writable = arg->has_writable,
.writable = arg->writable,
};
- QAPI_CLONE_MEMBERS(BlockExportOptionsNbd, &export_opts->u.nbd,
+ QAPI_CLONE_MEMBERS(BlockExportOptionsNbdBase, &export_opts->u.nbd,
qapi_NbdServerAddOptions_base(arg));
+ if (arg->has_bitmap) {
+ export_opts->u.nbd.has_bitmaps = true;
+ QAPI_LIST_PREPEND(export_opts->u.nbd.bitmaps, g_strdup(arg->bitmap));
+ }
/*
* nbd-server-add doesn't complain when a read-only device should be
diff --git a/nbd/server.c b/nbd/server.c
index 08b621f70a3a..8d01662b4511 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1474,6 +1474,7 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
uint64_t perm, shared_perm;
bool readonly = !exp_args->writable;
bool shared = !exp_args->writable;
+ strList *bitmaps;
int ret;
assert(exp_args->type == BLOCK_EXPORT_TYPE_NBD);
@@ -1533,12 +1534,18 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
}
exp->size = QEMU_ALIGN_DOWN(size, BDRV_SECTOR_SIZE);
- if (arg->bitmap) {
+ /* XXX Allow more than one bitmap */
+ if (arg->bitmaps && arg->bitmaps->next) {
+ error_setg(errp, "multiple bitmaps per export not supported yet");
+ return -EOPNOTSUPP;
+ }
+ for (bitmaps = arg->bitmaps; bitmaps; bitmaps = bitmaps->next) {
+ const char *bitmap = bitmaps->value;
BlockDriverState *bs = blk_bs(blk);
BdrvDirtyBitmap *bm = NULL;
while (bs) {
- bm = bdrv_find_dirty_bitmap(bs, arg->bitmap);
+ bm = bdrv_find_dirty_bitmap(bs, bitmap);
if (bm != NULL) {
break;
}
@@ -1548,7 +1555,7 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
if (bm == NULL) {
ret = -ENOENT;
- error_setg(errp, "Bitmap '%s' is not found", arg->bitmap);
+ error_setg(errp, "Bitmap '%s' is not found", bitmap);
goto fail;
}
@@ -1562,15 +1569,15 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
ret = -EINVAL;
error_setg(errp,
"Enabled bitmap '%s' incompatible with readonly export",
- arg->bitmap);
+ bitmap);
goto fail;
}
bdrv_dirty_bitmap_set_busy(bm, true);
exp->export_bitmap = bm;
- assert(strlen(arg->bitmap) <= BDRV_BITMAP_MAX_NAME_SIZE);
+ assert(strlen(bitmap) <= BDRV_BITMAP_MAX_NAME_SIZE);
exp->export_bitmap_context = g_strdup_printf("qemu:dirty-bitmap:%s",
- arg->bitmap);
+ bitmap);
assert(strlen(exp->export_bitmap_context) < NBD_MAX_STRING_SIZE);
}
diff --git a/qemu-nbd.c b/qemu-nbd.c
index a0701cdf369d..74e73a74657b 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -574,7 +574,7 @@ int main(int argc, char **argv)
QDict *options = NULL;
const char *export_name = NULL; /* defaults to "" later for server mode */
const char *export_description = NULL;
- const char *bitmap = NULL;
+ strList *bitmaps = NULL;
const char *tlscredsid = NULL;
bool imageOpts = false;
bool writethrough = true;
@@ -690,7 +690,7 @@ int main(int argc, char **argv)
flags &= ~BDRV_O_RDWR;
break;
case 'B':
- bitmap = optarg;
+ QAPI_LIST_PREPEND(bitmaps, g_strdup(optarg));
break;
case 'k':
sockpath = optarg;
@@ -786,7 +786,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
if (export_name || export_description || dev_offset ||
- device || disconnect || fmt || sn_id_or_name || bitmap ||
+ device || disconnect || fmt || sn_id_or_name || bitmaps ||
seen_aio || seen_discard || seen_cache) {
error_report("List mode is incompatible with per-device settings");
exit(EXIT_FAILURE);
@@ -1067,12 +1067,12 @@ int main(int argc, char **argv)
.has_writable = true,
.writable = !readonly,
.u.nbd = {
- .has_name = true,
- .name = g_strdup(export_name),
- .has_description = !!export_description,
- .description = g_strdup(export_description),
- .has_bitmap = !!bitmap,
- .bitmap = g_strdup(bitmap),
+ .has_name = true,
+ .name = g_strdup(export_name),
+ .has_description = !!export_description,
+ .description = g_strdup(export_description),
+ .has_bitmaps = !!bitmaps,
+ .bitmaps = bitmaps,
},
};
blk_exp_add(export_opts, &error_fatal);
--
2.29.0
4 years
[PATCH] re-add cscope db files to .gitignore
by Laine Stump
Commit f7114e61db removed these lines as being "old and
obsolete". cscope may be old, but it is still very much useful and
used (i.e. *not* obsolete), and having the files show up as "Untracked
files:" every time git status is run is annoying.
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
I'm not sure why I didn't notice this omission until now, but a couple
weeks ago it resulted in my accidentally committing my cscope.out and
cscope.files to git (fortunately I noticed it before I posted the
patch!)
It could be argued (as abologna did on IRC) that users should just add
these to their private user-global .gitignore, but if that's the case,
then the vim and emacs-related files should also be removed from
libvirt's .gitignore (also suggested by abologna :-)).
However if you do that, then any time you checkout libvirt on some
random new machine where you haven't imported your personal home
directory template will end up showing these by-product files. Also,
somebody newly entering the project will potentially have the files
showing up and bothering them.
Anyway, I'm not necessarily advocating for re-adding the cscope files,
but sending a patch seemed to be like the most useful way of
discussing it.
.gitignore | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/.gitignore b/.gitignore
index 6d44a50061..feb2bcb017 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,12 @@
.#*
*~
+# cscope related ignores
+cscope.files
+cscope.in.out
+cscope.out
+cscope.po.out
+
# git related ignores
*.rej
*.orig
--
2.26.2
4 years
[PATCH] cpu_ppc64: compare CPU function is ignoring return value
by Julio Faracco
Function to compare CPU on 64-bit PowerPC is ignoring the flag to avoid
failure in case of CPUs (host and guest) are incompatible. Basically, the
function is returning -1 even if it is set to continue.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/cpu/cpu_ppc64.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index 2fedcd25da..23ea5a6a3e 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -517,7 +517,7 @@ virCPUppc64Compare(virCPUDefPtr host,
virCPUDefPtr cpu,
bool failIncompatible)
{
- virCPUCompareResult ret;
+ virCPUCompareResult ret = -1;
g_autofree char *message = NULL;
if (!host || !host->model) {
@@ -528,7 +528,7 @@ virCPUppc64Compare(virCPUDefPtr host,
VIR_WARN("unknown host CPU");
ret = VIR_CPU_COMPARE_INCOMPATIBLE;
}
- return -1;
+ return ret;
}
ret = ppc64Compute(host, cpu, NULL, &message);
--
2.25.1
4 years
[PATCH] util: Avoid double free in virProcessSetAffinity
by Martin Kletzander
The cpu mask was free()'d immediately on any error and at the end of the
function, where it was expected that it would either error out and return or
goto another allocation if the code was to fail. However since commit
9514e24984ee the error path did not return in one new case which caused
double-free in such situation. In order to make the code more straightforward
just free the mask after it's been used even before checking the return code of
the call.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1819801
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/util/virprocess.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 9366f0630c42..37413796b3f6 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -447,6 +447,7 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map, bool quiet)
int numcpus = 1024;
size_t masklen;
cpu_set_t *mask;
+ int rv = -1;
VIR_DEBUG("Set process affinity on %lld", (long long)pid);
@@ -472,8 +473,10 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map, bool quiet)
CPU_SET_S(i, masklen, mask);
}
- if (sched_setaffinity(pid, masklen, mask) < 0) {
- CPU_FREE(mask);
+ rv = sched_setaffinity(pid, masklen, mask);
+ CPU_FREE(mask);
+
+ if (rv < 0) {
if (errno == EINVAL &&
numcpus < (1024 << 8)) { /* 262144 cpus ought to be enough for anyone */
numcpus = numcpus << 2;
@@ -488,7 +491,6 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map, bool quiet)
return -1;
}
}
- CPU_FREE(mask);
return 0;
}
--
2.28.0
4 years
[PATCH 00/13] Replace virHashTable by GHashTable (for 6.10)
by Peter Krempa
Our hash table API was surprisingly close to glibs.
Peter Krempa (13):
virhashtest: testHashGetItems: Remove test case for sorting by value
util: hash: Rewrite sorting of elements in virHashGetItems
util: virhash: Standardize on 'opaque' for opaque data
util: hash: Introduce virHashForEachSorted
Use virHashForEachSorted in tested code
tests: remove virdeterministichashmock.so
util: hash: Add delete-safe hash iterator
util: hash: Use virHashForEachSafe in places which might delete the
element
util: hash: Don't use 'const' with virHashTablePtr
util: hash: Reimplement virHashTable using GHashTable
util: hash: Retire 'virHashTable' in favor of 'GHashTable'
util: hash: Add deprecation notices for functions which have
g_hash_table replacements
tests: Remove 'virhashtest'
src/conf/backup_conf.c | 2 +-
src/conf/domain_addr.h | 2 +-
src/conf/domain_conf.c | 12 +-
src/conf/domain_conf.h | 2 +-
src/conf/nwfilter_conf.h | 2 +-
src/conf/nwfilter_ipaddrmap.c | 2 +-
src/conf/nwfilter_params.c | 34 +-
src/conf/nwfilter_params.h | 18 +-
src/conf/snapshot_conf.c | 2 +-
src/conf/virchrdev.c | 4 +-
src/conf/virdomainmomentobjlist.c | 4 +-
src/conf/virdomainobjlist.c | 6 +-
src/conf/virinterfaceobj.c | 2 +-
src/conf/virnetworkobj.c | 8 +-
src/conf/virnodedeviceobj.c | 2 +-
src/conf/virnwfilterbindingdef.h | 2 +-
src/conf/virnwfilterbindingobjlist.c | 4 +-
src/conf/virsecretobj.c | 2 +-
src/conf/virstorageobj.c | 14 +-
src/hyperv/hyperv_driver.c | 4 +-
src/hyperv/hyperv_wmi.c | 18 +-
src/hyperv/hyperv_wmi.h | 12 +-
src/hypervisor/virclosecallbacks.c | 2 +-
src/libvirt_private.syms | 6 +-
src/libxl/libxl_logger.c | 2 +-
src/locking/lock_daemon.c | 4 +-
src/nwfilter/nwfilter_dhcpsnoop.c | 6 +-
src/nwfilter/nwfilter_ebiptables_driver.c | 19 +-
src/nwfilter/nwfilter_gentech_driver.c | 36 +-
src/nwfilter/nwfilter_gentech_driver.h | 2 +-
src/nwfilter/nwfilter_learnipaddr.c | 4 +-
src/nwfilter/nwfilter_tech_driver.h | 2 +-
src/qemu/qemu_agent.c | 4 +-
src/qemu/qemu_backup.c | 14 +-
src/qemu/qemu_backup.h | 2 +-
src/qemu/qemu_block.c | 42 +-
src/qemu/qemu_block.h | 18 +-
src/qemu/qemu_blockjob.c | 6 +-
src/qemu/qemu_capabilities.c | 8 +-
src/qemu/qemu_checkpoint.c | 6 +-
src/qemu/qemu_checkpoint.h | 2 +-
src/qemu/qemu_conf.c | 4 +-
src/qemu/qemu_conf.h | 2 +-
src/qemu/qemu_domain.c | 8 +-
src/qemu/qemu_domain.h | 2 +-
src/qemu/qemu_driver.c | 24 +-
src/qemu/qemu_interop_config.c | 13 +-
src/qemu/qemu_migration.c | 2 +-
src/qemu/qemu_migration_cookie.c | 2 +-
src/qemu/qemu_monitor.c | 28 +-
src/qemu/qemu_monitor.h | 20 +-
src/qemu/qemu_monitor_json.c | 50 +-
src/qemu/qemu_monitor_json.h | 22 +-
src/qemu/qemu_process.c | 18 +-
src/qemu/qemu_qapi.c | 14 +-
src/qemu/qemu_qapi.h | 6 +-
src/qemu/qemu_snapshot.c | 16 +-
src/rpc/virnetdaemon.c | 13 +-
src/security/security_selinux.c | 2 +-
src/util/meson.build | 1 -
src/util/virfilecache.c | 2 +-
src/util/virhash.c | 569 +++++++-----------
src/util/virhash.h | 57 +-
src/util/virhashcode.c | 125 ----
src/util/virhashcode.h | 33 -
src/util/viriptables.c | 4 +-
src/util/virlockspace.c | 4 +-
src/util/virmacmap.c | 4 +-
src/util/virstoragefile.c | 8 +-
src/util/virsystemd.c | 2 +-
tests/meson.build | 2 -
tests/nwfilterxml2firewalltest.c | 24 +-
tests/qemublocktest.c | 26 +-
tests/qemuhotplugtest.c | 6 +-
tests/qemumigparamstest.c | 4 +-
tests/qemumonitorjsontest.c | 30 +-
tests/qemumonitortestutils.c | 6 +-
tests/qemumonitortestutils.h | 4 +-
tests/qemusecuritymock.c | 4 +-
.../blockjob-blockdev-in.xml | 116 ++--
tests/qemuxml2argvtest.c | 4 +-
tests/qemuxml2xmltest.c | 5 +-
tests/testutilsqemu.c | 6 +-
tests/testutilsqemu.h | 4 +-
tests/testutilsqemuschema.c | 10 +-
tests/testutilsqemuschema.h | 8 +-
tests/virdeterministichashmock.c | 36 --
tests/virhashdata.h | 284 ---------
tests/virhashtest.c | 564 -----------------
tests/virmacmaptest.c | 2 +-
90 files changed, 680 insertions(+), 1863 deletions(-)
delete mode 100644 src/util/virhashcode.c
delete mode 100644 src/util/virhashcode.h
delete mode 100644 tests/virdeterministichashmock.c
delete mode 100644 tests/virhashdata.h
delete mode 100644 tests/virhashtest.c
--
2.26.2
4 years
[PATCH] news: Mention nodedev support for CSS on S390
by Boris Fiuczynski
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
NEWS.rst | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/NEWS.rst b/NEWS.rst
index 5bd8ed1c91..2fef3f706c 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -13,6 +13,12 @@ v6.9.0 (unreleased)
* **New features**
+ * nodedev: Add support for channel subsystem (CSS) devices on S390
+
+ A CSS device is represented as a parent device of a CCW device.
+ This support allows to create vfio-ccw mediated devices with
+ ``virNodeDeviceCreateXML()``.
+
* qemu: Implement memory failure event
New event is implemented that is emitted whenever a guest encounters a
--
2.25.1
4 years
[PATCH v6 04/11] nbd: Update qapi to support exporting multiple bitmaps
by Eric Blake
Since 'block-export-add' is new to 5.2, we can still tweak the
interface; there, allowing 'bitmaps':['str'] is nicer than
'bitmap':'str'. This wires up the qapi and qemu-nbd changes to permit
passing multiple bitmaps as distinct metadata contexts that the NBD
client may request, but the actual support for more than one will
require a further patch to the server.
Note that there are no changes made to the existing deprecated
'nbd-server-add' command; this required splitting the QAPI type
BlockExportOptionsNbd, which fortunately does not affect QMP
introspection.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
docs/system/deprecated.rst | 3 ++-
qapi/block-export.json | 41 +++++++++++++++++++++++++++-----------
blockdev-nbd.c | 6 +++++-
nbd/server.c | 19 ++++++++++++------
qemu-nbd.c | 18 ++++++++---------
5 files changed, 58 insertions(+), 29 deletions(-)
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 0ebce37a1919..32a0e620dbb9 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -257,7 +257,8 @@ the 'wait' field, which is only applicable to sockets in server mode
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Use the more generic commands ``block-export-add`` and ``block-export-del``
-instead.
+instead. As part of this deprecation, where ``nbd-server-add`` used a
+single ``bitmap``, the new ``block-export-add`` uses a list of ``bitmaps``.
Human Monitor Protocol (HMP) commands
-------------------------------------
diff --git a/qapi/block-export.json b/qapi/block-export.json
index 480c497690b0..c4125f4d2104 100644
--- a/qapi/block-export.json
+++ b/qapi/block-export.json
@@ -63,10 +63,10 @@
'*max-connections': 'uint32' } }
##
-# @BlockExportOptionsNbd:
+# @BlockExportOptionsNbdBase:
#
-# An NBD block export (options shared between nbd-server-add and the NBD branch
-# of block-export-add).
+# An NBD block export (common options shared between nbd-server-add and
+# the NBD branch of block-export-add).
#
# @name: Export name. If unspecified, the @device parameter is used as the
# export name. (Since 2.12)
@@ -74,15 +74,27 @@
# @description: Free-form description of the export, up to 4096 bytes.
# (Since 5.0)
#
-# @bitmap: Also export the dirty bitmap reachable from @device, so the
-# NBD client can use NBD_OPT_SET_META_CONTEXT with
-# "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0)
-#
# Since: 5.0
##
+{ 'struct': 'BlockExportOptionsNbdBase',
+ 'data': { '*name': 'str', '*description': 'str' } }
+
+##
+# @BlockExportOptionsNbd:
+#
+# An NBD block export (distinct options used in the NBD branch of
+# block-export-add).
+#
+# @bitmaps: Also export each of the named dirty bitmaps reachable from
+# @device, so the NBD client can use NBD_OPT_SET_META_CONTEXT with
+# the metadata context name "qemu:dirty-bitmap:BITMAP" to inspect
+# each bitmap.
+#
+# Since: 5.2
+##
{ 'struct': 'BlockExportOptionsNbd',
- 'data': { '*name': 'str', '*description': 'str',
- '*bitmap': 'str' } }
+ 'base': 'BlockExportOptionsNbdBase',
+ 'data': { '*bitmaps': ['str'] } }
##
# @BlockExportOptionsVhostUserBlk:
@@ -106,19 +118,24 @@
##
# @NbdServerAddOptions:
#
-# An NBD block export.
+# An NBD block export, per legacy nbd-server-add command.
#
# @device: The device name or node name of the node to be exported
#
# @writable: Whether clients should be able to write to the device via the
# NBD connection (default false).
#
+# @bitmap: Also export a single dirty bitmap reachable from @device, so the
+# NBD client can use NBD_OPT_SET_META_CONTEXT with the metadata
+# context name "qemu:dirty-bitmap:BITMAP" to inspect the bitmap
+# (since 4.0).
+#
# Since: 5.0
##
{ 'struct': 'NbdServerAddOptions',
- 'base': 'BlockExportOptionsNbd',
+ 'base': 'BlockExportOptionsNbdBase',
'data': { 'device': 'str',
- '*writable': 'bool' } }
+ '*writable': 'bool', '*bitmap': 'str' } }
##
# @nbd-server-add:
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index cee9134b12eb..d1d41f635564 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -209,8 +209,12 @@ void qmp_nbd_server_add(NbdServerAddOptions *arg, Error **errp)
.has_writable = arg->has_writable,
.writable = arg->writable,
};
- QAPI_CLONE_MEMBERS(BlockExportOptionsNbd, &export_opts->u.nbd,
+ QAPI_CLONE_MEMBERS(BlockExportOptionsNbdBase, &export_opts->u.nbd,
qapi_NbdServerAddOptions_base(arg));
+ if (arg->has_bitmap) {
+ export_opts->u.nbd.has_bitmaps = true;
+ QAPI_LIST_ADD(export_opts->u.nbd.bitmaps, g_strdup(arg->bitmap));
+ }
/*
* nbd-server-add doesn't complain when a read-only device should be
diff --git a/nbd/server.c b/nbd/server.c
index 08b621f70a3a..8d01662b4511 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1474,6 +1474,7 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
uint64_t perm, shared_perm;
bool readonly = !exp_args->writable;
bool shared = !exp_args->writable;
+ strList *bitmaps;
int ret;
assert(exp_args->type == BLOCK_EXPORT_TYPE_NBD);
@@ -1533,12 +1534,18 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
}
exp->size = QEMU_ALIGN_DOWN(size, BDRV_SECTOR_SIZE);
- if (arg->bitmap) {
+ /* XXX Allow more than one bitmap */
+ if (arg->bitmaps && arg->bitmaps->next) {
+ error_setg(errp, "multiple bitmaps per export not supported yet");
+ return -EOPNOTSUPP;
+ }
+ for (bitmaps = arg->bitmaps; bitmaps; bitmaps = bitmaps->next) {
+ const char *bitmap = bitmaps->value;
BlockDriverState *bs = blk_bs(blk);
BdrvDirtyBitmap *bm = NULL;
while (bs) {
- bm = bdrv_find_dirty_bitmap(bs, arg->bitmap);
+ bm = bdrv_find_dirty_bitmap(bs, bitmap);
if (bm != NULL) {
break;
}
@@ -1548,7 +1555,7 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
if (bm == NULL) {
ret = -ENOENT;
- error_setg(errp, "Bitmap '%s' is not found", arg->bitmap);
+ error_setg(errp, "Bitmap '%s' is not found", bitmap);
goto fail;
}
@@ -1562,15 +1569,15 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
ret = -EINVAL;
error_setg(errp,
"Enabled bitmap '%s' incompatible with readonly export",
- arg->bitmap);
+ bitmap);
goto fail;
}
bdrv_dirty_bitmap_set_busy(bm, true);
exp->export_bitmap = bm;
- assert(strlen(arg->bitmap) <= BDRV_BITMAP_MAX_NAME_SIZE);
+ assert(strlen(bitmap) <= BDRV_BITMAP_MAX_NAME_SIZE);
exp->export_bitmap_context = g_strdup_printf("qemu:dirty-bitmap:%s",
- arg->bitmap);
+ bitmap);
assert(strlen(exp->export_bitmap_context) < NBD_MAX_STRING_SIZE);
}
diff --git a/qemu-nbd.c b/qemu-nbd.c
index a0701cdf369d..4b7825c44093 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -574,7 +574,7 @@ int main(int argc, char **argv)
QDict *options = NULL;
const char *export_name = NULL; /* defaults to "" later for server mode */
const char *export_description = NULL;
- const char *bitmap = NULL;
+ strList *bitmaps = NULL;
const char *tlscredsid = NULL;
bool imageOpts = false;
bool writethrough = true;
@@ -690,7 +690,7 @@ int main(int argc, char **argv)
flags &= ~BDRV_O_RDWR;
break;
case 'B':
- bitmap = optarg;
+ QAPI_LIST_ADD(bitmaps, g_strdup(optarg));
break;
case 'k':
sockpath = optarg;
@@ -786,7 +786,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
if (export_name || export_description || dev_offset ||
- device || disconnect || fmt || sn_id_or_name || bitmap ||
+ device || disconnect || fmt || sn_id_or_name || bitmaps ||
seen_aio || seen_discard || seen_cache) {
error_report("List mode is incompatible with per-device settings");
exit(EXIT_FAILURE);
@@ -1067,12 +1067,12 @@ int main(int argc, char **argv)
.has_writable = true,
.writable = !readonly,
.u.nbd = {
- .has_name = true,
- .name = g_strdup(export_name),
- .has_description = !!export_description,
- .description = g_strdup(export_description),
- .has_bitmap = !!bitmap,
- .bitmap = g_strdup(bitmap),
+ .has_name = true,
+ .name = g_strdup(export_name),
+ .has_description = !!export_description,
+ .description = g_strdup(export_description),
+ .has_bitmaps = !!bitmaps,
+ .bitmaps = bitmaps,
},
};
blk_exp_add(export_opts, &error_fatal);
--
2.29.0
4 years