[libvirt] [PATCH 0/4] Some ABI incompatible changes to virtlogd
by Daniel P. Berrange
Having looked at the code again there is a wire-ABI incompatible
change I think we should make to virtlogd to make it more
flexible. Since we've not released 1.3.0 yet, this is the only
chance we'll have to change the wire protocol. There are also
a couple of fixes in this series we should have before release.
Daniel P. Berrange (4):
qemu: fix memory leak in opening log file
logging: preserve driver, dom name & uuid against log file
logging: change log protocol to be more reusable
logging: validate flags passed from client in virtlogd
src/logging/log_daemon_dispatch.c | 14 ++--
src/logging/log_handler.c | 135 +++++++++++++++++++-------------------
src/logging/log_handler.h | 14 ++--
src/logging/log_manager.c | 18 ++---
src/logging/log_manager.h | 9 +--
src/logging/log_protocol.x | 7 +-
src/qemu/qemu_domain.c | 47 ++++++-------
7 files changed, 114 insertions(+), 130 deletions(-)
--
2.5.0
8 years, 11 months
[libvirt] [PATCH] libxl: free ifname on migration begin phase
by Joao Martins
Commit d2e5538b1 changes virDomainDef to create ifnames
that are autogenerated by libxl, and also clearing them up
on domain cleanup. One place that was missing was also
on migration, when domain xml is sent to dst libvirtd and
would contain ifnames from the source libvirtd. This
would lead to erronous behaviour (as seen in osstest CI)
such as failing to migrate when a vif with the a name
that existed on the destination host (belonging to another domain).
This patch adds an helper libxlDomainFreeIfaceNames for
freeing autogenerated ifnames on both migration begin phase
and domain cleanup.
Signed-off-by: Joao Martins <joao.m.martins(a)oracle.com>
---
src/libxl/libxl_domain.c | 32 ++++++++++++++++++++++----------
src/libxl/libxl_domain.h | 3 +++
src/libxl/libxl_migration.c | 2 ++
3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index ef92974..487589d 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -728,16 +728,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
}
}
- if ((vm->def->nnets)) {
- size_t i;
-
- for (i = 0; i < vm->def->nnets; i++) {
- virDomainNetDefPtr net = vm->def->nets[i];
-
- if (STRPREFIX(net->ifname, "vif"))
- VIR_FREE(net->ifname);
- }
- }
+ libxlDomainFreeIfaceNames(vm->def);
if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name) > 0) {
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
@@ -923,6 +914,27 @@ libxlDomainCreateIfaceNames(virDomainDefPtr def, libxl_domain_config *d_config)
}
}
+/*
+ * Removes autogenerated interface names for the network devices in
+ * parameter def. User-provided interface names are skipped.
+ */
+void
+libxlDomainFreeIfaceNames(virDomainDefPtr def)
+{
+ size_t i;
+
+ for (i = 0; i < def->nnets; i++) {
+ virDomainNetDefPtr net = def->nets[i];
+
+ if (!net->ifname)
+ continue;
+
+ if (STRPREFIX(net->ifname, "vif"))
+ VIR_FREE(net->ifname);
+ }
+}
+
+
/*
* Start a domain through libxenlight.
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 44b3e0b..70c139c 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -135,6 +135,9 @@ int
libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver,
virDomainObjPtr vm);
+void
+libxlDomainFreeIfaceNames(virDomainDefPtr def);
+
int
libxlDomainStart(libxlDriverPrivatePtr driver,
virDomainObjPtr vm,
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 0d23e5f..1ee19ae 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -249,6 +249,8 @@ libxlDomainMigrationBegin(virConnectPtr conn,
def = tmpdef;
} else {
def = vm->def;
+
+ libxlDomainFreeIfaceNames(def);
}
if (!libxlDomainMigrationIsAllowed(def))
--
2.1.4
8 years, 11 months
[libvirt] [PATCH 0/3] libvirt: Fix automatic SCSI controller create in hotplug
by Boris Fiuczynski
Trying to hotplug a SCSI device to a domain without the required SCSI
controller fails.
For hostdev SCSI device hotplug commits 0d8b24f6 and 0785966d rearranged
the automatic creation of the required SCSI controllers from the parsing
xml code into the post parsing code section of virDomainDefParseXML. In
doing so the code will create but not hotplug the missing SCSI controller
and on the hotplug path thru the same code the SCSI controller will not get
hotplugged since it already exits. Then the SCSI hostdev device is
hotplugged and runs into the following internal error
error: Failed to attach device from scsidev.xml
error: internal error: Device alias was not set for scsi controller with index 0
For disk SCSI device hotplug commit 0260506c added in method
qemuBuildDriveDevStr a lookup of the controller alias. The internal error
error: Failed to attach device from scsi_disk.xml
error: internal error: Could not find scsi controller with index 0 required for device
occurs because in method qemuDomainAttachSCSIDisk the automatic creation
of the missing SCSI controller occurs after calling qemuBuildDriveDevStr.
Boris Fiuczynski (3):
conf: Reposition adding SCSI controller for SCSI hostdev hotplug
Revert "conf: Try controller add when searching hostdev bus for unit"
Automatic SCSI controller creation in SCSI disk hotplug broken
src/conf/domain_conf.c | 16 ++++------------
src/qemu/qemu_hotplug.c | 12 ++++++------
2 files changed, 10 insertions(+), 18 deletions(-)
--
2.3.0
8 years, 11 months
[libvirt] [PATCH] log: include hostname in initial log message
by Daniel P. Berrange
On the very first log message we send to any output, we include
the libvirt version number and package string. In some bug reports
we have been given libvirtd.log files that came from a different
host than the corresponding /var/log/libvirt/qemu log files. So
extend the initial log message to include the hostname too.
eg on first log message we would now see:
$ libvirtd
2015-12-04 17:35:36.610+0000: 20917: info : libvirt version: 1.3.0
2015-12-04 17:35:36.610+0000: 20917: info : dhcp-1-180.lcy.redhat.com
2015-12-04 17:35:36.610+0000: 20917: error : qemuMonitorIO:687 : internal error: End of file from monitor
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
cfg.mk | 2 +-
src/util/virlog.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 98 insertions(+), 18 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index cf3f36c..2e3af1a 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1160,7 +1160,7 @@ _src2=src/(util/vircommand|libvirt|lxc/lxc_controller|locking/lock_daemon|loggin
exclude_file_name_regexp--sc_prohibit_fork_wrappers = \
(^($(_src2)|tests/testutils|daemon/libvirtd)\.c$$)
-exclude_file_name_regexp--sc_prohibit_gethostname = ^src/util/virutil\.c$$
+exclude_file_name_regexp--sc_prohibit_gethostname = ^src/util/vir(log|util)\.c$$
exclude_file_name_regexp--sc_prohibit_internal_functions = \
^src/(util/(viralloc|virutil|virfile)\.[hc]|esx/esx_vi\.c)$$
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 627f4cb..34e7f2a 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -39,6 +39,7 @@
#if HAVE_SYS_UN_H
# include <sys/un.h>
#endif
+#include <netdb.h>
#include "virerror.h"
#include "virlog.h"
@@ -94,7 +95,7 @@ static int virLogNbFilters;
* after filtering, multiple output can be used simultaneously
*/
struct _virLogOutput {
- bool logVersion;
+ bool logInitMessage;
void *data;
virLogOutputFunc f;
virLogCloseFunc c;
@@ -402,7 +403,7 @@ virLogDefineOutput(virLogOutputFunc f,
goto cleanup;
}
ret = virLogNbOutputs++;
- virLogOutputs[ret].logVersion = true;
+ virLogOutputs[ret].logInitMessage = true;
virLogOutputs[ret].f = f;
virLogOutputs[ret].c = c;
virLogOutputs[ret].data = data;
@@ -452,6 +453,73 @@ virLogVersionString(const char **rawmsg,
return virLogFormatString(msg, 0, NULL, VIR_LOG_INFO, VIR_LOG_VERSION_STRING);
}
+/* Similar to virGetHostname() but avoids use of error
+ * reporting APIs or logging APIs, to prevent recursion
+ */
+static int
+virLogHostnameString(const char **rawmsg,
+ char **msg)
+{
+ int r;
+ char hostname[HOST_NAME_MAX+1];
+ struct addrinfo hints, *info;
+ char *result = NULL;
+
+ *rawmsg = *msg = NULL;
+ r = gethostname(hostname, sizeof(hostname));
+ if (r == -1)
+ return -1;
+ NUL_TERMINATE(hostname);
+
+ if (STRPREFIX(hostname, "localhost") || strchr(hostname, '.')) {
+ /* in this case, gethostname returned localhost (meaning we can't
+ * do any further canonicalization), or it returned an FQDN (and
+ * we don't need to do any further canonicalization). Return the
+ * string as-is; it's up to callers to check whether "localhost"
+ * is allowed.
+ */
+ ignore_value(VIR_STRDUP_QUIET(result, hostname));
+ goto cleanup;
+ }
+
+ /* otherwise, it's a shortened, non-localhost, hostname. Attempt to
+ * canonicalize the hostname by running it through getaddrinfo
+ */
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_flags = AI_CANONNAME|AI_CANONIDN;
+ hints.ai_family = AF_UNSPEC;
+ r = getaddrinfo(hostname, NULL, &hints, &info);
+ if (r != 0) {
+ ignore_value(VIR_STRDUP_QUIET(result, hostname));
+ goto cleanup;
+ }
+
+ /* Tell static analyzers about getaddrinfo semantics. */
+ sa_assert(info);
+
+ if (info->ai_canonname == NULL ||
+ STRPREFIX(info->ai_canonname, "localhost"))
+ /* in this case, we tried to canonicalize and we ended up back with
+ * localhost. Ignore the canonicalized name and just return the
+ * original hostname
+ */
+ ignore_value(VIR_STRDUP_QUIET(result, hostname));
+ else
+ /* Caller frees this string. */
+ ignore_value(VIR_STRDUP_QUIET(result, info->ai_canonname));
+
+ freeaddrinfo(info);
+
+ cleanup:
+ if (virLogFormatString(msg, 0, NULL, VIR_LOG_INFO, result) < 0) {
+ VIR_FREE(result);
+ return -1;
+ }
+ *rawmsg = result;
+ return 0;
+}
+
static void
virLogSourceUpdate(virLogSourcePtr source)
@@ -533,7 +601,7 @@ virLogVMessage(virLogSourcePtr source,
const char *fmt,
va_list vargs)
{
- static bool logVersionStderr = true;
+ static bool logInitMessageStderr = true;
char *str = NULL;
char *msg = NULL;
char timestamp[VIR_TIME_STRING_BUFLEN];
@@ -583,16 +651,22 @@ virLogVMessage(virLogSourcePtr source,
*/
for (i = 0; i < virLogNbOutputs; i++) {
if (priority >= virLogOutputs[i].priority) {
- if (virLogOutputs[i].logVersion) {
- const char *rawver;
- char *ver = NULL;
- if (virLogVersionString(&rawver, &ver) >= 0)
+ if (virLogOutputs[i].logInitMessage) {
+ const char *rawinitmsg;
+ char *initmsg = NULL;
+ if (virLogVersionString(&rawinitmsg, &initmsg) >= 0)
+ virLogOutputs[i].f(&virLogSelf, VIR_LOG_INFO,
+ __FILE__, __LINE__, __func__,
+ timestamp, NULL, 0, rawinitmsg, initmsg,
+ virLogOutputs[i].data);
+ VIR_FREE(initmsg);
+ if (virLogHostnameString(&rawinitmsg, &initmsg) >= 0)
virLogOutputs[i].f(&virLogSelf, VIR_LOG_INFO,
__FILE__, __LINE__, __func__,
- timestamp, NULL, 0, rawver, ver,
+ timestamp, NULL, 0, rawinitmsg, initmsg,
virLogOutputs[i].data);
- VIR_FREE(ver);
- virLogOutputs[i].logVersion = false;
+ VIR_FREE(initmsg);
+ virLogOutputs[i].logInitMessage = false;
}
virLogOutputs[i].f(source, priority,
filename, linenr, funcname,
@@ -601,16 +675,22 @@ virLogVMessage(virLogSourcePtr source,
}
}
if (virLogNbOutputs == 0) {
- if (logVersionStderr) {
- const char *rawver;
- char *ver = NULL;
- if (virLogVersionString(&rawver, &ver) >= 0)
+ if (logInitMessageStderr) {
+ const char *rawinitmsg;
+ char *initmsg = NULL;
+ if (virLogVersionString(&rawinitmsg, &initmsg) >= 0)
+ virLogOutputToFd(&virLogSelf, VIR_LOG_INFO,
+ __FILE__, __LINE__, __func__,
+ timestamp, NULL, 0, rawinitmsg, initmsg,
+ (void *) STDERR_FILENO);
+ VIR_FREE(initmsg);
+ if (virLogHostnameString(&rawinitmsg, &initmsg) >= 0)
virLogOutputToFd(&virLogSelf, VIR_LOG_INFO,
__FILE__, __LINE__, __func__,
- timestamp, NULL, 0, rawver, ver,
+ timestamp, NULL, 0, rawinitmsg, initmsg,
(void *) STDERR_FILENO);
- VIR_FREE(ver);
- logVersionStderr = false;
+ VIR_FREE(initmsg);
+ logInitMessageStderr = false;
}
virLogOutputToFd(source, priority,
filename, linenr, funcname,
--
2.5.0
8 years, 11 months
[libvirt] [PATCH] rotatingfile: mark log files as close-on-exec
by Daniel P. Berrange
The log file descriptor associated with the virRotatingFile
struct should be marked close-on-exec, as even when virtlogd
re-exec's itself it expect to open the log file fresh. It
does not need to preserve the logfile handles, only the network
client FDs.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/util/virrotatingfile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/virrotatingfile.c b/src/util/virrotatingfile.c
index a32759a..6654aff 100644
--- a/src/util/virrotatingfile.c
+++ b/src/util/virrotatingfile.c
@@ -108,7 +108,7 @@ virRotatingFileWriterEntryNew(const char *path,
if (VIR_ALLOC(entry) < 0)
return NULL;
- if ((entry->fd = open(path, O_CREAT|O_APPEND|O_WRONLY, mode)) < 0) {
+ if ((entry->fd = open(path, O_CREAT|O_APPEND|O_WRONLY|O_CLOEXEC, mode)) < 0) {
virReportSystemError(errno,
_("Unable to open file: %s"), path);
goto error;
@@ -151,7 +151,7 @@ virRotatingFileReaderEntryNew(const char *path)
if (VIR_ALLOC(entry) < 0)
return NULL;
- if ((entry->fd = open(path, O_RDONLY)) < 0) {
+ if ((entry->fd = open(path, O_RDONLY|O_CLOEXEC)) < 0) {
if (errno != ENOENT) {
virReportSystemError(errno,
_("Unable to open file: %s"), path);
--
2.5.0
8 years, 11 months
[libvirt] [PATCH] qemu: include hostname in QEMU log files
by Daniel P. Berrange
Often when debugging bug reports one is given a copy of the file
from /var/log/libvirt/qemu/$NAME.log along with other supporting
files. In a number of cases I've been given sets of files which
were from different machines. Including the hostname in the QEMU
log file will help identify when the bug reporter is providing
bad information.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_process.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b35fc69..e974989 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4091,16 +4091,18 @@ qemuLogOperation(virDomainObjPtr vm,
qemuDomainObjPrivatePtr priv = vm->privateData;
int qemuVersion = virQEMUCapsGetVersion(priv->qemuCaps);
const char *package = virQEMUCapsGetPackage(priv->qemuCaps);
+ char *hostname = virGetHostname();
if ((timestamp = virTimeStringNow()) == NULL)
goto cleanup;
- if (qemuDomainLogContextWrite(logCtxt, "%s: %s %s, qemu version: %d.%d.%d%s\n",
+ if (qemuDomainLogContextWrite(logCtxt, "%s: %s %s, qemu version: %d.%d.%d%s, hostname:%s\n",
timestamp, msg, VIR_LOG_VERSION_STRING,
(qemuVersion / 1000000) % 1000,
(qemuVersion / 1000) % 1000,
qemuVersion % 1000,
- package ? package : "") < 0)
+ package ? package : "",
+ hostname ? hostname : "") < 0)
goto cleanup;
if (cmd) {
@@ -4110,6 +4112,7 @@ qemuLogOperation(virDomainObjPtr vm,
}
cleanup:
+ VIR_FREE(hostname);
VIR_FREE(timestamp);
}
--
2.5.0
8 years, 11 months
[libvirt] [PATCH v2] libxl: add p2p migration
by Joao Martins
Introduce support for VIR_MIGRATE_PEER2PEER in libxl driver
for supporting migration in Openstack. Most of the changes
occur at the source and no modifications at the receiver.
In P2P mode there is only the Perform phase so we must handle
the connection with the destination and actually perform the
migration. libxlDomainPerformP2P implements the connection to
the destination and let libxlDoMigrateP2P implements the actual
migration logic with virConnectPtr. In this function we do
the migration steps in the destination similar to
virDomainMigrateVersion3Full. We appropriately save the last
error reported in each of the phases to provide proper
reporting. We don't yet support VIR_MIGRATE_TUNNELED and
we always use V3 with extensible params, making the
implementation simpler.
It is worth noting that the receiver didn't have any changes,
and because it's still the v3 sequence thus it is possible to
migrate from a P2P to non-P2P host.
Signed-off-by: Joao Martins <joao.m.martins(a)oracle.com>
---
Changes since v1:
- Move Begin step to libxlDoMigrateP2P to have all 4 steps
together.
- Remove if before VIR_FREE(dom_xml)
---
src/libxl/libxl_driver.c | 13 ++-
src/libxl/libxl_migration.c | 220 ++++++++++++++++++++++++++++++++++++++++++++
src/libxl/libxl_migration.h | 11 +++
3 files changed, 241 insertions(+), 3 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index fcdcbdb..da98265 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -4713,6 +4713,7 @@ libxlConnectSupportsFeature(virConnectPtr conn, int feature)
switch (feature) {
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
+ case VIR_DRV_FEATURE_MIGRATION_P2P:
return 1;
default:
return 0;
@@ -5039,9 +5040,15 @@ libxlDomainMigratePerform3Params(virDomainPtr dom,
if (virDomainMigratePerform3ParamsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (libxlDomainMigrationPerform(driver, vm, dom_xml, dconnuri,
- uri, dname, flags) < 0)
- goto cleanup;
+ if (flags & VIR_MIGRATE_PEER2PEER) {
+ if (libxlDomainMigrationPerformP2P(driver, vm, dom->conn, dom_xml,
+ dconnuri, uri, dname, flags) < 0)
+ goto cleanup;
+ } else {
+ if (libxlDomainMigrationPerform(driver, vm, dom_xml, dconnuri,
+ uri, dname, flags) < 0)
+ goto cleanup;
+ }
ret = 0;
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 0d23e5f..a1c7b55 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -42,6 +42,7 @@
#include "libxl_conf.h"
#include "libxl_migration.h"
#include "locking/domain_lock.h"
+#include "virtypedparam.h"
#define VIR_FROM_THIS VIR_FROM_LIBXL
@@ -456,6 +457,225 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
return ret;
}
+/* This function is a simplification of virDomainMigrateVersion3Full
+ * excluding tunnel support and restricting it to migration v3
+ * with params since it was the first to be introduced in libxl.
+ */
+static int
+libxlDoMigrateP2P(libxlDriverPrivatePtr driver,
+ virDomainObjPtr vm,
+ virConnectPtr sconn,
+ const char *xmlin,
+ virConnectPtr dconn,
+ const char *dconnuri ATTRIBUTE_UNUSED,
+ const char *dname,
+ const char *uri,
+ unsigned int flags)
+{
+ virDomainPtr ddomain = NULL;
+ virTypedParameterPtr params = NULL;
+ int nparams = 0;
+ int maxparams = 0;
+ char *uri_out = NULL;
+ char *dom_xml = NULL;
+ unsigned long destflags;
+ bool cancelled = true;
+ virErrorPtr orig_err = NULL;
+ int ret = -1;
+
+ dom_xml = libxlDomainMigrationBegin(sconn, vm, xmlin);
+ if (!dom_xml)
+ goto cleanup;
+
+ if (virTypedParamsAddString(¶ms, &nparams, &maxparams,
+ VIR_MIGRATE_PARAM_DEST_XML, dom_xml) < 0)
+ goto cleanup;
+
+ if (dname &&
+ virTypedParamsAddString(¶ms, &nparams, &maxparams,
+ VIR_MIGRATE_PARAM_DEST_NAME, dname) < 0)
+ goto cleanup;
+
+ if (uri &&
+ virTypedParamsAddString(¶ms, &nparams, &maxparams,
+ VIR_MIGRATE_PARAM_URI, uri) < 0)
+ goto cleanup;
+
+ /* We don't require the destination to have P2P support
+ * as it looks to be normal migration from the receiver perpective.
+ */
+ destflags = flags & ~(VIR_MIGRATE_PEER2PEER);
+
+ VIR_DEBUG("Prepare3");
+ virObjectUnlock(vm);
+ ret = dconn->driver->domainMigratePrepare3Params
+ (dconn, params, nparams, NULL, 0, NULL, NULL, &uri_out, destflags);
+ virObjectLock(vm);
+
+ if (ret == -1)
+ goto cleanup;
+
+ if (uri_out) {
+ if (virTypedParamsReplaceString(¶ms, &nparams,
+ VIR_MIGRATE_PARAM_URI, uri_out) < 0) {
+ orig_err = virSaveLastError();
+ goto finish;
+ }
+ } else {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("domainMigratePrepare3 did not set uri"));
+ goto finish;
+ }
+
+ VIR_DEBUG("Perform3 uri=%s", NULLSTR(uri_out));
+ ret = libxlDomainMigrationPerform(driver, vm, NULL, NULL,
+ uri_out, NULL, flags);
+
+ if (ret < 0)
+ orig_err = virSaveLastError();
+
+ cancelled = (ret < 0);
+
+ finish:
+ VIR_DEBUG("Finish3 ret=%d", ret);
+ if (virTypedParamsGetString(params, nparams,
+ VIR_MIGRATE_PARAM_DEST_NAME, NULL) <= 0 &&
+ virTypedParamsReplaceString(¶ms, &nparams,
+ VIR_MIGRATE_PARAM_DEST_NAME,
+ vm->def->name) < 0) {
+ ddomain = NULL;
+ } else {
+ virObjectUnlock(vm);
+ ddomain = dconn->driver->domainMigrateFinish3Params
+ (dconn, params, nparams, NULL, 0, NULL, NULL,
+ destflags, cancelled);
+ virObjectLock(vm);
+ }
+
+ cancelled = (ddomain == NULL);
+
+ /* If Finish3Params set an error, and we don't have an earlier
+ * one we need to preserve it in case confirm3 overwrites
+ */
+ if (!orig_err)
+ orig_err = virSaveLastError();
+
+ VIR_DEBUG("Confirm3 cancelled=%d vm=%p", cancelled, vm);
+ ret = libxlDomainMigrationConfirm(driver, vm, flags, cancelled);
+
+ if (ret < 0)
+ VIR_WARN("Guest %s probably left in 'paused' state on source",
+ vm->def->name);
+
+ cleanup:
+ if (ddomain) {
+ virObjectUnref(ddomain);
+ ret = 0;
+ } else {
+ ret = -1;
+ }
+
+ if (orig_err) {
+ virSetError(orig_err);
+ virFreeError(orig_err);
+ }
+
+ VIR_FREE(dom_xml);
+ VIR_FREE(uri_out);
+ virTypedParamsFree(params, nparams);
+ return ret;
+}
+
+static int virConnectCredType[] = {
+ VIR_CRED_AUTHNAME,
+ VIR_CRED_PASSPHRASE,
+};
+
+static virConnectAuth virConnectAuthConfig = {
+ .credtype = virConnectCredType,
+ .ncredtype = ARRAY_CARDINALITY(virConnectCredType),
+};
+
+static void
+libxlMigrationConnectionClosed(virConnectPtr conn,
+ int reason,
+ void *opaque)
+{
+ virDomainObjPtr vm = opaque;
+
+ VIR_DEBUG("conn=%p, reason=%d, vm=%s", conn, reason, vm->def->name);
+ virDomainObjBroadcast(vm);
+}
+
+/* On P2P mode there is only the Perform3 phase and we need to handle
+ * the connection with the destination libvirtd and perform the migration.
+ * Here we first tackle the first part of it, and libxlDoMigrationP2P handles
+ * the migration process with an established virConnectPtr to the destination.
+ */
+int
+libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver,
+ virDomainObjPtr vm,
+ virConnectPtr sconn,
+ const char *xmlin,
+ const char *dconnuri,
+ const char *uri_str ATTRIBUTE_UNUSED,
+ const char *dname,
+ unsigned int flags)
+{
+ int ret = -1;
+ int keepAliveInterval = 5;
+ int keepAliveCount = 5;
+ bool useParams;
+ virConnectPtr dconn = NULL;
+ virErrorPtr orig_err = NULL;
+
+ virObjectUnlock(vm);
+ dconn = virConnectOpenAuth(dconnuri, &virConnectAuthConfig, 0);
+ virObjectLock(vm);
+
+ if (dconn == NULL) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("Failed to connect to remote libvirt URI %s: %s"),
+ dconnuri, virGetLastErrorMessage());
+ return ret;
+ }
+
+ if (virConnectSetKeepAlive(dconn, keepAliveInterval,
+ keepAliveCount) < 0)
+ goto cleanup;
+
+ if (virConnectRegisterCloseCallback(dconn, libxlMigrationConnectionClosed,
+ vm, NULL) < 0) {
+ goto cleanup;
+ }
+
+ virObjectUnlock(vm);
+ useParams = VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
+ VIR_DRV_FEATURE_MIGRATION_PARAMS);
+ virObjectLock(vm);
+
+ if (!useParams) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("Destination libvirt does not support migration with extensible parameters"));
+ goto cleanup;
+ }
+
+ ret = libxlDoMigrateP2P(driver, vm, sconn, xmlin, dconn, dconnuri,
+ dname, uri_str, flags);
+
+ cleanup:
+ orig_err = virSaveLastError();
+ virObjectUnlock(vm);
+ virConnectUnregisterCloseCallback(dconn, libxlMigrationConnectionClosed);
+ virObjectUnref(dconn);
+ virObjectLock(vm);
+ if (orig_err) {
+ virSetError(orig_err);
+ virFreeError(orig_err);
+ }
+ return ret;
+}
+
int
libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,
virDomainObjPtr vm,
diff --git a/src/libxl/libxl_migration.h b/src/libxl/libxl_migration.h
index 20b45d8..0f83bb4 100644
--- a/src/libxl/libxl_migration.h
+++ b/src/libxl/libxl_migration.h
@@ -28,6 +28,7 @@
# define LIBXL_MIGRATION_FLAGS \
(VIR_MIGRATE_LIVE | \
+ VIR_MIGRATE_PEER2PEER | \
VIR_MIGRATE_UNDEFINE_SOURCE | \
VIR_MIGRATE_PAUSED)
@@ -56,6 +57,16 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
unsigned int flags);
int
+libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver,
+ virDomainObjPtr vm,
+ virConnectPtr sconn,
+ const char *dom_xml,
+ const char *dconnuri,
+ const char *uri_str,
+ const char *dname,
+ unsigned int flags);
+
+int
libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,
virDomainObjPtr vm,
const char *dom_xml,
--
2.1.4
8 years, 11 months
[libvirt] [PATCH] libvirtd: require virtlogd to start before libvirtd
by Guido Günther
In the non-systemd case, without socket activation, we need to proper
ordering.
---
daemon/libvirtd.init.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/libvirtd.init.in b/daemon/libvirtd.init.in
index ed42195..22006c4 100644
--- a/daemon/libvirtd.init.in
+++ b/daemon/libvirtd.init.in
@@ -5,7 +5,7 @@
#
### BEGIN INIT INFO
# Provides: libvirtd
-# Required-Start: $network messagebus
+# Required-Start: $network messagebus virtlogd
# Should-Start: $named
# Should-Start: xend
# Should-Start: avahi-daemon
--
2.6.2
8 years, 11 months
[libvirt] [PATCH v2 0/5] Add read error ignore to storage backend vol info APIs
by John Ferlan
v1 took a simplistic approach:
http://www.redhat.com/archives/libvir-list/2015-October/msg00919.html
but not specific enough according to the review. So adding some extra
complexity of checking for specific errors and flag bits to "ignore" the
error similar to the catch-all openflags VIR_STORAGE_VOL_OPEN_NOERROR for
all the virStorageBackendUpdateVol{Info|TargetInfo|TargetInfoFD} API's
which are used to get the volume capacity, allocation, etc. data.
Along the way an inavertent bug was found and fixed in patch 3 in
virStorageBackendUpdateVolTargetInfo where an error could have been
reported, but not propagated back to the user since 'ret' would have
been 0 after the virStorageBackendUpdateVolTargetInfoFD call.
John Ferlan (5):
storage: Add readflags for backend error processing
storage: Add comments for backend APIs
storage: Handle readflags errors
storage: Add debug message
storage: Ignore block devices that fail format detection
src/storage/storage_backend.c | 151 +++++++++++++++++++++++++++-------
src/storage/storage_backend.h | 20 ++++-
src/storage/storage_backend_disk.c | 5 +-
src/storage/storage_backend_fs.c | 8 +-
src/storage/storage_backend_gluster.c | 2 +-
src/storage/storage_backend_logical.c | 2 +-
src/storage/storage_backend_mpath.c | 2 +-
src/storage/storage_backend_scsi.c | 6 +-
8 files changed, 153 insertions(+), 43 deletions(-)
--
2.5.0
8 years, 11 months
[libvirt] [libvirt-snmp][PATCH] libvirt-snmp.spec.in: Fix changelog
by Michal Privoznik
The initial version was released on Wednesday, not Thursday. I
would not care, but rpmlint is kind of sad:
libvirt-snmp.src: E: specfile-error warning: bogus date in %changelog: Thu Feb 2 2011 Michal Privoznik <mprivozn(a)redhat.com> 0.0.1-1
13 packages and 0 specfiles checked; 1 errors, 0 warnings.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under trivial rule.
libvirt-snmp.spec.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt-snmp.spec.in b/libvirt-snmp.spec.in
index a4be218..c5a1a41 100644
--- a/libvirt-snmp.spec.in
+++ b/libvirt-snmp.spec.in
@@ -49,5 +49,5 @@ make install DESTDIR=$RPM_BUILD_ROOT
- resolve licensing conflicts
- add unified header to sources
-* Thu Feb 2 2011 Michal Privoznik <mprivozn(a)redhat.com> 0.0.1-1
+* Wed Feb 2 2011 Michal Privoznik <mprivozn(a)redhat.com> 0.0.1-1
- initial revision
--
2.4.10
8 years, 11 months