[libvirt] [PATCH] conf: Add a function virDomainDefCputuneValidate
by Suyang Chen
move all the def->cputune 'period must be in range' errors into
virDomainDefCputuneValidate function and have it called from
virDomainDefValidateInternal and virDomainDefParseXML function
Solve the bitsizedtask:
"Move validation checks out of domain XML parsing"
Resolves:
https://wiki.libvirt.org/page/BiteSizedTasks#Move_validation_checks_out_o...
Signed-off-by: Suyang Chen <dawson0xff(a)gmail.com>
---
src/conf/domain_conf.c | 75 ++++++++++++++++++++++++------------------
1 file changed, 43 insertions(+), 32 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 995f87bcbe..e17ca0e0cb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6589,6 +6589,45 @@ virDomainDefMemtuneValidate(const virDomainDef *def)
return 0;
}
+static int
+virDomainDefCputuneValidate(const virDomainDef *def)
+{
+ if (def->cputune.period > 0 &&
+ (def->cputune.period < 1000 || def->cputune.period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ if (def->cputune.global_period > 0 &&
+ (def->cputune.global_period < 1000 || def->cputune.global_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune global period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ if (def->cputune.emulator_period > 0 &&
+ (def->cputune.emulator_period < 1000 ||
+ def->cputune.emulator_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune emulator_period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ if (def->cputune.iothread_period > 0 &&
+ (def->cputune.iothread_period < 1000 ||
+ def->cputune.iothread_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune iothread_period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ return 0;
+}
static int
virDomainDefValidateInternal(const virDomainDef *def)
@@ -6628,6 +6667,9 @@ virDomainDefValidateInternal(const virDomainDef *def)
if (virDomainDefMemtuneValidate(def) < 0)
return -1;
+ if (virDomainDefCputuneValidate(def) < 0)
+ return -1;
+
return 0;
}
@@ -19594,13 +19636,8 @@ virDomainDefParseXML(xmlDocPtr xml,
goto error;
}
- if (def->cputune.period > 0 &&
- (def->cputune.period < 1000 || def->cputune.period > 1000000)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Value of cputune period must be in range "
- "[1000, 1000000]"));
+ if (virDomainDefCputuneValidate(def) < 0)
goto error;
- }
if (virXPathLongLong("string(./cputune/quota[1])", ctxt,
&def->cputune.quota) < -1) {
@@ -19625,14 +19662,6 @@ virDomainDefParseXML(xmlDocPtr xml,
goto error;
}
- if (def->cputune.global_period > 0 &&
- (def->cputune.global_period < 1000 || def->cputune.global_period > 1000000)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Value of cputune global period must be in range "
- "[1000, 1000000]"));
- goto error;
- }
-
if (virXPathLongLong("string(./cputune/global_quota[1])", ctxt,
&def->cputune.global_quota) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -19656,15 +19685,6 @@ virDomainDefParseXML(xmlDocPtr xml,
goto error;
}
- if (def->cputune.emulator_period > 0 &&
- (def->cputune.emulator_period < 1000 ||
- def->cputune.emulator_period > 1000000)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Value of cputune emulator_period must be in range "
- "[1000, 1000000]"));
- goto error;
- }
-
if (virXPathLongLong("string(./cputune/emulator_quota[1])", ctxt,
&def->cputune.emulator_quota) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -19688,15 +19708,6 @@ virDomainDefParseXML(xmlDocPtr xml,
goto error;
}
- if (def->cputune.iothread_period > 0 &&
- (def->cputune.iothread_period < 1000 ||
- def->cputune.iothread_period > 1000000)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Value of cputune iothread_period must be in range "
- "[1000, 1000000]"));
- goto error;
- }
-
if (virXPathLongLong("string(./cputune/iothread_quota[1])", ctxt,
&def->cputune.iothread_quota) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
--
2.20.1
5 years, 9 months
[libvirt] [libvirt-go-xml PATCH] Make @Path of UNIX chr device source optional
by Erik Skultety
According to the libvirt RNG schema, @path is an optional attribute for
the character source element, so we should be okay if it was omitted.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
domain.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/domain.go b/domain.go
index a964cc8..a1a3fcb 100644
--- a/domain.go
+++ b/domain.go
@@ -735,7 +735,7 @@ type DomainChardevSourceTCP struct {
type DomainChardevSourceUNIX struct {
Mode string `xml:"mode,attr,omitempty"`
- Path string `xml:"path,attr"`
+ Path string `xml:"path,attr,omitempty"`
Reconnect *DomainChardevSourceReconnect `xml:"reconnect"`
SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
}
--
2.20.1
5 years, 9 months
[libvirt] [PATCH v4 0/8] bulk snapshot list/redefine (incremental backup saga)
by Eric Blake
While looking at my work on incremental backups, Nir raised a good
point: if we want to recreate a set of known checkpoints on one
machine that will be taking over a domain from another machine,
my initial proposal required making multiple API calls to list the
XML for each checkpoint on the source, and then more API calls to
redefine each checkpoint on the destination; it also had the drawback
that the list has to be presented in topological order (the API won't
let you define a child checkpoint if the parent is not defined first).
He asked if I could instead add bulk APIs, for getting the XML for
all checkpoints at once, and then for redefining all checkpoints at
once.
Since my checkpoint code borrows heavily from concepts in the snapshot
code, I chose to tackle the problem by starting with this series, which
does the same thing for snapshots as what I plan to do for checkpoints.
That is, since this patch series adds 2 new APIs, the checkpoint series
will do likewise with very similar code.
I'm also toying with the idea of followup patches that store all
snapshots alongside the persistent <domain> XML in a single file,
rather than in one snapshot per <domainsnapshot> file (we'd still
support reading from the old method at libvirtd startup, but would
not need to output in that manner any more).
Based-on: <20190308060512.17733-1-eblake(a)redhat.com>
[0/5 snapshots: topological sorting]
Changes from v3:
- introduce 2 new API instead of flags to 2 existing API [Jan]
- rebase on top of minor changes that already landed in the
non-controversial first half of the v3 series [John]
git backport-diff gets confused by patch renames, but this is quite
obviously more or less a rewrite:
001/8:[down] 'snapshot: Add new API for bulk dumpxml/redefine'
002/8:[down] 'snapshot: Support topological virDomainSnapshotForEach()'
003/8:[down] 'snapshot: Tweaks to support new bulk dumpxml/import API'
004/8:[down] 'remote: Wire up snapshot bulk dumpxml/import'
005/8:[down] 'virsh: Expose bulk snapshot dumpxml/import'
006/8:[0087] [FC] 'test: Implement bulk snapshot operations'
007/8:[0040] [FC] 'qemu: Factor out qemuDomainSnapshotValidate() helper'
008/8:[0152] [FC] 'qemu: Implement bulk snapshot operations'
Eric Blake (8):
snapshot: Add new API for bulk dumpxml/redefine
snapshot: Support topological virDomainSnapshotForEach()
snapshot: Tweaks to support new bulk dumpxml/import API
remote: Wire up snapshot bulk dumpxml/import
virsh: Expose bulk snapshot dumpxml/import
test: Implement bulk snapshot operations
qemu: Factor out qemuDomainSnapshotValidate() helper
qemu: Implement bulk snapshot operations
include/libvirt/libvirt-domain-snapshot.h | 16 +-
src/conf/snapshot_conf.h | 1 +
src/driver-hypervisor.h | 13 +-
src/conf/snapshot_conf.c | 34 ++--
src/libvirt-domain-snapshot.c | 122 ++++++++++-
src/libvirt_public.syms | 2 +
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_driver.c | 236 +++++++++++++++++-----
src/remote/remote_driver.c | 6 +-
src/remote/remote_protocol.x | 38 +++-
src/remote_protocol-structs | 17 ++
src/test/test_driver.c | 62 +++++-
src/vz/vz_driver.c | 3 +-
tools/virsh-snapshot.c | 111 ++++++++--
tools/virsh.pod | 15 +-
15 files changed, 584 insertions(+), 94 deletions(-)
--
2.20.1
5 years, 9 months
[libvirt] [PATCH 0/8] tests: Improve QEMU capability testing
by Andrea Bolognani
This series removes the need to fiddle with test programs every
time a new .replies file is added to the test suite, and also
completely removes the possibility of missing on some test
coverage because only one of the two test programs is updated.
Andrea Bolognani (8):
tests: Introduce testQemuDataInit() and testQemuDataReset()
tests: Move ret into testQemuData
tests: Move data directories into testQemuData
tests: Use virAsprintf() to build titles
tests: Move code from DO_TEST() to doCapsTest()
tests: Add testutilsqemu dependency for qemucaps2xmltest
tests: Introduce testQemuCapsIterate()
tests: Use testQemuCapsIterate()
tests/Makefile.am | 1 +
tests/qemucapabilitiestest.c | 123 ++++++++++++++++++-----------------
tests/qemucaps2xmltest.c | 104 ++++++++++++++---------------
tests/testutilsqemu.c | 53 +++++++++++++++
tests/testutilsqemu.h | 8 +++
5 files changed, 179 insertions(+), 110 deletions(-)
--
2.20.1
5 years, 9 months
[libvirt] [PATCH 0/2] Small apparmor fixes
by Jim Fehlig
This series fixes a few things I broke when changing the libvirtd apparmor
profile to a named profile. See patches for details. Too bad I didn't make
it for 5.1.0 release....
Jim Fehlig (2):
apparmor: Check libvirtd profile status by name
apparmor: Add ptrace and signal rules for named profile
src/security/apparmor/libvirt-qemu | 2 ++
src/security/security_apparmor.c | 12 +++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
--
2.20.1
5 years, 9 months
[libvirt] [PATCH v2 00/15] Firmware auto selection
by Michal Privoznik
v2 of:
https://www.redhat.com/archives/libvir-list/2019-February/msg01503.html
As usual, you can find my patches at my github:
https://github.com/zippy2/libvirt/commits/firmware_v2
diff to v1:
- Hopefully all Lazlo's comment are worked in (fixing the logic that
chooses suitable firmware for secboot/SMM domains, commit message
adjustements, sanity check for parsed FW descriptions, etc.)
- Added more debug messages around FW selection code, i.e. it'll be
visible from the logs why given FS is not suitable (or that it is).
Michal Prívozník (15):
virmock: Initialize both symbols in VIR_MOCK_REAL_INIT_ALT
qemu_domain: Separate NVRAM VAR store file name generation
qemu_capabilities: Expose qemu <-> libvirt arch translators
virDomainLoaderDefParseXML: Allow loader path to be NULL
conf: Introduce VIR_DOMAIN_LOADER_TYPE_NONE
conf: Introduce firmware attribute to <os/>
qemu: Introduce basic skeleton for parsing firmware description
test: Introduce qemufirmwaretest
qemu_firmware: Introduce qemuFirmwareFetchConfigs
qemufirmwaretest: Test qemuFirmwareFetchConfigs()
qemu_firmware: Introduce qemuFirmwareFillDomain()
qemu_process: Call qemuFirmwareFillDomain
qemuDomainDefValidate: Don't require SMM if automatic firmware
selection enabled
qemu: Enable firmware autoselection
qemuxml2argvtest: Test os.firmware autoselection
docs/formatdomain.html.in | 22 +-
docs/schemas/domaincommon.rng | 12 +-
src/conf/domain_conf.c | 113 +-
src/conf/domain_conf.h | 15 +-
src/libvirt_private.syms | 2 +
src/qemu/Makefile.inc.am | 2 +
src/qemu/qemu_capabilities.c | 4 +-
src/qemu/qemu_capabilities.h | 3 +
src/qemu/qemu_command.c | 1 +
src/qemu/qemu_domain.c | 34 +-
src/qemu/qemu_domain.h | 4 +
src/qemu/qemu_firmware.c | 1364 +++++++++++++++++
src/qemu/qemu_firmware.h | 50 +
src/qemu/qemu_process.c | 5 +
tests/Makefile.am | 14 +-
tests/domaincapsschemadata/full.xml | 1 +
.../etc/qemu/firmware/40-ovmf-sb-keys.json | 1 +
.../etc/qemu/firmware/60-ovmf-sb.json | 0
.../user/.config/qemu/firmware/10-bios.json | 0
.../usr/share/qemu/firmware/40-bios.json | 35 +
.../share/qemu/firmware/50-ovmf-sb-keys.json | 36 +
.../usr/share/qemu/firmware/60-ovmf-sb.json | 35 +
.../usr/share/qemu/firmware/61-ovmf.json | 33 +
.../usr/share/qemu/firmware/70-aavmf.json | 35 +
tests/qemufirmwaretest.c | 135 ++
...arch64-os-firmware-efi.aarch64-latest.args | 37 +
.../aarch64-os-firmware-efi.xml | 30 +
.../os-firmware-bios.x86_64-latest.args | 39 +
tests/qemuxml2argvdata/os-firmware-bios.xml | 68 +
...os-firmware-efi-secboot.x86_64-latest.args | 43 +
.../os-firmware-efi-secboot.xml | 68 +
.../os-firmware-efi.x86_64-latest.args | 42 +
tests/qemuxml2argvdata/os-firmware-efi.xml | 68 +
tests/qemuxml2argvtest.c | 17 +
.../aarch64-os-firmware-efi.xml | 1 +
tests/qemuxml2xmloutdata/os-firmware-bios.xml | 1 +
.../os-firmware-efi-secboot.xml | 1 +
tests/qemuxml2xmloutdata/os-firmware-efi.xml | 1 +
tests/qemuxml2xmltest.c | 27 +
tests/virmock.h | 5 +-
40 files changed, 2374 insertions(+), 30 deletions(-)
create mode 100644 src/qemu/qemu_firmware.c
create mode 100644 src/qemu/qemu_firmware.h
create mode 120000 tests/qemufirmwaredata/etc/qemu/firmware/40-ovmf-sb-keys.json
create mode 100644 tests/qemufirmwaredata/etc/qemu/firmware/60-ovmf-sb.json
create mode 100644 tests/qemufirmwaredata/home/user/.config/qemu/firmware/10-bios.json
create mode 100644 tests/qemufirmwaredata/usr/share/qemu/firmware/40-bios.json
create mode 100644 tests/qemufirmwaredata/usr/share/qemu/firmware/50-ovmf-sb-keys.json
create mode 100644 tests/qemufirmwaredata/usr/share/qemu/firmware/60-ovmf-sb.json
create mode 100644 tests/qemufirmwaredata/usr/share/qemu/firmware/61-ovmf.json
create mode 100644 tests/qemufirmwaredata/usr/share/qemu/firmware/70-aavmf.json
create mode 100644 tests/qemufirmwaretest.c
create mode 100644 tests/qemuxml2argvdata/aarch64-os-firmware-efi.aarch64-latest.args
create mode 100644 tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml
create mode 100644 tests/qemuxml2argvdata/os-firmware-bios.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/os-firmware-bios.xml
create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-secboot.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-secboot.xml
create mode 100644 tests/qemuxml2argvdata/os-firmware-efi.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/os-firmware-efi.xml
create mode 120000 tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.xml
create mode 120000 tests/qemuxml2xmloutdata/os-firmware-bios.xml
create mode 120000 tests/qemuxml2xmloutdata/os-firmware-efi-secboot.xml
create mode 120000 tests/qemuxml2xmloutdata/os-firmware-efi.xml
--
2.19.2
5 years, 9 months
[libvirt] [PATCH] conf: Add a function virDomainDefCputuneValidate
by Suyang Chen
Solve the bitsizedtask:
"Move validation checks out of domain XML parsing"
Resolves: https://wiki.libvirt.org/page/BiteSizedTasks#Move_validation_checks_out_o...
Signed-off-by: Suyang Chen <dawson0xff(a)gmail.com>
---
src/conf/domain_conf.c | 43 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 995f87bcbe..eb63800b9a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6589,6 +6589,46 @@ virDomainDefMemtuneValidate(const virDomainDef *def)
return 0;
}
+static int
+virDomainDefCputuneValidate(const virDomainDef *def)
+{
+ if (def->cputune.global_period > 0 &&
+ (def->cputune.global_period < 1000 || def->cputune.global_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune global period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ if (def->cputune.emulator_period > 0 &&
+ (def->cputune.emulator_period < 1000 ||
+ def->cputune.emulator_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune emulator_period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ if (def->cputune.emulator_period > 0 &&
+ (def->cputune.emulator_period < 1000 ||
+ def->cputune.emulator_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune emulator_period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ if (def->cputune.iothread_period > 0 &&
+ (def->cputune.iothread_period < 1000 ||
+ def->cputune.iothread_period > 1000000)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Value of cputune iothread_period must be in range "
+ "[1000, 1000000]"));
+ return -1;
+ }
+
+ return 0;
+}
static int
virDomainDefValidateInternal(const virDomainDef *def)
@@ -6628,6 +6668,9 @@ virDomainDefValidateInternal(const virDomainDef *def)
if (virDomainDefMemtuneValidate(def) < 0)
return -1;
+ if (virDomainDefCputuneValidate(def) < 0)
+ return -1;
+
return 0;
}
--
2.20.1
5 years, 9 months
[libvirt] [PATCH 0/5] snapshots: topological sorting (incremental backup saga)
by Eric Blake
While working to add new API for bulk dumpxml/redefine, and turn
virDomainSnapshotObjList into a base class for sharing with
checkpoints, I realized how trivial it would be to take advantage of
information already present on the server, instead of using a lot of
CPU time with 'virsh snapshot-list --tree' to reconstruct a DAG on
the client side.
Eric Blake (5):
snapshots: Add flag to guarantee topological sort
snapshots: Support topological visits
test: Support topological visits
qemu: Support topological visits
virsh: Add snapshot-list --topological
include/libvirt/libvirt-domain-snapshot.h | 4 +++
src/conf/snapshot_conf.c | 15 +++++---
src/libvirt-domain-snapshot.c | 42 ++++++++++++++++++++++-
src/qemu/qemu_driver.c | 6 ++++
src/test/test_driver.c | 6 ++++
tools/virsh-snapshot.c | 16 +++++++--
tools/virsh.pod | 7 +++-
7 files changed, 86 insertions(+), 10 deletions(-)
--
2.20.1
5 years, 9 months
[libvirt] [PATCH] tools: vsh: Don't use assert()
by Peter Krempa
It's meant for testing, not for production builds. Also we have a helper
for reporting OOM errors. Introduced by 23e0bf1c4eb6
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tools/vsh.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/vsh.c b/tools/vsh.c
index 5e483a5d26..5903f129c1 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -385,7 +385,7 @@ vshCmddefCheckInternals(vshControl *ctl,
}
if ((p = strchr(name, '=')) &&
VIR_STRNDUP(name, name, p - name) < 0)
- assert(false); /* Allocation failure during self-test is bad */
+ vshErrorOOM();
for (j = i + 1; cmd->opts[j].name; j++) {
if (STREQ(name, cmd->opts[j].name) &&
cmd->opts[j].type != VSH_OT_ALIAS)
--
2.20.1
5 years, 9 months
[libvirt] [PATCH 0/6] lxc: Add suport to virConnectGetAllDomainStats().
by Julio Faracco
This series has a collection of new methods to enable support for
virConnectGetAllDomainStats() to LXC driver. The only difference is Disk
Stats. It needs to consider only the host file system operations or any
other block device as a external disk or partition.
Julio Faracco (6):
lxc: Introduce method lxcConnectGetAllDomainStats().
lxc: Introduce method lxcDomainGetStats().
lxc: Introduce method lxcDomainGetStatsCpu().
lxc: Introduce method lxcDomainGetStatsState().
lxc: Introduce method lxcDomainGetBlockStats().
lxc: Introduce method lxcDomainGetBalloonStats().
src/lxc/lxc_driver.c | 357 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 357 insertions(+)
--
2.19.1
5 years, 9 months