[libvirt] [libvirt-glib] Release 0.0.2
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
NEWS | 20 ++++++++++++++++++++
configure.ac | 3 +--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index a0cbb60..b7b11a9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,23 @@
+0.0.2 - Nov 22, 2011
+====================
+
+- Add API to redefine an existing domain.
+- Expicitely call virInitialize() to avoid connection races.
+- Adjust example to latest pygobject-3.0.
+- Add missing deps on libxml2-devel & libtool.
+- Don't introspect on RHEL6.
+- Add download / mailing list links to README.
+- Fix parallel build with vala bindings.
+- Fix a typo in a pkg-config file.
+
+All contributors to this release:
+
+Daniel P. Berrange <berrange(a)redhat.com>
+Guido Günther <agx(a)sigxcpu.org>
+Marc-André Lureau <marcandre.lureau(a)redhat.com>
+Nirbheek Chauhan <nirbheek(a)gentoo.org>
+Zeeshan Ali (Khattak) <zeeshanak(a)gnome.org>
+
0.0.1 - Nov 16, 2011
====================
diff --git a/configure.ac b/configure.ac
index 464160c..56110d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,4 @@
-
-AC_INIT(libvirt-glib, 0.0.1)
+AC_INIT(libvirt-glib, 0.0.2)
AC_CONFIG_SRCDIR(libvirt-glib/libvirt-glib-main.c)
AC_CONFIG_AUX_DIR([build-aux])
AM_CONFIG_HEADER(config.h)
--
1.7.7.1
13 years
[libvirt] [libvirt-glib] Add API to redefine an existing domain
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
libvirt-gobject/libvirt-gobject-domain.c | 48 ++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 3 ++
libvirt-gobject/libvirt-gobject.sym | 1 +
3 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 1fa27bd..01ae1f4 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -449,6 +449,54 @@ GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom,
return conf;
}
+/**
+ * gvir_domain_set_config:
+ * @domain: the domain
+ * @conf: the new configuration for the domain
+ * @error: (allow-none): Place-holder for error or NULL
+ *
+ * Resets configuration of an existing domain.
+ *
+ * Note: If domain is already running, the new configuration will not take
+ * affect until domain reboots.
+ *
+ * Returns: TRUE on success, FALSE if an error occurred.
+ */
+gboolean gvir_domain_set_config(GVirDomain *domain,
+ GVirConfigDomain *conf,
+ GError **error)
+{
+ const gchar *xml;
+ virConnectPtr conn;
+ GVirDomainPrivate *priv = domain->priv;
+
+ g_return_val_if_fail(GVIR_IS_DOMAIN (domain), FALSE);
+ g_return_val_if_fail(GVIR_IS_CONFIG_DOMAIN (conf), FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+
+ xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf));
+
+ g_return_val_if_fail(xml != NULL, FALSE);
+
+ if ((conn = virDomainGetConnect(priv->handle)) == NULL) {
+ if (error != NULL)
+ *error = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
+ 0,
+ "Failed to get domain connection");
+ return FALSE;
+ }
+
+ if (virDomainDefineXML(conn, xml) == NULL) {
+ if (error != NULL)
+ *error = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
+ 0,
+ "Failed to set "
+ "domain configuration");
+ return FALSE;
+ }
+
+ return TRUE;
+}
/**
* gvir_domain_get_info:
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 94bd53e..0479de8 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -123,6 +123,9 @@ GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom,
GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom,
guint64 flags,
GError **err);
+gboolean gvir_domain_set_config(GVirDomain *domain,
+ GVirConfigDomain *conf,
+ GError **err);
gchar *gvir_domain_screenshot(GVirDomain *dom,
GVirStream *stream,
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 164b6b8..46c53f9 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -53,6 +53,7 @@ LIBVIRT_GOBJECT_0.0.1 {
gvir_domain_shutdown;
gvir_domain_reboot;
gvir_domain_get_config;
+ gvir_domain_set_config;
gvir_domain_get_info;
gvir_domain_screenshot;
--
1.7.7.1
13 years
[libvirt] [PATCH RESEND v5] Export KVM Host Power Management capabilities
by Srivatsa S. Bhat
This patch exports KVM Host Power Management capabilities as XML so that
higher-level systems management software can make use of these features
available in the host.
The script "pm-is-supported" (from pm-utils package) is run to discover if
Suspend-to-RAM (S3) or Suspend-to-Disk (S4) is supported by the host.
If either of them are supported, then a new tag "<power_management>" is
introduced in the XML under the <host> tag.
Eg: When the host supports both S3 and S4, the XML looks like this:
<capabilities>
<host>
<uuid>dc699581-48a2-11cb-b8a8-9a0265a79bbe</uuid>
<cpu>
<arch>i686</arch>
<model>coreduo</model>
<vendor>Intel</vendor>
<topology sockets='1' cores='2' threads='1'/>
<feature name='xtpr'/>
<feature name='tm2'/>
<feature name='est'/>
<feature name='vmx'/>
<feature name='pbe'/>
<feature name='tm'/>
<feature name='ht'/>
<feature name='ss'/>
<feature name='acpi'/>
<feature name='ds'/>
</cpu>
<power_management> <<<=== New host power management features
<S3/>
<S4/>
</power_management>
<migration_features>
<live/>
<uri_transports>
<uri_transport>tcp</uri_transport>
</uri_transports>
</migration_features>
</host>
.
.
.
However in case the query to check for power management features succeeded,
but the host does not support any such feature, then the XML will contain
an empty <power_management/> tag. In the event that the PM query itself
failed, the XML will not contain any "power_management" tag.
To use this, new APIs could be implemented in libvirt to exploit power
management features such as S3/S4. This was discussed in [1] and [2].
Changelog:
---------
This version v5:
Some redundant error messages were removed and the code was streamlined.
v4: http://www.redhat.com/archives/libvir-list/2011-August/msg00316.html
v3: http://www.redhat.com/archives/libvir-list/2011-August/msg00282.html
v2: http://www.redhat.com/archives/libvir-list/2011-August/msg00238.html
v1: http://thread.gmane.org/gmane.comp.emulators.libvirt/40886
References:
----------
[1] http://www.redhat.com/archives/libvir-list/2011-August/msg00248.html
[2] http://www.redhat.com/archives/libvir-list/2011-August/msg00302.html
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat(a)linux.vnet.ibm.com>
---
docs/formatcaps.html.in | 19 ++++++++++++----
docs/schemas/capability.rng | 18 +++++++++++++++
include/libvirt/virterror.h | 1 +
libvirt.spec.in | 2 ++
src/conf/capabilities.c | 27 +++++++++++++++++++++-
src/conf/capabilities.h | 4 +++
src/libvirt_private.syms | 1 +
src/qemu/qemu_capabilities.c | 7 ++++++
src/util/util.c | 51 ++++++++++++++++++++++++++++++++++++++++++
src/util/util.h | 14 ++++++++++++
src/util/virterror.c | 3 ++
11 files changed, 141 insertions(+), 6 deletions(-)
diff --git a/docs/formatcaps.html.in b/docs/formatcaps.html.in
index a4297ce..ce6f9a6 100644
--- a/docs/formatcaps.html.in
+++ b/docs/formatcaps.html.in
@@ -28,6 +28,10 @@ BIOS you will see</p>
<feature name='xtpr'/>
...
</cpu>
+ <power_management>
+ <S3/>
+ <S4/>
+ <power_management/>
</host></span>
<!-- xen-3.0-x86_64 -->
@@ -61,11 +65,16 @@ BIOS you will see</p>
...
</capabilities></pre>
<p>The first block (in red) indicates the host hardware capabilities, currently
-it is limited to the CPU properties but other information may be available,
-it shows the CPU architecture, topology, model name, and additional features
-which are not included in the model but the CPU provides them. Features of the
-chip are shown within the feature block (the block is similar to what you will
-find in a Xen fully virtualized domain description).</p>
+it is limited to the CPU properties and the power management features of
+the host platform, but other information may be available, it shows the CPU architecture,
+topology, model name, and additional features which are not included in the model but the
+CPU provides them. Features of the chip are shown within the feature block (the block is
+similar to what you will find in a Xen fully virtualized domain description). Further,
+the power management features supported by the host are shown, such as Suspend-to-RAM (S3)
+and Suspend-to-Disk (S4). In case the query for power management features succeeded but the
+host does not support any such feature, then an empty <power_management/>
+tag will be shown. Otherwise, if the query itself failed, no such tag will
+be displayed (i.e., there will not be any power_management block or empty tag in the XML).</p>
<p>The second block (in blue) indicates the paravirtualization support of the
Xen support, you will see the os_type of xen to indicate a paravirtual
kernel, then architecture information and potential features.</p>
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index 0a63a1c..eac1d02 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -35,6 +35,9 @@
</optional>
</element>
<optional>
+ <ref name='power_management'/>
+ </optional>
+ <optional>
<ref name='migration'/>
</optional>
<optional>
@@ -105,6 +108,21 @@
</zeroOrMore>
</define>
+ <define name='power_management'>
+ <element name='power_management'>
+ <optional>
+ <element name='S3'>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name='S4'>
+ <empty/>
+ </element>
+ </optional>
+ </element>
+ </define>
+
<define name='migration'>
<element name='migration_features'>
<optional>
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index a8549b7..7063ef6 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -84,6 +84,7 @@ typedef enum {
VIR_FROM_LIBXL = 41, /* Error from libxenlight driver */
VIR_FROM_LOCKING = 42, /* Error from lock manager */
VIR_FROM_HYPERV = 43, /* Error from Hyper-V driver */
+ VIR_FROM_CAPABILITIES = 44, /* Error from capabilities */
} virErrorDomain;
diff --git a/libvirt.spec.in b/libvirt.spec.in
index c74b0ea..23487e3 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -493,6 +493,8 @@ Requires: nc
Requires: gettext
# Needed by virt-pki-validate script.
Requires: gnutls-utils
+# Needed for probing the power management features of the host.
+Requires: pm-utils
%if %{with_sasl}
Requires: cyrus-sasl
# Not technically required, but makes 'out-of-box' config
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 40e2976..87b60b0 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -29,6 +29,13 @@
#include "util.h"
#include "uuid.h"
#include "cpu_conf.h"
+#include "virterror_internal.h"
+
+
+#define VIR_FROM_THIS VIR_FROM_CAPABILITIES
+
+VIR_ENUM_IMPL(virHostPMCapability, VIR_HOST_PM_LAST,
+ "S3", "S4")
/**
* virCapabilitiesNew:
@@ -201,7 +208,6 @@ virCapabilitiesAddHostFeature(virCapsPtr caps,
return 0;
}
-
/**
* virCapabilitiesAddHostMigrateTransport:
* @caps: capabilities to extend
@@ -687,6 +693,25 @@ virCapabilitiesFormatXML(virCapsPtr caps)
virBufferAddLit(&xml, " </cpu>\n");
+ if (caps->host.powerMgmt_valid) {
+ /* The PM query was successful. */
+ if (caps->host.powerMgmt) {
+ /* The host supports some PM features. */
+ unsigned int pm = caps->host.powerMgmt;
+ virBufferAddLit(&xml, " <power_management>\n");
+ while (pm) {
+ int bit = ffs(pm) - 1;
+ virBufferAsprintf(&xml, " <%s/>\n",
+ virHostPMCapabilityTypeToString(bit));
+ pm &= ~(1U << bit);
+ }
+ virBufferAddLit(&xml, " </power_management>\n");
+ } else {
+ /* The host does not support any PM feature. */
+ virBufferAddLit(&xml, " <power_management/>\n");
+ }
+ }
+
if (caps->host.offlineMigrate) {
virBufferAddLit(&xml, " <migration_features>\n");
if (caps->host.liveMigrate)
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index dd4a827..148c7cc 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -105,6 +105,10 @@ struct _virCapsHost {
size_t nfeatures;
size_t nfeatures_max;
char **features;
+ bool powerMgmt_valid;
+ unsigned int powerMgmt; /* Bitmask of the PM capabilities.
+ * See enum virHostPMCapability.
+ */
int offlineMigrate;
int liveMigrate;
size_t nmigrateTrans;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6a1562e..4d366d4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1128,6 +1128,7 @@ virFormatMacAddr;
virGenerateMacAddr;
virGetGroupID;
virGetHostname;
+virGetPMCapabilities;
virGetUserDirectory;
virGetUserID;
virGetUserName;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 26a7f11..e1cc760 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -848,6 +848,13 @@ virCapsPtr qemuCapsInit(virCapsPtr old_caps)
old_caps->host.cpu = NULL;
}
+ /* Add the power management features of the host */
+
+ if (virGetPMCapabilities(&caps->host.powerMgmt) < 0)
+ VIR_WARN("Failed to get host power management capabilities");
+ else
+ caps->host.powerMgmt_valid = true; /* The PM query succeeded. */
+
virCapabilitiesAddHostMigrateTransport(caps,
"tcp");
diff --git a/src/util/util.c b/src/util/util.c
index 959c224..6f0f84a 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2607,3 +2607,54 @@ or other application using the libvirt API.\n\
return 0;
}
+
+/**
+ * Get the Power Management Capabilities of the host system.
+ * The script 'pm-is-supported' (from the pm-utils package) is run
+ * to find out all the power management features supported by the host,
+ * such as Suspend-to-RAM (S3) and Suspend-to-Disk (S4).
+ *
+ * @bitmask: Pointer to the bitmask which will be set appropriately to
+ * indicate all the supported host power management features.
+ *
+ * Returns 0 if the query was successful, -1 upon failure.
+ */
+int
+virGetPMCapabilities(unsigned int *bitmask)
+{
+ int ret = -1;
+ int status;
+ virCommandPtr cmd;
+
+ *bitmask = 0;
+
+ /* Check support for Suspend-to-RAM (S3) */
+ cmd = virCommandNewArgList("pm-is-supported", "--suspend", NULL);
+ if (virCommandRun(cmd, &status) < 0)
+ goto cleanup;
+
+ /* Check return code of command == 0 for success
+ * (i.e., the PM capability is supported)
+ */
+ if (status == 0)
+ *bitmask |= 1U << VIR_HOST_PM_S3;
+ virCommandFree(cmd);
+
+ /* Check support for Suspend-to-Disk (S4) */
+ cmd = virCommandNewArgList("pm-is-supported", "--hibernate", NULL);
+ if (virCommandRun(cmd, &status) < 0)
+ goto cleanup;
+
+ /* Check return code of command == 0 for success
+ * (i.e., the PM capability is supported)
+ */
+ if (status == 0)
+ *bitmask |= 1U << VIR_HOST_PM_S4;
+
+ ret = 0;
+
+cleanup:
+ virCommandFree(cmd);
+ return ret;
+}
+
diff --git a/src/util/util.h b/src/util/util.h
index d8176a8..b1c4847 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -258,4 +258,18 @@ bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1);
int virEmitXMLWarning(int fd,
const char *name,
const char *cmd) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+
+/* Power Management Capabilities of the host system */
+
+enum virHostPMCapability {
+ VIR_HOST_PM_S3, /* Suspend-to-RAM */
+ VIR_HOST_PM_S4, /* Suspend-to-Disk */
+
+ VIR_HOST_PM_LAST
+};
+
+VIR_ENUM_DECL(virHostPMCapability)
+
+int virGetPMCapabilities(unsigned int *);
+
#endif /* __VIR_UTIL_H__ */
diff --git a/src/util/virterror.c b/src/util/virterror.c
index 5006fa2..44a276a 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -175,6 +175,9 @@ static const char *virErrorDomainName(virErrorDomain domain) {
case VIR_FROM_HYPERV:
dom = "Hyper-V ";
break;
+ case VIR_FROM_CAPABILITIES:
+ dom = "Capabilities ";
+ break;
}
return(dom);
}
13 years
[libvirt] New feature for libvirt network filter
by Amit Tewari
Hi,
I wanted to suggest a new feature in libvirt network filter.
Currently libvirt allow only one ip address to be provided in the guest
configuration xml file.
We should allow multiple ip addresses to be provided statically in the
guest xml for an interface, so that packets matching either of these
multiple ip addresses should be allowed to be routed out from the guest
machine.
Reagrds
Amit tTewari
NHST
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only.
It shall not attach any liability on the originator or NECHCL or its
affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the
opinions of NECHCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. .
-----------------------------------------------------------------------------------------------------------------------
13 years
[libvirt] [PATCH] Add strings.h include to capabilities.h for ffs() function prototype
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Pushed the following to fix the build on mingw32
On Mingw32 the ffs() function was not declared due to missing header
include
* src/conf/capabilities.c: The ffs() function lives in strings.h
---
src/conf/capabilities.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 87b60b0..ac132f9 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -23,6 +23,8 @@
#include <config.h>
+#include <strings.h>
+
#include "capabilities.h"
#include "buf.h"
#include "memory.h"
--
1.7.6.4
13 years
[libvirt] problem with nwfilter and ip6tables
by Reinier Schoof
Hi,
I'm investigating using the nwfilter-functionality of libvirt to give my
clients the possibility to block ports of their VPSes. The same
mechanism allows me to restrict the outgoing traffic a VPS is
generating. In the end, I want to restrict MAC, IPv4 and IPv6 traffic,
while the client can also restrict traffic to UDP and TCP.
All goes well, until I want to restrict the UDP/TCP traffic to certain
IPv6 addresses. Where iptables shows the IPv4-restriction I've put up,
ip6tables doesn't show anything. In the logs, I only see some ip6tables
-D, -X and -F commands failing, which is expected when libvirt tries to
delete/flush rules that were never there.
I've built my nwfilter containing the following IPv6-rules, which I for
instance reference once for all the TCP-ports which should be open.
<!-- Allow established traffic -->
<filter name='ipv6-allow-statefull' chain='ipv6'>
<rule action='accept' direction='in' priority='500'>
<all state='ESTABLISHED'/>
</rule>
<rule action='accept' direction='out' priority='500'>
<all state='ESTABLISHED,RELATED'/>
</rule>
</filter>
<!-- Allow TCP in $PORT -->
<filter name='ipv6-allow-create-state-by-port' chain='ipv6'>
<rule action='accept' direction='in' priority='500'>
<tcp state='NEW' dstportstart='$PORT'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<udp state='NEW' dstportstart='$PORT'/>
</rule>
</filter>
<!-- Allow IPv6 traffic from $RANGE -->
<filter name='ipv6-allow-create-state-by-range' chain='ipv6'>
<rule action='accept' direction='out' priority='500'>
<ipv6 srcipaddr='$RANGE' srcipmask='64'/>
</rule>
</filter>
<!-- Drop all other IPv6 traffic -->
<filter name='ipv6-drop-stateless' chain='ipv6'>
<rule action='drop' direction='inout' priority='999'>
<all/>
</rule>
</filter>
I use a similar approach for my IPv4 firewall, and it works perfectly.
When I use these IPv6 rules, all IPv6 traffic is apparently dropped, but
it's hard to debug when the result of this config is abscent in ip6tables.
I'm using these version of software on debian 6.0 squeeze:
virsh # version
Compiled against library: libvir 0.9.2
Using library: libvir 0.9.2
Using API: QEMU 0.9.2
Running hypervisor: QEMU 0.15.0
Does anyone have any clues? Thanks in advance!
Regards,
Reinier Schoof
--
TransIP BV | https://www.transip.nl/
13 years
[libvirt] [test-API][PATCH] Update clean part for cases
by Wayne Sun
* add clean function for missing ones
* clean the system configuration files which been touched
---
repos/domain/balloon_memory.py | 2 ++
repos/domain/cpu_topology.py | 5 +++++
repos/domain/ownership_test.py | 10 ++++++++++
repos/libvirtd/qemu_hang.py | 12 ++++++++++--
repos/remoteAccess/unix_perm_sasl.py | 10 ++++++++++
repos/sVirt/domain_nfs_start.py | 10 ++++++++++
repos/snapshot/delete.py | 18 +++---------------
repos/snapshot/file_flag.py | 28 +++++-----------------------
repos/snapshot/flag_check.py | 4 +++-
repos/snapshot/internal_create.py | 4 +++-
repos/snapshot/revert.py | 3 +++
repos/snapshot/snapshot_list.py | 16 +++-------------
12 files changed, 67 insertions(+), 55 deletions(-)
diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py
index 30f5edb..0a40591 100644
--- a/repos/domain/balloon_memory.py
+++ b/repos/domain/balloon_memory.py
@@ -299,6 +299,8 @@ def balloon_memory(params):
logger.info("the actual size of memory is \
rounded to the value %s we expected" % maxmem)
+ util.clean_ssh()
+
if count:
return return_close(conn, logger, 1)
else:
diff --git a/repos/domain/cpu_topology.py b/repos/domain/cpu_topology.py
index 7202559..adf238c 100644
--- a/repos/domain/cpu_topology.py
+++ b/repos/domain/cpu_topology.py
@@ -246,3 +246,8 @@ def cpu_topology(params):
conn.close()
return 0
+
+def cpu_topology_clean(params):
+ """clean testing enviorment"""
+ return 0
+
diff --git a/repos/domain/ownership_test.py b/repos/domain/ownership_test.py
index 74620f4..1eacbcf 100644
--- a/repos/domain/ownership_test.py
+++ b/repos/domain/ownership_test.py
@@ -307,6 +307,9 @@ def ownership_test_clean(params):
for i in range(len(out)):
logger.error(out[i])
+ clean_nfs_conf = "sed -i '$d' /etc/exports"
+ util.exec_cmd(clean_nfs_conf, shell=True)
+
filepath = TEMP_FILE
elif use_nfs == 'disable':
filepath = SAVE_FILE
@@ -314,3 +317,10 @@ def ownership_test_clean(params):
if os.path.exists(filepath):
os.remove(filepath)
+ clean_qemu_conf = "sed -i '$d' %s" % QEMU_CONF
+ util.exec_cmd(clean_qemu_conf, shell=True)
+
+ cmd = "service libvirtd restart"
+ util.exec_cmd(cmd, shell=True)
+
+ return 0
diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py
index c97e0b7..8b1ffda 100644
--- a/repos/libvirtd/qemu_hang.py
+++ b/repos/libvirtd/qemu_hang.py
@@ -135,8 +135,16 @@ def qemu_hang(params):
return 0
-def qemu_hang_cleanup(params):
+def qemu_hang_clean(params):
""" clean testing environment """
- pass
+ logger = params['logger']
+ guestname = params['guestname']
+ util = utils.Utils()
+ ret = get_domain_pid(util, logger, guestname)
+ cmd = "kill -CONT %s" % ret[1]
+ ret = util.exec_cmd(cmd, shell=True)
+ if ret[0]:
+ logger.error("failed to resume qemu process of %s" % guestname)
+ return 0
diff --git a/repos/remoteAccess/unix_perm_sasl.py b/repos/remoteAccess/unix_perm_sasl.py
index 54fa108..5db758c 100644
--- a/repos/remoteAccess/unix_perm_sasl.py
+++ b/repos/remoteAccess/unix_perm_sasl.py
@@ -22,6 +22,7 @@ import sys
import commands
from pwd import getpwnam
+from utils.Python import utils
def append_path(path):
"""Append root path of package"""
@@ -214,6 +215,7 @@ def unix_perm_sasl(params):
def unix_perm_sasl_clean(params):
"""clean testing environment"""
logger = params['logger']
+ util = utils.Utils()
auth_unix_ro = params['auth_unix_ro']
auth_unix_rw = params['auth_unix_rw']
@@ -241,3 +243,11 @@ def unix_perm_sasl_clean(params):
if status:
logger.error("failed to delete sasl user %s" % TESTING_USER)
+ clean_libvirtd_conf = "sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' %s" % \
+ LIBVIRTD_CONF
+ util.exec_cmd(clean_libvirtd_conf, shell=True)
+
+ cmd = "service libvirtd restart"
+ util.exec_cmd(cmd, shell=True)
+
+ return 0
diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py
index 2479366..edaf2f2 100644
--- a/repos/sVirt/domain_nfs_start.py
+++ b/repos/sVirt/domain_nfs_start.py
@@ -483,3 +483,13 @@ def domain_nfs_start_clean(params):
conn.close()
+ clean_nfs_conf = "sed -i '$d' /etc/exports"
+ util.exec_cmd(clean_nfs_conf, shell=True)
+
+ clean_qemu_conf = "sed -i '$d' %s" % QEMU_CONF
+ util.exec_cmd(clean_qemu_conf, shell=True)
+
+ cmd = "service libvirtd restart"
+ util.exec_cmd(cmd, shell=True)
+
+ return 0
diff --git a/repos/snapshot/delete.py b/repos/snapshot/delete.py
index 8a7eef6..98f82a5 100644
--- a/repos/snapshot/delete.py
+++ b/repos/snapshot/delete.py
@@ -124,18 +124,6 @@ def delete(params):
return 0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+def delete_clean(params):
+ """ clean testing environment """
+ return 0
diff --git a/repos/snapshot/file_flag.py b/repos/snapshot/file_flag.py
index a1479cc..5c5b2c7 100644
--- a/repos/snapshot/file_flag.py
+++ b/repos/snapshot/file_flag.py
@@ -126,27 +126,9 @@ def file_flag(params):
return return_close(conn, logger, 0)
+def file_flag_clean(params):
+ """ clean testing environment """
+ util = utils.Utils()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ util.clean_ssh()
+ return 0
diff --git a/repos/snapshot/flag_check.py b/repos/snapshot/flag_check.py
index 2e9cb4d..70fb506 100644
--- a/repos/snapshot/flag_check.py
+++ b/repos/snapshot/flag_check.py
@@ -127,4 +127,6 @@ def flag_check(params):
return return_close(conn, logger, 0)
-
+def flag_check_clean(params):
+ """ clean testing environment """
+ return 0
diff --git a/repos/snapshot/internal_create.py b/repos/snapshot/internal_create.py
index 123e38a..7ec1d30 100644
--- a/repos/snapshot/internal_create.py
+++ b/repos/snapshot/internal_create.py
@@ -125,7 +125,9 @@ def internal_create(params):
return 0
-
+def internal_create_clean(params):
+ """ clean testing environment """
+ return 0
diff --git a/repos/snapshot/revert.py b/repos/snapshot/revert.py
index f70e5dc..dafcf44 100644
--- a/repos/snapshot/revert.py
+++ b/repos/snapshot/revert.py
@@ -95,4 +95,7 @@ def revert(params):
return 0
+def revert_clean(params):
+ """ clean testing environment """
+ return 0
diff --git a/repos/snapshot/snapshot_list.py b/repos/snapshot/snapshot_list.py
index 2622d1f..e8ec686 100644
--- a/repos/snapshot/snapshot_list.py
+++ b/repos/snapshot/snapshot_list.py
@@ -93,17 +93,7 @@ def snapshot_list(params):
return 1
return 0
-
-
-
-
-
-
-
-
-
-
-
-
-
+def snapshot_list_clean(params):
+ """ clean testing environment """
+ return 0
--
1.7.1
13 years
[libvirt] [PATCH v2] storage:add lvchange operation while lvremove fails.
by zituan@taobao.com
From: Chang Liu <lingjiao.lc(a)taobao.com>
We found an issue that virStorageBackendLogicalDeleteVol() could not remove
the lv with notificaton "could not remove open logical volume.", in such
situation, we should disable the lv first, then delete it. this patch fix it.
*src/storage/storage_backend_logical.c
(virStorageBackendLogicalDeleteVol):lvremove fail, lvchange the volume
and then lvremove it second.
---
configure.ac | 4 +++
src/storage/storage_backend_logical.c | 39 ++++++++++++++++++++++++++------
2 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5753c08..6092c47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1691,6 +1691,7 @@ if test "$with_storage_lvm" = "yes" || test "$with_storage_lvm" = "check"; then
AC_PATH_PROG([PVREMOVE], [pvremove], [], [$PATH:/sbin:/usr/sbin])
AC_PATH_PROG([VGREMOVE], [vgremove], [], [$PATH:/sbin:/usr/sbin])
AC_PATH_PROG([LVREMOVE], [lvremove], [], [$PATH:/sbin:/usr/sbin])
+ AC_PATH_PROG([LVCHANGE], [lvchange], [], [$PATH:/sbin:/usr/sbin])
AC_PATH_PROG([VGCHANGE], [vgchange], [], [$PATH:/sbin:/usr/sbin])
AC_PATH_PROG([VGSCAN], [vgscan], [], [$PATH:/sbin:/usr/sbin])
AC_PATH_PROG([PVS], [pvs], [], [$PATH:/sbin:/usr/sbin])
@@ -1704,6 +1705,7 @@ if test "$with_storage_lvm" = "yes" || test "$with_storage_lvm" = "check"; then
if test -z "$PVREMOVE" ; then AC_MSG_ERROR([We need pvremove for LVM storage driver]) ; fi
if test -z "$VGREMOVE" ; then AC_MSG_ERROR([We need vgremove for LVM storage driver]) ; fi
if test -z "$LVREMOVE" ; then AC_MSG_ERROR([We need lvremove for LVM storage driver]) ; fi
+ if test -z "$LVCHANGE" ; then AC_MSG_ERROR([We need lvchange for LVM storage driver]) ; fi
if test -z "$VGCHANGE" ; then AC_MSG_ERROR([We need vgchange for LVM storage driver]) ; fi
if test -z "$VGSCAN" ; then AC_MSG_ERROR([We need vgscan for LVM storage driver]) ; fi
if test -z "$PVS" ; then AC_MSG_ERROR([We need pvs for LVM storage driver]) ; fi
@@ -1716,6 +1718,7 @@ if test "$with_storage_lvm" = "yes" || test "$with_storage_lvm" = "check"; then
if test -z "$PVREMOVE" ; then with_storage_lvm=no ; fi
if test -z "$VGREMOVE" ; then with_storage_lvm=no ; fi
if test -z "$LVREMOVE" ; then with_storage_lvm=no ; fi
+ if test -z "$LVCHANGE" ; then with_storage_lvm=no ; fi
if test -z "$VGCHANGE" ; then with_storage_lvm=no ; fi
if test -z "$VGSCAN" ; then with_storage_lvm=no ; fi
if test -z "$PVS" ; then with_storage_lvm=no ; fi
@@ -1733,6 +1736,7 @@ if test "$with_storage_lvm" = "yes" || test "$with_storage_lvm" = "check"; then
AC_DEFINE_UNQUOTED([PVREMOVE],["$PVREMOVE"],[Location of pvremove program])
AC_DEFINE_UNQUOTED([VGREMOVE],["$VGREMOVE"],[Location of vgremove program])
AC_DEFINE_UNQUOTED([LVREMOVE],["$LVREMOVE"],[Location of lvremove program])
+ AC_DEFINE_UNQUOTED([LVCHANGE],["$LVCHANGE"],[Location of lvchange program])
AC_DEFINE_UNQUOTED([VGCHANGE],["$VGCHANGE"],[Location of vgchange program])
AC_DEFINE_UNQUOTED([VGSCAN],["$VGSCAN"],[Location of vgscan program])
AC_DEFINE_UNQUOTED([PVS],["$PVS"],[Location of pvs program])
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index 3c3e736..f84c068 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -768,18 +768,41 @@ virStorageBackendLogicalDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virStorageVolDefPtr vol,
unsigned int flags)
{
- const char *cmdargv[] = {
- LVREMOVE, "-f", vol->target.path, NULL
- };
+ int ret = -1;
+ virCommandPtr lvchange_cmd = NULL;
+ virCommandPtr lvremove_cmd = NULL;
+
virCheckFlags(0, -1);
-
+
virFileWaitForDevices();
+
+ lvchange_cmd = virCommandNewArgList(LVCHANGE,
+ "-aln",
+ vol->target.path,
+ NULL);
+
+ lvremove_cmd = virCommandNewArgList(LVREMOVE,
+ "-f",
+ vol->target.path,
+ NULL);
+
+ if (virCommandRun(lvremove_cmd, NULL) < 0)
+ {
+ if(virCommandRun(lvchange_cmd, NULL) < 0)
+ goto cleanup;
+ else{
+ if(virCommandRun(lvremove_cmd,NULL) < 0)
+ goto cleanup;
+ }
+ }
- if (virRun(cmdargv, NULL) < 0)
- return -1;
-
- return 0;
+ ret = 0;
+
+cleanup:
+ virCommandFree(lvchange_cmd);
+ virCommandFree(lvremove_cmd);
+ return ret;
}
--
1.7.6.4
13 years