[libvirt] [PATCH 1/4] conf: use typedefs for enums in "src/conf/{node_device_conf, nwfilter_params}.h"
by Julio Faracco
In "src/conf/" there are many enumeration (enum) declarations. Similar to the recent cleanup to "src/util" directory, it's better to use a typedef for variable types, function types and other usages. Other enumeration and folders will be changed to typedef's in the future. Most of the files changed in this commit are reltaed to Network (node_device_conf.h and nwfilter_params.*) enums.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/conf/node_device_conf.h | 24 ++++++++++++------------
src/conf/nwfilter_params.c | 2 +-
src/conf/nwfilter_params.h | 14 +++++++-------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 9b5d172..50e6805 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -35,7 +35,7 @@
# define CREATE_DEVICE 1
# define EXISTING_DEVICE 0
-enum virNodeDevCapType {
+typedef enum {
/* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */
VIR_NODE_DEV_CAP_SYSTEM, /* System capability */
VIR_NODE_DEV_CAP_PCI_DEV, /* PCI device */
@@ -51,38 +51,38 @@ enum virNodeDevCapType {
VIR_NODE_DEV_CAP_SCSI_GENERIC, /* SCSI generic device */
VIR_NODE_DEV_CAP_LAST
-};
+} virNodeDevCapType;
-enum virNodeDevNetCapType {
+typedef enum {
/* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */
VIR_NODE_DEV_CAP_NET_80203, /* 802.03 network device */
VIR_NODE_DEV_CAP_NET_80211, /* 802.11 network device */
VIR_NODE_DEV_CAP_NET_LAST
-};
+} virNodeDevNetCapType;
VIR_ENUM_DECL(virNodeDevCap)
VIR_ENUM_DECL(virNodeDevNetCap)
-enum virNodeDevStorageCapFlags {
+typedef enum {
VIR_NODE_DEV_CAP_STORAGE_REMOVABLE = (1 << 0),
VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE = (1 << 1),
VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE = (1 << 2),
-};
+} virNodeDevStorageCapFlags;
-enum virNodeDevSCSIHostCapFlags {
+typedef enum {
VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST = (1 << 0),
VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS = (1 << 1),
-};
+} virNodeDevSCSIHostCapFlags;
-enum virNodeDevPCICapFlags {
+typedef enum {
VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION = (1 << 0),
VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION = (1 << 1),
-};
+} virNodeDevPCICapFlags;
typedef struct _virNodeDevCapsDef virNodeDevCapsDef;
typedef virNodeDevCapsDef *virNodeDevCapsDefPtr;
struct _virNodeDevCapsDef {
- enum virNodeDevCapType type;
+ virNodeDevCapType type;
union _virNodeDevCapData {
struct {
char *product_name;
@@ -135,7 +135,7 @@ struct _virNodeDevCapsDef {
char *address;
unsigned int address_len;
char *ifname;
- enum virNodeDevNetCapType subtype; /* LAST -> no subtype */
+ virNodeDevNetCapType subtype; /* LAST -> no subtype */
} net;
struct {
unsigned int host;
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index ac4d4a8..a12e645 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -1061,7 +1061,7 @@ virNWFilterVarAccessGetVarName(const virNWFilterVarAccess *vap)
return vap->varName;
}
-enum virNWFilterVarAccessType
+virNWFilterVarAccessType
virNWFilterVarAccessGetType(const virNWFilterVarAccess *vap)
{
return vap->accessType;
diff --git a/src/conf/nwfilter_params.h b/src/conf/nwfilter_params.h
index 08e448f..98610a7 100644
--- a/src/conf/nwfilter_params.h
+++ b/src/conf/nwfilter_params.h
@@ -27,17 +27,17 @@
# include "virbuffer.h"
# include "virmacaddr.h"
-enum virNWFilterVarValueType {
+typedef enum {
NWFILTER_VALUE_TYPE_SIMPLE,
NWFILTER_VALUE_TYPE_ARRAY,
NWFILTER_VALUE_TYPE_LAST
-};
+} virNWFilterVarValueType;
typedef struct _virNWFilterVarValue virNWFilterVarValue;
typedef virNWFilterVarValue *virNWFilterVarValuePtr;
struct _virNWFilterVarValue {
- enum virNWFilterVarValueType valType;
+ virNWFilterVarValueType valType;
union {
struct {
char *value;
@@ -98,17 +98,17 @@ bool virNWFilterHashTableEqual(virNWFilterHashTablePtr a,
# define NWFILTER_VARNAME_CTRL_IP_LEARNING "CTRL_IP_LEARNING"
# define NWFILTER_VARNAME_DHCPSERVER "DHCPSERVER"
-enum virNWFilterVarAccessType {
+typedef enum {
VIR_NWFILTER_VAR_ACCESS_ELEMENT = 0,
VIR_NWFILTER_VAR_ACCESS_ITERATOR = 1,
VIR_NWFILTER_VAR_ACCESS_LAST,
-};
+} virNWFilterVarAccessType;
typedef struct _virNWFilterVarAccess virNWFilterVarAccess;
typedef virNWFilterVarAccess *virNWFilterVarAccessPtr;
struct _virNWFilterVarAccess {
- enum virNWFilterVarAccessType accessType;
+ virNWFilterVarAccessType accessType;
union {
struct {
unsigned int index;
@@ -128,7 +128,7 @@ virNWFilterVarAccessPtr virNWFilterVarAccessParse(const char *varAccess);
void virNWFilterVarAccessPrint(virNWFilterVarAccessPtr vap,
virBufferPtr buf);
const char *virNWFilterVarAccessGetVarName(const virNWFilterVarAccess *vap);
-enum virNWFilterVarAccessType virNWFilterVarAccessGetType(
+virNWFilterVarAccessType virNWFilterVarAccessGetType(
const virNWFilterVarAccess *vap);
unsigned int virNWFilterVarAccessGetIterId(const virNWFilterVarAccess *vap);
unsigned int virNWFilterVarAccessGetIndex(const virNWFilterVarAccess *vap);
--
1.7.10.4
10 years, 11 months
[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, 11 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, 11 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, 11 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, 11 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, 11 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, 11 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, 11 months