[libvirt] [PATCH v2 0/4] cleanup resolving persistent/running/current flags
by Nikolay Shirokovskiy
Original name of series was:
Subject: [PATCH 0/3] make virDomainObjGetPersistentDef return only persistent definition
Changes from version1
=====================
Original motivation of the series was fixing virDomainObjGetPersistentDef so
that it would not return configs other than persistent. However the final patch
that does it in the first version is absent in current version. I think the
fix should be done another way and in different series. Thus this version has
only misc cleanups which are better splitted into patches in this version.
A few words why I leave patch for virDomainObjGetPersistentDef. First I should
not return NULL from the function as this value already has different meaning
- memory allocation error and there is code that checks for this error. This
code calls virDomainObjGetPersistentDef unconditionally but later use the
return value only for persistent domains, thus it could get NULL pointer on
function call and treat it as an allocation error.
I think the proper way would be chaning virDomainObjGetPersistentDef so it
could not fail that is not call virDomainObjSetDefTransient. Looks like this
is already true because drivers that distiguish between running/persistent
config call virDomainObjSetDefTransient ealy in the domain start process (and
even two times) so that later calls for virDomainObjSetDefTransient are
unnecessary.
Nikolay Shirokovskiy (4):
virDomainObjUpdateModificationImpact: reduce nesting
libxlDomainSetMemoryFlags : reuse virDomainLiveConfigHelperMethod
lxc, libxl: reuse virDomainObjUpdateModificationImpact
libxlDomainPinVcpuFlags: remove check duplicates
src/conf/domain_conf.c | 12 +++---
src/libxl/libxl_driver.c | 103 ++++-------------------------------------------
src/lxc/lxc_driver.c | 75 +++-------------------------------
3 files changed, 19 insertions(+), 171 deletions(-)
--
1.8.3.1
8 years, 9 months
[libvirt] [PATCH] Use correct LDFLAGS for leaseshelper
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/Makefile.am | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/Makefile.am b/src/Makefile.am
index a316b4d..d57d303 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2810,6 +2810,10 @@ libvirt_iohelper_CFLAGS = \
if WITH_NETWORK
libexec_PROGRAMS += libvirt_leaseshelper
libvirt_leaseshelper_SOURCES = $(NETWORK_LEASES_HELPER_SOURCES)
+libvirt_leaseshelper_LDFLAGS = \
+ $(AM_LDFLAGS) \
+ $(PIE_LDFLAGS) \
+ $(NULL)
libvirt_leaseshelper_LDADD = \
libvirt_util.la \
../gnulib/lib/libgnu.la
--
2.7.2
8 years, 9 months
[libvirt] [PATCH] qemu: Check if domain is active in GetControlInfo
by Jiri Denemark
Reporting status of a control connection makes no sense for an inactive
domain.
https://bugzilla.redhat.com/show_bug.cgi?id=1281706
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_driver.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4bd4071..9fd4c57 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2763,6 +2763,12 @@ qemuDomainGetControlInfo(virDomainPtr dom,
if (virDomainGetControlInfoEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("domain is not running"));
+ goto cleanup;
+ }
+
priv = vm->privateData;
memset(info, 0, sizeof(*info));
--
2.7.2
8 years, 9 months
[libvirt] [PATCH] qemu: forbid renaming domain which has managedsave file
by Shanzhi Yu
after rename a domain which has managedsave file, the new name domain
can't boot up from the state it saved, and the managedsave file will
exist with the original name.
Signed-off-by: Shanzhi Yu <shyu(a)redhat.com>
---
src/qemu/qemu_driver.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4bd4071..036a367 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20000,6 +20000,12 @@ static int qemuDomainRename(virDomainPtr dom,
goto endjob;
}
+ if (vm->hasManagedSave) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("can't rename a domain has managedsave file"));
+ goto endjob;
+ }
+
if (virDomainObjListRename(driver->domains, vm, new_name, flags,
qemuDomainRenameCallback, driver) < 0)
goto endjob;
--
2.5.0
8 years, 9 months
[libvirt] [PATCH 0/7] Couple of -Os fixes
by Michal Privoznik
So while trying to bring down the size of my nss module, one of the things I've
tried was compiling with -Os instead of -O3. Interesting errors pop up. Here
are the fixes. If you think I should squash some patches together, I will
gladly do that.
Michal Privoznik (7):
virCommandAddEnv: Drop inline
virDomainNumatuneNodeSpecified: Drop inline
virDomainChrRemove: Initialize @ret
vbox: Initialize @rc
qemuDomainBlockCommit: Initialize @baseSource
virNetworkDefForwardIf: drop inline
virStorageBackendLogicalMatchPoolSource: Initialize @thisSource
src/conf/domain_conf.c | 2 +-
src/conf/network_conf.c | 8 ++++++++
src/conf/network_conf.h | 8 +-------
src/conf/numa_conf.c | 2 +-
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 2 +-
src/storage/storage_backend_logical.c | 2 +-
src/util/vircommand.c | 2 +-
src/vbox/vbox_common.c | 2 +-
src/vbox/vbox_tmpl.c | 2 +-
10 files changed, 17 insertions(+), 14 deletions(-)
--
2.4.10
8 years, 9 months
[libvirt] [PATCH] daemon: fixup refcounting in close callback handling
by Nikolay Shirokovskiy
remoteDispatchConnectCloseCallbackRegister introduced in
f484310add53ebdc26a6fdcb88bc398750325b7e has problems. It refcounts
network client object and in case of NOOP driver operations
for close callback registering/unregistering (any driveres besides
vz) nobody will unref it later. As a result client connection
will not be disposed and driver connection will not be closed.
The fix is easy. We don't need to refcount at all. We don't get
dangling pointer because in remoteClientFreeFunc which is called
upon disposing this network client object we unregistering close
callback.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
daemon/remote.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 04d8ada..17783fa 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3382,11 +3382,9 @@ remoteDispatchConnectCloseCallbackRegister(virNetServerPtr server ATTRIBUTE_UNUS
goto cleanup;
}
- // on behalf of close callback
- virObjectRef(client);
if (virConnectRegisterCloseCallback(priv->conn,
remoteRelayConnectionClosedEvent,
- client, virObjectFreeCallback) < 0)
+ client, NULL) < 0)
goto cleanup;
priv->closeRegistered = true;
--
1.8.3.1
8 years, 9 months
[libvirt] [PATCH] Reject migration with both --live and --offline when migration requested from other clients/API.
by Nitesh Konkar
---
src/libvirt-domain.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 9491845..6a5034e 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -3616,6 +3616,13 @@ virDomainMigrate(virDomainPtr domain,
VIR_MIGRATE_NON_SHARED_INC,
error);
+ if ((flags & VIR_MIGRATE_OFFLINE) && (flags & VIR_MIGRATE_LIVE)) {
+ virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+ _("Options --live and --offline are "
+ "mutually exclusive"));
+ goto error;
+ }
+
if (flags & VIR_MIGRATE_OFFLINE) {
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
@@ -3840,6 +3847,13 @@ virDomainMigrate2(virDomainPtr domain,
VIR_MIGRATE_NON_SHARED_INC,
error);
+ if ((flags & VIR_MIGRATE_OFFLINE) && (flags & VIR_MIGRATE_LIVE)) {
+ virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+ _("Options --live and --offline are "
+ "mutually exclusive"));
+ goto error;
+ }
+
if (flags & VIR_MIGRATE_OFFLINE) {
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
@@ -4014,6 +4028,13 @@ virDomainMigrate3(virDomainPtr domain,
VIR_MIGRATE_NON_SHARED_INC,
error);
+ if ((flags & VIR_MIGRATE_OFFLINE) && (flags & VIR_MIGRATE_LIVE)) {
+ virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+ _("Options --live and --offline are "
+ "mutually exclusive"));
+ goto error;
+ }
+
if (flags & VIR_MIGRATE_PEER2PEER) {
virReportInvalidArg(flags, "%s",
_("use virDomainMigrateToURI3 for peer-to-peer "
--
1.8.3.1
8 years, 9 months
[libvirt] [PATCH v3] This patch gives an error when migration is attempted with both --live and --offline options.
by Nitesh Konkar
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
tools/virsh-domain.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 43c8436..b9f678f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9838,6 +9838,8 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd)
bool live_flag = false;
virshCtrlData data = { .dconn = NULL };
+ VSH_EXCLUSIVE_OPTIONS("live", "offline");
+
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
--
1.8.3.1
8 years, 9 months
[libvirt] [PATCH] util: Cleanup error path for virPolkitAgentCreate
by John Ferlan
More fallout from changing to using virPolkitAgent and handling error
paths. Needed to clear the 'cmd' once stored and of course add the
virCommandFree(cmd) in the error: label.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
Found by coverity...
Pushed as trivial...
src/util/virpolkit.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c
index 44f2328..2038744 100644
--- a/src/util/virpolkit.c
+++ b/src/util/virpolkit.c
@@ -182,6 +182,7 @@ virPolkitAgentCreate(void)
if (VIR_ALLOC(agent) < 0)
goto error;
agent->cmd = cmd;
+ cmd = NULL;
virCommandAddArgFormat(cmd, "%lld", (long long int) getpid());
virCommandAddArg(cmd, "--notify-fd");
@@ -206,6 +207,7 @@ virPolkitAgentCreate(void)
VIR_FORCE_CLOSE(pipe_fd[0]);
VIR_FORCE_CLOSE(pipe_fd[1]);
virPolkitAgentDestroy(agent);
+ virCommandFree(cmd);
return NULL;
}
--
2.5.0
8 years, 9 months
[libvirt] [PATCH] datatypes.c: Replace 'close' with 'closeData'
by Michal Privoznik
Older compilers fail to see that 'close' is not used a function
rather than a variable and produce the following error:
cc1: warnings being treated as errors
../../src/datatypes.c: In function 'virConnectCloseCallbackDataReset':
../../src/datatypes.c:149: error: declaration of 'close' shadows a global declaration [-Wshadow]
Replace all the 'close' occurrences with 'closeData' to resolve
this.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/datatypes.c | 72 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/src/datatypes.c b/src/datatypes.c
index 163db39..696e8c0 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -145,16 +145,16 @@ virConnectDispose(void *obj)
}
-static
-void virConnectCloseCallbackDataReset(virConnectCloseCallbackDataPtr close)
+static void
+virConnectCloseCallbackDataReset(virConnectCloseCallbackDataPtr closeData)
{
- if (close->freeCallback)
- close->freeCallback(close->opaque);
+ if (closeData->freeCallback)
+ closeData->freeCallback(closeData->opaque);
- close->freeCallback = NULL;
- close->opaque = NULL;
- virObjectUnref(close->conn);
- close->conn = NULL;
+ closeData->freeCallback = NULL;
+ closeData->opaque = NULL;
+ virObjectUnref(closeData->conn);
+ closeData->conn = NULL;
}
/**
@@ -178,77 +178,77 @@ virNewConnectCloseCallbackData(void)
return virObjectLockableNew(virConnectCloseCallbackDataClass);
}
-void virConnectCloseCallbackDataRegister(virConnectCloseCallbackDataPtr close,
+void virConnectCloseCallbackDataRegister(virConnectCloseCallbackDataPtr closeData,
virConnectPtr conn,
virConnectCloseFunc cb,
void *opaque,
virFreeCallback freecb)
{
- virObjectLock(close);
+ virObjectLock(closeData);
- if (close->callback != NULL) {
+ if (closeData->callback != NULL) {
VIR_WARN("Attempt to register callback on armed"
- " close callback object %p", close);
+ " close callback object %p", closeData);
goto cleanup;
return;
}
- close->conn = conn;
- virObjectRef(close->conn);
- close->callback = cb;
- close->opaque = opaque;
- close->freeCallback = freecb;
+ closeData->conn = conn;
+ virObjectRef(closeData->conn);
+ closeData->callback = cb;
+ closeData->opaque = opaque;
+ closeData->freeCallback = freecb;
cleanup:
- virObjectUnlock(close);
+ virObjectUnlock(closeData);
}
-void virConnectCloseCallbackDataUnregister(virConnectCloseCallbackDataPtr close,
+void virConnectCloseCallbackDataUnregister(virConnectCloseCallbackDataPtr closeData,
virConnectCloseFunc cb)
{
- virObjectLock(close);
+ virObjectLock(closeData);
- if (close->callback != cb) {
+ if (closeData->callback != cb) {
VIR_WARN("Attempt to unregister different callback on "
- " close callback object %p", close);
+ " close callback object %p", closeData);
goto cleanup;
}
- virConnectCloseCallbackDataReset(close);
- close->callback = NULL;
+ virConnectCloseCallbackDataReset(closeData);
+ closeData->callback = NULL;
cleanup:
- virObjectUnlock(close);
+ virObjectUnlock(closeData);
}
-void virConnectCloseCallbackDataCall(virConnectCloseCallbackDataPtr close,
+void virConnectCloseCallbackDataCall(virConnectCloseCallbackDataPtr closeData,
int reason)
{
- virObjectLock(close);
+ virObjectLock(closeData);
- if (!close->conn)
+ if (!closeData->conn)
goto exit;
VIR_DEBUG("Triggering connection close callback %p reason=%d, opaque=%p",
- close->callback, reason, close->opaque);
- close->callback(close->conn, reason, close->opaque);
+ closeData->callback, reason, closeData->opaque);
+ closeData->callback(closeData->conn, reason, closeData->opaque);
- virConnectCloseCallbackDataReset(close);
+ virConnectCloseCallbackDataReset(closeData);
exit:
- virObjectUnlock(close);
+ virObjectUnlock(closeData);
}
virConnectCloseFunc
-virConnectCloseCallbackDataGetCallback(virConnectCloseCallbackDataPtr close)
+virConnectCloseCallbackDataGetCallback(virConnectCloseCallbackDataPtr closeData)
{
virConnectCloseFunc cb;
- virObjectLock(close);
- cb = close->callback;
- virObjectUnlock(close);
+ virObjectLock(closeData);
+ cb = closeData->callback;
+ virObjectUnlock(closeData);
return cb;
}
--
2.4.10
8 years, 9 months