[libvirt] [PATCH] qemu: qapi: Limit traversal depth for QAPI schema queries
by Peter Krempa
Implicitly the query depth is limited by the length of the QAPI schema
query, but 'alternate' and 'array' QAPI meta-types don't consume a part
of the query string thus a loop on such types would get our traversal
code stuck in an infinite loop. Prevent this from happening by limiting
the nesting depth to 1000.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_qapi.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c
index 0226d6c659..93fcae0d44 100644
--- a/src/qemu/qemu_qapi.c
+++ b/src/qemu/qemu_qapi.c
@@ -74,9 +74,23 @@ struct virQEMUQAPISchemaTraverseContext {
virHashTablePtr schema;
char **queries;
virJSONValuePtr returnType;
+ size_t depth;
};
+static int
+virQEMUQAPISchemaTraverseContextValidateDepth(struct virQEMUQAPISchemaTraverseContext *ctxt)
+{
+ if (ctxt->depth++ > 1000) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("possible loop in QMP schema"));
+ return -1;
+ }
+
+ return 0;
+}
+
+
static void
virQEMUQAPISchemaTraverseContextInit(struct virQEMUQAPISchemaTraverseContext *ctxt,
char **queries,
@@ -329,6 +343,9 @@ virQEMUQAPISchemaTraverse(const char *baseName,
const char *metatype;
size_t i;
+ if (virQEMUQAPISchemaTraverseContextValidateDepth(ctxt) < 0)
+ return -2;
+
if (!(cur = virHashLookup(ctxt->schema, baseName)))
return -2;
--
2.21.0
5 years, 2 months
[libvirt] [PATCH] qemu: maintain user alias for video type 'none'
by Jonathon Jongsma
After parsing a video device with a model type of
VIR_DOMAIN_VIDEO_TYPE_NONE, all device info is cleared (see
virDomainDefPostParseVideo()) in order to avoid formatting any
auto-generated values for the XML. Subsequently, however, an alias is
generated for the video device (e.g. 'video0'), which results in an
alias property being formatted in the XML output anyway. This creates
confusion if the user has explicitly provided an alias for the video
device since the alias will change.
To avoid this, don't clear the user-defined alias for video devices of
type "none".
See https://bugzilla.redhat.com/show_bug.cgi?id=1720612
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/conf/domain_conf.c | 7 +++++--
tests/qemuxml2argvdata/video-none-device.xml | 1 +
tests/qemuxml2xmloutdata/video-none-device.xml | 1 +
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6c429cd593..d11d1fb903 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5635,11 +5635,14 @@ virDomainDefPostParseVideo(virDomainDefPtr def,
return 0;
if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_NONE) {
+ char *alias;
/* we don't want to format any values we automatically fill in for
- * videos into the XML, so clear them
- */
+ * videos into the XML, so clear them, but retain any user-assigned
+ * alias */
+ VIR_STEAL_PTR(alias, def->videos[0]->info.alias);
virDomainVideoDefClear(def->videos[0]);
def->videos[0]->type = VIR_DOMAIN_VIDEO_TYPE_NONE;
+ VIR_STEAL_PTR(def->videos[0]->info.alias, alias);
} else {
virDomainDeviceDef device = {
.type = VIR_DOMAIN_DEVICE_VIDEO,
diff --git a/tests/qemuxml2argvdata/video-none-device.xml b/tests/qemuxml2argvdata/video-none-device.xml
index 4b591562b7..c1c60c1d9e 100644
--- a/tests/qemuxml2argvdata/video-none-device.xml
+++ b/tests/qemuxml2argvdata/video-none-device.xml
@@ -31,6 +31,7 @@
<graphics type='vnc'/>
<video>
<model type='none'/>
+ <alias name='ua-user-video-alias'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
diff --git a/tests/qemuxml2xmloutdata/video-none-device.xml b/tests/qemuxml2xmloutdata/video-none-device.xml
index 6e76b394fe..82615f5125 100644
--- a/tests/qemuxml2xmloutdata/video-none-device.xml
+++ b/tests/qemuxml2xmloutdata/video-none-device.xml
@@ -34,6 +34,7 @@
</graphics>
<video>
<model type='none'/>
+ <alias name='ua-user-video-alias'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
--
2.21.0
5 years, 2 months
[libvirt] [PATCH] vircgroupv2: fix setting cpu.max period
by Pavel Hrdina
When we set cpu.max period we need to parse the cpu.max file first as
it contains both quota and period values separated by space. When only
a single number is written to that file it will set quota, in order to
change period we need to write both values.
The code was prepared for that but mistakenly used new line to end the
string with the first value.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1749227
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/vircgroupv2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 2aca4e5d62..0663c67190 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1508,7 +1508,7 @@ virCgroupV2SetCpuCfsPeriod(virCgroupPtr group,
_("Invalid 'cpu.max' data."));
return -1;
}
- *tmp = '\n';
+ *tmp = '\0';
if (virAsprintf(&value, "%s %llu", str, cfs_period) < 0)
return -1;
--
2.21.0
5 years, 2 months
[libvirt] [PATCH] qemu: Fix qemuDomainObjTaint with virtlogd
by Jiri Denemark
When virtlogd is used to capture QEMU's stdout, qemuDomainObjTaint would
always fail to write the message to the log file when QEMU is already
running (i.e., outside qemuProcessLaunch). This can happen during device
hotplug or by sending a custom QEMU guest agent command:
warning : qemuDomainObjTaint:8757 : Domain id=9 name='blaf'
uuid=9cfa4e37-2930-405b-bcb4-faac1829dad8 is tainted:
custom-ga-command
error : virLogHandlerDomainOpenLogFile:388 : Cannot open log file:
'/var/log/libvirt/qemu/blaf.log': Device or resource busy
error : virNetClientProgramDispatchError:172 : Cannot open log file:
'/var/log/libvirt/qemu/blaf.log': Device or resource busy
The fix is easy, we just need to use the right API for appending a
message to QEMU log file instead of creating a new log context.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_domain.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c7eb0b5e9a..709e4e568b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8783,9 +8783,9 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
qemuDomainLogContextPtr logCtxt)
{
virErrorPtr orig_err = NULL;
- bool closeLog = false;
char *timestamp = NULL;
char uuidstr[VIR_UUID_STRING_BUFLEN];
+ int rc;
if (!virDomainObjTaint(obj, taint))
return;
@@ -8806,27 +8806,25 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
if (!(timestamp = virTimeStringNow()))
goto cleanup;
- if (logCtxt == NULL) {
- logCtxt = qemuDomainLogContextNew(driver, obj,
- QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH);
- if (!logCtxt) {
- VIR_WARN("Unable to open domainlog");
- goto cleanup;
- }
- closeLog = true;
+ if (logCtxt) {
+ rc = qemuDomainLogContextWrite(logCtxt,
+ "%s: Domain id=%d is tainted: %s\n",
+ timestamp,
+ obj->def->id,
+ virDomainTaintTypeToString(taint));
+ } else {
+ rc = qemuDomainLogAppendMessage(driver, obj,
+ "%s: Domain id=%d is tainted: %s\n",
+ timestamp,
+ obj->def->id,
+ virDomainTaintTypeToString(taint));
}
- if (qemuDomainLogContextWrite(logCtxt,
- "%s: Domain id=%d is tainted: %s\n",
- timestamp,
- obj->def->id,
- virDomainTaintTypeToString(taint)) < 0)
+ if (rc < 0)
virResetLastError();
cleanup:
VIR_FREE(timestamp);
- if (closeLog)
- virObjectUnref(logCtxt);
if (orig_err) {
virSetError(orig_err);
virFreeError(orig_err);
--
2.23.0
5 years, 2 months
[libvirt] [PATCH 0/3] qemu: Fix disk IO tuning on hotplug with -blockdev (blockdev-add saga)
by Peter Krempa
Few cleanups and a bugfix as with blockdev we need to issue an extra
command to honour disk throttling config.
Peter Krempa (3):
qemu: hotplug: Simplify cleanup in qemuDomainChangeMediaLegacy
qemu: hotplug: Use VIR_AUTOFREE in qemuDomainAttachDiskGeneric
qemu: hotplug: Setup disk throttling with blockdev
src/qemu/qemu_hotplug.c | 52 ++++++++++++++++++++++++-----------------
src/qemu/qemu_process.c | 1 +
2 files changed, 32 insertions(+), 21 deletions(-)
--
2.21.0
5 years, 2 months
[libvirt] [PATCH 0/2] qemu: Limit backing chain to max 200 layers (blockdev-add saga)
by Peter Krempa
More than 256 deep element tree break with our XML parser. Backing
chains are one of the simple ways to get there. Forbid them. Note that
the practical limit/sane approach is way less than 200.
Peter Krempa (2):
qemu: domain: Refactor cleanup in qemuDomainDetermineDiskChain
qemu: Prevent storage causing too much nested XML
src/qemu/qemu_domain.c | 91 +++++++++++++++++++++++++++++++-----------
src/qemu/qemu_domain.h | 4 ++
src/qemu/qemu_driver.c | 6 +++
3 files changed, 78 insertions(+), 23 deletions(-)
--
2.21.0
5 years, 2 months
[libvirt] [PATCH v3 00/18] qemu: Blockdevize external snapshot creation (blokcdev-add saga)
by Peter Krempa
Another posting of this series as I've added a few patches which fix a
problem with shallow block copy.
Patches 1-5 of the original series were pushed.
Patches 1-3 of this series were originally posted and reviewed
separately but were not pushed yet due to the ongoing freeze. They are
included as they make the snapshots actually usable.
Patches 4-9 are new and fix a problem in block copy. The changes
necessary would conflict with the snapshot code so this version rebases
everything and includes them here.
Patches 10-12 fix a snapshot locking regression as outlined in the
previous posting.
The rest is from the original external snapshot blockdevization series
with feedback applied.
Peter Krempa (18):
qemu: block: Use correct type when creating image size JSON entries
tests: qemublock: Use bigger numbers as dummy capacity/physical
qemu: monitor: Fix formatting of 'offset' in qemuMonitorJSONSaveMemory
qemu: block: Unify conditions to format backing store of format node
definition
qemu: block: Explicitly specify backingStore when creating format
layer props
qemu: command: Refactor
qemuBuildStorageSourceChainAttachPrepareBlockdevInternal
qemu: block: explicitly pass backing store to
qemuBlockStorageSourceAttachPrepareBlockdev
qemu: Explicitly pass backing store to
qemuBuildStorageSourceChainAttachPrepareBlockdevTop
qemu: driver: Fix shallow non-reuse block copy
qemu: snapshot: Fix image lock handling when taking a snapshot
qemu: snapshot: Save status and config XMLs only on success
qemu: snapshot: Move error preservation to
qemuDomainSnapshotDiskDataCleanup
qemu: snapshot: Rename external disk snapshot handling functions
qemu: Disband qemuDomainSnapshotCreateSingleDiskActive
qemu: Merge use of 'reuse' flag in qemuDomainSnapshotDiskPrepareOne
qemu: snapshot: Skip overlay file creation/interogation if unsupported
qemu: Add -blockdev support for external snapshots
qemu: Defer support checks for external active snapshots to blockdev
code or qemu
src/qemu/qemu_block.c | 54 ++--
src/qemu/qemu_block.h | 4 +-
src/qemu/qemu_command.c | 63 ++--
src/qemu/qemu_command.h | 1 +
src/qemu/qemu_driver.c | 279 +++++++++++-------
src/qemu/qemu_migration.c | 4 +-
src/qemu/qemu_monitor_json.c | 2 +-
tests/qemublocktest.c | 6 +-
.../imagecreate/luks-encopts.json | 4 +-
.../imagecreate/luks-noopts.json | 4 +-
.../imagecreate/network-gluster-qcow2.json | 4 +-
.../imagecreate/network-rbd-qcow2.json | 4 +-
.../imagecreate/network-sheepdog-qcow2.json | 4 +-
.../imagecreate/network-ssh-qcow2.json | 4 +-
.../imagecreate/qcow2-backing-luks.json | 4 +-
.../imagecreate/qcow2-backing-raw-nbd.json | 4 +-
.../imagecreate/qcow2-backing-raw.json | 4 +-
.../qcow2-luks-encopts-backing.json | 4 +-
.../imagecreate/qcow2-luks-encopts.json | 4 +-
.../imagecreate/qcow2-luks-noopts.json | 4 +-
.../qemublocktestdata/imagecreate/qcow2.json | 4 +-
tests/qemublocktestdata/imagecreate/raw.json | 2 +-
22 files changed, 280 insertions(+), 187 deletions(-)
--
2.21.0
5 years, 2 months
[libvirt] [PATCH 00/11] scripts: convert many scripts from perl to python
by Daniel P. Berrangé
Less of
use re 'eval';
''=~('(?{'.(
('`')| '%').('['^'-').
('`'|'!'). ('`'|',').'"\\$~='
.('['^'+') .('`'| '/').('['^'+').'||'.
"'"."'".';'.('`'|'/' ).('['^'+').('`'|'%').
('`'|'.').('\\$%;').( '['^'"').(',!-~,#,,').(
'['^'(').',(.).,\\' .'$+,'.('`'|"'").('['^'(')
.',\\$~&&(\\$' .'_='.('['^')').('`'|('%')).(
'['^'-').('`'| '%').('['^')').('['^'(').(('`')|
'%').')'.("\`"| '&').('`'|'/').('['^"\)").'\\@~='.(
'`'|"'").("\["^ ')').('`'|'%').('['^'+').('\\$|--,(').
"'"."'".(')').( '['^'#').('^'^('`'|'/')).(':'&'=').',<'.
('^'^('`'|'.') ).'>;\\@;='.('`'|'-').('`'|'!').('['^'+')
.'~~'.('['^')' ).('`'|'%').('['^'-').('`'|'%').('['^')').
('['^'(').('`'|'%').','.('['^')').('`'|'%').('['^'-').('`'
|'%').('['^')').('['^'(').('`'|'%').'\\@~;'.('`'|'-').('`'|
'!').('['^'+').'\\{'.('['^'(').('['^'"').('['^'(').(('[')^
'/').('`'|'%').('`'|'-').'\\$^'.('`'^'/').'=~'.('{'^"\,").(
'`'|')').('`'|'.').'?'.('`'^'#').('`'^',').('{'^'(').(':').
"'".('`'|'#').('`'|',').('`'|'%').('`'|'!').('['^')')."'".
';(\\$-=\\$_%'.('^'^('`'|'-')).')||(--\\$|,'.('`'|'-' ).(
'`'|'!').('['^'+').'\\$_='.('['^')').('`'|'%').('[' ^((
'-'))).('`'|'%').('['^')').('['^'(').('`' |('%')). ','
.'\\@~,\\@;);'.('['^'+').('['^(')')).( '`'|')' ).(
"\`"| '.').('['^'/').'\\$\\"'.("\["^ ('#')). '('
.'\\$=/'.('^'^('`'|'-')).'*'. (('`')| '!'
).("\`"| '"').('['^ "\("). '\\$|' .+
('*').( '^'^('`' |',')) .'-\\' .+
'$-),'. '\\$_,'. '\\$' .'/'. (
('`')| ('&')).( '`'| '/')
.('['^ ')').'\\' .'$' .'-'
.'&'. (('^')^( '`'| '/')
).'?' .'\\@;' .':' .''.
'\\' .'@~;' .''. ('['
^'(' ).( '`'| ',')
.''. ((( '`' ))|
'%' ).( '`' |((
'%' ))) .+( '['
^(( '+' ))) .+
(( '!')). ((
(( '\\') ))
). '$%\\}'. ((
((( '\\' ))))) .+
'$' .'%..' .''. (((
'^') )^("\`"| '/' )).(
"\^"^( ('`')|
('/'))). '"})');
More
######
## #########
## ###### #####
####################
###############
######## #
####### #
######## #
####### ##
######## ###
####### ####
####### ###### #####
####### ############ #####
######## ################## ######
###################### #################
################# #############
########### #######
Daniel P. Berrangé (11):
cfg.mk: fix comment detection for python semicolon check
docs: rewrite hvsupport.html page generator in python
docs: rewrite ACL permissions checker in Python
docs: rewrite symfile sorting checker in Python
docs: rewrite symfile library checker in Python
docs: rewrite augest test generator in Python
docs: rewrite po file minimizer in Python
docs: rewrite duplicate header checker in Python
docs: rewrite whitespace checker in Python
docs: rewrite mock inline checker in Python
docs: rewrite header ifdef checker in Python
Makefile.am | 12 +-
build-aux/augeas-gentest.pl | 60 ----
build-aux/augeas-gentest.py | 72 ++++
build-aux/check-spacing.pl | 198 ----------
build-aux/check-spacing.py | 204 +++++++++++
build-aux/header-ifdef.pl | 182 ----------
build-aux/header-ifdef.py | 206 +++++++++++
build-aux/minimize-po.pl | 37 --
build-aux/minimize-po.py | 60 ++++
build-aux/mock-noinline.pl | 75 ----
build-aux/mock-noinline.py | 88 +++++
build-aux/prohibit-duplicate-header.pl | 26 --
build-aux/prohibit-duplicate-header.py | 54 +++
cfg.mk | 10 +-
docs/Makefile.am | 6 +-
docs/hvsupport.pl | 458 -----------------------
docs/hvsupport.py | 479 +++++++++++++++++++++++++
po/Makefile.am | 2 +-
src/Makefile.am | 16 +-
src/check-aclperms.pl | 73 ----
src/check-aclperms.py | 77 ++++
src/check-symfile.pl | 70 ----
src/check-symfile.py | 80 +++++
src/check-symsorting.pl | 106 ------
src/check-symsorting.py | 112 ++++++
25 files changed, 1455 insertions(+), 1308 deletions(-)
delete mode 100755 build-aux/augeas-gentest.pl
create mode 100755 build-aux/augeas-gentest.py
delete mode 100755 build-aux/check-spacing.pl
create mode 100755 build-aux/check-spacing.py
delete mode 100644 build-aux/header-ifdef.pl
create mode 100644 build-aux/header-ifdef.py
delete mode 100755 build-aux/minimize-po.pl
create mode 100755 build-aux/minimize-po.py
delete mode 100644 build-aux/mock-noinline.pl
create mode 100644 build-aux/mock-noinline.py
delete mode 100644 build-aux/prohibit-duplicate-header.pl
create mode 100644 build-aux/prohibit-duplicate-header.py
delete mode 100755 docs/hvsupport.pl
create mode 100755 docs/hvsupport.py
delete mode 100755 src/check-aclperms.pl
create mode 100755 src/check-aclperms.py
delete mode 100755 src/check-symfile.pl
create mode 100755 src/check-symfile.py
delete mode 100755 src/check-symsorting.pl
create mode 100755 src/check-symsorting.py
--
2.21.0
5 years, 2 months
[libvirt] [ocaml PATCH] Use caml_raise_out_of_memory() where needed.
by Pino Toscano
Raise the proper exception on malloc failures.
Signed-off-by: Pino Toscano <ptoscano(a)redhat.com>
---
libvirt/libvirt_c_oneoffs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c
index e23c0db..40384e8 100644
--- a/libvirt/libvirt_c_oneoffs.c
+++ b/libvirt/libvirt_c_oneoffs.c
@@ -749,7 +749,7 @@ ocaml_libvirt_domain_get_cpu_stats (value domv)
CHECK_ERROR (nparams < 0, "virDomainGetCPUStats");
if ((params = malloc(sizeof(*params) * nparams * 128)) == NULL)
- caml_failwith ("virDomainGetCPUStats: malloc");
+ caml_raise_out_of_memory ();
cpustats = caml_alloc (nr_pcpus, 0); /* cpustats: array of params(list of typed_param) */
cpu = 0;
@@ -1461,7 +1461,7 @@ ocaml_libvirt_event_add_timeout (value connv, value ms, value callback_id)
/* Store the int64 callback_id as the opaque data so the OCaml
callback can demultiplex to the correct OCaml handler. */
if ((opaque = malloc(sizeof(long))) == NULL)
- caml_failwith ("virEventAddTimeout: malloc");
+ caml_raise_out_of_memory ();
*((long*)opaque) = Int64_val(callback_id);
NONBLOCKING(r = virEventAddTimeout(Int_val(ms), cb, opaque, freecb));
CHECK_ERROR(r == -1, "virEventAddTimeout");
@@ -1551,7 +1551,7 @@ ocaml_libvirt_connect_domain_event_register_any(value connv, value domv, value c
/* Store the int64 callback_id as the opaque data so the OCaml
callback can demultiplex to the correct OCaml handler. */
if ((opaque = malloc(sizeof(long))) == NULL)
- caml_failwith ("virConnectDomainEventRegisterAny: malloc");
+ caml_raise_out_of_memory ();
*((long*)opaque) = Int64_val(callback_id);
NONBLOCKING(r = virConnectDomainEventRegisterAny(conn, dom, eventID, cb, opaque, freecb));
CHECK_ERROR(r == -1, "virConnectDomainEventRegisterAny");
--
2.21.0
5 years, 2 months