[libvirt] [PATCH v3] storage: Fix several issues with transient pool cleanup
by Jovanka Gulicoska
There are several cases where we do not handle transient pool destroy
and cleanup correctly. For example:
https://bugzilla.redhat.com/show_bug.cgi?id=1227475
Move the pool cleanup logic to a new function storagePoolSetInactive and
use it consistently.
---
src/storage/storage_driver.c | 45 +++++++++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 19 deletions(-)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index e2d729f..930ae5a 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -77,6 +77,23 @@ static void storageDriverUnlock(void)
}
static void
+storagePoolSetInactive(virStoragePoolObjPtr *poolptr)
+{
+ virStoragePoolObjPtr pool = *poolptr;
+
+ pool->active = false;
+
+ if (pool->configFile == NULL) {
+ virStoragePoolObjRemove(&driver->pools, pool);
+ *poolptr = NULL;
+ } else if (pool->newDef) {
+ virStoragePoolDefFree(pool->def);
+ pool->def = pool->newDef;
+ pool->newDef = NULL;
+ }
+}
+
+static void
storagePoolUpdateState(virStoragePoolObjPtr pool)
{
bool active;
@@ -115,16 +132,19 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
if (backend->refreshPool(NULL, pool) < 0) {
if (backend->stopPool)
backend->stopPool(NULL, pool);
+ active = false;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to restart storage pool '%s': %s"),
pool->def->name, virGetLastErrorMessage());
goto error;
}
+ active = true;
}
- pool->active = active;
ret = 0;
error:
+ if (!active)
+ storagePoolSetInactive(&pool);
if (ret < 0) {
if (stateFile)
unlink(stateFile);
@@ -201,6 +221,8 @@ storageDriverAutostart(void)
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to autostart storage pool '%s': %s"),
pool->def->name, virGetLastErrorMessage());
+ storagePoolSetInactive(&pool);
+ continue;
} else {
pool->active = true;
}
@@ -737,8 +759,7 @@ storagePoolCreateXML(virConnectPtr conn,
unlink(stateFile);
if (backend->stopPool)
backend->stopPool(conn, pool);
- virStoragePoolObjRemove(&driver->pools, pool);
- pool = NULL;
+ storagePoolSetInactive(&pool);
goto cleanup;
}
@@ -1068,16 +1089,7 @@ storagePoolDestroy(virStoragePoolPtr obj)
VIR_STORAGE_POOL_EVENT_STOPPED,
0);
- pool->active = false;
-
- if (pool->configFile == NULL) {
- virStoragePoolObjRemove(&driver->pools, pool);
- pool = NULL;
- } else if (pool->newDef) {
- virStoragePoolDefFree(pool->def);
- pool->def = pool->newDef;
- pool->newDef = NULL;
- }
+ storagePoolSetInactive(&pool);
ret = 0;
@@ -1197,12 +1209,7 @@ storagePoolRefresh(virStoragePoolPtr obj,
pool->def->uuid,
VIR_STORAGE_POOL_EVENT_STOPPED,
0);
- pool->active = false;
-
- if (pool->configFile == NULL) {
- virStoragePoolObjRemove(&driver->pools, pool);
- pool = NULL;
- }
+ storagePoolSetInactive(&pool);
goto cleanup;
}
--
2.5.5
8 years, 6 months
[libvirt] [PATCH 0/4] Move ccwaddrs and pciaddrs to domainDef
by Tomasz Flendrich
This patch depends on another one, because it was created on top
of the changes in the other one. Link to the dependency:
https://www.redhat.com/archives/libvir-list/2016-June/msg01227.html
This is the next patch of the ongoing process of abstracting device
address generation.
In this patch, addres sets are moved from QEMU's (ccw and pci)
and bhyve's (pci only) private data to domainDef. In the future,
it's likely that more hypervisors will add the feature of explicitly
specifying the device addresses, so handling the addresses should be
made more generic.
Tomasz Flendrich (4):
Move functions from qemu_domain_address to domain_addr
Move ccwaddrs from QEMU's private data to domainDef
Move virDomainPCIAddressSetFree from domain_addr to domain_conf
Move pciaddrs from private data to domainDef
src/bhyve/bhyve_device.c | 16 +-
src/bhyve/bhyve_domain.c | 2 -
src/bhyve/bhyve_domain.h | 3 -
src/conf/domain_addr.c | 497 ++++++++++++++++++++++++++++++++++--
src/conf/domain_addr.h | 67 ++---
src/conf/domain_conf.c | 21 ++
src/conf/domain_conf.h | 51 ++++
src/libvirt_private.syms | 11 +-
src/qemu/qemu_domain.c | 4 +-
src/qemu/qemu_domain.h | 3 -
src/qemu/qemu_domain_address.c | 561 +++--------------------------------------
src/qemu/qemu_domain_address.h | 3 +-
src/qemu/qemu_hotplug.c | 23 +-
src/qemu/qemu_process.c | 6 +-
tests/qemuhotplugtest.c | 2 +-
15 files changed, 629 insertions(+), 641 deletions(-)
--
2.7.4 (Apple Git-66)
8 years, 6 months
[libvirt] [PATCH 0/2] Abstracting device address allocation
by Tomasz Flendrich
More hypervisors may implement the possibility of specifying device
addresses, so it makes sense to make QEMU-specific code more generic
to be prepared for it.
If this approach will be acceptable, all the other address sets
will be moved from QEMU's private data to domainDef, the
qemu_domain_address.c will shrink in size and the functionality
will be moved to domain_addr.[hc].
Tomasz Flendrich (2):
Move virtio *Free() functions from domain_addr to domain_conf
Move vioserialaddrs from QEMU's private data to domainDef
src/conf/domain_addr.c | 22 ----------------------
src/conf/domain_addr.h | 17 -----------------
src/conf/domain_conf.c | 23 +++++++++++++++++++++++
src/conf/domain_conf.h | 19 +++++++++++++++++++
src/libvirt_private.syms | 3 ++-
src/qemu/qemu_domain.c | 1 -
src/qemu/qemu_domain.h | 1 -
src/qemu/qemu_domain_address.c | 20 ++++++++------------
src/qemu/qemu_hotplug.c | 9 +++++----
9 files changed, 57 insertions(+), 58 deletions(-)
--
2.7.4 (Apple Git-66)
8 years, 6 months
[libvirt] [PATCH] qemu: make monitor command API available during async jobs
by Nikolay Shirokovskiy
One can not issue monitor commands manually during async calls thru
designated API while this could be useful for testing/debugging purposes.
qemuDomainQemuMonitorCommand uses job of type QEMU_JOB_MODIFY and any async
call disable parallel execution of this type of job. The only state that is
changed is taint variable. AFAIU the only place we can mess is resetting
taint flag in qemuProcessStop routine under some async job. But this can not
happen thanx to both virDomainObjIsActive check in qemuDomainQemuMonitorCommand
and resetting active status in qemuProcessStop before taint flag.
Change job type to QEMU_JOB_QUERY and thus make the API call available for
most of async jobs.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 931efae..d6aa640 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15514,7 +15514,7 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
if (virDomainQemuMonitorCommandEnsureACL(domain->conn, vm->def) < 0)
goto cleanup;
- if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
--
1.8.3.1
8 years, 6 months
[libvirt] [PATCH 00/11] Add auto convergence migration parameters
by Jiri Denemark
This series adds support for a couple of migration parameters which can
be used to tune the auto-convergence algorithm in QEMU.
Jiri Denemark (11):
qemu: Make qemuMonitorSetMigrationCompression saner
qemu: Decouple migration parameters from compression settings
qemu: Rename qemuMonitorMigrationCompression
qemu: Rework qemuMonitorJSONGetMigrationParams
qemu: Rework qemuMonitorJSONSetMigrationParams
test: Rework qemuMonitorJSONGetMigrationParams test
Add auto convergence migration parameters
qemu: Introduce qemuMigrationSetParams
qemu: Add support for cpu throttling parameters
qemu: Implement auto convergence migration parameters
Report auto convergence throttle rate in migration stats
include/libvirt/libvirt-domain.h | 27 ++++++
src/qemu/qemu_domain.c | 6 ++
src/qemu/qemu_driver.c | 13 ++-
src/qemu/qemu_migration.c | 195 ++++++++++++++++++++++++++++++---------
src/qemu/qemu_migration.h | 17 +++-
src/qemu/qemu_monitor.c | 29 ++++--
src/qemu/qemu_monitor.h | 37 +++++---
src/qemu/qemu_monitor_json.c | 74 +++++++--------
src/qemu/qemu_monitor_json.h | 8 +-
tests/qemumonitorjsontest.c | 60 ++++++------
tools/virsh-domain.c | 35 +++++++
tools/virsh.pod | 16 ++--
12 files changed, 364 insertions(+), 153 deletions(-)
--
2.9.0
8 years, 6 months
[libvirt] [PATCH] syntax-check: rewrite prohibit-duplicate-header in perl
by Ján Tomko
Invoke the script only once instead of once for every file.
---
build-aux/prohibit-duplicate-header.pl | 22 ++++++++++++++++++++++
cfg.mk | 29 +++++------------------------
2 files changed, 27 insertions(+), 24 deletions(-)
create mode 100644 build-aux/prohibit-duplicate-header.pl
diff --git a/build-aux/prohibit-duplicate-header.pl b/build-aux/prohibit-duplicate-header.pl
new file mode 100644
index 0000000..f9ab3f5
--- /dev/null
+++ b/build-aux/prohibit-duplicate-header.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+
+use strict;
+
+my $file = " ";
+my $ret = 0;
+my %includes = ( );
+
+while (<>) {
+ if (not $file eq $ARGV) {
+ %includes = ( );
+ $file = $ARGV;
+ }
+ if (/^# *include *[<"]([^>"]*\.h)[">]/) {
+ $includes{$1}++;
+ if ($includes{$1} == 2) {
+ $ret = 1;
+ print STDERR "$1 included multiple times in $ARGV\n";
+ }
+ }
+}
+exit $ret;
diff --git a/cfg.mk b/cfg.mk
index 297ca3a..69ab6fe 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -813,30 +813,6 @@ sc_prohibit_exit_in_tests:
halt='use return, not exit(), in tests' \
$(_sc_search_regexp)
-# Don't include duplicate header in the source (either *.c or *.h)
-sc_prohibit_duplicate_header:
- @fail=0; for i in $$($(VC_LIST_EXCEPT) | grep '\.[chx]$$'); do \
- awk '/# *include.*\.h/ { \
- match($$0, /[<"][^>"]*[">]/); \
- arr[substr($$0, RSTART + 1, RLENGTH - 2)]++; \
- } \
- END { \
- for (key in arr) { \
- if (arr[key] > 1) { \
- fail=1; \
- printf("%d %s are included\n", arr[key], key); \
- } \
- } \
- if (fail == 1) { \
- printf("duplicate header(s) in " FILENAME "\n"); \
- exit 1; \
- } \
- }' $$i || fail=1; \
- done; \
- if test $$fail -eq 1; then \
- { echo '$(ME): avoid duplicate headers' 1>&2; exit 1; } \
- fi;
-
# Don't include "libvirt/*.h" in "" form.
sc_prohibit_include_public_headers_quote:
@prohibit='# *include *"libvirt/.*\.h"' \
@@ -1100,6 +1076,11 @@ ifneq ($(_gl-Makefile),)
syntax-check: $(top_srcdir)/HACKING spacing-check test-wrap-argv
endif
+# Don't include duplicate header in the source (either *.c or *.h)
+prohibit_duplicate_header:
+ $(AM_V_GEN)files= $$($(VC_LIST_EXCEPT) | grep '\.[chx]$$') \
+ $(PERL) -W $(top_srcdir)/build-aux/prohibit-duplicate-header.pl $$files
+
spacing-check:
$(AM_V_GEN)files=`$(VC_LIST) | grep '\.c$$'`; \
$(PERL) $(top_srcdir)/build-aux/check-spacing.pl $$files || \
--
2.7.3
8 years, 6 months
[libvirt] [PATCH] conf: Simplify conditions in CPU parser/formatter
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/conf/cpu_conf.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 7230b89..b71528e 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -330,8 +330,7 @@ virCPUDefParseXML(xmlNodePtr node,
goto error;
if (n > 0) {
- if (!def->model && def->mode != VIR_CPU_MODE_HOST_MODEL &&
- def->mode != VIR_CPU_MODE_HOST_PASSTHROUGH) {
+ if (!def->model && def->mode == VIR_CPU_MODE_CUSTOM) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Non-empty feature list specified without "
"CPU model"));
@@ -518,10 +517,7 @@ virCPUDefFormatBuf(virBufferPtr buf,
(def->mode == VIR_CPU_MODE_HOST_MODEL ||
(def->mode == VIR_CPU_MODE_CUSTOM && def->model)));
- if (!def->model &&
- def->mode != VIR_CPU_MODE_HOST_MODEL &&
- def->mode != VIR_CPU_MODE_HOST_PASSTHROUGH &&
- def->nfeatures) {
+ if (!def->model && def->mode == VIR_CPU_MODE_CUSTOM && def->nfeatures) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Non-empty feature list specified without CPU model"));
return -1;
--
2.9.0
8 years, 6 months
[libvirt] [PATCH] qemucapsprobe: Don't put empty line at EOF
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
tests/qemucapsprobemock.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/qemucapsprobemock.c b/tests/qemucapsprobemock.c
index 8ff4de9..0c4c786 100644
--- a/tests/qemucapsprobemock.c
+++ b/tests/qemucapsprobemock.c
@@ -62,6 +62,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,
const char *line,
qemuMonitorMessagePtr msg)
{
+ static bool first = true;
virJSONValuePtr value = NULL;
char *json = NULL;
int ret;
@@ -76,6 +77,11 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,
char *p;
bool skip = false;
+ if (first)
+ first = false;
+ else
+ putchar('\n');
+
for (p = json; *p; p++) {
if (skip && *p == '\n') {
continue;
@@ -84,7 +90,6 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,
putchar(*p);
}
}
- putchar('\n');
}
VIR_FREE(json);
--
2.9.0
8 years, 6 months
[libvirt] [PATCH] conf: Remove redundant free in virCPUDefFree
by Jiri Denemark
vendor_id is (and always was) already freed in virCPUDefFreeModel.
This effectively reverts commit fb49ffc3.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/conf/cpu_conf.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 1ba1d82..7230b89 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -77,9 +77,6 @@ virCPUDefFree(virCPUDefPtr def)
return;
virCPUDefFreeModel(def);
-
- VIR_FREE(def->vendor_id);
-
VIR_FREE(def);
}
--
2.9.0
8 years, 6 months
[libvirt] [PATCH] qemu: Fix reference leak in qemuDomainDefPostParse
by Jiri Denemark
The function gets a reference on virQEMUDriverConfig which needs to be
released before returning.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_domain.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 29f6b93..8f19fb5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2134,13 +2134,13 @@ qemuDomainDefPostParse(virDomainDefPtr def,
if (def->os.bootloader || def->os.bootloaderArgs) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("bootloader is not supported by QEMU"));
- return ret;
+ goto cleanup;
}
if (!def->os.machine) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing machine type"));
- return ret;
+ goto cleanup;
}
if (def->os.loader &&
@@ -2155,7 +2155,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
/* check for emulator and create a default one if needed */
if (!def->emulator &&
!(def->emulator = virDomainDefGetDefaultEmulator(def, caps)))
- return ret;
+ goto cleanup;
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
def->emulator)))
--
2.9.0
8 years, 6 months