[libvirt] [PATCH] maint: don't permit format strings without %
by Eric Blake
Any time we have a string with no % passed through gettext, a
translator can inject a % to cause a stack overread. When there
is nothing to format, it's easier to ask for a string that cannot
be used as a formatter, by using a trivial "%s" format instead.
In the past, we have used --disable-nls to catch some of the
offenders, but that doesn't get run very often, and many more
uses have crept in. Syntax check to the rescue!
The syntax check can catch uses such as
virReportError(code,
_("split "
"string"));
by using a sed script to fold context lines into one pattern
space before checking for a string without %.
This patch is just mechanical insertion of %s; there are probably
several messages touched by this patch where we would be better
off giving the user more information than a fixed string.
* cfg.mk (sc_prohibit_diagnostic_without_format): New rule.
* src/datatypes.c (virUnrefConnect, virGetDomain)
(virUnrefDomain, virGetNetwork, virUnrefNetwork, virGetInterface)
(virUnrefInterface, virGetStoragePool, virUnrefStoragePool)
(virGetStorageVol, virUnrefStorageVol, virGetNodeDevice)
(virGetSecret, virUnrefSecret, virGetNWFilter, virUnrefNWFilter)
(virGetDomainSnapshot, virUnrefDomainSnapshot): Add %s wrapper.
* src/lxc/lxc_driver.c (lxcDomainSetBlkioParameters)
(lxcDomainGetBlkioParameters): Likewise.
* src/conf/domain_conf.c (virSecurityDeviceLabelDefParseXML)
(virDomainDiskDefParseXML, virDomainGraphicsDefParseXML):
Likewise.
* src/conf/network_conf.c (virNetworkDNSHostsDefParseXML)
(virNetworkDefParseXML): Likewise.
* src/conf/nwfilter_conf.c (virNWFilterIsValidChainName):
Likewise.
* src/conf/nwfilter_params.c (virNWFilterVarValueCreateSimple)
(virNWFilterVarAccessParse): Likewise.
* src/libvirt.c (virDomainSave, virDomainSaveFlags)
(virDomainRestore, virDomainRestoreFlags)
(virDomainSaveImageGetXMLDesc, virDomainSaveImageDefineXML)
(virDomainCoreDump, virDomainGetXMLDesc)
(virDomainMigrateVersion1, virDomainMigrateVersion2)
(virDomainMigrateVersion3, virDomainMigrate, virDomainMigrate2)
(virStreamSendAll, virStreamRecvAll)
(virDomainSnapshotGetXMLDesc): Likewise.
* src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
(virNWFilterDHCPSnoopReq): Likewise.
* src/openvz/openvz_driver.c (openvzUpdateDevice): Likewise.
* src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupCgroup): Likewise.
* src/qemu/qemu_command.c (qemuBuildHubDevStr, qemuBuildChrChardevStr)
(qemuBuildCommandLine): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
* src/rpc/virnetsaslcontext.c (virNetSASLSessionGetIdentity):
Likewise.
* src/rpc/virnetsocket.c (virNetSocketNewConnectUNIX)
(virNetSocketSendFD, virNetSocketRecvFD): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskBuildPool): Likewise.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemProbe)
(virStorageBackendFileSystemBuild): Likewise.
* src/storage/storage_backend_rbd.c
(virStorageBackendRBDOpenRADOSConn): Likewise.
* src/storage/storage_driver.c (storageVolumeResize): Likewise.
* src/test/test_driver.c (testInterfaceChangeBegin)
(testInterfaceChangeCommit, testInterfaceChangeRollback):
Likewise.
* src/vbox/vbox_tmpl.c (vboxListAllDomains): Likewise.
* src/xenxs/xen_sxpr.c (xenFormatSxprDisk, xenFormatSxpr):
Likewise.
* src/xenxs/xen_xm.c (xenXMConfigGetUUID, xenFormatXMDisk)
(xenFormatXM): Likewise.
---
danpb asked me on IRC if it was possible to automate the checking
for our recent %s additions. Of course, my answer was yes, before
I knew it would take me three hours to get here...
cfg.mk | 15 ++++++++++++-
src/conf/domain_conf.c | 22 +++++++++----------
src/conf/network_conf.c | 8 +++----
src/conf/nwfilter_conf.c | 4 ++--
src/conf/nwfilter_params.c | 8 +++----
src/datatypes.c | 41 +++++++++++++++++++-----------------
src/libvirt.c | 34 +++++++++++++++---------------
src/lxc/lxc_driver.c | 6 ++++--
src/nwfilter/nwfilter_dhcpsnoop.c | 5 +++--
src/openvz/openvz_driver.c | 2 +-
src/openvz/openvz_util.c | 2 +-
src/qemu/qemu_cgroup.c | 4 ++--
src/qemu/qemu_command.c | 8 +++----
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_hotplug.c | 2 +-
src/rpc/virnetsaslcontext.c | 4 ++--
src/rpc/virnetsocket.c | 6 +++---
src/storage/storage_backend_disk.c | 8 +++----
src/storage/storage_backend_fs.c | 8 +++----
src/storage/storage_backend_rbd.c | 8 +++----
src/storage/storage_driver.c | 10 ++++-----
src/test/test_driver.c | 6 +++---
src/vbox/vbox_tmpl.c | 2 +-
src/xenxs/xen_sxpr.c | 6 +++---
src/xenxs/xen_xm.c | 8 +++----
25 files changed, 124 insertions(+), 105 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index d054e5a..085ef34 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -547,7 +547,7 @@ msg_gen_function += xenapiSessionErrorHandler
# msg_gen_function += vshPrint
# msg_gen_function += vshError
-func_or := $(shell printf '$(msg_gen_function)'|tr -s '[[:space:]]' '|')
+func_or := $(shell echo $(msg_gen_function)|tr -s '[[:space:]]' '|')
func_re := ($(func_or))
# Look for diagnostics that aren't marked for translation.
@@ -567,6 +567,19 @@ sc_libvirt_unmarked_diagnostics:
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
+# Look for diagnostics that lack a % in the format string, except that we
+# allow VIR_ERROR to do this, and ignore functions that take a single
+# string rather than a format argument.
+sc_prohibit_diagnostic_without_format:
+ @{ grep -nE '\<$(func_re) *\(.*;$$' $$($(VC_LIST_EXCEPT)); \
+ grep -A2 -nE '\<$(func_re) *\(.*,$$' $$($(VC_LIST_EXCEPT)); } \
+ | sed -rn -e ':l; /[,"]$$/ {N;b l;}' \
+ -e '/xenapiSessionErrorHandler/d' \
+ -e '/\<$(func_re) *\([^"]*"([^%"]|"\n[^"]*")*"[,)]/p' \
+ | grep -vE '(VIR_ERROR|vah_(error|warning))' && \
+ { echo '$(ME): found diagnostic without %' 1>&2; \
+ exit 1; } || :
+
# Like the above, but prohibit a newline at the end of a diagnostic.
# This is subject to false positives partly because it naively looks for
# `\n"', which may not be the end of the string, and also because it takes
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1b5dad9..c92c6d4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3236,7 +3236,7 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr *def,
(*def)->label = p;
if ((*def)->label && (*def)->norelabel) {
- virReportError(VIR_ERR_XML_ERROR,
+ virReportError(VIR_ERR_XML_ERROR, "%s",
_("Cannot specify a label if relabelling is turned off"));
VIR_FREE((*def)->label);
VIR_FREE(*def);
@@ -3423,7 +3423,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
}
if (!(source = virXMLPropString(cur, "name")) &&
def->protocol != VIR_DOMAIN_DISK_PROTOCOL_NBD) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing name for disk source"));
goto error;
}
@@ -3509,7 +3509,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
} else if (xmlStrEqual(cur->name, BAD_CAST "auth")) {
authUsername = virXMLPropString(cur, "username");
if (authUsername == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing username for auth"));
goto error;
}
@@ -3521,7 +3521,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
xmlStrEqual(child->name, BAD_CAST "secret")) {
usageType = virXMLPropString(child, "type");
if (usageType == NULL) {
- virReportError(VIR_ERR_XML_ERROR,
+ virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing type for secret"));
goto error;
}
@@ -3537,7 +3537,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
authUsage = virXMLPropString(child, "usage");
if (authUUID != NULL && authUsage != NULL) {
- virReportError(VIR_ERR_XML_ERROR,
+ virReportError(VIR_ERR_XML_ERROR, "%s",
_("only one of uuid and usage can be specified"));
goto error;
}
@@ -3599,7 +3599,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
def->blkdeviotune.read_bytes_sec) ||
(def->blkdeviotune.total_bytes_sec &&
def->blkdeviotune.write_bytes_sec)) {
- virReportError(VIR_ERR_XML_ERROR,
+ virReportError(VIR_ERR_XML_ERROR, "%s",
_("total and read/write bytes_sec "
"cannot be set at the same time"));
goto error;
@@ -3609,7 +3609,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
def->blkdeviotune.read_iops_sec) ||
(def->blkdeviotune.total_iops_sec &&
def->blkdeviotune.write_iops_sec)) {
- virReportError(VIR_ERR_XML_ERROR,
+ virReportError(VIR_ERR_XML_ERROR, "%s",
_("total and read/write iops_sec "
"cannot be set at the same time"));
goto error;
@@ -3825,7 +3825,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
if (ioeventfd) {
if (def->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk ioeventfd mode supported "
"only for virtio bus"));
goto error;
@@ -3843,7 +3843,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
if (event_idx) {
if (def->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk event_idx mode supported "
"only for virtio bus"));
goto error;
@@ -6411,7 +6411,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
if ((compressionVal =
virDomainGraphicsSpicePlaybackCompressionTypeFromString(compression)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unknown spice playback compression"));
VIR_FREE(compression);
goto error;
@@ -6431,7 +6431,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
}
if ((modeVal =
virDomainGraphicsSpiceStreamingModeTypeFromString(mode)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unknown spice streaming mode"));
VIR_FREE(mode);
goto error;
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 41864be..5550c95 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -519,7 +519,7 @@ virNetworkDNSHostsDefParseXML(virNetworkDNSDefPtr def,
if (!(ip = virXMLPropString(node, "ip")) ||
(virSocketAddrParse(&inaddr, ip, AF_UNSPEC) < 0)) {
- virReportError(VIR_ERR_XML_DETAIL,
+ virReportError(VIR_ERR_XML_DETAIL, "%s",
_("Missing IP address in DNS host definition"));
VIR_FREE(ip);
goto error;
@@ -1086,7 +1086,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
nForwardPfs = virXPathNodeSet("./pf", ctxt, &forwardPfNodes);
if (nForwardIfs < 0 || nForwardPfs < 0) {
- virReportError(VIR_ERR_XML_ERROR,
+ virReportError(VIR_ERR_XML_ERROR, "%s",
_("No interface pool or SRIOV physical device given"));
goto error;
}
@@ -1098,7 +1098,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
}
if (forwardDev) {
- virReportError(VIR_ERR_XML_ERROR,
+ virReportError(VIR_ERR_XML_ERROR, "%s",
_("A forward Dev should not be used when using a SRIOV PF"));
goto error;
}
@@ -1116,7 +1116,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
forwardDev = NULL;
def->nForwardPfs++;
} else if (nForwardPfs > 1) {
- virReportError(VIR_ERR_XML_ERROR,
+ virReportError(VIR_ERR_XML_ERROR, "%s",
_("Use of more than one physical interface is not allowed"));
goto error;
}
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 70fadaa..2b68f41 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2,7 +2,7 @@
* nwfilter_conf.c: network filter XML processing
* (derived from storage_conf.c)
*
- * Copyright (C) 2006-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2012 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* Copyright (C) 2010-2011 IBM Corporation
@@ -2423,7 +2423,7 @@ virNWFilterIsValidChainName(const char *chainname)
}
if (chainname[strspn(chainname, VALID_CHAINNAME)] != 0) {
- virReportError(VIR_ERR_INVALID_ARG,
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Chain name contains invalid characters"));
return false;
}
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index d08e860..6481c84 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -113,7 +113,7 @@ virNWFilterVarValueCreateSimple(char *value)
virNWFilterVarValuePtr val;
if (!isValidVarValue(value)) {
- virReportError(VIR_ERR_INVALID_ARG,
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Variable value contains invalid character"));
return NULL;
}
@@ -998,10 +998,10 @@ virNWFilterVarAccessParse(const char *varAccess)
}
if (parseError) {
if (dest->accessType == VIR_NWFILTER_VAR_ACCESS_ELEMENT)
- virReportError(VIR_ERR_INVALID_ARG,
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Malformatted array index"));
else
- virReportError(VIR_ERR_INVALID_ARG,
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Malformatted iterator id"));
goto err_exit;
}
@@ -1026,7 +1026,7 @@ virNWFilterVarAccessParse(const char *varAccess)
return dest;
} else {
- virReportError(VIR_ERR_INVALID_ARG,
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Malformatted variable"));
}
diff --git a/src/datatypes.c b/src/datatypes.c
index d718170..c5c4717 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -1,7 +1,7 @@
/*
* datatypes.h: management of structs for public data types
*
- * Copyright (C) 2006-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2012 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
@@ -138,7 +138,7 @@ virUnrefConnect(virConnectPtr conn) {
int refs;
if ((!VIR_IS_CONNECT(conn))) {
- virLibConnError(VIR_ERR_INVALID_CONN, _("no connection"));
+ virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection"));
return -1;
}
virMutexLock(&conn->lock);
@@ -173,7 +173,7 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(VIR_ERR_INVALID_CONN, _("no connection"));
+ virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection"));
return NULL;
}
virCheckNonNullArgReturn(name, NULL);
@@ -264,7 +264,8 @@ virUnrefDomain(virDomainPtr domain) {
int refs;
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibConnError(VIR_ERR_INVALID_DOMAIN, _("bad domain or no connection"));
+ virLibConnError(VIR_ERR_INVALID_DOMAIN, "%s",
+ _("bad domain or no connection"));
return -1;
}
virMutexLock(&domain->conn->lock);
@@ -300,7 +301,7 @@ virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(VIR_ERR_INVALID_CONN, _("no connection"));
+ virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection"));
return NULL;
}
virCheckNonNullArgReturn(name, NULL);
@@ -389,7 +390,7 @@ virUnrefNetwork(virNetworkPtr network) {
int refs;
if (!VIR_IS_CONNECTED_NETWORK(network)) {
- virLibConnError(VIR_ERR_INVALID_NETWORK,
+ virLibConnError(VIR_ERR_INVALID_NETWORK, "%s",
_("bad network or no connection"));
return -1;
}
@@ -427,7 +428,7 @@ virGetInterface(virConnectPtr conn, const char *name, const char *mac) {
virInterfacePtr ret = NULL;
if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(VIR_ERR_INVALID_CONN, _("no connection"));
+ virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection"));
return NULL;
}
virCheckNonNullArgReturn(name, NULL);
@@ -522,7 +523,7 @@ virUnrefInterface(virInterfacePtr iface) {
int refs;
if (!VIR_IS_CONNECTED_INTERFACE(iface)) {
- virLibConnError(VIR_ERR_INVALID_INTERFACE,
+ virLibConnError(VIR_ERR_INVALID_INTERFACE, "%s",
_("bad interface or no connection"));
return -1;
}
@@ -561,7 +562,7 @@ virGetStoragePool(virConnectPtr conn, const char *name,
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(VIR_ERR_INVALID_CONN, _("no connection"));
+ virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection"));
return NULL;
}
virCheckNonNullArgReturn(name, NULL);
@@ -651,7 +652,7 @@ virUnrefStoragePool(virStoragePoolPtr pool) {
int refs;
if (!VIR_IS_CONNECTED_STORAGE_POOL(pool)) {
- virLibConnError(VIR_ERR_INVALID_STORAGE_POOL,
+ virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, "%s",
_("bad storage pool or no connection"));
return -1;
}
@@ -690,7 +691,7 @@ virGetStorageVol(virConnectPtr conn, const char *pool, const char *name,
virStorageVolPtr ret = NULL;
if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(VIR_ERR_INVALID_CONN, _("no connection"));
+ virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection"));
return NULL;
}
virCheckNonNullArgReturn(name, NULL);
@@ -790,7 +791,7 @@ virUnrefStorageVol(virStorageVolPtr vol) {
int refs;
if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) {
- virLibConnError(VIR_ERR_INVALID_STORAGE_VOL,
+ virLibConnError(VIR_ERR_INVALID_STORAGE_VOL, "%s",
_("bad storage volume or no connection"));
return -1;
}
@@ -827,7 +828,7 @@ virGetNodeDevice(virConnectPtr conn, const char *name)
virNodeDevicePtr ret = NULL;
if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(VIR_ERR_INVALID_CONN, _("no connection"));
+ virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection"));
return NULL;
}
virCheckNonNullArgReturn(name, NULL);
@@ -945,7 +946,7 @@ virGetSecret(virConnectPtr conn, const unsigned char *uuid,
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(VIR_ERR_INVALID_CONN, _("no connection"));
+ virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection"));
return NULL;
}
virCheckNonNullArgReturn(uuid, NULL);
@@ -1031,7 +1032,8 @@ virUnrefSecret(virSecretPtr secret) {
int refs;
if (!VIR_IS_CONNECTED_SECRET(secret)) {
- virLibConnError(VIR_ERR_INVALID_SECRET, _("bad secret or no connection"));
+ virLibConnError(VIR_ERR_INVALID_SECRET, "%s",
+ _("bad secret or no connection"));
return -1;
}
virMutexLock(&secret->conn->lock);
@@ -1126,7 +1128,7 @@ virGetNWFilter(virConnectPtr conn, const char *name, const unsigned char *uuid)
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!VIR_IS_CONNECT(conn)) {
- virLibConnError(VIR_ERR_INVALID_CONN, _("no connection"));
+ virLibConnError(VIR_ERR_INVALID_CONN, "%s", _("no connection"));
return NULL;
}
virCheckNonNullArgReturn(name, NULL);
@@ -1218,7 +1220,7 @@ virUnrefNWFilter(virNWFilterPtr nwfilter)
int refs;
if (!VIR_IS_CONNECTED_NWFILTER(nwfilter)) {
- virLibConnError(VIR_ERR_INVALID_NWFILTER,
+ virLibConnError(VIR_ERR_INVALID_NWFILTER, "%s",
_("bad nwfilter or no connection"));
return -1;
}
@@ -1244,7 +1246,7 @@ virGetDomainSnapshot(virDomainPtr domain, const char *name)
virDomainSnapshotPtr ret = NULL;
if (!VIR_IS_DOMAIN(domain)) {
- virLibConnError(VIR_ERR_INVALID_DOMAIN, _("bad domain"));
+ virLibConnError(VIR_ERR_INVALID_DOMAIN, "%s", _("bad domain"));
return NULL;
}
virCheckNonNullArgReturn(name, NULL);
@@ -1307,7 +1309,8 @@ virUnrefDomainSnapshot(virDomainSnapshotPtr snapshot)
int refs;
if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) {
- virLibConnError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, _("not a snapshot"));
+ virLibConnError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT, "%s",
+ _("not a snapshot"));
return -1;
}
diff --git a/src/libvirt.c b/src/libvirt.c
index 8315b4f..1ed9e32 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2555,7 +2555,7 @@ virDomainSave(virDomainPtr domain, const char *to)
/* We must absolutize the file path as the save is done out of process */
if (virFileAbsPath(to, &absolute_to) < 0) {
- virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute output file path"));
goto error;
}
@@ -2650,7 +2650,7 @@ virDomainSaveFlags(virDomainPtr domain, const char *to,
/* We must absolutize the file path as the save is done out of process */
if (virFileAbsPath(to, &absolute_to) < 0) {
- virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute output file path"));
goto error;
}
@@ -2706,7 +2706,7 @@ virDomainRestore(virConnectPtr conn, const char *from)
/* We must absolutize the file path as the restore is done out of process */
if (virFileAbsPath(from, &absolute_from) < 0) {
- virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute input file path"));
goto error;
}
@@ -2788,7 +2788,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,
/* We must absolutize the file path as the restore is done out of process */
if (virFileAbsPath(from, &absolute_from) < 0) {
- virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute input file path"));
goto error;
}
@@ -2845,7 +2845,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
virCheckNonNullArgGoto(file, error);
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
- virLibConnError(VIR_ERR_OPERATION_DENIED,
+ virLibConnError(VIR_ERR_OPERATION_DENIED, "%s",
_("virDomainSaveImageGetXMLDesc with secure flag"));
goto error;
}
@@ -2856,7 +2856,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
/* We must absolutize the file path as the read is done out of process */
if (virFileAbsPath(file, &absolute_file) < 0) {
- virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute input file path"));
goto error;
}
@@ -2937,7 +2937,7 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file,
/* We must absolutize the file path as the read is done out of process */
if (virFileAbsPath(file, &absolute_file) < 0) {
- virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute input file path"));
goto error;
}
@@ -3029,7 +3029,7 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags)
/* We must absolutize the file path as the save is done out of process */
if (virFileAbsPath(to, &absolute_to) < 0) {
- virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute core file path"));
goto error;
}
@@ -4341,7 +4341,7 @@ virDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
conn = domain->conn;
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
- virLibConnError(VIR_ERR_OPERATION_DENIED,
+ virLibConnError(VIR_ERR_OPERATION_DENIED, "%s",
_("virDomainGetXMLDesc with secure flag"));
goto error;
}
@@ -4523,7 +4523,7 @@ virDomainMigrateVersion1 (virDomainPtr domain,
goto done;
if (uri == NULL && uri_out == NULL) {
- virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domainMigratePrepare did not set uri"));
goto done;
}
@@ -4635,7 +4635,7 @@ virDomainMigrateVersion2 (virDomainPtr domain,
goto done;
if (uri == NULL && uri_out == NULL) {
- virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domainMigratePrepare2 did not set uri"));
virDispatchError(domain->conn);
cancelled = 1;
@@ -4781,7 +4781,7 @@ virDomainMigrateVersion3(virDomainPtr domain,
}
if (uri == NULL && uri_out == NULL) {
- virLibConnError(VIR_ERR_INTERNAL_ERROR,
+ virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domainMigratePrepare3 did not set uri"));
virDispatchError(domain->conn);
goto finish;
@@ -5198,7 +5198,7 @@ virDomainMigrate (virDomainPtr domain,
}
flags &= ~VIR_MIGRATE_CHANGE_PROTECTION;
if (flags & VIR_MIGRATE_TUNNELLED) {
- virLibConnError(VIR_ERR_OPERATION_INVALID,
+ virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot perform tunnelled migration without using peer2peer flag"));
goto error;
}
@@ -5400,7 +5400,7 @@ virDomainMigrate2(virDomainPtr domain,
}
flags &= ~VIR_MIGRATE_CHANGE_PROTECTION;
if (flags & VIR_MIGRATE_TUNNELLED) {
- virLibConnError(VIR_ERR_OPERATION_INVALID,
+ virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot perform tunnelled migration without using peer2peer flag"));
goto error;
}
@@ -14951,7 +14951,7 @@ int virStreamSendAll(virStreamPtr stream,
virCheckNonNullArgGoto(handler, cleanup);
if (stream->flags & VIR_STREAM_NONBLOCK) {
- virLibConnError(VIR_ERR_OPERATION_INVALID,
+ virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
_("data sources cannot be used for non-blocking streams"));
goto cleanup;
}
@@ -15050,7 +15050,7 @@ int virStreamRecvAll(virStreamPtr stream,
virCheckNonNullArgGoto(handler, cleanup);
if (stream->flags & VIR_STREAM_NONBLOCK) {
- virLibConnError(VIR_ERR_OPERATION_INVALID,
+ virLibConnError(VIR_ERR_OPERATION_INVALID, "%s",
_("data sinks cannot be used for non-blocking streams"));
goto cleanup;
}
@@ -17040,7 +17040,7 @@ virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
conn = snapshot->domain->conn;
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
- virLibConnError(VIR_ERR_OPERATION_DENIED,
+ virLibConnError(VIR_ERR_OPERATION_DENIED, "%s",
_("virDomainSnapshotGetXMLDesc with secure flag"));
goto error;
}
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 09c64b2..a057bdd 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2023,7 +2023,8 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (!lxcCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_BLKIO)) {
- lxcError(VIR_ERR_OPERATION_INVALID, _("blkio cgroup isn't mounted"));
+ lxcError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("blkio cgroup isn't mounted"));
goto cleanup;
}
@@ -2127,7 +2128,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (!lxcCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_BLKIO)) {
- lxcError(VIR_ERR_OPERATION_INVALID, _("blkio cgroup isn't mounted"));
+ lxcError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("blkio cgroup isn't mounted"));
goto cleanup;
}
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index 0a12be5..1971e1a 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -2,6 +2,7 @@
* nwfilter_dhcpsnoop.c: support for DHCP snooping used by a VM
* on an interface
*
+ * Copyright (C) 2012 Red Hat, Inc.
* Copyright (C) 2011,2012 IBM Corp.
*
* Authors:
@@ -886,7 +887,7 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
if (req->techdriver &&
req->techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr,
dhcpsrvrs, false) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("virNWFilterSnoopListDel failed"));
ret = -1;
}
@@ -1633,7 +1634,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
if (techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr,
dhcpsrvrs, false) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("applyDHCPOnlyRules "
"failed - spoofing not protected!"));
goto exit_snoopreqput;
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index a144408..43819a4 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -2017,7 +2017,7 @@ openvzUpdateDevice(virDomainDefPtr vmdef,
|| cur->accessmode != fs->accessmode
|| cur->wrpolicy != fs->wrpolicy
|| cur->readonly != fs->readonly) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Can only modify disk quota"));
return -1;
}
diff --git a/src/openvz/openvz_util.c b/src/openvz/openvz_util.c
index a878dd6..17528a0 100644
--- a/src/openvz/openvz_util.c
+++ b/src/openvz/openvz_util.c
@@ -45,7 +45,7 @@ openvzKBPerPages(void)
if (kb_per_pages > 0) {
kb_per_pages /= 1024;
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Can't determine page size"));
kb_per_pages = 0;
return -1;
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index b93887c..9b59738 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -333,7 +333,7 @@ int qemuSetupCgroup(struct qemud_driver *driver,
}
}
} else {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Block I/O tuning is not available on this host"));
goto cleanup;
}
@@ -372,7 +372,7 @@ int qemuSetupCgroup(struct qemud_driver *driver,
}
}
} else {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Memory cgroup is not available on this host"));
}
}
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d6df4ee..1641929 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3424,7 +3424,7 @@ qemuBuildHubDevStr(virDomainHubDefPtr dev,
}
if (!qemuCapsGet(qemuCaps, QEMU_CAPS_USB_HUB)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("usb-hub not supported by QEMU binary"));
goto error;
}
@@ -3553,7 +3553,7 @@ qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
if (!qemuCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEVMC)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("spicevmc not supported in this QEMU binary"));
goto error;
}
@@ -4806,7 +4806,7 @@ qemuBuildCommandLine(virConnectPtr conn,
def->controllers[i]->model == -1 &&
!qemuCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI)) {
if (usblegacy) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Multiple legacy USB controller not supported"));
goto error;
}
@@ -5813,7 +5813,7 @@ qemuBuildCommandLine(virConnectPtr conn,
switch (mode) {
case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE:
if (!driver->spiceTLS) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("spice secure channels set in XML configuration, but TLS is disabled in qemu.conf"));
goto error;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ecd2ec1..79ca208 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12886,7 +12886,7 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
if (!map[i]) {
cpu_time = 0;
} else if (virStrToLong_ull(pos, &pos, 10, &cpu_time) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cpuacct parse error"));
goto cleanup;
} else {
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index d7e2a73..66ac683 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -832,7 +832,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
goto try_remove;
}
} else {
- virReportError(VIR_ERR_OPERATION_FAILED,
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("setting of link state not supported: Link is up"));
}
diff --git a/src/rpc/virnetsaslcontext.c b/src/rpc/virnetsaslcontext.c
index 9943057..d35d016 100644
--- a/src/rpc/virnetsaslcontext.c
+++ b/src/rpc/virnetsaslcontext.c
@@ -1,7 +1,7 @@
/*
* virnetsaslcontext.c: SASL encryption/auth handling
*
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 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
@@ -313,7 +313,7 @@ const char *virNetSASLSessionGetIdentity(virNetSASLSessionPtr sasl)
goto cleanup;
}
if (val == NULL) {
- virReportError(VIR_ERR_AUTH_FAILED,
+ virReportError(VIR_ERR_AUTH_FAILED, "%s",
_("no client username was found"));
goto cleanup;
}
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index aee3c19..87afa2c 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -482,7 +482,7 @@ int virNetSocketNewConnectUNIX(const char *path,
remoteAddr.len = sizeof(remoteAddr.data.un);
if (spawnDaemon && !binary) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Auto-spawn of daemon requested, but no binary specified"));
return -1;
}
@@ -1178,7 +1178,7 @@ int virNetSocketSendFD(virNetSocketPtr sock, int fd)
{
int ret = -1;
if (!virNetSocketHasPassFD(sock)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Sending file descriptors is not supported on this socket"));
return -1;
}
@@ -1212,7 +1212,7 @@ int virNetSocketRecvFD(virNetSocketPtr sock, int *fd)
*fd = -1;
if (!virNetSocketHasPassFD(sock)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Receiving file descriptors is not supported on this socket"));
return -1;
}
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 75d2927..fc3a9d2 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -1,7 +1,7 @@
/*
* storage_backend_disk.c: storage backend for disk handling
*
- * Copyright (C) 2007-2008, 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2007-2008, 2010-2012 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -399,7 +399,7 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
if (flags == (VIR_STORAGE_POOL_BUILD_OVERWRITE |
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Overwrite and no overwrite flags"
" are mutually exclusive"));
goto error;
@@ -415,10 +415,10 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
if (check > 0) {
ok_to_mklabel = true;
} else if (check < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Error checking for disk label"));
} else {
- virReportError(VIR_ERR_OPERATION_INVALID,
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Disk label already present"));
}
}
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 8da985e..cb5e3f3 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1,7 +1,7 @@
/*
* storage_backend_fs.c: storage backend for FS and directory handling
*
- * Copyright (C) 2007-2011 Red Hat, Inc.
+ * Copyright (C) 2007-2012 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -598,7 +598,7 @@ virStorageBackendFileSystemProbe(const char *device,
}
if (blkid_do_probe(probe) != 1) {
- virReportError(VIR_ERR_STORAGE_PROBE_FAILED,
+ virReportError(VIR_ERR_STORAGE_PROBE_FAILED, "%s",
_("Found additional probes to run, "
"filesystem probing may be incorrect"));
ret = FILESYSTEM_PROBE_ERROR;
@@ -620,7 +620,7 @@ static virStoragePoolProbeResult
virStorageBackendFileSystemProbe(const char *device ATTRIBUTE_UNUSED,
const char *format ATTRIBUTE_UNUSED)
{
- virReportError(VIR_ERR_OPERATION_INVALID,
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("probing for filesystems is unsupported "
"by this build"));
@@ -743,7 +743,7 @@ virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
if (flags == (VIR_STORAGE_POOL_BUILD_OVERWRITE |
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Overwrite and no overwrite flags"
" are mutually exclusive"));
goto error;
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 4df0b54..185ad0e 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -65,7 +65,7 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr,
VIR_DEBUG("Using cephx authorization");
if (rados_create(&ptr->cluster,
pool->def->source.auth.cephx.username) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to initialize RADOS"));
goto cleanup;
}
@@ -84,7 +84,7 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr,
}
if (secret == NULL) {
- virReportError(VIR_ERR_NO_SECRET,
+ virReportError(VIR_ERR_NO_SECRET, "%s",
_("failed to find the secret"));
goto cleanup;
}
@@ -95,7 +95,7 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr,
memset(secret_value, 0, secret_value_size);
if (rados_key == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to decode the RADOS key"));
goto cleanup;
}
@@ -119,7 +119,7 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr,
} else {
VIR_DEBUG("Not using cephx authorization");
if (rados_create(&ptr->cluster, NULL) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to create the RADOS cluster"));
goto cleanup;
}
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index c9b8021..e83b1e5 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1715,13 +1715,13 @@ storageVolumeResize(virStorageVolPtr obj,
storageDriverUnlock(driver);
if (!pool) {
- virReportError(VIR_ERR_NO_STORAGE_POOL,
+ virReportError(VIR_ERR_NO_STORAGE_POOL, "%s",
_("no storage pool with matching uuid"));
goto out;
}
if (!virStoragePoolObjIsActive(pool)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("storage pool is not active"));
goto out;
}
@@ -1753,20 +1753,20 @@ storageVolumeResize(virStorageVolPtr obj,
}
if (abs_capacity < vol->allocation) {
- virReportError(VIR_ERR_INVALID_ARG,
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("can't shrink capacity below "
"existing allocation"));
goto out;
}
if (abs_capacity > vol->capacity + pool->def->available) {
- virReportError(VIR_ERR_OPERATION_FAILED,
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Not enough space left on storage pool"));
goto out;
}
if (!backend->resizeVol) {
- virReportError(VIR_ERR_NO_SUPPORT,
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("storage pool does not support changing of "
"volume capacity"));
goto out;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 990b20d..a36af7e 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3534,7 +3534,7 @@ static int testInterfaceChangeBegin(virConnectPtr conn,
testDriverLock(privconn);
if (privconn->transaction_running) {
- virReportError(VIR_ERR_OPERATION_INVALID,
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("there is another transaction running."));
goto cleanup;
}
@@ -3562,7 +3562,7 @@ static int testInterfaceChangeCommit(virConnectPtr conn,
testDriverLock(privconn);
if (!privconn->transaction_running) {
- virReportError(VIR_ERR_OPERATION_INVALID,
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("no transaction running, "
"nothing to be committed."));
goto cleanup;
@@ -3590,7 +3590,7 @@ static int testInterfaceChangeRollback(virConnectPtr conn,
testDriverLock(privconn);
if (!privconn->transaction_running) {
- virReportError(VIR_ERR_OPERATION_INVALID,
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("no transaction running, "
"nothing to rollback."));
goto cleanup;
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 17e7e9a..b672b24 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -9311,7 +9311,7 @@ vboxListAllDomains(virConnectPtr conn,
if (MATCH(VIR_CONNECT_LIST_FILTERS_SNAPSHOT)) {
rc = machine->vtbl->GetSnapshotCount(machine, &snapshotCount);
if (NS_FAILED(rc)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get snapshot count for listed domains"));
goto cleanup;
}
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 42533ce..4e005f4 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -1870,7 +1870,7 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
else
virBufferAddLit(buf, "(mode 'w')");
if (def->transient) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("transient disks not supported yet"));
return -1;
}
@@ -2515,7 +2515,7 @@ xenFormatSxpr(virConnectPtr conn,
break;
case VIR_DOMAIN_CLOCK_OFFSET_UTC:
if (def->clock.data.utc_reset) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported clock adjustment='reset'"));
goto error;
}
@@ -2524,7 +2524,7 @@ xenFormatSxpr(virConnectPtr conn,
break;
case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
if (def->clock.data.utc_reset) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported clock adjustment='reset'"));
goto error;
}
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 99e736e..76c1faa 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -208,7 +208,7 @@ static int xenXMConfigGetUUID(virConfPtr conf, const char *name, unsigned char *
virConfValuePtr val;
if (!uuid || !name || !conf) {
- virReportError(VIR_ERR_INVALID_ARG,
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Arguments must be non null"));
return -1;
}
@@ -1242,7 +1242,7 @@ static int xenFormatXMDisk(virConfValuePtr list,
else
virBufferAddLit(&buf, ",w");
if (disk->transient) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("transient disks not supported yet"));
return -1;
}
@@ -1686,7 +1686,7 @@ virConfPtr xenFormatXM(virConnectPtr conn,
break;
case VIR_DOMAIN_CLOCK_OFFSET_UTC:
if (def->clock.data.utc_reset) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported clock adjustment='reset'"));
goto cleanup;
}
@@ -1695,7 +1695,7 @@ virConfPtr xenFormatXM(virConnectPtr conn,
break;
case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
if (def->clock.data.utc_reset) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported clock adjustment='reset'"));
goto cleanup;
}
--
1.7.10.4
12 years, 5 months
[libvirt] [PATCH v8 0/8] Add basic driver for Parallels Virtuozzo Server
by Dmitry Guryanov
Parallels Cloud Server is a virtualization solution
that allows users to simultaneously run multiple virtual
machines and containers on the same physical server.
More information can be found here: http://www.parallels.com/products/pcs/
Also beta version of Parallels Cloud Server can be downloaded there.
Dmitry Guryanov (8):
parallels: add driver skeleton
parallels: add functions to list domains and get info
parallels: implement functions for domain life cycle management
parallels: get info about serial ports
parallels: add support of VNC remote display
parallels: implement virDomainDefineXML operation for existing
domains
parallels: add storage driver
parallels: implement VM creation
cfg.mk | 1 +
configure.ac | 23 +
docs/drvparallels.html.in | 28 +
include/libvirt/virterror.h | 2 +-
libvirt.spec.in | 9 +-
po/POTFILES.in | 4 +
src/Makefile.am | 15 +
src/conf/domain_conf.c | 3 +-
src/conf/domain_conf.h | 1 +
src/driver.h | 1 +
src/libvirt.c | 9 +
src/parallels/parallels_driver.c | 1309 +++++++++++++++++++++++++++++++++
src/parallels/parallels_driver.h | 75 ++
src/parallels/parallels_storage.c | 1456 +++++++++++++++++++++++++++++++++++++
src/parallels/parallels_utils.c | 131 ++++
src/util/virterror.c | 3 +-
16 files changed, 3066 insertions(+), 4 deletions(-)
create mode 100644 docs/drvparallels.html.in
create mode 100644 src/parallels/parallels_driver.c
create mode 100644 src/parallels/parallels_driver.h
create mode 100644 src/parallels/parallels_storage.c
create mode 100644 src/parallels/parallels_utils.c
12 years, 5 months
[libvirt] [PATCH 0/6 v3] Support forward mode='hostdev' and interface pools
by Shradha Shah
This patch series supports the forward mode='hostdev'. The functionality
of this mode is the same as interface type='hostdev' but with the added
benefit of using interface pools.
The patch series also contains a patch to support use of interface names
and PCI device addresses interchangeably in a network xml, and return
the appropriate one in actualDevice when networkAllocateActualDevice is
called.
At the top level managed attribute can be specified with identical results
as when it's specified for a hostdev.
Currently forward mode='hostdev' does not support USB devices.
Shradha Shah (6):
Prerequisite Patch. virDomainDevicePCIAddress and respective
functions moved to a new file called conf/device_conf.ch
Moved the code to create implicit interface pool from PF to a new
function
RNG updates, new xml parser/formatter code to support forward
mode=hostdev
Code to return interface name or pci_addr of the VF in actualDevice
Forward Mode Hostdev network driver Implementation
Forward Mode 'Hostdev' qemu driver implementation
docs/formatnetwork.html.in | 62 ++++++
docs/schemas/network.rng | 82 ++++++++-
include/libvirt/virterror.h | 1 +
src/Makefile.am | 7 +-
src/conf/device_conf.c | 135 +++++++++++++
src/conf/device_conf.h | 65 +++++++
src/conf/domain_conf.c | 114 ++----------
src/conf/domain_conf.h | 25 +---
src/conf/network_conf.c | 126 +++++++++++--
src/conf/network_conf.h | 29 +++-
src/libvirt_private.syms | 10 +-
src/network/bridge_driver.c | 322 +++++++++++++++++++++++++-------
src/qemu/qemu_command.c | 27 ++-
src/qemu/qemu_hotplug.c | 7 +-
src/qemu/qemu_monitor.c | 14 +-
src/qemu/qemu_monitor.h | 17 +-
src/qemu/qemu_monitor_json.c | 14 +-
src/qemu/qemu_monitor_json.h | 14 +-
src/qemu/qemu_monitor_text.c | 16 +-
src/qemu/qemu_monitor_text.h | 14 +-
src/util/virnetdev.c | 29 ++--
src/util/virnetdev.h | 4 +-
src/xen/xend_internal.c | 3 +-
tests/networkxml2xmlin/hostdev-pf.xml | 11 +
tests/networkxml2xmlin/hostdev.xml | 10 +
tests/networkxml2xmlout/hostdev-pf.xml | 7 +
tests/networkxml2xmlout/hostdev.xml | 10 +
tests/networkxml2xmltest.c | 2 +
28 files changed, 890 insertions(+), 287 deletions(-)
create mode 100644 src/conf/device_conf.c
create mode 100644 src/conf/device_conf.h
create mode 100644 tests/networkxml2xmlin/hostdev-pf.xml
create mode 100644 tests/networkxml2xmlin/hostdev.xml
create mode 100644 tests/networkxml2xmlout/hostdev-pf.xml
create mode 100644 tests/networkxml2xmlout/hostdev.xml
--
1.7.4.4
12 years, 5 months
[libvirt] [PATCH] virsh: check if specified debug level is in range
by Ján Tomko
---
tools/virsh.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 5658796..34ae171 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3097,6 +3097,10 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
vshError(ctl, "%s", _("option -d takes a numeric argument"));
exit(EXIT_FAILURE);
}
+ if (ctl->debug < VSH_ERR_DEBUG || ctl->debug > VSH_ERR_ERROR) {
+ vshError(ctl, _("ignoring debug level %d out of range [0-4]"),
+ ctl->debug);
+ }
break;
case 'h':
vshUsage();
--
1.7.8.6
12 years, 5 months
[libvirt] No /dev/tty device within LXC guest?
by Yufang Zhang
Hi all,
When I create a LXC guest(RHEL5.4) via libvirt, the guest could boot
successfully. I could ping to guest, but can not ssh into the it. The
secure log in the guest shows that this is due to lack of '/dev/tty' device:
# tail /path/to/rootfs/of/container/var/log/secure
Jul 27 04:25:25 xen2143v sshd[671]: Accepted password for zhangyufang from
10.0.0.1 port 34102 ssh2
Jul 27 04:25:25 xen2143v sshd[671]: pam_unix(sshd:session): session opened
for user zhangyufang by (uid=0)
Jul 27 04:25:25 xen2143v sshd[671]: pam_loginuid(sshd:session):
set_loginuid failed
*Jul 27 04:25:25 xen2143v sshd[671]: error: PAM: pam_open_session(): Cannot
make/remove an entry for the specified session*
*Jul 27 04:25:25 xen2143v sshd[674]: error: open /dev/tty failed - could
not set controlling tty: No such file or directory*
*Jul 27 04:25:25 xen2143v sshd[673]: Received disconnect from 10.0.0.1: 11:
disconnected by user*
The xml of the guest:
# virsh --connect lxc:/// dumpxml instance-00000034
<domain type='lxc' id='30090'>
<name>instance-00000034</name>
<uuid>8387e0f1-6df3-41c8-82ba-cde7d2b60844</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='x86_64'>exe</type>
<init>/sbin/init</init>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/libvirt_lxc</emulator>
<filesystem type='mount' accessmode='passthrough'>
<source dir='/var/lib/nova/instances/instance-00000034/rootfs'/>
<target dir='/'/>
</filesystem>
<interface type='bridge'>
<mac address='fa:16:3e:3c:1d:95'/>
<source bridge='demonetbr0'/>
<target dev='veth0'/>
<filterref filter='nova-instance-instance-00000034-fa163e3c1d95'>
<parameter name='DHCPSERVER' value='10.0.0.1'/>
<parameter name='IP' value='10.0.0.3'/>
</filterref>
</interface>
<console type='pty' tty='/dev/pts/0'>
<source path='/dev/pts/0'/>
<target type='serial' port='0'/>
</console>
</devices>
</domain>
Could anyone point me to where the problem is? Thanks.
Best Regards.
Yufang
12 years, 5 months
[libvirt] [PATCH 0/2] Refactor and fix error resetting on fallback paths in virsh
by Peter Krempa
This series fixes places where errors were not reset correctly and adds a
function for resetting libvirt errors in virsh.
Peter Krempa (2):
virsh: Refactor error clearing on graceful fallback paths
virsh: Fix error resetting on fallback paths
tools/virsh-domain-monitor.c | 16 ++++++----------
tools/virsh-domain.c | 35 ++++++++++++-----------------------
tools/virsh-network.c | 3 +--
tools/virsh-pool.c | 3 +--
tools/virsh-snapshot.c | 19 +++++++------------
tools/virsh.c | 13 +++++++++++--
6 files changed, 38 insertions(+), 51 deletions(-)
--
1.7.8.6
12 years, 5 months
[libvirt] [PATCH v3][PATCH] add test case for block job lifecycle testing
by Kyla Zhang
v3: Add skip for block_pull not implemented
v2: Add skip block for qemu only and 120s timeout for test
v1: Add tests for block job lifecyle and the test flow is as follows:
create 50M qed img with qed backing img->
block pull->abort block job->resume block pull->set block job speed->
wait to finish
---
scripts/qemu/300-blockjob-lifecycle.t | 146 +++++++++++++++++++++++++++++++++
1 files changed, 146 insertions(+), 0 deletions(-)
create mode 100644 scripts/qemu/300-blockjob-lifecycle.t
diff --git a/scripts/qemu/300-blockjob-lifecycle.t b/scripts/qemu/300-blockjob-lifecycle.t
new file mode 100644
index 0000000..e43dfe2
--- /dev/null
+++ b/scripts/qemu/300-blockjob-lifecycle.t
@@ -0,0 +1,146 @@
+# -*- perl -*-
+#
+# Copyright (C) 2011-2012 Red Hat, Inc.
+# Copyright (C) 2011 Xiaoqiang Hu <xhu redhat com>
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+qemu/300-blockjob-lifecycle.t - verify the lifecycle of block job:
+block pull, set block job speed, get block job info and abort block job
+
+=head1 DESCRIPTION
+
+The test case validates that it is possible to block pull, set block job
+speed, get block job info and abort block job for domain using qed img
+with qed backing img
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 16;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+use File::Spec::Functions qw(catfile);
+use File::stat;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END {
+ $tck->cleanup if $tck;
+}
+
+SKIP:{
+ skip "Only relevant to QEMU driver", 16 unless $conn->get_type() eq "QEMU";
+ my $xml = $tck->generic_pool("dir")
+ ->mode("0755")->as_xml;
+
+ diag "Defining transient storage pool $xml";
+ my $pool;
+
+ ok_pool(sub { $pool = $conn->define_storage_pool($xml) }, "define transient storage pool");
+ lives_ok(sub { $pool->build(0) }, "built storage pool");
+ lives_ok(sub { $pool->create }, "started storage pool");
+
+ my $volbackxml = $tck->generic_volume("tck-back", "qed", 1024*1024*50)->allocation(0)->as_xml;
+
+ my ($volback, $pathback);
+ diag "back $volbackxml";
+ ok_volume(sub { $volback = $pool->create_volume($volbackxml) }, "create qed backing file volume");
+
+ my $st;
+ $pathback = xpath($volback, "string(/volume/target/path)");
+ $st = stat($pathback);
+
+ ok($st, "path $pathback exists");
+
+ ok($st->size < 1024*1024, "size is < 1M");
+
+ my $volmainxml = $tck->generic_volume("tck-main", "qed", 1024*1024*50)
+ ->backing_file($pathback)
+ ->backing_format("qed")
+ ->allocation(0)->as_xml;
+
+ my ($volmain, $pathmain);
+ diag "main $volmainxml";
+ ok_volume(sub { $volmain = $pool->create_volume($volmainxml) }, "create qed backing file volume");
+
+ $pathmain = xpath($volmain, "string(/volume/target/path)");
+ $st = stat($pathmain);
+
+ ok($st, "path $pathmain exists");
+
+ ok($st->size < 1024*1024, "size is < 1M");
+
+ # define the guest at a qed image
+ # and the backing store in this qed image.
+ $xml = $tck->generic_domain("tck")
+ ->disk(format => { name => "qemu", type => "qed" },
+ type => "file",
+ src => $pathmain,
+ dst => "vdb")
+ ->as_xml;
+
+ diag "Defining an inactive domain config $xml";
+ my $dom;
+ ok_domain(sub { $dom = $conn->define_domain($xml) }, "defined persistent domain config");
+
+ diag "Starting inactive domain config";
+ $dom->create;
+ ok($dom->get_id() > 0, "running domain has an ID > 0");
+
+ # start to block pull and bandwidth is 1MB/S
+ my ($bandwidth, $flags, $jobinfo, $timeout);
+ # 1MB/S
+ $bandwidth = 1;
+ $flags=0;
+ eval { $dom->block_pull($pathmain, $bandwidth, $flags); };
+ SKIP: {
+ skip "block_pull not implemented", 5 if $@ && $@->code() == 55;
+
+ # $jobinfo is a hash reference summarising the execution state of the block job
+ # and it has four keys:cur, end, bandwidth, type
+ $jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ ok($jobinfo->{bandwidth} == $bandwidth, "start to block pull and block job bandwidth is $bandwidth"."MB/S");
+
+ $dom->abort_block_job($pathmain, $flags);
+ $jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ ok($jobinfo->{type} == 0, "abort block job");
+
+ $dom->block_pull($pathmain, $bandwidth, $flags);
+ $jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ ok($jobinfo->{bandwidth} == $bandwidth, "continue to block pull and block job bandwidth is $bandwidth"."MB/S");
+
+ # set block job bandwidth to 2MB/S
+ $bandwidth = 2;
+ $dom->set_block_job_speed($pathmain, $bandwidth, $flags);
+ $jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ ok($jobinfo->{bandwidth} == $bandwidth, "block job bandwidth is set to $bandwidth"."MB/S");
+
+ # wait for the end of block pull and timeout is 120s
+ $timeout = 120;
+ while($jobinfo->{cur} < $jobinfo->{end} && $jobinfo->{type} == 1 && $timeout > 0) {
+ sleep(1);
+ $jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ $timeout--;
+ }
+
+ diag "block pull is not finished in 120S" if $jobinfo->{type} == 1 && $timeout == 0;
+ ok($jobinfo->{type} == 0, "block pull is finished");
+ }
+}
+# end
--
1.7.1
12 years, 5 months
[libvirt] [PATCH] virsh: Check for existence of storage before undefining the domain
by Peter Krempa
When undefining a domain and removing associated storage using "virsh
undefine --storage" the domain was at first undefined and after that the
storage removal proces was started. If the user specified an invalid
disk to remove, the error could not be corrected.
This patch moves enumeration and filtering of volumes that should be
removed before the domain is undefined, but the removal process is still
kept after the domain has been undefined.
---
tools/virsh.c | 280 +++++++++++++++++++++++++++++----------------------------
1 files changed, 144 insertions(+), 136 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 0354822..e6b8e5f 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3007,6 +3007,12 @@ static const vshCmdOptDef opts_undefine[] = {
{NULL, 0, 0, NULL}
};
+typedef struct {
+ virStorageVolPtr vol;
+ char *source;
+ char *target;
+} vshUndefineVolume;
+
static bool
cmdUndefine(vshControl *ctl, const vshCmd *cmd)
{
@@ -3019,7 +3025,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
bool managed_save = vshCommandOptBool(cmd, "managed-save");
bool snapshots_metadata = vshCommandOptBool(cmd, "snapshots-metadata");
bool wipe_storage = vshCommandOptBool(cmd, "wipe-storage");
- bool remove_storage = false;
bool remove_all_storage = vshCommandOptBool(cmd, "remove-all-storage");
/* Positive if these items exist. */
int has_managed_save = 0;
@@ -3031,6 +3036,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
int rc = -1;
int running;
/* list of volumes to remove along with this domain */
+ vshUndefineVolume *vlist = NULL;
+ int nvols = 0;
const char *volumes_arg = NULL;
char *volumes = NULL;
char **volume_tokens = NULL;
@@ -3045,8 +3052,10 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
xmlXPathContextPtr ctxt = NULL;
xmlNodePtr *vol_nodes = NULL;
int nvolumes = 0;
- virStorageVolPtr vol = NULL;
- bool vol_del_failed = false;
+ bool vol_not_found = false;
+
+ ignore_value(vshCommandOptString(cmd, "storage", &volumes_arg));
+ volumes = vshStrdup(ctl, volumes_arg);
if (managed_save) {
flags |= VIR_DOMAIN_UNDEFINE_MANAGED_SAVE;
@@ -3063,36 +3072,21 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false;
- /* check if a string that should contain list of volumes to remove is present */
- if (vshCommandOptString(cmd, "storage", &volumes_arg) > 0) {
- volumes = vshStrdup(ctl, volumes_arg);
-
- if (remove_all_storage) {
- vshError(ctl, _("Specified both --storage and --remove-all-storage"));
- goto cleanup;
- }
- remove_storage = true;
- }
-
/* Do some flag manipulation. The goal here is to disable bits
* from flags to reduce the likelihood of a server rejecting
* unknown flag bits, as well as to track conditions which are
* safe by default for the given hypervisor and server version. */
- running = virDomainIsActive(dom);
- if (running < 0) {
- virshReportError(ctl);
- goto cleanup;
- }
+ if ((running = virDomainIsActive(dom)) < 0)
+ goto error;
+
if (!running) {
/* Undefine with snapshots only fails for inactive domains,
* and managed save only exists on inactive domains; if
* running, then we don't want to remove anything. */
has_managed_save = virDomainHasManagedSaveImage(dom, 0);
if (has_managed_save < 0) {
- if (last_error->code != VIR_ERR_NO_SUPPORT) {
- virshReportError(ctl);
- goto cleanup;
- }
+ if (last_error->code != VIR_ERR_NO_SUPPORT)
+ goto error;
virFreeError(last_error);
last_error = NULL;
has_managed_save = 0;
@@ -3100,10 +3094,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
has_snapshots = virDomainSnapshotNum(dom, 0);
if (has_snapshots < 0) {
- if (last_error->code != VIR_ERR_NO_SUPPORT) {
- virshReportError(ctl);
- goto cleanup;
- }
+ if (last_error->code != VIR_ERR_NO_SUPPORT)
+ goto error;
virFreeError(last_error);
last_error = NULL;
has_snapshots = 0;
@@ -3137,16 +3129,116 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
}
/* Stash domain description for later use */
- if (remove_storage || remove_all_storage) {
+ if (volumes || remove_all_storage) {
if (running) {
vshError(ctl, _("Storage volume deletion is supported only on stopped domains"));
goto cleanup;
}
+ if (volumes && remove_all_storage) {
+ vshError(ctl, _("Specified both --storage and --remove-all-storage"));
+ goto cleanup;
+ }
+
if (!(def = virDomainGetXMLDesc(dom, 0))) {
vshError(ctl, _("Could not retrieve domain XML description"));
goto cleanup;
}
+
+ if (!(doc = virXMLParseStringCtxt(def, _("(domain_definition)"),
+ &ctxt)))
+ goto error;
+
+ /* tokenize the string from user and save it's parts into an array */
+ if (volumes) {
+ /* count the delimiters */
+ volume_tok = volumes;
+ nvolume_tokens = 1; /* we need at least one member */
+ while (*volume_tok) {
+ if (*(volume_tok++) == ',')
+ nvolume_tokens++;
+ }
+
+ volume_tokens = vshCalloc(ctl, nvolume_tokens, sizeof(char *));
+
+ /* tokenize the input string */
+ nvolume_tokens = 0;
+ volume_tok = volumes;
+ do {
+ volume_tokens[nvolume_tokens] = strsep(&volume_tok, ",");
+ nvolume_tokens++;
+ } while (volume_tok);
+ }
+
+ if ((nvolumes = virXPathNodeSet("./devices/disk", ctxt,
+ &vol_nodes)) < 0)
+ goto error;
+
+ if (nvolumes > 0)
+ vlist = vshCalloc(ctl, nvolumes, sizeof(*vlist));
+
+ for (vol_i = 0; vol_i < nvolumes; vol_i++) {
+ ctxt->node = vol_nodes[vol_i];
+
+ /* get volume source and target paths */
+ if (!(target = virXPathString("string(./target/@dev)", ctxt)))
+ goto error;
+
+ if (!(source = virXPathString("string("
+ "./source/@file|"
+ "./source/@dir|"
+ "./source/@name|"
+ "./source/@dev)", ctxt))) {
+ if (last_error && last_error->code != VIR_ERR_OK)
+ goto error;
+ else
+ continue;
+ }
+
+ /* lookup if volume was selected by user */
+ if (volumes) {
+ volume_tok = NULL;
+ for (tok_i = 0; tok_i < nvolume_tokens; tok_i++) {
+ if (volume_tokens[tok_i] &&
+ (STREQ(volume_tokens[tok_i], target) ||
+ STREQ(volume_tokens[tok_i], source))) {
+ volume_tok = volume_tokens[tok_i];
+ volume_tokens[tok_i] = NULL;
+ break;
+ }
+ }
+ if (!volume_tok)
+ continue;
+ }
+
+ if (!(vlist[nvols].vol = virStorageVolLookupByPath(ctl->conn,
+ source))) {
+ vshPrint(ctl,
+ _("Storage volume '%s'(%s) is not managed by libvirt. "
+ "Remove it manually.\n"), target, source);
+ virFreeError(last_error);
+ last_error = NULL;
+ continue;
+ }
+ vlist[nvols].source = source;
+ vlist[nvols].target = target;
+ nvols++;
+ }
+
+ /* print volumes specified by user that were not found in domain definition */
+ if (volumes) {
+ for (tok_i = 0; tok_i < nvolume_tokens; tok_i++) {
+ if (volume_tokens[tok_i]) {
+ vshError(ctl, _("Volume '%s' was not found in domain's "
+ "definition.\n"),
+ volume_tokens[tok_i]);
+ vol_not_found = true;
+ }
+ }
+
+ if (vol_not_found)
+ goto cleanup;
+ }
}
/* Generally we want to try the new API first. However, while
@@ -3202,96 +3294,15 @@ out:
}
/* try to undefine storage volumes associated with this domain, if it's requested */
- if (remove_storage || remove_all_storage) {
- ret = false;
-
- /* tokenize the string from user and save it's parts into an array */
- if (volumes) {
- /* count the delimiters */
- volume_tok = volumes;
- nvolume_tokens = 1; /* we need at least one member */
- while (*volume_tok) {
- if (*volume_tok == ',')
- nvolume_tokens++;
- volume_tok++;
- }
-
- volume_tokens = vshCalloc(ctl, nvolume_tokens, sizeof(char *));
-
- /* tokenize the input string */
- nvolume_tokens = 0;
- volume_tok = volumes;
- do {
- volume_tokens[nvolume_tokens] = strsep(&volume_tok, ",");
- nvolume_tokens++;
- } while (volume_tok);
- }
-
- doc = virXMLParseStringCtxt(def, _("(domain_definition)"), &ctxt);
- if (!doc)
- goto cleanup;
-
- nvolumes = virXPathNodeSet("./devices/disk", ctxt, &vol_nodes);
-
- if (nvolumes < 0)
- goto cleanup;
-
- for (vol_i = 0; vol_i < nvolumes; vol_i++) {
- ctxt->node = vol_nodes[vol_i];
- VIR_FREE(target);
- VIR_FREE(source);
- if (vol) {
- virStorageVolFree(vol);
- vol = NULL;
- }
-
- /* get volume source and target paths */
- if (!(target = virXPathString("string(./target/@dev)", ctxt))) {
- vshError(ctl, _("Failed to enumerate devices"));
- goto cleanup;
- }
-
- if (!(source = virXPathString("string("
- "./source/@file|"
- "./source/@dir|"
- "./source/@name|"
- "./source/@dev)", ctxt)) &&
- virGetLastError())
- goto cleanup;
-
- /* lookup if volume was selected by user */
- if (volumes) {
- volume_tok = NULL;
- for (tok_i = 0; tok_i < nvolume_tokens; tok_i++) {
- if (volume_tokens[tok_i] &&
- (STREQ_NULLABLE(volume_tokens[tok_i], target) ||
- STREQ_NULLABLE(volume_tokens[tok_i], source))) {
- volume_tok = volume_tokens[tok_i];
- volume_tokens[tok_i] = NULL;
- break;
- }
- }
- if (!volume_tok)
- continue;
- }
-
- if (!source)
- continue;
-
- if (!(vol = virStorageVolLookupByPath(ctl->conn, source))) {
- vshPrint(ctl,
- _("Storage volume '%s'(%s) is not managed by libvirt. "
- "Remove it manually.\n"), target, source);
- virResetLastError();
- continue;
- }
-
+ if (nvols) {
+ for (vol_i = 0; vol_i < nvols; vol_i++) {
if (wipe_storage) {
- vshPrint(ctl, _("Wiping volume '%s'(%s) ... "), target, source);
+ vshPrint(ctl, _("Wiping volume '%s'(%s) ... "),
+ vlist[vol_i].target, vlist[vol_i].source);
fflush(stdout);
- if (virStorageVolWipe(vol, 0) < 0) {
+ if (virStorageVolWipe(vlist[vol_i].vol, 0) < 0) {
vshError(ctl, _("Failed! Volume not removed."));
- vol_del_failed = true;
+ ret = false;
continue;
} else {
vshPrint(ctl, _("Done.\n"));
@@ -3299,41 +3310,38 @@ out:
}
/* delete the volume */
- if (virStorageVolDelete(vol, 0) < 0) {
+ if (virStorageVolDelete(vlist[vol_i].vol, 0) < 0) {
vshError(ctl, _("Failed to remove storage volume '%s'(%s)"),
- target, source);
- vol_del_failed = true;
- }
- vshPrint(ctl, _("Volume '%s' removed.\n"), volume_tok?volume_tok:source);
- }
-
- /* print volumes specified by user that were not found in domain definition */
- if (volumes) {
- for (tok_i = 0; tok_i < nvolume_tokens; tok_i++) {
- if (volume_tokens[tok_i])
- vshPrint(ctl, _("Volume '%s' was not found in domain's "
- "definition.\n"),
- volume_tokens[tok_i]);
+ vlist[vol_i].target, vlist[vol_i].source);
+ ret = false;
+ } else {
+ vshPrint(ctl, _("Volume '%s'(%s) removed.\n"),
+ vlist[vol_i].target, vlist[vol_i].source);
}
}
-
- if (!vol_del_failed)
- ret = true;
}
cleanup:
- VIR_FREE(source);
- VIR_FREE(target);
+ for (vol_i = 0; vol_i < nvols; vol_i++) {
+ VIR_FREE(vlist[vol_i].source);
+ VIR_FREE(vlist[vol_i].target);
+ if (vlist[vol_i].vol)
+ virStorageVolFree(vlist[vol_i].vol);
+ }
+ VIR_FREE(vlist);
+
VIR_FREE(volumes);
VIR_FREE(volume_tokens);
VIR_FREE(def);
VIR_FREE(vol_nodes);
- if (vol)
- virStorageVolFree(vol);
xmlFreeDoc(doc);
xmlXPathFreeContext(ctxt);
virDomainFree(dom);
return ret;
+
+error:
+ virshReportError(ctl);
+ goto cleanup;
}
--
1.7.8.6
12 years, 5 months
[libvirt] [PATCH v3] util: set minimum value of nodesuspend duration to 60 seconds
by Guannan Ren
Change the permissible minimum value of nodesuspend duration time
to 60 seconds. If option is less than the value, reports error.
Update virsh help and manpage the infomation.
---
src/util/virnodesuspend.c | 2 +-
tools/virsh.c | 2 +-
tools/virsh.pod | 3 ++-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index 71beb3d..91dfdf6 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -90,7 +90,7 @@ static int virNodeSuspendSetNodeWakeup(unsigned long long alarmTime)
virCommandPtr setAlarmCmd;
int ret = -1;
- if (alarmTime <= MIN_TIME_REQ_FOR_SUSPEND) {
+ if (alarmTime < MIN_TIME_REQ_FOR_SUSPEND) {
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Suspend duration is too short"));
return -1;
}
diff --git a/tools/virsh.c b/tools/virsh.c
index 6d65036..d236950 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -6986,7 +6986,7 @@ static const vshCmdInfo info_nodesuspend[] = {
static const vshCmdOptDef opts_node_suspend[] = {
{"target", VSH_OT_DATA, VSH_OFLAG_REQ, N_("mem(Suspend-to-RAM), "
"disk(Suspend-to-Disk), hybrid(Hybrid-Suspend)")},
- {"duration", VSH_OT_INT, VSH_OFLAG_REQ, N_("Suspend duration in seconds")},
+ {"duration", VSH_OT_INT, VSH_OFLAG_REQ, N_("Suspend duration in seconds, at least 60")},
{"flags", VSH_OT_INT, VSH_OFLAG_NONE, N_("Suspend flags, 0 for default")},
{NULL, 0, 0, NULL}
};
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 6ecf6ce..dffd588 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -290,7 +290,8 @@ If I<cell> is specified, this will prints specified cell statistics only.
Puts the node (host machine) into a system-wide sleep state such as
Suspend-to-RAM, Suspend-to-Disk or Hybrid-Suspend and sets up a
Real-Time-Clock interrupt to fire (to wake up the node) after a time delay
-specified by the 'duration' parameter.
+specified by the 'duration' parameter. The duration time should be
+at least 60 seconds.
=item B<capabilities>
--
1.7.7.5
12 years, 5 months
[libvirt] [PATCH] doc: add more description on libvirtd option timeout
by Guannan Ren
Only when there is no running guest, virtual network, etc on each
registered drivers and no client connections, the timeout take effect.
---
daemon/libvirtd.pod.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/libvirtd.pod.in b/daemon/libvirtd.pod.in
index ea6c37d..75c9040 100644
--- a/daemon/libvirtd.pod.in
+++ b/daemon/libvirtd.pod.in
@@ -54,7 +54,7 @@ Use this name for the PID file, overriding the default value.
=item B<-t, --timeout> I<SECONDS>
-Exit after timeout period (in seconds) expires.
+When there is no any active resources on each registered driver and client connections, exit after timeout period (in seconds) expires.
=item B<-v, --verbose>
--
1.7.10.4
12 years, 5 months