[libvirt] [PATCH] Don't log an internal error when the guest hasn't updated balloon stats
by Ján Tomko
If virDomainMemoryStats is called too soon after domain startup,
QEMU returns:
"error":{"class":"GenericError","desc":"guest hasn't updated any stats yet"}
when we try to query balloon stats.
Check for this reply and log it as OPERATION_INVALID instead of
INTERNAL_ERROR. This means the daemon only logs it at the debug level,
without polluting system logs.
Reported by Laszlo Pal:
https://www.redhat.com/archives/libvirt-users/2014-May/msg00023.html
---
src/qemu/qemu_monitor_json.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index f8ab975..88f6b6c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1460,26 +1460,38 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
goto cleanup;
if (!(cmd = qemuMonitorJSONMakeCommand("qom-get",
"s:path", balloonpath,
"s:property", "guest-stats",
NULL)))
goto cleanup;
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
- if (ret == 0)
- ret = qemuMonitorJSONCheckError(cmd, reply);
-
if (ret < 0)
goto cleanup;
+ if ((data = virJSONValueObjectGet(reply, "error"))) {
+ const char *klass = virJSONValueObjectGetString(data, "class");
+ const char *desc = virJSONValueObjectGetString(data, "desc");
+
+ if (STREQ_NULLABLE(klass, "GenericError") &&
+ STREQ_NULLABLE(desc, "guest hasn't updated any stats yet")) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("the guest hasn't updated any stats yet"));
+ ret = -1;
+ goto cleanup;
+ }
+ }
+
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+
if (!(data = virJSONValueObjectGet(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("qom-get reply was missing return data"));
goto cleanup;
}
if (!(statsdata = virJSONValueObjectGet(data, "stats"))) {
VIR_DEBUG("data does not include 'stats'");
goto cleanup;
}
--
1.8.3.2
10 years, 7 months
[libvirt] [PATCH] Prevent guest be paused when do external system checkpoint snapshot
by Shanzhi Yu
https://bugzilla.redhat.com/show_bug.cgi?id=1097503
Guest will be paused when do external system checkpoint snapshot with
invalid compression format.
Signed-off-by: Shanzhi Yu <shyu(a)redhat.com>
---
src/qemu/qemu_driver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a5c7f4f..0761760 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13207,13 +13207,13 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Invalid snapshot image format specified "
"in configuration file"));
- goto cleanup;
+ goto endjob;
}
if (!qemuCompressProgramAvailable(compressed)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Compression program for image format "
"in configuration file isn't available"));
- goto cleanup;
+ goto endjob;
}
}
--
1.8.3.1
10 years, 7 months
[libvirt] [PATCH] network: Defer online of macvtap during qemu migration
by Matthew Rosato
When generating macvtaps via virNetDevMacVLanCreateWithVPortProfile,
the macvtap device is unconditionally set to the up state. However,
during migration, this results in a case where both the source and
target system are simultaneously up with the same MAC address. This
patch defers bringing the target macvtap up until later in the
migration to shrink this window.
Signed-off-by: Matthew Rosato <mjrosato(a)linux.vnet.ibm.com>
---
src/qemu/qemu_migration.c | 18 ++++++++++++++++++
src/util/virnetdevmacvlan.c | 11 ++++++++---
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index a9f7fea..aee803a 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -56,6 +56,7 @@
#include "virhook.h"
#include "virstring.h"
#include "virtypedparam.h"
+#include "virnetdev.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
@@ -4468,6 +4469,8 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
virCapsPtr caps = NULL;
unsigned short port;
+ virDomainNetDefPtr net;
+ size_t i;
VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, flags=%lx, retcode=%d",
@@ -4574,6 +4577,21 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
}
if (!(flags & VIR_MIGRATE_PAUSED) && !(flags & VIR_MIGRATE_OFFLINE)) {
+ /* Macvtaps were previously left offline, bring them online now */
+ for (i = 0; i < vm->def->nnets; i++) {
+ net = vm->def->nets[i];
+ if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
+ if (virNetDevSetOnline(net->ifname, true) < 0) {
+ ignore_value(virNetDevVPortProfileDisassociate(net->ifname,
+ virDomainNetGetActualVirtPortProfile(net),
+ &net->mac,
+ virDomainNetGetActualDirectDev(net),
+ -1,
+ VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH));
+ ignore_value(virNetDevMacVLanDelete(net->ifname));
+ }
+ }
+ }
/* run 'cont' on the destination, which allows migration on qemu
* >= 0.10.6 to work properly. This isn't strictly necessary on
* older qemu's, but it also doesn't hurt anything there
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 7bbf540..3da845b 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -898,9 +898,14 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
goto link_del_exit;
}
- if (virNetDevSetOnline(cr_ifname, true) < 0) {
- rc = -1;
- goto disassociate_exit;
+ /* If this device is being created as part of an inbound
+ * migration, leave the device offline for now.
+ */
+ if (vmOp != VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START) {
+ if (virNetDevSetOnline(cr_ifname, true) < 0) {
+ rc = -1;
+ goto disassociate_exit;
+ }
}
if (withTap) {
--
1.7.9.5
10 years, 7 months
[libvirt] [PATCH] qemu: snapshot: Terminate job when memory compression program isn't found
by Peter Krempa
If the compression program for external snapshot memory image isn't
found we exitted the function without terminating the domain job. This
caused the domain to be unusable.
The problem was introduced in commit 7df5093f.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1097503
---
src/qemu/qemu_driver.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a5c7f4f..52ca47c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13207,13 +13207,14 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Invalid snapshot image format specified "
"in configuration file"));
- goto cleanup;
+ goto endjob;
}
+
if (!qemuCompressProgramAvailable(compressed)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Compression program for image format "
"in configuration file isn't available"));
- goto cleanup;
+ goto endjob;
}
}
--
1.9.2
10 years, 7 months
[libvirt] daemon-config-network dependency
by Cedric Bosdonnat
Hi all,
The libvirt-daemon-config-network package is only pulled by libvirt. So
a user installing only libvirt-daemon-lxc (qemu, xen, etc) won't get
that package... and no default network.
Would it be OK if I move the dependency to
libvirt-daemon-{lxc,qemu,xen,...} packages?
--
Cedric
10 years, 7 months
Re: [libvirt] [Qemu-devel] qemu leaving unix sockets behind after VM is shut down
by Stefan Hajnoczi
On Tue, Apr 01, 2014 at 02:34:58PM -0600, Chris Friesen wrote:
> When running qemu with something like this
>
> -device virtio-serial \
> -chardev socket,path=/tmp/foo,server,nowait,id=foo \
> -device virtserialport,chardev=foo,name=host.port.0
>
> the VM starts up as expected and creates a socket at /tmp/foo as expected.
>
> However, when I shut down the VM the socket at /tmp/foo is left
> behind in the filesystem. Basically qemu has "leaked" a file.
>
> With something like OpenStack where we could be creating/destroying
> many VMs this could end up creating a significant number of files in
> the specified directory.
>
> Has any thought been given to either automatically cleaning up the
> unix socket in the filesystem when qemu exits, or else supporting
> the abstract namespace for unix sockets to allow for automatic
> cleanup?
Libvirt has a special case for the monitor socket in its
qemuProcessStop() function.
Are you using the OpenStack libvirt driver?
Perhaps QEMU should support cleanup but first I think we should check
the situation with libvirt.
Stefan
10 years, 7 months
[libvirt] [libvirt-python PATCH] override: add virDomainFSFreeze and virDomainFSThaw API
by Tomoki Sekiyama
Add binding for the new virDomainFSFreeze and virDomainFSThaw functions
added in libvirt 1.2.5. These require override since these take a list
of mountpoints path string. The methods are named 'fSFreeze' and 'fSThaw',
like a existing 'fSTrim' method.
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama(a)hds.com>
---
generator.py | 2 +
libvirt-override-api.xml | 14 +++++++
libvirt-override.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 113 insertions(+)
diff --git a/generator.py b/generator.py
index 05ec743..eec81b0 100755
--- a/generator.py
+++ b/generator.py
@@ -462,6 +462,8 @@ skip_impl = (
'virDomainMigrate3',
'virDomainMigrateToURI3',
'virConnectGetCPUModelNames',
+ 'virDomainFSFreeze',
+ 'virDomainFSThaw',
)
lxc_skip_impl = (
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index d5b25b5..a3db33e 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -624,5 +624,19 @@
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='flags' type='int' info='unused, pass 0'/>
</function>
+ <function name='virDomainFSFreeze' file='python'>
+ <info>Freeze specified filesystems within the guest</info>
+ <return type='int' info='the number of frozen filesystems on success, -1 otherwise.'/>
+ <arg name='dom' type='virDomainPtr' info='a domain object'/>
+ <arg name='mountpoints' type='const char **' info='list of mount points to be frozen, or None'/>
+ <arg name='flags' type='unsigned int' info='unused, pass 0'/>
+ </function>
+ <function name='virDomainFSThaw' file='python'>
+ <info>Thaw specified filesystems within the guest</info>
+ <return type='int' info='the number of thawed filesystems on success, -1 otherwise.'/>
+ <arg name='dom' type='virDomainPtr' info='a domain object'/>
+ <arg name='mountpoints' type='const char **' info='list of mount points to be thawed, or None'/>
+ <arg name='flags' type='unsigned int' info='unused, pass 0'/>
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index 3fa9b9b..d0557c2 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -7554,6 +7554,99 @@ cleanup:
#endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
+#if LIBVIR_CHECK_VERSION(1, 2, 5)
+static PyObject *
+libvirt_virDomainFSFreeze(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
+ PyObject *py_retval = NULL;
+ int c_retval;
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ PyObject *pyobj_list;
+ unsigned int flags;
+ unsigned int nmountpoints = 0;
+ const char **mountpoints = NULL;
+ size_t i = 0, j;
+
+ if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainFSFreeze",
+ &pyobj_domain, &pyobj_list, &flags))
+ return NULL;
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ if (PyList_Check(pyobj_list)) {
+ nmountpoints = PyList_Size(pyobj_list);
+
+ if (VIR_ALLOC_N(mountpoints, nmountpoints) < 0)
+ return PyErr_NoMemory();
+
+ for (i = 0; i < nmountpoints; i++) {
+ if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i),
+ (char **)mountpoints+i) < 0 ||
+ mountpoints[i] == NULL)
+ goto cleanup;
+ }
+ }
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainFSFreeze(domain, mountpoints, nmountpoints, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+ py_retval = libvirt_intWrap((int) c_retval);
+
+cleanup:
+ if (mountpoints) {
+ for (j = 0 ; j < i ; j++)
+ VIR_FREE(mountpoints[j]);
+ VIR_FREE(mountpoints);
+ }
+ return py_retval;
+}
+
+
+static PyObject *
+libvirt_virDomainFSThaw(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
+ PyObject *py_retval = NULL;
+ int c_retval;
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ PyObject *pyobj_list;
+ unsigned int flags;
+ unsigned int nmountpoints = 0;
+ const char **mountpoints = NULL;
+ size_t i = 0, j;
+
+ if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainFSThaw",
+ &pyobj_domain, &pyobj_list, &flags))
+ return NULL;
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ if (PyList_Check(pyobj_list)) {
+ nmountpoints = PyList_Size(pyobj_list);
+
+ if (VIR_ALLOC_N(mountpoints, nmountpoints) < 0)
+ return PyErr_NoMemory();
+
+ for (i = 0; i < nmountpoints; i++) {
+ if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i),
+ (char **)mountpoints+i) < 0 ||
+ mountpoints[i] == NULL)
+ goto cleanup;
+ }
+ }
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainFSThaw(domain, mountpoints, nmountpoints, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+ py_retval = libvirt_intWrap((int) c_retval);
+
+cleanup:
+ if (mountpoints) {
+ for (j = 0 ; j < i ; j++)
+ VIR_FREE(mountpoints[j]);
+ VIR_FREE(mountpoints);
+ }
+ return py_retval;
+}
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
+
/************************************************************************
* *
* The registration stuff *
@@ -7729,6 +7822,10 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainCreateXMLWithFiles", libvirt_virDomainCreateXMLWithFiles, METH_VARARGS, NULL},
{(char *) "virDomainCreateWithFiles", libvirt_virDomainCreateWithFiles, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */
+#if LIBVIR_CHECK_VERSION(1, 2, 5)
+ {(char *) "virDomainFSFreeze", libvirt_virDomainFSFreeze, METH_VARARGS, NULL},
+ {(char *) "virDomainFSThaw", libvirt_virDomainFSThaw, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 5) */
{NULL, NULL, 0, NULL}
};
10 years, 7 months
[libvirt] [Question] (python API) setMemoryParameters doesn't support flags CONFIG | LIVE
by Wangrui (K)
Hi, all
when I use (python API) setMemoryParameters with flags= VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE ,
an error occurs as follow: (libvirt 1.2.4)
libvirt: error : flags 'affect live' and 'affect config' in virDomainGetMemoryParameters are mutually exclusive
I check the function libvirt_virDomainSetMemoryParameters in libvirt-override.c and find the code below:
Line 1204-1206:
LIBVIRT_BEGIN_ALLOW_THREADS;
i_retval = virDomainGetMemoryParameters(domain, NULL, &nparams, flags);
LIBVIRT_END_ALLOW_THREADS;
Line 1220-1222:
LIBVIRT_BEGIN_ALLOW_THREADS;
i_retval = virDomainGetMemoryParameters(domain, params, &nparams, flags);
LIBVIRT_END_ALLOW_THREADS;
Function virDomainGetMemoryParameters doesn't support flags VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE.
So the error above occurs.
The first call of virDomainGetMemoryParameters is to "cause @nparams on output to contain the number of parameters
supported by the hypervisor". And what's the role of the second call?
Maybe, so do other functions such as *libvirt_virDomainSetSchedulerParameters, *libvirt_virDomainSetBlkioParameters
In commit 56cec18d761a1f99862c43811de60380c65881e6.
IMHO, an example flag (such as VIR_DOMAIN_AFFECT_CONFIG) can be used in virDomainGetMemoryParameters
just to get something from hypervisor rather than @flags which is a parameter of setMemoryParameters .
10 years, 7 months