[libvirt] [PATCH] util: typos in fallback code fo virDoubleToStr
by Martin Kletzander
Fixes for some typos that somehow didn't get to the final push of the
commit 43bfa23e6f968be9a8c134a4b5c3cfb6da3816d9.
---
Pushing as a build-breaker.
src/util/util.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index 4a720d8..9068e0f 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2106,7 +2106,7 @@ virDoubleToStr(char **strp, double number)
char *radix, *tmp;
struct lconv *lc;
- if ((ret = virVasprintf(strp, "%lf", number) < 0)
+ if ((ret = virAsprintf(strp, "%lf", number) < 0))
goto error;
lc = localeconv();
@@ -2115,7 +2115,7 @@ virDoubleToStr(char **strp, double number)
if (tmp) {
*tmp = '.';
if (strlen(radix) > 1)
- memmove(tmp + 1, tmp + strlen(radix), strlen(*strp) - (tmp - str));
+ memmove(tmp + 1, tmp + strlen(radix), strlen(*strp) - (tmp - *strp));
}
#endif /* HAVE_NEWLOCALE */
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH 0/4] support <vlan> element for interfaces and networks
by Laine Stump
The purpose of these patches is to define a data type that can
properly describe an interface's vlan configuration (including
multiple vlans for trunking), provide XML parser and formatter to
translate to and from the new data type, add the new <vlan> element to
both domain <interface> and to <network> in appropriate places, and to
provide the new vlan data to the hypervisor driver.
Once these 4 patches are applied, all that will be left to support
vlan configuration for any network connection that supports it, is to
request the vlan data for the interface with
virDomainNetGetActualVlan(netdef). If that function returns NULL,
there is no vlan config for this interface; if it's non-zero, it is a
pointer to virNetDevVlan, and you can grab the data from there.
Since I currently know of only two types of network connection we will
be able to easily support this for (sr-iov VFs using PCI passthrough,
and openvswitch), any type other than those will refuse to start if a
vlan has been requested (see PATCH 4/4). This covers validation for
the qemu and lxc drivers (since they use common code), but I'm not
sure about xen, esx, or any other driver - they will likely require
extra code to either implement transparent vlan configuration, or log
an error if it's requested (my guess is that, in spite of our best
efforts, *many* people will misunderstand the limitations of this
functionality, and try to put all sorts of interfaces on vlans; it
will be much friendlier to inform them of the problem rather than
simply ignore the vlan config.
==
This patchset was developed on top of the 9 part patchset here:
https://www.redhat.com/archives/libvir-list/2012-August/msg00293.html
and the 5 part set here:
https://www.redhat.com/archives/libvir-list/2012-August/msg00293.html
It doesn't depend on any of the functionality, but not having those
patchset will probably lead to some merge conflicts.
12 years, 3 months
[libvirt] [PATCH 0/5] network: report #connections in network xml
by Laine Stump
The forward devices in direct mode (aka macvtap) networks already have
a counter to keep track of how many guest interfaces are using each
physical device. This series renames that counter to "connections",
then adds another connects counter to the toplevel of each network,
and outputs both of these counters (when non-0) with the live XML for
the network (i.e. it isn't output if you ask for the --inactive xml).
Someone working on a management application had requested this info,
and it already existed, so I thought I may as well expose it.
In-Reply-To:
12 years, 3 months
[libvirt] [PATCH v4] json: fix interface locale dependency
by Martin Kletzander
libvirt creates invalid commands if wrong locale is selected. For
example with locale that uses comma as a decimal point, JSON commands
created with decimal numbers are invalid because comma separates the
entries in JSON. Fortunately even when decimal point is affected,
thousands grouping is not, because for grouping to be enabled with
*printf, there has to be an apostrophe flag specified (and supported).
This patch adds specific internal function for converting doubles to
strings with C locale.
--
v4:
- changed according to Eric's suggestions
---
bootstrap.conf | 1 +
configure.ac | 4 +-
src/libvirt_private.syms | 1 +
src/util/json.c | 2 +-
src/util/util.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
src/util/util.h | 3 ++
6 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index c112ccd..a4e1c2f 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -62,6 +62,7 @@ ioctl
isatty
largefile
listen
+localeconv
maintainer-makefile
manywarnings
mkstemp
diff --git a/configure.ac b/configure.ac
index 8a04d91..3951012 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,8 +132,8 @@ AC_CHECK_SIZEOF([long])
dnl Availability of various common functions (non-fatal if missing),
dnl and various less common threadsafe functions
AC_CHECK_FUNCS_ONCE([cfmakeraw geteuid getgid getgrnam_r getmntent_r \
- getpwuid_r getuid initgroups kill mmap posix_fallocate posix_memalign \
- regexec sched_getaffinity])
+ getpwuid_r getuid initgroups kill mmap newlocale posix_fallocate \
+ posix_memalign regexec sched_getaffinity])
dnl Availability of pthread functions (if missing, win32 threading is
dnl assumed). Because of $LIB_PTHREAD, we cannot use AC_CHECK_FUNCS_ONCE.
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c023dbf..018d3a9 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1140,6 +1140,7 @@ virArgvToString;
virAsprintf;
virBuildPathInternal;
virDirCreate;
+virDoubleToStr;
virEnumFromString;
virEnumToString;
virEventAddHandle;
diff --git a/src/util/json.c b/src/util/json.c
index 5132989..40d50a1 100644
--- a/src/util/json.c
+++ b/src/util/json.c
@@ -201,7 +201,7 @@ virJSONValuePtr virJSONValueNewNumberDouble(double data)
{
virJSONValuePtr val = NULL;
char *str;
- if (virAsprintf(&str, "%lf", data) < 0)
+ if (virDoubleToStr(&str, data) < 0)
return NULL;
val = virJSONValueNewNumber(str);
VIR_FREE(str);
diff --git a/src/util/util.c b/src/util/util.c
index e5bb27b..4a720d8 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -44,6 +44,7 @@
#include <signal.h>
#include <termios.h>
#include <pty.h>
+#include <locale.h>
#if HAVE_LIBDEVMAPPER_H
# include <libdevmapper.h>
@@ -2060,6 +2061,68 @@ int virEnumFromString(const char *const*types,
return -1;
}
+/* In case thread-safe locales are available */
+#if HAVE_NEWLOCALE
+
+static locale_t virLocale;
+
+static int
+virLocaleOnceInit(void)
+{
+ virLocale = newlocale(LC_ALL_MASK, "C", (locale_t)0);
+ if (!virLocale)
+ return -1;
+ return 0;
+}
+
+VIR_ONCE_GLOBAL_INIT(virLocale)
+#endif
+
+/**
+ * virDoubleToStr
+ *
+ * converts double to string with C locale (thread-safe).
+ *
+ * Returns -1 on error, size of the string otherwise.
+ */
+int
+virDoubleToStr(char **strp, double number)
+{
+ int ret = -1;
+
+#if HAVE_NEWLOCALE
+
+ locale_t old_loc;
+
+ if (virLocaleInitialize() < 0)
+ goto error;
+
+ old_loc = uselocale(virLocale);
+ ret = virAsprintf(strp, "%lf", number);
+ uselocale(old_loc);
+
+#else
+
+ char *radix, *tmp;
+ struct lconv *lc;
+
+ if ((ret = virVasprintf(strp, "%lf", number) < 0)
+ goto error;
+
+ lc = localeconv();
+ radix = lc->decimal_point;
+ tmp = strstr(*strp, radix);
+ if (tmp) {
+ *tmp = '.';
+ if (strlen(radix) > 1)
+ memmove(tmp + 1, tmp + strlen(radix), strlen(*strp) - (tmp - str));
+ }
+
+#endif /* HAVE_NEWLOCALE */
+ error:
+ return ret;
+}
+
const char *virEnumToString(const char *const*types,
unsigned int ntypes,
int type)
diff --git a/src/util/util.h b/src/util/util.h
index d151c27..a5d892d 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -209,6 +209,9 @@ char *virStrcpy(char *dest, const char *src, size_t destbytes)
ATTRIBUTE_RETURN_CHECK;
# define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
+int virDoubleToStr(char **strp, double number)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+
int virDiskNameToIndex(const char* str);
char *virIndexToDiskName(int idx, const char *prefix);
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH] virsh: say save-image-edit failed only when it does
by Ján Tomko
The common code for editing files in virsh-edit.c expects EDIT_DEFINE to
return 0 on failure. virDomainSaveImageDefineXML returns 0 on success.
---
tools/virsh-domain.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 33b1727..69e0133 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2973,7 +2973,7 @@ cmdSaveImageEdit(vshControl *ctl, const vshCmd *cmd)
"not changed.\n"), file); \
ret = true; goto edit_cleanup;
#define EDIT_DEFINE \
- virDomainSaveImageDefineXML(ctl->conn, file, doc_edited, define_flags)
+ (virDomainSaveImageDefineXML(ctl->conn, file, doc_edited, define_flags) == 0)
#define EDIT_FREE /* */
#include "virsh-edit.c"
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH] Do not unlink sanlock lockspace if registering with sanlock daemon returns error
by Asad Saeed
This is a patch for bug 847848
If registering an existing lockspace with the sanlock daemon
returns an error, libvirt should not proceed to unlink the lockspace.
Signed-off-by: Asad Saeed <asad.saeed(a)acidseed.com>
---
src/locking/lock_driver_sanlock.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 9ec99dd..f046102 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -242,7 +242,7 @@ static int virLockManagerSanlockSetupLockspace(void)
virReportSystemError(-rv,
_("Unable to add lockspace %s"),
path);
- goto error_unlink;
+ goto error;
} else {
VIR_DEBUG("Lockspace %s is already registered", path);
}
--
1.7.1
12 years, 3 months
[libvirt] ANNOUNCE: libvirt 0.9.6.2 maintenance release
by Cole Robinson
libvirt 0.9.6.2 maintenance release is now available. This is
libvirt 0.9.6 with additional bugfixes that have accumulated
upstream since the initial release.
This release can be downloaded at:
http://libvirt.org/sources/stable_updates/libvirt-0.9.6.2.tar.gz
Changes in this version:
* Prep for release 0.9.6.2
* build: drop check for ANSI compiler
* tests: avoid seclabeltest crash
* Remove unused <dirent.h> imports to appease syntax-check
* Appease gnulib sc_makefile_at_at_check
* test: fix segfault in networkxml2argvtest
* tests: dynamically replace dnsmasq path
* daemon: Fix crash in virTypedParameterArrayClear
* build: update to latest gnulib, for secure tarball
* build: update to latest gnulib
* build: update to latest gnulib
For info about past maintenance releases, see:
http://wiki.libvirt.org/page/Maintenance_Releases
Thanks,
Cole
12 years, 3 months
[libvirt] [PATCH] qemu: snapshot: Wire up revert for disk only snapshots
by Cole Robinson
This just uses the existing plumping to update the guest XML to point
at the chosen snapshot disk images. It requires the VM to be inactive.
---
Reverting to a snapshot with children and then running the guest is
probably unsafe, since the backing image will change state on the child
snapshots. How do internal snapshots work around this?
src/qemu/qemu_driver.c | 72 ++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 64 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9bf89bb..53f5340 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11205,6 +11205,65 @@ qemuDomainSnapshotRevertInactive(struct qemud_driver *driver,
return ret > 0 ? -1 : ret;
}
+/* The domain is expected to be locked */
+static int qemuDomainRevertToSnapshotDisk(virDomainSnapshotObjPtr snap,
+ virDomainObjPtr vm,
+ virDomainDefPtr config,
+ unsigned int flags)
+{
+ int ret = -1;
+ int i;
+
+ if (virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("domain must be stopped to revert to a "
+ "disk only snapshot"));
+ goto cleanup;
+ }
+
+ if (flags & (VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING |
+ VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("domain can only be shutoff after reverting to a"
+ "disk only snapshot"));
+ goto cleanup;
+ }
+
+ if (!config) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("domain XML must be present in the snapshot metadata"));
+ goto cleanup;
+ }
+
+ for (i = 0; i < snap->def->ndisks; i++) {
+ virDomainDiskDefPtr vmdisk = config->disks[i];
+ virDomainSnapshotDiskDefPtr snapdisk = &(snap->def->disks[i]);
+ char *src = NULL;
+ char *type = NULL;
+
+ if (snapdisk->snapshot == VIR_DOMAIN_DISK_SNAPSHOT_NO)
+ continue;
+
+ if (!(src = strdup(snapdisk->file)) ||
+ !(type = strdup(snapdisk->driverType))) {
+ virReportOOMError();
+ VIR_FREE(src);
+ VIR_FREE(type);
+ goto cleanup;
+ }
+
+ VIR_FREE(vmdisk->src);
+ vmdisk->src = src;
+ VIR_FREE(vmdisk->driverType);
+ vmdisk->driverType = type;
+ }
+
+ virDomainObjAssignDef(vm, config, false);
+ ret = 0;
+cleanup:
+ return ret;
+}
+
static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
@@ -11265,12 +11324,6 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
"to revert to inactive snapshot"));
goto cleanup;
}
- if (snap->def->state == VIR_DOMAIN_DISK_SNAPSHOT) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("revert to external disk snapshot not supported "
- "yet"));
- goto cleanup;
- }
if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) {
if (!snap->def->dom) {
virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY,
@@ -11289,7 +11342,6 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
}
}
-
if (vm->current_snapshot) {
vm->current_snapshot->def->current = false;
if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
@@ -11325,6 +11377,11 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
+ if (snap->def->state == VIR_DOMAIN_DISK_SNAPSHOT) {
+ ret = qemuDomainRevertToSnapshotDisk(snap, vm, config, flags);
+ goto endjob;
+ }
+
if (snap->def->state == VIR_DOMAIN_RUNNING
|| snap->def->state == VIR_DOMAIN_PAUSED) {
/* Transitions 2, 3, 5, 6, 8, 9 */
@@ -11522,7 +11579,6 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
}
ret = 0;
-
endjob:
if (vm && qemuDomainObjEndJob(driver, vm) == 0)
vm = NULL;
--
1.7.11.2
12 years, 3 months
[libvirt] [PATCH 1/3] virsh.c: Fix compiler warning
by Cole Robinson
For some reason I only get this after applying subsequent upcoming
patches that touch virsh, but don't seem to actually cause the warning.
virsh.c: In function ‘vshCommandParse’:
virsh.c:2014:46: error: ‘opt_index’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1: all warnings being treated as errors
---
tools/virsh.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index b95a008..64e2e18 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1975,7 +1975,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
} else if (tkdata[0] == '-' && tkdata[1] == '-' &&
c_isalnum(tkdata[2])) {
char *optstr = strchr(tkdata + 2, '=');
- int opt_index;
+ int opt_index = 0;
if (optstr) {
*optstr = '\0'; /* convert the '=' to '\0' */
--
1.7.11.2
12 years, 3 months
[libvirt] [PATCH] build: Distribute check-symfile.pl
by Cole Robinson
Otherwise distcheck can fail with:
GEN check-symfile
Can't open perl script "../../src/check-symfile.pl": No such file or directory
make[4]: *** [check-symfile] Error 2
---
src/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 79b4e59..8a93a32 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -331,7 +331,7 @@ else !WITH_REMOTE
# re-generated when configured --without-remote.
check-protocol:
endif
-EXTRA_DIST += $(PROTOCOL_STRUCTS)
+EXTRA_DIST += $(PROTOCOL_STRUCTS) check-symfile.pl
check-local: check-protocol check-symfile
.PHONY: check-protocol $(PROTOCOL_STRUCTS:structs=struct)
--
1.7.11.2
12 years, 3 months