[libvirt] [PATCH] build: import latest gnulib
by Eric Blake
* .gnulib: Update to latest.
* cfg.mk (sc_prohibit_test_minus_ao): Delete, it was moved into
gnulib's maint.mk.
---
Here's the full list of gnulib changes:
* .gnulib 4f01268...e01b458 (44):
> maint.mk: check for [ as well as test
> gnumakefile: don't squelch _version output
> sys_time: avoid compiler warnings
> maint.mk: split a long line
> maint.mk: s/_header_without_use/_sc_header_without_use/
> maint: improve module indicators
> fdopendir: work around FreeBSD bug
> Emit #pragma system_header after the inclusion guard, not before.
> Fix indentation.
> save-cwd: don't leak a file descriptor when the caller execs
> Remove vestiges of fts-lgpl module.
> Fix definition of tests witness macro.
> Fix definition of tests witness macro.
> Fix ioctl's protoype on glibc systems.
> Normalize copyright line formatting.
> exclude: fix the case of globs vs. EXCLUDE_INCLUDE
> maint.mk: prohibit use of test's -o and -a operators
> Remove unused GNULIB_XYZ macro definitions.
> Mark privileged tests modules.
> Split C++ tests into separate tests modules.
> gnulib-tool: Allow 'foo-tests' module even if there is no module 'foo'.
> gnulib-tool: Add support for special categories of tests.
> ansi-c++-opt: Allow turning off the C++ build by default.
> unistd: Avoid #define replacements in C++ mode.
> Fix link errors on mingw.
> lib-ignore: Determine different options for different compilers.
> Remove unused GNULIB_XYZ macro definitions.
> Add a remark about certain modules.
> Resolve conflict between the two kinds of module indicators.
> autoupdate
> Distinguish two kinds of module indicators.
> New module description field 'Comment'.
> Addendum to 2010-02-07 commit.
> Use GNULIB_POSIXCHECK instead of GNULIB_PORTCHECK.
> Avoid side effects from tests-related modules on the compilation of lib.
> Factorize common .m4 code.
> Fix a compilation error on Cygwin with g++ >= 4.3.
> Rename gl_GETLOGIN.
> Rename gl_GETLOGIN_R.
> Rename gl_INET_NTOP.
> Rename gl_INET_PTON.
> Rename gl_MBSLEN.
> Rename gl_FORKPTY and gl_OPENPTY.
> top/maint.mk (sc_texinfo_acronym): Don't infloop if there is no *.texi files.
.gnulib | 2 +-
cfg.mk | 8 --------
2 files changed, 1 insertions(+), 9 deletions(-)
diff --git a/.gnulib b/.gnulib
index 4f01268..e01b458 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 4f01268d0c584c20704e42527f4fa125e7525aae
+Subproject commit e01b458f40440e64ce6f59beb0b446219bb6302d
diff --git a/cfg.mk b/cfg.mk
index 2e7b68a..07360b0 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -272,14 +272,6 @@ sc_preprocessor_indentation:
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
fi
-_m1 = use "test C1 && test C2", not "test C1 -''a C2"
-_m2 = use "test C1 || test C2", not "test C1 -''o C2"
-# Using test's -a and -o operators is not portable.
-sc_prohibit_test_minus_ao:
- @re='(\<test| \[+) .+ -[ao] ' \
- msg='$(_m1); $(_m2)' \
- $(_prohibit_regexp)
-
sc_copyright_format:
@$(VC_LIST_EXCEPT) | xargs grep -ni 'copyright .*Red 'Hat \
| grep -v Inc \
--
1.6.6.1
14 years, 7 months
[libvirt] Pushed qemuDomainRestore fix
by Chris Lalancette
FYI, I just pushed this fix (with blessing from DV):
commit d62f4c36c2c28b96952143247a1360e8c18f64c7
Author: Chris Lalancette <clalance(a)redhat.com>
Date: Tue Mar 23 09:11:29 2010 -0400
Don't use virFileReadLimFD in qemuDomainRestore.
virFileReadLimFD is a poor fit for reading the header
of the restore file. The problem is that virFileReadLimFD
returns an error when there is more data after the amount
you ask to read, but that is *expected* in this case.
This patch is essentially a revert of
1a4d5c9543641c444dccd682f6256ee3faf22a80, but I don't think
that commit does what it says anyway. It purports to prevent
an unwarranted OOM error, but since virFileReadLimFD will
allocate memory up to the maximum anyway, the upper limit
on the total amount of memory allocated is the same for either
the old version or the new version. Since the old saferead
actually works and virFileReadLimFD does not, revert to
using saferead.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4291bc7..70d2781 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5547,7 +5547,12 @@ static int qemudDomainRestore(virConnectPtr conn,
goto cleanup;
}
- if (virFileReadLimFD(fd, header.xml_len, &xml) != header.xml_len) {
+ if (VIR_ALLOC_N(xml, header.xml_len) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (saferead(fd, xml, header.xml_len) != header.xml_len) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("failed to read XML"));
goto cleanup;
--
Chris Lalancette
14 years, 7 months
[libvirt] [PATCH] VBox: Fix use of uninitialized value
by Jiri Denemark
---
src/vbox/vbox_tmpl.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 14fdcda..59ad1b8 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -1570,7 +1570,7 @@ static int vboxDomainDestroy(virDomainPtr dom) {
#if VBOX_API_VERSION == 2002
console->vtbl->PowerDown(console);
#else
- IProgress *progress;
+ IProgress *progress = NULL;
console->vtbl->PowerDown(console, &progress);
if (progress) {
progress->vtbl->WaitForCompletion(progress, -1);
--
1.7.0.4
14 years, 7 months
[libvirt] [PATCH] Changes to clock timer XML to match final design.
by Laine Stump
The clock timer XML is being updated in the following ways (based on
further off-list discussion that was missed during the initial
implementation):
1) 'wallclock' is changed to 'track', and the possible values are 'boot'
(corresponds to old 'host'), 'guest', and 'wall'.
2) 'mode' has an additional value 'smpsafe'
3) when tickpolicy='catchup', there can be an optional sub-element of
timer called 'catchup':
<catchup threshold=123 slew=120 limit=10000/>
Those three values are all longs, always optional, and if they are present,
they are positive. Internally, 0 indicates "unspecified".
* docs/schemas/domain.rng: updated RNG definition to account for changes
* src/conf/domain_conf.h: change the C struct and enums to match changes.
* src/conf/domain_conf.c: timer parse and format functions changed to
handle the new selections and new element.
* src/libvirt_private.syms: *TimerWallclock* changes to *TimerTrack*
* src/qemu/qemu_conf.c: again, account for Wallclock --> Track change.
---
docs/schemas/domain.rng | 24 +++++++++++-
src/conf/domain_conf.c | 89 +++++++++++++++++++++++++++++++++++----------
src/conf/domain_conf.h | 26 ++++++++++----
src/libvirt_private.syms | 4 +-
src/qemu/qemu_conf.c | 17 +++++++--
5 files changed, 126 insertions(+), 34 deletions(-)
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index d804301..228665c 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -344,10 +344,11 @@
</choice>
</attribute>
<optional>
- <attribute name="wallclock">
+ <attribute name="track">
<choice>
- <value>host</value>
+ <value>boot</value>
<value>guest</value>
+ <value>wall</value>
</choice>
</attribute>
</optional>
@@ -362,6 +363,9 @@
</attribute>
</optional>
<optional>
+ <ref name="catchup"/>
+ </optional>
+ <optional>
<attribute name="frequency">
<ref name="unsignedInt"/>
</attribute>
@@ -373,6 +377,7 @@
<value>native</value>
<value>emulate</value>
<value>paravirt</value>
+ <value>smpsafe</value>
</choice>
</attribute>
</optional>
@@ -387,6 +392,21 @@
<empty/>
</element>
</define>
+ <define name="catchup">
+ <element name="catchup">
+ <optional>
+ <attribute name="threshold">
+ <ref name="unsignedInt"/>
+ </attribute>
+ <attribute name="slew">
+ <ref name="unsignedInt"/>
+ </attribute>
+ <attribute name="limit">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
+ </element>
+ </define>
<!--
A bootloader may be used to extract the OS information instead of
defining the OS parameter in the instance. It points just to the
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 66aa53e..b8acab9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -252,9 +252,10 @@ VIR_ENUM_IMPL(virDomainTimerName, VIR_DOMAIN_TIMER_NAME_LAST,
"hpet",
"tsc");
-VIR_ENUM_IMPL(virDomainTimerWallclock, VIR_DOMAIN_TIMER_WALLCLOCK_LAST,
- "host",
- "guest");
+VIR_ENUM_IMPL(virDomainTimerTrack, VIR_DOMAIN_TIMER_TRACK_LAST,
+ "boot",
+ "guest",
+ "wall");
VIR_ENUM_IMPL(virDomainTimerTickpolicy, VIR_DOMAIN_TIMER_TICKPOLICY_LAST,
"delay",
@@ -266,7 +267,8 @@ VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST,
"auto",
"native",
"emulate",
- "paravirt");
+ "paravirt",
+ "smpsafe");
#define virDomainReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_DOMAIN, code, __FILE__, \
@@ -2555,7 +2557,7 @@ virDomainTimerDefParseXML(const xmlNodePtr node,
char *name = NULL;
char *present = NULL;
char *tickpolicy = NULL;
- char *wallclock = NULL;
+ char *track = NULL;
char *mode = NULL;
virDomainTimerDefPtr def;
@@ -2603,12 +2605,12 @@ virDomainTimerDefParseXML(const xmlNodePtr node,
}
}
- def->wallclock = -1;
- wallclock = virXMLPropString(node, "wallclock");
- if (wallclock != NULL) {
- if ((def->wallclock = virDomainTimerWallclockTypeFromString(wallclock)) < 0) {
+ def->track = -1;
+ track = virXMLPropString(node, "track");
+ if (track != NULL) {
+ if ((def->track = virDomainTimerTrackTypeFromString(track)) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
- _("unknown timer wallclock '%s'"), wallclock);
+ _("unknown timer track '%s'"), track);
goto error;
}
}
@@ -2616,7 +2618,7 @@ virDomainTimerDefParseXML(const xmlNodePtr node,
int ret = virXPathULong("string(./frequency)", ctxt, &def->frequency);
if (ret == -1) {
def->frequency = 0;
- } else if (ret <= 0) {
+ } else if (ret < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("invalid timer frequency"));
goto error;
@@ -2632,11 +2634,42 @@ virDomainTimerDefParseXML(const xmlNodePtr node,
}
}
+ xmlNodePtr catchup = virXPathNode("./catchup", ctxt);
+ if (catchup != NULL) {
+ ret = virXPathULong("string(./catchup/@threshold)", ctxt,
+ &def->catchup.threshold);
+ if (ret == -1) {
+ def->catchup.threshold = 0;
+ } else if (ret < 0) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("invalid catchup threshold"));
+ goto error;
+ }
+
+ ret = virXPathULong("string(./catchup/@slew)", ctxt, &def->catchup.slew);
+ if (ret == -1) {
+ def->catchup.slew = 0;
+ } else if (ret < 0) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("invalid catchup slew"));
+ goto error;
+ }
+
+ ret = virXPathULong("string(./catchup/@limit)", ctxt, &def->catchup.limit);
+ if (ret == -1) {
+ def->catchup.limit = 0;
+ } else if (ret < 0) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("invalid catchup limit"));
+ goto error;
+ }
+ }
+
cleanup:
VIR_FREE(name);
VIR_FREE(present);
VIR_FREE(tickpolicy);
- VIR_FREE(wallclock);
+ VIR_FREE(track);
VIR_FREE(mode);
ctxt->node = oldnode;
@@ -5456,16 +5489,16 @@ virDomainTimerDefFormat(virBufferPtr buf,
if ((def->name == VIR_DOMAIN_TIMER_NAME_PLATFORM)
|| (def->name == VIR_DOMAIN_TIMER_NAME_RTC)) {
- if (def->wallclock != -1) {
- const char *wallclock
- = virDomainTimerWallclockTypeToString(def->wallclock);
- if (!wallclock) {
+ if (def->track != -1) {
+ const char *track
+ = virDomainTimerTrackTypeToString(def->track);
+ if (!track) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected timer wallclock %d"),
- def->wallclock);
+ _("unexpected timer track %d"),
+ def->track);
return -1;
}
- virBufferVSprintf(buf, " wallclock='%s'", wallclock);
+ virBufferVSprintf(buf, " track='%s'", track);
}
}
@@ -5487,7 +5520,23 @@ virDomainTimerDefFormat(virBufferPtr buf,
}
}
- virBufferAddLit(buf, "/>\n");
+ if ((def->catchup.threshold == 0)
+ && (def->catchup.slew == 0)
+ && (def->catchup.limit == 0)) {
+ virBufferAddLit(buf, "/>\n");
+ } else {
+ virBufferAddLit(buf, ">\n <catchup ");
+ if (def->catchup.threshold > 0) {
+ virBufferVSprintf(buf, " threshold='%lu'", def->catchup.threshold);
+ }
+ if (def->catchup.slew > 0) {
+ virBufferVSprintf(buf, " slew='%lu'", def->catchup.slew);
+ }
+ if (def->catchup.limit > 0) {
+ virBufferVSprintf(buf, " limit='%lu'", def->catchup.limit);
+ }
+ virBufferAddLit(buf, "/>\n </timer>\n");
+ }
return 0;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ed1a4ad..435d546 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -656,11 +656,12 @@ enum virDomainTimerNameType {
VIR_DOMAIN_TIMER_NAME_LAST,
};
-enum virDomainTimerWallclockType {
- VIR_DOMAIN_TIMER_WALLCLOCK_HOST = 0,
- VIR_DOMAIN_TIMER_WALLCLOCK_GUEST,
+enum virDomainTimerTrackType {
+ VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
+ VIR_DOMAIN_TIMER_TRACK_GUEST,
+ VIR_DOMAIN_TIMER_TRACK_WALL,
- VIR_DOMAIN_TIMER_WALLCLOCK_LAST,
+ VIR_DOMAIN_TIMER_TRACK_LAST,
};
enum virDomainTimerTickpolicyType {
@@ -677,10 +678,19 @@ enum virDomainTimerModeType {
VIR_DOMAIN_TIMER_MODE_NATIVE,
VIR_DOMAIN_TIMER_MODE_EMULATE,
VIR_DOMAIN_TIMER_MODE_PARAVIRT,
+ VIR_DOMAIN_TIMER_MODE_SMPSAFE,
VIR_DOMAIN_TIMER_MODE_LAST,
};
+typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
+typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
+struct _virDomainTimerCatchupDef {
+ unsigned long threshold;
+ unsigned long slew;
+ unsigned long limit;
+};
+
typedef struct _virDomainTimerDef virDomainTimerDef;
typedef virDomainTimerDef *virDomainTimerDefPtr;
struct _virDomainTimerDef {
@@ -688,8 +698,10 @@ struct _virDomainTimerDef {
int present; /* unspecified = -1, no = 0, yes = 1 */
int tickpolicy; /* none|catchup|merge|discard */
- /* wallclock is only valid for name='platform|rtc' */
- int wallclock; /* host|guest */
+ virDomainTimerCatchupDef catchup;
+
+ /* track is only valid for name='platform|rtc' */
+ int track; /* host|guest */
/* frequency & mode are only valid for name='tsc' */
unsigned long frequency; /* in Hz, unspecified = 0 */
@@ -1029,7 +1041,7 @@ VIR_ENUM_DECL(virDomainClockOffset)
VIR_ENUM_DECL(virDomainNetdevMacvtap)
VIR_ENUM_DECL(virDomainTimerName)
-VIR_ENUM_DECL(virDomainTimerWallclock)
+VIR_ENUM_DECL(virDomainTimerTrack)
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index cc943f8..08a6b97 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -199,8 +199,8 @@ virDomainClockOffsetTypeFromString;
virDomainDiskErrorPolicyTypeToString;
virDomainTimerNameTypeToString;
virDomainTimerNameTypeFromString;
-virDomainTimerWallclockTypeToString;
-virDomainTimerWallclockTypeFromString;
+virDomainTimerTrackTypeToString;
+virDomainTimerTrackTypeFromString;
virDomainTimerTickpolicyTypeToString;
virDomainTimerTickpolicyTypeFromString;
virDomainTimerModeTypeToString;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 8f6f7ec..4f279be 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -3183,11 +3183,22 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
int i;
for (i = 0; i < def->ntimers; i++) {
if (def->timers[i]->name == VIR_DOMAIN_TIMER_NAME_RTC) {
- if (def->timers[i]->wallclock == VIR_DOMAIN_TIMER_WALLCLOCK_HOST) {
- virBufferAddLit(&buf, ",clock=host");
- } else if (def->timers[i]->wallclock == VIR_DOMAIN_TIMER_WALLCLOCK_GUEST) {
+ switch (def->timers[i]->track) {
+ case -1: /* unspecified - use hypervisor default */
+ break;
+ case VIR_DOMAIN_TIMER_TRACK_BOOT:
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported rtc timer track '%s'"),
+ virDomainTimerTrackTypeToString(def->timers[i]->track));
+ goto error;
+ case VIR_DOMAIN_TIMER_TRACK_GUEST:
virBufferAddLit(&buf, ",clock=vm");
+ break;
+ case VIR_DOMAIN_TIMER_TRACK_WALL:
+ virBufferAddLit(&buf, ",clock=host");
+ break;
}
+
switch (def->timers[i]->tickpolicy) {
case -1:
case VIR_DOMAIN_TIMER_TICKPOLICY_DELAY:
--
1.6.6.1
14 years, 7 months
[libvirt] [PATCH] Eliminate compile warnings in nwfilter error log calls
by Laine Stump
---
src/nwfilter/nwfilter_ebiptables_driver.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index 68bada6..172394d 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -156,13 +156,13 @@ printDataType(virConnectPtr conn,
case DATATYPE_IPADDR:
data = virSocketFormatAddr(&item->u.ipaddr.addr);
if (!data) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
_("internal IPv4 address representation "
"is bad"));
return 1;
}
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
_("buffer too small for IP address"));
VIR_FREE(data);
return 1;
@@ -173,14 +173,14 @@ printDataType(virConnectPtr conn,
case DATATYPE_IPV6ADDR:
data = virSocketFormatAddr(&item->u.ipaddr.addr);
if (!data) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
_("internal IPv6 address representation "
"is bad"));
return 1;
}
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
_("buffer too small for IPv6 address"));
VIR_FREE(data);
return 1;
@@ -191,7 +191,7 @@ printDataType(virConnectPtr conn,
case DATATYPE_MACADDR:
case DATATYPE_MACMASK:
if (bufsize < VIR_MAC_STRING_BUFLEN) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER, "%s",
_("Buffer too small for MAC address"));
return 1;
}
@@ -202,7 +202,7 @@ printDataType(virConnectPtr conn,
case DATATYPE_UINT16:
if (snprintf(buf, bufsize, "%d",
item->u.u16) >= bufsize) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER, "%s",
_("Buffer too small for uint16 type"));
return 1;
}
@@ -213,7 +213,7 @@ printDataType(virConnectPtr conn,
case DATATYPE_UINT8:
if (snprintf(buf, bufsize, "%d",
item->u.u8) >= bufsize) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER, "%s",
_("Buffer too small for uint8 type"));
return 1;
}
--
1.6.6.1
14 years, 7 months
[libvirt] [PATCH] Allow domain disk images on root-squash NFS to coexist with security driver.
by Laine Stump
(suggested by Daniel Berrange, tested by Dan Kenigsberg)
virStorageFileGetMetadata will fail for disk images that are stored on
a root-squash NFS share that isn't world-readable.
SELinuxSetSecurityImageLabel is called during the startup of every
domain (as long as security_driver != "none"), and it will propogate
the error from virStorageFileGetMetadata, causing the domain startup
to fail. This is, however, a common scenario when qemu is run as a
non-root user and the disk image is stored on NFS.
Ignoring this failure (which doesn't matter in this case, since the
next thing done by SELinuxSetSecurityImageLabel - setting the file
context - will also fail (and that function already ignores failures
due to root-squash NFS) will allow us to continue bringing up the
domain. The result is that we don't need to disable the entire
security driver just because a domain's disk image is stored on
root-squashed NFS.
---
src/security/security_selinux.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 6680e2d..3e20475 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -430,7 +430,7 @@ SELinuxSetSecurityImageLabel(virDomainObjPtr vm,
path = NULL;
if (ret < 0)
- return -1;
+ break;
if (meta.backingStore != NULL &&
SELinuxSetFilecon(meta.backingStore,
--
1.6.6.1
14 years, 7 months
[libvirt] [RFC]: Snapshot API v4
by Chris Lalancette
Hello,
Here is the 4th (and hopefully final) draft for the snapshot API that
we've been discussing. There is one minor change and one major change in
this draft. The minor change is that we've added a virDomainSnapshotHasCurrent
and virDomainSnapshotCurrent methods to get at the current snapshot. The
major change is that I've removed all but one of the possible
virDomainSnapshotDelete() flags. After reviewing ESX, virtualbox, and qemu, it
seems that the deletion of any snapshots that have children will *automatically*
merge the changes from that snapshot into the children to keep the children
viable. Therefore, the MERGE and MERGE_FORCE flags are nonsensical. Since this
is the virDomainSnapshotDelete call, we don't really need a flag to say "delete",
so I've removed the DISCARD flag. What that leaves us with is a single flag to
the delete API that says to delete this snapshot, and all children of this
snapshot. This could be useful to clean out a tree of snapshots instead of
doing it one-by-one.
If there are no further major objections to this API, we'll be posting
patches later today or tomorrow that implement this API for both qemu and
virtualbox.
Note that I've not included my full notes from last time. If anyone
is still interested in those, I can either repost them or send them privately.
/* NOTE: struct _virDomainSnapshot is a private structure, ala
* struct _virDomain.
*/
typedef struct _virDomainSnapshot virDomainSnapshot;
/* Take a snapshot of the current VM state. */
virDomainSnapshotPtr virDomainSnapshotCreateXML(virDomainPtr domain,
const char *xmlDesc,
unsigned int flags);
/* Dump the XML of a snapshot */
/* NOTE: see below for proposed XML */
char *virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
unsigned int flags);
/* Return the number of snapshots for this domain */
int virDomainSnapshotNum(virDomainPtr domain, unsigned int flags);
/* Get the names of all snapshots for this domain */
int virDomainListSnapshotNames(virDomainPtr domain, char **names, int nameslen,
unsigned int flags);
/* Get a handle to a named snapshot */
virDomainSnapshotPtr virDomainSnapshotLookupByName(virDomainPtr domain,
const char *name,
unsigned int flags);
/* Find out if domain "domain" has a current snapshot */
int virDomainSnapshotHasCurrent(virDomainPtr domain, unsigned int flags);
/* Get a handle to the current in-use snapshot for the domain. */
int virDomainSnapshotCurrent(virDomainPtr domain,
unsigned int flags);
/* Start the guest from the snapshot "snapshot". Note that
* the guest may either be running or not.
*
* In the case the VM is running, then the snapshot *must* have
* been taken while the VM was running (i.e. the snapshot <state>
* tag must be "RUNNING"). This will revert the disk and memory to
* "snapshot".
*
* In the case the VM is not running, then the snapshot may
* have been taken while the VM was not running or not. In
* either case it will revert just the disk to "snapshot".
*/
int virDomainCreateFromSnapshot(virDomainSnapshotPtr snapshot,
unsigned int flags);
/* Delete a snapshot.
*
* TREE: discard this snapshot and any children snapshots
*
* Note that this operation can happen when the domain is running or shut
* down, though this is hypervisor specific */
*/
typedef enum {
VIR_DOMAIN_SNAPSHOT_DELETE_TREE,
} virDomainSnapshotDelete;
int virDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
unsigned int flags);
int virDomainSnapshotFree(virDomainSnapshotPtr snapshot);
NOTE: During snapshot creation, *none* of the fields are required. That is,
you can call virDomainSnapshotCreateXML() with an XML of "<domainsnapshot/>".
In this case, the individual driver will make up a <name> for you,
the <creationdate> will be set to the current time+date, <description> will be
empty, <state> will be the current state of the VM, and <parent> will
be set to the current snapshot (if any). If you do want to specify some
fields during virDomainSnapshotCreateXML(), note that the only ones that are
settable are <name> and <description>;
the rest are ignored, and filled in by the driver when the snapshot is
actually created.
NOTE: <state> refers to the state of the VM when the snapshot was taken.
NOTE: <creationdate> is in the format %Y-%m-%d_%T as defined by strptime.
Also note that the granularity of <creationdate> is in seconds.
<domainsnapshot>
<name>XYZ</name>
<creationdate>...</creationdate>
<description>...</description>
<state>RUNNING</state>
<domain>
<uuid>XXXXX-XXXX-XXXX-XXXX-XXXXXXXXX</uuid>
</domain>
<parent>
<name>ABC</name>
</parent>
</domainsnapshot>
The virsh commands will be:
virsh snapshot-create <dom> [<xmlfile>]
virsh snapshot-list <dom>
virsh snapshot-dumpxml <dom> <name>
virsh start-from-snapshot <dom> <snapshotname>
virsh snapshot-delete <dom> <snapshotname> [--children]
--
Chris Lalancette
14 years, 7 months
[libvirt] [PATCH] nwfilter: Some fixes to XML parser
by Stefan Berger
While writing a couple of test cases for the nwfilter's XML parser I
found some cases where the output ended up not looking as expected. So
the following changes are in the patch below:
- if the protocol ID in the MAC header is an integer, just write it into
the datastructure without trying to find a corresponding string for it
and if none is found failing
- when writing the protocol ID as string, simply write it as integer if
no corresponding string can be found
- same changes for arpOpcode parsing and printing
- same changes for protocol ID in an IP packet
- DSCP value needs to be written into the data structure
- IP protocol version number is redundant at this level, so remove it
- parse the protocol ID found inside an IP packet not only as string but
also as uint8
- arrange the display of the src and destination masks to be shown after
the src and destination ip address respectively in the XML
- the existing libvirt IP address parser accepts for example '25' as an
IP address. I want this to be parsed as a CIDR type netmask. So try to
parse it as an integer first (CIDR netmask) and if that doesn't work as
a dotted IP address style netmask.
- instantiation of rules with MAC masks didn't work because they weren't
printed into a buffer, yet.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/conf/nwfilter_conf.c | 128 ++++++++++++++----------------
src/nwfilter/nwfilter_ebiptables_driver.c | 1
2 files changed, 61 insertions(+), 68 deletions(-)
Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.c
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -403,15 +403,12 @@ checkMacProtocolID(enum attrDatatype dat
virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
{
int32_t res = -1;
- const char *str;
if (datatype == DATATYPE_STRING) {
if (intMapGetByString(macProtoMap, (char *)value, 1, &res) == 0)
res = -1;
} else if (datatype == DATATYPE_UINT16) {
- if (intMapGetByInt(macProtoMap,
- (int32_t)*(uint16_t *)value, &str) == 0)
- res = -1;
+ res = (uint32_t)*(uint16_t *)value;
}
if (res != -1) {
@@ -433,9 +430,10 @@ macProtocolIDFormatter(virBufferPtr buf,
nwf->p.ethHdrFilter.dataProtocolID.u.u16,
&str)) {
virBufferVSprintf(buf, "%s", str);
- return 1;
+ } else {
+ virBufferVSprintf(buf, "%d", nwf->p.ethHdrFilter.dataProtocolID.u.u16);
}
- return 0;
+ return 1;
}
@@ -500,15 +498,12 @@ arpOpcodeValidator(enum attrDatatype dat
virNWFilterRuleDefPtr nwf)
{
int32_t res = -1;
- const char *str;
if (datatype == DATATYPE_STRING) {
if (intMapGetByString(arpOpcodeMap, (char *)value, 1, &res) == 0)
res = -1;
} else if (datatype == DATATYPE_UINT16) {
- if (intMapGetByInt(arpOpcodeMap,
- (uint32_t)*(uint16_t *)value, &str) == 0)
- res = -1;
+ res = (uint32_t)*(uint16_t *)value;
}
if (res != -1) {
@@ -530,9 +525,10 @@ arpOpcodeFormatter(virBufferPtr buf,
nwf->p.arpHdrFilter.dataOpcode.u.u16,
&str)) {
virBufferVSprintf(buf, "%s", str);
- return 1;
+ } else {
+ virBufferVSprintf(buf, "%d", nwf->p.arpHdrFilter.dataOpcode.u.u16);
}
- return 0;
+ return 1;
}
@@ -560,16 +556,12 @@ static bool checkIPProtocolID(enum attrD
virNWFilterRuleDefPtr nwf)
{
int32_t res = -1;
- const char *str;
if (datatype == DATATYPE_STRING) {
if (intMapGetByString(ipProtoMap, (char *)value, 1, &res) == 0)
res = -1;
} else if (datatype == DATATYPE_UINT8) {
- // may just accept what user provides and not test...
- if (intMapGetByInt(ipProtoMap,
- (uint32_t)*(uint16_t *)value, &str) == 0)
- res = -1;
+ res = (uint32_t)*(uint16_t *)value;
}
if (res != -1) {
@@ -591,19 +583,24 @@ formatIPProtocolID(virBufferPtr buf,
nwf->p.ipHdrFilter.ipHdr.dataProtocolID.u.u8,
&str)) {
virBufferVSprintf(buf, "%s", str);
- return 1;
+ } else {
+ virBufferVSprintf(buf, "%d",
+ nwf->p.ipHdrFilter.ipHdr.dataProtocolID.u.u8);
}
- return 0;
+ return 1;
}
static bool
dscpValidator(enum attrDatatype datatype ATTRIBUTE_UNUSED, void *val,
- virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
+ virNWFilterRuleDefPtr nwf)
{
uint8_t dscp = *(uint16_t *)val;
if (dscp > 63)
return 0;
+
+ nwf->p.ipHdrFilter.ipHdr.dataDSCP.u.u8 = dscp;
+
return 1;
}
@@ -685,11 +682,6 @@ static const virXMLAttr2Struct arpAttrib
static const virXMLAttr2Struct ipAttributes[] = {
COMMON_MAC_PROPS(ipHdrFilter),
{
- .name = "version",
- .datatype = DATATYPE_UINT8,
- .dataIdx = offsetof(virNWFilterRuleDef, p.ipHdrFilter.ipHdr.dataIPVersion),
- },
- {
.name = SRCIPADDR,
.datatype = DATATYPE_IPADDR,
.dataIdx = offsetof(virNWFilterRuleDef, p.ipHdrFilter.ipHdr.dataSrcIPAddr),
@@ -711,7 +703,7 @@ static const virXMLAttr2Struct ipAttribu
},
{
.name = "protocol",
- .datatype = DATATYPE_STRING,
+ .datatype = DATATYPE_STRING | DATATYPE_UINT8,
.dataIdx = offsetof(virNWFilterRuleDef, p.ipHdrFilter.ipHdr.dataProtocolID),
.validator= checkIPProtocolID,
.formatter= formatIPProtocolID,
@@ -756,16 +748,16 @@ static const virXMLAttr2Struct ipv6Attri
.dataIdx = offsetof(virNWFilterRuleDef, p.ipv6HdrFilter.ipHdr.dataSrcIPAddr),
},
{
- .name = DSTIPADDR,
- .datatype = DATATYPE_IPV6ADDR,
- .dataIdx = offsetof(virNWFilterRuleDef, p.ipv6HdrFilter.ipHdr.dataDstIPAddr),
- },
- {
.name = SRCIPMASK,
.datatype = DATATYPE_IPV6MASK,
.dataIdx = offsetof(virNWFilterRuleDef, p.ipv6HdrFilter.ipHdr.dataSrcIPMask),
},
{
+ .name = DSTIPADDR,
+ .datatype = DATATYPE_IPV6ADDR,
+ .dataIdx = offsetof(virNWFilterRuleDef, p.ipv6HdrFilter.ipHdr.dataDstIPAddr),
+ },
+ {
.name = DSTIPMASK,
.datatype = DATATYPE_IPV6MASK,
.dataIdx = offsetof(virNWFilterRuleDef, p.ipv6HdrFilter.ipHdr.dataDstIPMask),
@@ -818,16 +810,16 @@ static const virXMLAttr2Struct ipv6Attri
.dataIdx = offsetof(virNWFilterRuleDef, p.STRUCT.ipHdr.dataSrcIPAddr),\
},\
{\
- .name = DSTIPADDR,\
- .datatype = ADDRTYPE,\
- .dataIdx = offsetof(virNWFilterRuleDef, p.STRUCT.ipHdr.dataDstIPAddr),\
- },\
- {\
.name = SRCIPMASK,\
.datatype = MASKTYPE,\
.dataIdx = offsetof(virNWFilterRuleDef, p.STRUCT.ipHdr.dataSrcIPMask),\
},\
{\
+ .name = DSTIPADDR,\
+ .datatype = ADDRTYPE,\
+ .dataIdx = offsetof(virNWFilterRuleDef, p.STRUCT.ipHdr.dataDstIPAddr),\
+ },\
+ {\
.name = DSTIPMASK,\
.datatype = MASKTYPE,\
.dataIdx = offsetof(virNWFilterRuleDef, p.STRUCT.ipHdr.dataDstIPMask),\
@@ -1276,26 +1268,26 @@ virNWFilterRuleDetailsParse(virConnectPt
case DATATYPE_IPMASK:
storage_ptr = &item->u.u8;
- if (!virNWIPv4AddressParser(prop, &ipaddr)) {
- if (sscanf(prop, "%d", &int_val) == 1) {
- if (int_val >= 0 && int_val <= 32) {
- if (!validator)
- *(uint8_t *)storage_ptr =
- (uint8_t)int_val;
- found = 1;
- data_ptr = &int_val;
- } else
- rc = -1;
+ if (virStrToLong_i(prop, NULL, 10, &int_val) == 0) {
+ if (int_val >= 0 && int_val <= 32) {
+ if (!validator)
+ *(uint8_t *)storage_ptr =
+ (uint8_t)int_val;
+ found = 1;
+ data_ptr = &int_val;
} else
rc = -1;
} else {
- int_val = virSocketGetNumNetmaskBits(
+ if (virNWIPv4AddressParser(prop, &ipaddr)) {
+ int_val = virSocketGetNumNetmaskBits(
&ipaddr.addr);
- if (int_val >= 0)
- *(uint8_t *)storage_ptr = int_val;
- else
+ if (int_val >= 0)
+ *(uint8_t *)storage_ptr = int_val;
+ else
+ rc = -1;
+ found = 1;
+ } else
rc = -1;
- found = 1;
}
break;
@@ -1330,26 +1322,26 @@ virNWFilterRuleDetailsParse(virConnectPt
case DATATYPE_IPV6MASK:
storage_ptr = &item->u.u8;
- if (!virNWIPv6AddressParser(prop, &ipaddr)) {
- if (sscanf(prop, "%d", &int_val) == 1) {
- if (int_val >= 0 && int_val <= 128) {
- if (!validator)
- *(uint8_t *)storage_ptr =
- (uint8_t)int_val;
- found = 1;
- data_ptr = &int_val;
- } else
- rc = -1;
+ if (virStrToLong_i(prop, NULL, 10, &int_val) == 0) {
+ if (int_val >= 0 && int_val <= 128) {
+ if (!validator)
+ *(uint8_t *)storage_ptr =
+ (uint8_t)int_val;
+ found = 1;
+ data_ptr = &int_val;
} else
rc = -1;
} else {
- int_val = virSocketGetNumNetmaskBits(
- &ipaddr.addr);
- if (int_val >= 0)
- *(uint8_t *)storage_ptr = int_val;
- else
- rc = -1;
- found = 1;
+ if (virNWIPv6AddressParser(prop, &ipaddr)) {
+ int_val = virSocketGetNumNetmaskBits(
+ &ipaddr.addr);
+ if (int_val >= 0)
+ *(uint8_t *)storage_ptr = int_val;
+ else
+ rc = -1;
+ found = 1;
+ } else
+ rc = -1;
}
break;
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -189,6 +189,7 @@ printDataType(virConnectPtr conn,
break;
case DATATYPE_MACADDR:
+ case DATATYPE_MACMASK:
if (bufsize < VIR_MAC_STRING_BUFLEN) {
virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
_("Buffer too small for MAC address"));
14 years, 7 months
[libvirt] Node devices XML format
by Dev.Atom
Hi,
I need help about Node devices XML format description, there's no infos at libvirt.org, is there another info source where I can have description of this XML file ?
Thanks,
Best regards,
Arnaud Champion
14 years, 7 months
[libvirt] [PATCHv2 00/10] Begin to replace scanf and atoi
by Matthias Bolte
This set of patches is a first step towards removing the scanf and atoi
usage in libvirt. I began with the simple cases and post this now to get
some feedback before I start to convert the more difficult cases.
Changes in v2:
- don't test tmp for NULL
- note in commit message if parsing is stricter now
- don't leak in PRUnicharToInt (vbox)
- strip a trailing \n in openvzGetVPSUUID, as it was done before
- don't use strspn to skip whitespaces, virStrToLong* does this already
- fix virStrToLong* return value tests to check for < 0 instead of < 3 or != 1
- add STRSKIP to skip a given prefix of a string
Thanks to Eric Blake and Jim Meyering.
Matthias
14 years, 7 months