[libvirt] libxl: Enable video device selection for Xen
by Stefan Bader
Sorry, this fell complete off my todos for a while. So I split off
the fixup of VRAM into a separate patch which may or may not be used
and only accept vga, xen and cirrus as supported types in the main
patch.
I believe I saw some discussions about how to fix some of the VRAM
values as they are passed into qemu. At least for the Cirrus type
I saw that the command line looked ok but the guest was getting a
much larger VRAM size than it was told.
-Stefan
10 years, 4 months
[libvirt] [PATCH 0/2] Disallow wiping a sparse logical volume
by John Ferlan
The first patch just changes 'building' into a bool as that's how I
found it used when going to add a new bool for patch 2
Patch 2 addresses the following bz:
https://bugzilla.redhat.com/show_bug.cgi?id=1091866
Essentially, wiping the lv caused it to disappear after a vol-refresh.
This was because the lv that was created was a sparse (or thin or
snapshot via --virtualsize of -V) logical volume. The multiple names
are the ways I found the feature described. When the sparse volume
was written to by the wipe algorithms it actually filled the volume
beyond it's capacity rendering it INACTIVE which causes pool-refresh
to ignore it. As it turns out a sparse lv created of size (for example)
4 MiB has metadata contained within the size created. While we could
adjust the size of the metadata, control over it's location becomes
the issue. It seems there is also some guard data at each end of the
sparse lv as when the wipe was done lost I/O messages were sent to
the system log.
After much searching it just seems that writing a sparse lv with some
sort of wipe algorithm will not work. Although if anyone has suggestions
I'm willing to try. I have found writing '0x00''s, the scrub utility,
and a "dd if=/dev/zero of=/dev/lv_pool/lv_test bs=4096 count=1024"
doesn't work.
It's also of interest to note that the 'scrub' utility doesn't seem
to recognize the logical volume format properly as none of the nonzero
algorithms are run - each fails to open the file - for example:
$ /usr/sbin/lvcreate --name lv_test -L 4096K lv_pool
$ /usr/bin/scrub -f -p bsi /dev/lv_pool/lv_test
scrub: using BSI patterns
scrub: warning: /dev/lv_pool/lv_test is zero length
$
John Ferlan (2):
storage: Convert 'building' into a bool
storage: Disallow vol_wipe for sparse logical volumes
src/conf/storage_conf.h | 2 +-
src/storage/storage_backend_logical.c | 39 ++++++++++++++++++++++++++++++++++-
src/storage/storage_driver.c | 8 +++----
src/util/virstoragefile.h | 1 +
4 files changed, 44 insertions(+), 6 deletions(-)
--
1.9.3
10 years, 4 months
[libvirt] [PATCH] examples: Introduce domtop
by Michal Privoznik
There's this question on the list that is asked over and over again.
How do I get {cpu, memory, ...} usage in percentage? Or its modified
version: How do I plot nice graphs like virt-manager does?
It would be nice if we have an example to inspire people. And that's
what domtop should do. Yes, it could be written in different ways, but
I've chosen this one as I think it show explicitly what users need to
implement in order to imitate virt-manager's graphing.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
.gitignore | 1 +
Makefile.am | 2 +-
cfg.mk | 2 +-
configure.ac | 1 +
examples/domtop/Makefile.am | 27 +++
examples/domtop/domtop.c | 388 ++++++++++++++++++++++++++++++++++++++++++++
libvirt.spec.in | 2 +-
7 files changed, 420 insertions(+), 3 deletions(-)
create mode 100644 examples/domtop/Makefile.am
create mode 100644 examples/domtop/domtop.c
diff --git a/.gitignore b/.gitignore
index 2d4d401..90fee91 100644
--- a/.gitignore
+++ b/.gitignore
@@ -75,6 +75,7 @@
/examples/dominfo/info1
/examples/domsuspend/suspend
/examples/dommigrate/dommigrate
+/examples/domtop/domtop
/examples/hellolibvirt/hellolibvirt
/examples/openauth/openauth
/gnulib/lib/*
diff --git a/Makefile.am b/Makefile.am
index a374e1a..4aafe94 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,7 +24,7 @@ SUBDIRS = . gnulib/lib include src daemon tools docs gnulib/tests \
examples/dominfo examples/domsuspend examples/apparmor \
examples/xml/nwfilter examples/openauth examples/systemtap \
tools/wireshark examples/dommigrate \
- examples/lxcconvert
+ examples/lxcconvert examples/domtop
ACLOCAL_AMFLAGS = -I m4
diff --git a/cfg.mk b/cfg.mk
index baaab71..9880704 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1078,7 +1078,7 @@ exclude_file_name_regexp--sc_prohibit_sprintf = \
exclude_file_name_regexp--sc_prohibit_strncpy = ^src/util/virstring\.c$$
exclude_file_name_regexp--sc_prohibit_strtol = \
- ^(src/(util/virsexpr|(vbox|xen|xenxs)/.*)\.c)|(examples/domsuspend/suspend.c)$$
+ ^(src/(util/virsexpr|(vbox|xen|xenxs)/.*)\.c)|(examples/domsuspend/suspend.c)|(examples/domtop/domtop.c)$$
exclude_file_name_regexp--sc_prohibit_xmlGetProp = ^src/util/virxml\.c$$
diff --git a/configure.ac b/configure.ac
index 8001e24..f37c716 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2755,6 +2755,7 @@ AC_CONFIG_FILES([\
examples/domsuspend/Makefile \
examples/dominfo/Makefile \
examples/dommigrate/Makefile \
+ examples/domtop/Makefile \
examples/openauth/Makefile \
examples/hellolibvirt/Makefile \
examples/systemtap/Makefile \
diff --git a/examples/domtop/Makefile.am b/examples/domtop/Makefile.am
new file mode 100644
index 0000000..c5cb6c7
--- /dev/null
+++ b/examples/domtop/Makefile.am
@@ -0,0 +1,27 @@
+## Process this file with automake to produce Makefile.in
+
+## Copyright (C) 2014 Red Hat, Inc.
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library. If not, see
+## <http://www.gnu.org/licenses/>.
+
+INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
+LDADDS = $(STATIC_BINARIES) $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \
+ $(COVERAGE_LDFLAGS)
+
+noinst_PROGRAMS=domtop
+
+domtop_SOURCES=domtop.c
+domtop_LDFLAGS=
+domtop_LDADD= $(LDADDS)
diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c
new file mode 100644
index 0000000..fcdcc66
--- /dev/null
+++ b/examples/domtop/domtop.c
@@ -0,0 +1,388 @@
+/*
+ * domtop.c: Demo program showing how to calculate CPU usage
+ *
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Michal Privoznik <mprivozn(a)redhat.com>
+ */
+
+#include <errno.h>
+#include <getopt.h>
+#include <libvirt/libvirt.h>
+#include <libvirt/virterror.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <signal.h>
+
+static int debug;
+static int run_top = 1;
+
+#define ERROR(...) \
+do { \
+ fprintf(stderr, "ERROR %s:%d : ", __FUNCTION__, __LINE__); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+} while (0)
+
+#define DEBUG(...) \
+do { \
+ if (!debug) \
+ break; \
+ fprintf(stderr, "DEBUG %s:%d : ", __FUNCTION__, __LINE__); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+} while (0)
+
+#define STREQ(a,b) (strcmp(a,b) == 0)
+
+static void
+print_usage(const char *progname)
+{
+ const char *unified_progname;
+
+ if (!(unified_progname = strrchr(progname, '/')))
+ unified_progname = progname;
+ else
+ unified_progname++;
+
+ printf("\n%s [options] [domain name]\n\n"
+ " options:\n"
+ " -d | --debug enable debug printings\n"
+ " -h | --help print this help\n"
+ " -c | --connect=URI hypervisor connection URI\n"
+ " -D | --delay=X delay between updates in miliseconds\n",
+ unified_progname);
+}
+
+static int
+parse_argv(int argc, char *argv[],
+ const char **uri,
+ const char **dom_name,
+ unsigned int *mili_seconds)
+{
+ int ret = -1;
+ int arg;
+ unsigned long val;
+ char *p;
+ struct option opt[] = {
+ {"debug", no_argument, NULL, 'd'},
+ {"help", no_argument, NULL, 'h'},
+ {"connect", required_argument, NULL, 'c'},
+ {"delay", required_argument, NULL, 'D'},
+ {NULL, 0, NULL, 0}
+ };
+
+ while ((arg = getopt_long(argc, argv, "+:dhc:D:", opt, NULL)) != -1) {
+ switch (arg) {
+ case 'd':
+ debug = 1;
+ break;
+ case 'h':
+ print_usage(argv[0]);
+ exit(EXIT_SUCCESS);
+ break;
+ case 'c':
+ *uri = optarg;
+ break;
+ case 'D':
+ /* strtoul man page suggest clearing errno prior to call */
+ errno = 0;
+ val = strtoul(optarg, &p, 10);
+ if (errno || *p || p == optarg) {
+ ERROR("Invalid number: '%s'", optarg);
+ goto cleanup;
+ }
+ *mili_seconds = val;
+ if (*mili_seconds != val) {
+ ERROR("Integer overflow: %ld", val);
+ goto cleanup;
+ }
+ break;
+ case ':':
+ ERROR("option '-%c' requires an argument", optopt);
+ exit(EXIT_FAILURE);
+ case '?':
+ if (optopt)
+ ERROR("unsupported option '-%c'. See --help.", optopt);
+ else
+ ERROR("unsupported option '%s'. See --help.", argv[optind - 1]);
+ exit(EXIT_FAILURE);
+ default:
+ ERROR("unknown option");
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if (argc > optind)
+ *dom_name = argv[optind];
+
+ ret = 0;
+ cleanup:
+ return ret;
+}
+
+static int
+fetch_domains(virConnectPtr conn)
+{
+ int num_domains, ret = -1;
+ virDomainPtr *domains = NULL;
+ size_t i;
+ const int list_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE;
+
+ DEBUG("Fetching list of running domains");
+ num_domains = virConnectListAllDomains(conn, &domains, list_flags);
+
+ DEBUG("num_domains=%d", num_domains);
+ if (num_domains < 0) {
+ ERROR("Unable to fetch list of running domains");
+ goto cleanup;
+ }
+
+ printf("Running domains:\n");
+ printf("----------------\n");
+ for (i = 0; i < num_domains; i++) {
+ virDomainPtr dom = domains[i];
+ const char *dom_name = virDomainGetName(dom);
+ printf("%s\n", dom_name);
+ virDomainFree(dom);
+ }
+
+ ret = 0;
+ cleanup:
+ free(domains);
+ return ret;
+}
+
+static void
+print_cpu_usage(const char *dom_name,
+ size_t cpu,
+ size_t ncpus,
+ unsigned long long then,
+ virTypedParameterPtr then_params,
+ size_t then_nparams,
+ unsigned long long now,
+ virTypedParameterPtr now_params,
+ size_t now_nparams)
+{
+ size_t i, j, k;
+ size_t nparams = now_nparams;
+
+ if (then_nparams != now_nparams) {
+ /* this should not happen (TM) */
+ ERROR("parameters counts don't match");
+ return;
+ }
+
+ for (i = 0; i < ncpus; i++) {
+ size_t pos;
+ double usage;
+
+ /* check if the vCPU is in the maps */
+ if (now_params[i * nparams].type == 0 ||
+ then_params[i * then_nparams].type == 0)
+ continue;
+
+ for (j = 0; j < nparams; j++) {
+ pos = i * nparams + j;
+ if (STREQ(then_params[pos].field, VIR_DOMAIN_CPU_STATS_CPUTIME) ||
+ STREQ(then_params[pos].field, VIR_DOMAIN_CPU_STATS_VCPUTIME))
+ break;
+ }
+
+ if (j == nparams) {
+ ERROR("unable to find %s", VIR_DOMAIN_CPU_STATS_CPUTIME);
+ return;
+ }
+
+ DEBUG("now_params=%llu then_params=%llu now=%llu then=%llu",
+ now_params[pos].value.ul, then_params[pos].value.ul, now, then);
+
+ /* @now_params and @then_params are in nanoseconds, @now and @then are
+ * in microseconds. In ideal world, we would translate them both into
+ * the same scale, divide one by another and multiply by factor of 100
+ * to get percentage. However, the count of floating point operations
+ * performed has a bad affect on the precision, so instead of dividing
+ * @now_params and @then_params by 1000 and then multiplying again by
+ * 100, we divide only once by 10 and get the same result. */
+ usage = (now_params[pos].value.ul - then_params[pos].value.ul) /
+ (now - then) / 10;
+
+ printf("CPU%zu: %.2lf\n", cpu + i, usage);
+
+ }
+
+}
+
+static void
+stop(int sig)
+{
+ DEBUG("Exiting on signal %d\n", sig);
+ run_top = 0;
+}
+
+static int
+do_top(virConnectPtr conn,
+ const char *dom_name,
+ unsigned int mili_seconds)
+{
+ int ret = -1;
+ virDomainPtr dom;
+ int max_id;
+ int nparams = 0, then_nparams = 0, now_nparams = 0;
+ virTypedParameterPtr then_params = NULL, now_params = NULL;
+ struct sigaction action_stop;
+
+ memset(&action_stop, 0, sizeof(action_stop));
+ action_stop.sa_handler = stop;
+
+ /* Lookup the domain */
+ if (!(dom = virDomainLookupByName(conn, dom_name))) {
+ ERROR("Unable to find domain '%s'", dom_name);
+ goto cleanup;
+ }
+
+ /* and see how many vCPUs can we fetch stats for */
+ if ((max_id = virDomainGetCPUStats(dom, NULL, 0, 0, 0, 0)) < 0) {
+ ERROR("Unable to get cpu stats");
+ goto cleanup;
+ }
+
+ /* how many stats can we get for a vCPU? */
+ if ((nparams = virDomainGetCPUStats(dom, NULL, 0, 0, 1, 0)) < 0) {
+ ERROR("Unable to get cpu stats");
+ goto cleanup;
+ }
+
+ if (!(now_params = calloc(nparams * max_id, sizeof(*now_params))) ||
+ !(then_params = calloc(nparams * max_id, sizeof(*then_params)))) {
+ ERROR("Unable to allocate memory");
+ goto cleanup;
+ }
+
+ sigaction(SIGTERM, &action_stop, NULL);
+ sigaction(SIGINT, &action_stop, NULL);
+
+ while (run_top) {
+ struct timeval then, now;
+
+ /* Get current time */
+ if (gettimeofday(&then, NULL) < 0) {
+ ERROR("unable to get time");
+ goto cleanup;
+ }
+
+ /* And current stats */
+ if ((then_nparams = virDomainGetCPUStats(dom, then_params,
+ nparams, 0, max_id, 0)) < 0) {
+ ERROR("Unable to get cpu stats");
+ goto cleanup;
+ }
+
+ /* Now sleep some time */
+ usleep(mili_seconds * 1000); /* usleep expects microseconds */
+
+ /* And get current time */
+ if (gettimeofday(&now, NULL) < 0) {
+ ERROR("unable to get time");
+ goto cleanup;
+ }
+
+ /* And current stats */
+ if ((now_nparams = virDomainGetCPUStats(dom, now_params,
+ nparams, 0, max_id, 0)) < 0) {
+ ERROR("Unable to get cpu stats");
+ goto cleanup;
+ }
+
+ print_cpu_usage(dom_name, 0, max_id,
+ then.tv_sec * 1000000 + then.tv_usec,
+ then_params, then_nparams,
+ now.tv_sec * 1000000 + now.tv_usec,
+ now_params, now_nparams);
+
+ virTypedParamsClear(now_params, now_nparams * max_id);
+ virTypedParamsClear(then_params, then_nparams * max_id);
+ }
+
+ ret = 0;
+ cleanup:
+ if (max_id > 0) {
+ if (now_nparams > 0)
+ virTypedParamsFree(now_params, now_nparams * max_id);
+ if (then_nparams > 0)
+ virTypedParamsFree(then_params, then_nparams * max_id);
+ }
+ if (dom)
+ virDomainFree(dom);
+ return ret;
+}
+
+int
+main(int argc, char *argv[])
+{
+ int ret = EXIT_FAILURE;
+ virConnectPtr conn = NULL;
+ const char *uri = NULL;
+ const char *dom_name = NULL;
+ unsigned int mili_seconds = 500; /* Sleep this long between two API calls */
+ const int connect_flags = 0; /* No connect flags for now */
+
+ if (parse_argv(argc, argv, &uri, &dom_name, &mili_seconds) < 0)
+ goto cleanup;
+
+ DEBUG("Proceeding with uri=%s dom_name=%s mili_seconds=%u",
+ uri, dom_name, mili_seconds);
+
+ if (!(conn = virConnectOpenAuth(uri,
+ virConnectAuthPtrDefault,
+ connect_flags))) {
+ ERROR("Failed to connect to hypervisor");
+ goto cleanup;
+ }
+
+ DEBUG("Successfully connected");
+
+ if (!dom_name) {
+ if (fetch_domains(conn) == 0)
+ ret = EXIT_SUCCESS;
+ goto cleanup;
+ }
+
+ if (do_top(conn, dom_name, mili_seconds) < 0)
+ goto cleanup;
+
+ ret = EXIT_SUCCESS;
+ cleanup:
+ if (conn) {
+ int tmp;
+ tmp = virConnectClose(conn);
+ if (tmp < 0) {
+ ERROR("Failed to disconnect from the hypervisor");
+ ret = EXIT_FAILURE;
+ } else if (tmp > 0) {
+ ERROR("One or more references were leaked after "
+ "disconnect from the hypervisor");
+ ret = EXIT_FAILURE;
+ } else {
+ DEBUG("Connection successfully closed");
+ }
+ }
+ return ret;
+}
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 9c7b241..a456c25 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1507,7 +1507,7 @@ rm -fr %{buildroot}
# on RHEL 5, thus we need to expand it here.
make install DESTDIR=%{?buildroot} SYSTEMD_UNIT_DIR=%{_unitdir}
-for i in object-events dominfo domsuspend hellolibvirt openauth xml/nwfilter systemtap dommigrate
+for i in object-events dominfo domsuspend hellolibvirt openauth xml/nwfilter systemtap dommigrate domtop
do
(cd examples/$i ; make clean ; rm -rf .deps .libs Makefile Makefile.in)
done
--
1.8.5.5
10 years, 4 months
[libvirt] [PATCH] esx: Fix a comment about VSphere versions
by Geoff Hickey
Update the VSphere version comment in esx_vi.c for ESX 5.1 and 5.5.
---
src/esx/esx_vi.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 3f5becb..c02a293 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -4556,12 +4556,14 @@ esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersio
/*
* virtualHW.version compatibility matrix:
*
- * 4 7 8 API
- * ESX 3.5 + 2.5
- * ESX 4.0 + + 4.0
- * ESX 4.1 + + 4.1
- * ESX 5.0 + + + 5.0
- * GSX 2.0 + + 2.5
+ * 4 7 8 9 10 API
+ * ESX 3.5 + 2.5
+ * ESX 4.0 + + 4.0
+ * ESX 4.1 + + 4.1
+ * ESX 5.0 + + + 5.0
+ * ESX 5.1 + + + + 5.1
+ * ESX 5.5 + + + + + 5.5
+ * GSX 2.0 + + 2.5
*/
switch (productVersion) {
case esxVI_ProductVersion_ESX35:
--
1.9.1
10 years, 4 months
[libvirt] [PATCH 0/2] virsh: negative numbers for specific commands
by John Ferlan
Following up to the recently restarted discussion:
http://www.redhat.com/archives/libvir-list/2014-July/msg00686.html
regarding negative values for certain virsh commands - these patches
will document the "feature" of using a negative value to indicate
the largest value *and* for the vol-{upload|download} change 'offset'
to not accept a negative value.
John Ferlan (2):
virsh vol-upload/download disallow negative offset
virsh: Document bandwidth maximum more clearly
tools/virsh-volume.c | 6 +++---
tools/virsh.pod | 33 +++++++++++++++++++++++++++------
2 files changed, 30 insertions(+), 9 deletions(-)
--
1.9.3
10 years, 4 months
[libvirt] [PATCH] test: metadata: Improve test coverate
by Peter Krempa
Test also the TITLE and DESCRIPTION metadata types.
---
tests/metadatatest.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/tests/metadatatest.c b/tests/metadatatest.c
index 91fc944..a8d8f10 100644
--- a/tests/metadatatest.c
+++ b/tests/metadatatest.c
@@ -167,6 +167,10 @@ verifyMetadata(virDomainPtr dom,
struct metadataTest {
virConnectPtr conn;
virDomainPtr dom;
+
+ const char *data;
+ int type;
+ bool fail;
};
@@ -216,6 +220,52 @@ testEraseMetadata(const void *data)
}
static int
+testTextMetadata(const void *data)
+{
+ const struct metadataTest *test = data;
+ char *actual = NULL;
+ int ret = -1;
+
+ if (virDomainSetMetadata(test->dom, test->type, test->data, NULL, NULL, 0) < 0) {
+ if (test->fail)
+ return 0;
+ return -1;
+ }
+
+ actual = virDomainGetMetadata(test->dom, test->type, NULL, 0);
+
+ if (STRNEQ_NULLABLE(test->data, actual)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "expected metadata doesn't match actual: "
+ "expected:'%s'\ngot: '%s'",
+ NULLSTR(test->data), NULLSTR(actual));
+ goto cleanup;
+ }
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(actual);
+
+ return ret;
+}
+
+#define TEST_TEXT_METADATA(INDEX, TYPE, DATA, FAIL) \
+ do { \
+ test.type = VIR_DOMAIN_METADATA_ ## TYPE; \
+ test.data = DATA; \
+ test.fail = FAIL; \
+ \
+ if (virtTestRun("text metadata: " #TYPE " " INDEX " ", \
+ testTextMetadata, &test) < 0) \
+ ret = EXIT_FAILURE; \
+ } while (0)
+
+#define TEST_TITLE(INDEX, DATA) TEST_TEXT_METADATA(INDEX, TITLE, DATA, false)
+#define TEST_TITLE_FAIL(INDEX, DATA) TEST_TEXT_METADATA(INDEX, TITLE, DATA, true)
+#define TEST_DESCR(INDEX, DATA) TEST_TEXT_METADATA(INDEX, DESCRIPTION, DATA, false)
+
+static int
mymain(void)
{
struct metadataTest test;
@@ -238,6 +288,20 @@ mymain(void)
if (virtTestRun("Erase metadata ", testEraseMetadata, &test) < 0)
ret = EXIT_FAILURE;
+ TEST_TITLE("1", "qwert");
+ TEST_TITLE("2", NULL);
+ TEST_TITLE("3", "blah");
+ TEST_TITLE_FAIL("4", "qwe\nrt");
+ TEST_TITLE("5", "");
+ TEST_TITLE_FAIL("6", "qwert\n");
+ TEST_TITLE_FAIL("7", "\n");
+
+ TEST_DESCR("1", "qwert\nqwert");
+ TEST_DESCR("2", NULL);
+ TEST_DESCR("3", "qwert");
+ TEST_DESCR("4", "\n");
+ TEST_DESCR("5", "");
+
virDomainFree(test.dom);
virConnectClose(test.conn);
--
2.0.0
10 years, 4 months
[libvirt] virsh capabilities vs. domcapabilities
by Eric Blake
We have some inconsistencies in the node capabilities (which shows guest
capabilities for some default binaries) and domcapabilities (which shows
guest capabilities for a specified binary). It might be nicer for
client applications if the two XML components share a common schema and
output layout, so that the same client code can be used to parse either
(sub-tree of) XML, modulo the name of the top-most element containing
the tree.
Furthermore, I'm trying to figure out how to advertise whether a given
domain will support active commit (and similarly, Peter's patches for
relative backing name preservation). Advertising the feature just
through 'virsh capabilities' is insufficient, because that only covers
the default binary; so it seems like the sort of thing that should also
be in 'virsh domcapabilities'.
Since virConnectGetDomainCapabilities is brand new to 1.2.7, we still
have time to change its XML. But I want consensus on whether we need
things to match, or whether we intentionally want people to rely only on
the newer XML format of the new API call (that is, don't bloat 'virsh
capabilities'/virConnectGetCapabilities any further, and learning
whether active commit is supported will have to be done via 'virsh
domcapabilities'/virConnectGetDomainCapabilities). That is, I'm
wondering if <domainCapabilities> should use <capabilities>/<guest> as
its starting point, rather than completely inventing new XML.
I'm also finding 'virsh domcapabilities' a bit hard to use - even though
it allows all its arguments to be optional at the RPC level, the qemu
implementation isn't so happy:
# tools/virsh domcapabilities
error: failed to get emulator capabilities
error: virttype_str in qemuConnectGetDomainCapabilities must not be NULL
but how am I supposed to know what --virttype strings are valid?
# tools/virsh domcapabilities --virttype kvm
error: failed to get emulator capabilities
error: invalid argument: at least one of emulatorbin or architecture
fields must be present
Would it be nicer to behave the same as 'virsh capabilities' and give
the details of the default binary in this case?
Now, for a comparison between the two XML per binary:
'virsh capabilities' gives me this segment:
<guest>
<os_type>hvm</os_type>
<arch name='alpha'>
<wordsize>64</wordsize>
<emulator>/usr/bin/qemu-system-alpha</emulator>
<machine maxCpus='4'>clipper</machine>
<domain type='qemu'>
</domain>
</arch>
<features>
<deviceboot/>
<disksnapshot default='on' toggle='no'/>
</features>
</guest>
while 'virsh domcapabilities --emulatorbin /usr/bin/qemu-system-alpha
--virttype kvm' gives this:
<domainCapabilities>
<path>/usr/bin/qemu-system-alpha</path>
<domain>kvm</domain>
<machine>clipper</machine>
<arch>alpha</arch>
<vcpu max='4'/>
<devices>
<disk supported='yes'>
<enum name='diskDevice'>
<value>disk</value>
<value>cdrom</value>
<value>floppy</value>
<value>lun</value>
</enum>
<enum name='bus'>
<value>ide</value>
<value>fdc</value>
<value>scsi</value>
<value>virtio</value>
<value>usb</value>
</enum>
</disk>
<hostdev supported='yes'>
<enum name='mode'>
<value>subsystem</value>
</enum>
<enum name='startupPolicy'>
<value>default</value>
<value>mandatory</value>
<value>requisite</value>
<value>optional</value>
</enum>
<enum name='subsysType'>
<value>usb</value>
<value>pci</value>
<value>scsi</value>
</enum>
<enum name='capsType'/>
<enum name='pciBackend'/>
</hostdev>
</devices>
</domainCapabilities>
I'm okay that the domcapabilites output is longer, and don't think we
need to backport any of the new stuff to the older API. But any
information present in the old API should be easily retrieved using the
new API, so that the information isn't lost, and so that a client can
learn the same amount of detail about a non-default binary as they can
about the defaults.
Look at the difference in XPath to get to some of the same information:
/guest/os_type vs. ? - where is os_type in domcapabilities?
/guest/arch@name vs. /domainCapabilities/arch - why is one an attribute
and the other an element?
/guest/arch/wordsize vs. nothing - where is wordsize in domcapabilities?
/guest/arch/emulator vs. /domainCapabilities/path - why 3 levels vs. 2,
and different naming?
/guest/arch/machine@maxCpus vs. /domainCapabilities/vcpu@max - why 3
levels vs. 2, with different naming?
/guest/arch/machine vs. /domainCapabilities/machine - why 3 levels vs. 2?
/guest/arch/domain@type vs. /domainCapabilities/domain - why attribute
of 3 levels vs. element at 2 levels? And did I expose an error when I
passed --virrtype kvm, even though qemu-system-alpha is only a qemu
emulator on my machine (since kvm emulators is only for hardware-assit
emulation, which is not possible when I'm doing cross architecture)?
/guest/features vs. ? - where are the features in domcapabilities?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
10 years, 4 months
[libvirt] [PATCH] Log an error when we fail to set the COW attribute
by Ján Tomko
Coverity complains about the return value of ioctl not being checked.
Even though we carry on when this fails (just like qemu-img does),
we can log an error.
---
src/storage/storage_backend.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 5e7aa3c..b8b89ca 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -464,9 +464,14 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
* The FS_IOC_SETFLAGS ioctl return value will be ignored since any
* failure of this operation should not block the left work.
*/
- if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) {
+ if (ioctl(fd, FS_IOC_GETFLAGS, &attr) < 0) {
+ virReportSystemError(errno, "%s", _("Failed to get fs flags"));
+ } else {
attr |= FS_NOCOW_FL;
- ioctl(fd, FS_IOC_SETFLAGS, &attr);
+ if (ioctl(fd, FS_IOC_SETFLAGS, &attr) < 0) {
+ virReportSystemError(errno, "%s",
+ _("Failed to set NOCOW flag"));
+ }
}
#endif
}
--
1.8.5.5
10 years, 4 months
[libvirt] [PATCH V3 0/2] storagevol: add 'nocow' option to vol xml
by Chunyan Liu
Add 'nocow' option to vol xml, so that user can have a chance to create
a volume with NOCOW flag set on btrfs. It improves performance when the
volume is a file image on btrfs and is used in VM environment.
---
Changes:
* fix typo in V2
* add test case for 'nocow', in separate patch
V2 is here:
http://www.redhat.com/archives/libvir-list/2014-July/msg00361.html
Chunyan Liu (2):
storagevol: add nocow to vol xml
add nocow test case
docs/formatstorage.html.in | 7 +++++
docs/schemas/storagevol.rng | 5 ++++
src/conf/storage_conf.c | 3 ++
src/storage/storage_backend.c | 22 +++++++++++++++
src/util/virstoragefile.h | 1 +
.../storagevolxml2argvdata/qcow2-nocow-compat.argv | 3 ++
tests/storagevolxml2argvdata/qcow2-nocow.argv | 3 ++
tests/storagevolxml2argvtest.c | 6 ++++
tests/storagevolxml2xmlin/vol-qcow2-nocow.xml | 32 ++++++++++++++++++++++
tests/storagevolxml2xmlout/vol-qcow2-nocow.xml | 31 +++++++++++++++++++++
10 files changed, 113 insertions(+)
create mode 100644 tests/storagevolxml2argvdata/qcow2-nocow-compat.argv
create mode 100644 tests/storagevolxml2argvdata/qcow2-nocow.argv
create mode 100644 tests/storagevolxml2xmlin/vol-qcow2-nocow.xml
create mode 100644 tests/storagevolxml2xmlout/vol-qcow2-nocow.xml
--
1.8.4.5
10 years, 4 months
[libvirt] Schedule for the next release 1.2.7
by Daniel Veillard
Plan is to get the new release on Friday Aug 1st, so
I think this mean entering freeze at some point on the
preceeding week-end, I will be travelling then, but I
should be able to do that at some point saturday 26.
We already have 180 commits in since 1.2.6 so deinitely
makes sense to push this month too,
thanks,
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard(a)redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
10 years, 4 months