[libvirt] [libvirt-glib 1/2] API to suspend a domain
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
libvirt-gobject/libvirt-gobject-domain.c | 30 ++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 3 +++
libvirt-gobject/libvirt-gobject.sym | 1 +
3 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 4301b14..e4963ed 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -678,3 +678,33 @@ gboolean gvir_domain_open_graphics(GVirDomain *dom,
cleanup:
return ret;
}
+
+/**
+ * gir_domain_suspend:
+ * @dom: the domain to suspend
+ * @err: Place-holder for possible errors
+ *
+ * Suspends an active domain, the process is frozen without further access to
+ * CPU resources and I/O but the memory used by the domain at the hypervisor
+ * level will stay allocated. Use gvir_domain_resume() to reactivate the domain.
+ *
+ * Returns: TRUE if domain was suspended successfully, FALSE otherwise.
+ */
+gboolean gvir_domain_suspend (GVirDomain *dom,
+ GError **err)
+{
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+
+ if (virDomainSuspend(dom->priv->handle) < 0) {
+ gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+ 0,
+ "Unable to suspend domain");
+ goto cleanup;
+ }
+
+ ret = TRUE;
+cleanup:
+ return ret;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 6fcec8d..a5923f4 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -153,6 +153,9 @@ gboolean gvir_domain_open_graphics(GVirDomain *dom,
unsigned int flags,
GError **err);
+gboolean gvir_domain_suspend (GVirDomain *dom,
+ GError **err);
+
G_END_DECLS
#endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index a523adc..526098d 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -51,6 +51,7 @@ LIBVIRT_GOBJECT_0.0.3 {
gvir_domain_start;
gvir_domain_resume;
gvir_domain_stop;
+ gvir_domain_suspend;
gvir_domain_delete;
gvir_domain_open_console;
gvir_domain_open_graphics;
--
1.7.7.4
12 years, 10 months
[libvirt] Xen driver and vif naming
by Tomas Kopal
Hello,
I am currently trying to use libvirt (debian stable, version 0.8.3) to
gather some information about our xen server. (I am complete libvirt
newbie :-) ). But when trying to get some info about network interfaces
(e.g. via "virsh -c xen:/// domifstat domname vif1.0"), I am receiving
an error:
error: Failed to get interface stats domname vif1.0
error: invalid argument in xenHypervisorDomainInterfaceStats: invalid
path, vif<domid> should match this domain ID
The error is right, the 1 in vif name does not match domain id. Due to
some restarts, the id is right now 6.
In Xen configuration, I am using the vifname=vif1.0 option to set the
interface name - I need this so I can refer to these names in firewall
configuration (I am not using a bridge between xen interfaces).
I have found no way to set the domain ID to a fixed number, so it is
always generated (and always different from the vif name).
So, for me, this mis-match is expected.
Why is libvirt checking the name against the id? Any real reason for
this? Any known workaround to circumvent this problem for me?
Thanks a lot
Regards
Tomas
P.S. - I am not subscribed to the list, please keep me on the cc-list.
12 years, 10 months
[libvirt] [libvirt-glib] Don't mix g_new0 and g_slice_free
by Christophe Fergeau
There were 2 places where memory was allocated with g_new0 and was
later freed with g_slice_free. This commit uses g_slice_new0 instead.
After this, there are no other occurrences of g_new0 in gobject/ so
the rest of the codebase should be safe from this issue.
---
libvirt-gobject/libvirt-gobject-storage-pool.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index f46dc32..0ba1768 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -621,7 +621,7 @@ void gvir_storage_pool_build_async (GVirStoragePool *pool,
GSimpleAsyncResult *res;
StoragePoolBuildData *data;
- data = g_new0(StoragePoolBuildData, 1);
+ data = g_slice_new0(StoragePoolBuildData);
data->flags = flags;
res = g_simple_async_result_new(G_OBJECT(pool),
@@ -721,7 +721,7 @@ void gvir_storage_pool_start_async (GVirStoragePool *pool,
GSimpleAsyncResult *res;
StoragePoolBuildData *data;
- data = g_new0(StoragePoolBuildData, 1);
+ data = g_slice_new0(StoragePoolBuildData);
data->flags = flags;
res = g_simple_async_result_new(G_OBJECT(pool),
--
1.7.7.5
12 years, 10 months
[libvirt] [PATCH] build: drop check for ANSI compiler
by Eric Blake
Using automake.git (will become 1.12 someday), I got this error:
configure.ac:90: error: automatic de-ANSI-fication support has been removed
/usr/local/share/aclocal-1.11a/protos.m4:13: AM_C_PROTOTYPES is expanded from...
configure.ac:90: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
In short, pre-C89 compilers are no longer a viable portability
target. Besides, our code base already requires C99, so worrying
about pre-C89 seems pointless.
* configure.ac (AM_C_PROTOTYPES): Drop, since newer automake no
longer provides it.
---
Pushing under the build-breaker rule.
configure.ac | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
index 46a9129..e9e17f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
-dnl Copyright (C) 2005-2011 Red Hat, Inc.
+dnl Copyright (C) 2005-2012 Red Hat, Inc.
dnl See COPYING.LIB for the License of this software
AC_INIT([libvirt], [0.9.8], [libvir-list(a)redhat.com], [], [http://libvirt.org])
@@ -86,10 +86,6 @@ gl_INIT
AC_TYPE_UID_T
-dnl Make sure we have an ANSI compiler
-AM_C_PROTOTYPES
-test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
-
dnl Support building Win32 DLLs (must appear *before* AM_PROG_LIBTOOL)
AC_LIBTOOL_WIN32_DLL
--
1.7.7.5
12 years, 10 months
[libvirt] [PATCH v2 0/5] RFC: grant KVM guests retain arbitrary capabilities
by Taku Izumi
Hi Daniel-san and all,
This patchset adds an option for KVM guests to retain arbitrary capabilities.
The first version is here:
http://www.redhat.com/archives/libvir-list/2011-December/msg00857.html
According to Daniel-san's comment, I changed my patch like the following:
v1 -> v2
- introduce "process" and "cap" elements in the capability XML
- change XML element name of domain XML likewise
; process capabilities host supports are found in the capability XML.
# virsh capabilities
<capabilities>
<host>
<uuid>00000000-0000-0000-0000-00199914f1c5</uuid>
...
<process>
<cap name='chown'/>
<cap name='dac_override'/>
<cap name='dac_read_search'/>
<cap name='fowner'/>
...
</process>
</host>
...
; VM can retain cap_sys_rawio capability
# virsh edit VM
...
</features>
<process>
<cap name='sys_rawio'/>
</process>
<clock offset='utc'/>
...
# virsh start VM
# cat /proc/<VM's PID>/status
...
CapInh: 0000000000000000
CapPrm: fffffffc00020000
CapEff: fffffffc00020000
CapBnd: fffffffc00020000
...
*[PATCH v2 1/5] conf: add XML schema for capability XML
*[PATCH v2 2/5] conf: add XML schema for domain XML
*[PATCH v2 3/5] util: add functions to keep capabilities
*[PATCH v2 4/5] util: extend virExecWithHook()
*[PATCH v2 5/5] qemu: make qemu processes to retain capabilities
Best regards,
Taku Izumi
12 years, 10 months
[libvirt] [PATCHv2] python: Fix problems of virDomain{Set, Get}BlkioParameters bindings
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
The parameter 'device_weight' is a string, however, the 'VIR_TYPED_PARAM_STRING'
type condition is missed by libvirt_virDomain{Set, Get}BlkioParameters bindings,
the result is we can't get or change 'device_weight' value.
* python/libvirt-override.c: Add missing 'VIR_TYPED_PARAM_STRING' condition into
libvirt_virDomain{Set, Get}BlkioParameters bindings and free allocated memory.
https://bugzilla.redhat.com/show_bug.cgi?id=770795
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
python/libvirt-override.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index d2aad0f..38a35b8 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -726,6 +726,10 @@ libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
}
break;
+ case VIR_TYPED_PARAM_STRING:
+ params[i].value.s = PyString_AsString(val);
+ break;
+
default:
free(params);
return VIR_PY_INT_FAIL;
@@ -735,6 +739,11 @@ libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
LIBVIRT_BEGIN_ALLOW_THREADS;
i_retval = virDomainSetBlkioParameters(domain, params, nparams, flags);
LIBVIRT_END_ALLOW_THREADS;
+
+ for(i=0; i < nparams; i++)
+ if (params[i].type == VIR_TYPED_PARAM_STRING)
+ free(params[i].value.s);
+
if (i_retval < 0) {
free(params);
return VIR_PY_INT_FAIL;
@@ -811,6 +820,10 @@ libvirt_virDomainGetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
val = PyBool_FromLong((long)params[i].value.b);
break;
+ case VIR_TYPED_PARAM_STRING:
+ val = PyString_FromString((char *)params[i].value.s);
+ break;
+
default:
free(params);
Py_DECREF(info);
@@ -819,7 +832,14 @@ libvirt_virDomainGetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
key = libvirt_constcharPtrWrap(params[i].field);
PyDict_SetItem(info, key, val);
+ Py_DECREF(key);
+ Py_DECREF(val);
}
+
+ for(i=0; i < nparams; i++)
+ if (params[i].type == VIR_TYPED_PARAM_STRING)
+ free(params[i].value.s);
+
free(params);
return(info);
}
--
1.7.1
12 years, 10 months
[libvirt] [PATCH] network: Avoid memory leaks on networkBuildDnsmasqArgv
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
Detected by valgrind. Leaks introduced in commit 973af236.
* src/network/bridge_driver.c: fix memory leaks on failure and successful path.
* How to reproduce?
% cd tests && valgrind -v --leak-check=full ./networkxml2argvtest
* Actual result:
==2226== 3 bytes in 1 blocks are definitely lost in loss record 1 of 24
==2226== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226== by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226== by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226== by 0x41E0B7: virAsprintf (util.c:1695)
==2226== by 0x41A2D9: networkBuildDhcpDaemonCommandLine (bridge_driver.c:545)
==2226== by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226== by 0x4156A1: virtTestRun (testutils.c:141)
==2226== by 0x414332: mymain (networkxml2argvtest.c:123)
==2226== by 0x414D97: virtTestMain (testutils.c:696)
==2226== by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== 3 bytes in 1 blocks are definitely lost in loss record 2 of 24
==2226== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226== by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226== by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226== by 0x41E0B7: virAsprintf (util.c:1695)
==2226== by 0x41A307: networkBuildDhcpDaemonCommandLine (bridge_driver.c:551)
==2226== by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226== by 0x4156A1: virtTestRun (testutils.c:141)
==2226== by 0x414332: mymain (networkxml2argvtest.c:123)
==2226== by 0x414D97: virtTestMain (testutils.c:696)
==2226== by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== 5 bytes in 1 blocks are definitely lost in loss record 4 of 24
==2226== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226== by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226== by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226== by 0x41E0B7: virAsprintf (util.c:1695)
==2226== by 0x41A2AB: networkBuildDhcpDaemonCommandLine (bridge_driver.c:539)
==2226== by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226== by 0x4156A1: virtTestRun (testutils.c:141)
==2226== by 0x414332: mymain (networkxml2argvtest.c:123)
==2226== by 0x414D97: virtTestMain (testutils.c:696)
==2226== by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== LEAK SUMMARY:
==2226== definitely lost: 11 bytes in 3 blocks
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/network/bridge_driver.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 9afada7..63a28a6 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -544,12 +544,15 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
if (dns->srvrecords[i].priority) {
if (virAsprintf(&recordPriority, "%d", dns->srvrecords[i].priority) < 0) {
virReportOOMError();
+ VIR_FREE(recordPort);
goto cleanup;
}
}
if (dns->srvrecords[i].weight) {
if (virAsprintf(&recordWeight, "%d", dns->srvrecords[i].weight) < 0) {
virReportOOMError();
+ VIR_FREE(recordPort);
+ VIR_FREE(recordPriority);
goto cleanup;
}
}
@@ -567,6 +570,9 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
}
virCommandAddArgPair(cmd, "--srv-host", record);
+ VIR_FREE(recordPort);
+ VIR_FREE(recordPriority);
+ VIR_FREE(recordWeight);
VIR_FREE(record);
}
}
--
1.7.1
12 years, 10 months
[libvirt] [PATCH] qemu: Avoid memory leaks on qemuParseRBDString
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
Detected by valgrind. Leak introduced in commit 5745dc1.
* src/qemu/qemu_command.c: fix memory leak on failure and successful path.
* How to reproduce?
% valgrind -v --leak-check=full ./qemuargv2xmltest
* Actual result:
==2196== 80 bytes in 1 blocks are definitely lost in loss record 3 of 4
==2196== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2196== by 0x39CF07F6E1: strdup (in /lib64/libc-2.12.so)
==2196== by 0x419823: qemuParseRBDString (qemu_command.c:1657)
==2196== by 0x4221ED: qemuParseCommandLine (qemu_command.c:5934)
==2196== by 0x422AFB: qemuParseCommandLineString (qemu_command.c:7561)
==2196== by 0x416864: testCompareXMLToArgvHelper (qemuargv2xmltest.c:48)
==2196== by 0x417DB1: virtTestRun (testutils.c:141)
==2196== by 0x415CAF: mymain (qemuargv2xmltest.c:175)
==2196== by 0x4174A7: virtTestMain (testutils.c:696)
==2196== by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2196==
==2196== LEAK SUMMARY:
==2196== definitely lost: 80 bytes in 1 blocks
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/qemu/qemu_command.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ea1b763..69bf868 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1709,9 +1709,11 @@ static int qemuParseRBDString(virDomainDiskDefPtr disk)
p = next;
}
+ VIR_FREE(options);
return 0;
no_memory:
+ VIR_FREE(options);
virReportOOMError();
return -1;
}
--
1.7.1
12 years, 10 months
[libvirt] hyperv connection
by Andy Li
Dear Sir or Madam:
I am trying to connect hyper-v with libvirt0.9.8 with hyperv driver, but it
always reply the follow error
virsh # connect hyperv://192.168.58.231:5985
Enter username for 192.168.58.231 [administrator]:
Enter administrator's password for 192.168.58.231:
2012-01-05 14:46:39.999+0000: 27155: info : libvirt version: 0.9.8
2012-01-05 14:46:39.999+0000: 27155: error : hypervDebugHandler:1308 :
openwsman error: NULL response
error: Failed to connect to the hypervisor
error: internal error Transport error during enumeration: SSL connection
error (16)
when I use the wsman to identify the hyper-v, it works, but I just can
identify the hyper-v, not others.
[root@localhost plugins]# wsman identify -h 192.168.58.231 -u Administrator
-p rd2@usi -d 6 -P 5985 -y basic
Jan 5 22:58:05 cl->authentication.verify_peer: 1
Jan 5 22:58:05 *****set post buf len = 238******
* About to connect() to 192.168.58.231 port 5985 (#0)
* Trying 192.168.58.231... * connected
* Connected to 192.168.58.231 (192.168.58.231) port 5985 (#0)
> POST /wsman HTTP/1.1
Host: 192.168.58.231:5985
Accept: */*
Content-Type: application/soap+xml;charset=UTF-8
User-Agent: openwsman 2.2.3
Content-Length: 238
< HTTP/1.1 401
< Server: Microsoft-HTTPAPI/2.0
* gss_init_sec_context() failed: : Credentials cache file '/tmp/krb5cc_0'
not found< WWW-Authenticate: Negotiate
< WWW-Authenticate: Basic realm="WSMAN"
< WWW-Authenticate: CredSSP
< Date: Fri, 06 Jan 2012 06:56:10 GMT
< Connection: close
< Content-Length: 0
<
* Closing connection #0
Jan 5 22:58:05 Basic authentication is used
* About to connect() to 192.168.58.231 port 5985 (#0)
* Trying 192.168.58.231... * connected
* Connected to 192.168.58.231 (192.168.58.231) port 5985 (#0)
* Server auth using Basic with user 'Administrator'
> POST /wsman HTTP/1.1
Authorization: Basic QWRtaW5pc3RyYXRvcjpyZDJAdXNp
Host: 192.168.58.231:5985
Accept: */*
Content-Type: application/soap+xml;charset=UTF-8
User-Agent: openwsman 2.2.3
Content-Length: 238
< HTTP/1.1 200
< Content-Type: application/soap+xml;charset=UTF-8
< Server: Microsoft-HTTPAPI/2.0
< Date: Fri, 06 Jan 2012 06:56:10 GMT
< Content-Length: 490
<
Jan 5 22:58:05 write_handler: recieved 490 bytes, all = 490
* Connection #0 to host 192.168.58.231 left intact
Jan 5 22:58:05 curl error code: 0.
Jan 5 22:58:05 cl->response_code: 200.
Jan 5 22:58:05 cl->last_error code: 0.
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xml:lang="en-US">
<s:Header/>
<s:Body>
<wsmid:IdentifyResponse
xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
">
<wsmid:ProtocolVersion>http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd</wsmid
:ProtocolVersion>
<wsmid:ProductVendor>Microsoft Corporation</wsmid:ProductVendor>
<wsmid:ProductVersion>OS: 6.1.7600 SP: 0.0 Stack:
2.0</wsmid:ProductVersion>
</wsmid:IdentifyResponse>
</s:Body>
</s:Envelope>
* Closing connection #0
[root@localhost plugins]#
I work on this for a long time, but I still fail at the connection. Hope you
can help.
Thanks,
Andy Li MFG Software Developer
Department of Storage Products R&D, SCS
Universal Scientific Industrial (Shanghai) Co., Ltd
421 Lishizhen Rd, Pudong New Area, Shanghai,P.R. China, 201203
Tel : +86 -21-5896 6996 ext. 81453
Fax : +86 -21-5080 4268
12 years, 10 months