[libvirt] [PATCH] docs: Add yet another libvirt based app
by Michal Privoznik
As announced on the list [1], Cherrypop is a management
application based on libvirt. It's a decentralized cloud software
with nice scaling ability.
1: https://www.redhat.com/archives/libvir-list/2015-September/msg00670.html
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
@Gustav: I've used the description from the github repo, if that's okay.
docs/apps.html.in | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/docs/apps.html.in b/docs/apps.html.in
index fd45189..86b3016 100644
--- a/docs/apps.html.in
+++ b/docs/apps.html.in
@@ -262,6 +262,16 @@
using a dashboard. Compute part uses libvirt to manage VM
life-cycle, monitoring and so on.
</dd>
+
+ <dt><a href="https://github.com/gustavfranssonnyvell/cherrypop">Cherrypop</a></dt>
+ <dd>
+ A cloud software with no masters or central points. Nodes
+ autodetect other nodes and autodistribute virtual
+ machines and autodivide up the workload. Also there is no
+ minimum limit for hosts, well, one might be nice. It's
+ perfect for setting up low-end servers in a cloud or a
+ cloud where you want the most bang for the bucks.
+ </dd>
</dl>
<h2><a name="libraries">Libraries</a></h2>
--
2.4.9
9 years, 2 months
[libvirt] by libvirt api(virStoragePoolRefresh) to refresh pool, discovered the connection is very slow
by 饶俊明
Hello
In ours project,use libvirt(libvirt-0.10.2-46.el6) to manage storage pool(the type of pool is ceph rbd),
by libvirt api(virStoragePoolRefresh) to refresh pool, discovered the connection(libvirt to ceph) is very slow
libvirt is how to deal with pool refresh.
tks!!!
Jason rao
-----邮件原件-----
发件人: libvir-list-bounces(a)redhat.com [mailto:libvir-list-bounces@redhat.com] 代表 libvir-list-request(a)redhat.com
发送时间: 2015年9月24日 7:19
收件人: libvir-list(a)redhat.com
主题: libvir-list Digest, Vol 118, Issue 146
Send libvir-list mailing list submissions to
libvir-list(a)redhat.com
To subscribe or unsubscribe via the World Wide Web, visit
https://www.redhat.com/mailman/listinfo/libvir-list
or, via email, send a message with subject or body 'help' to
libvir-list-request(a)redhat.com
You can reach the person managing the list at
libvir-list-owner(a)redhat.com
When replying, please edit your Subject line so it is more specific than "Re: Contents of libvir-list digest..."
Today's Topics:
1. [PATCH] domain: Fix migratable XML with graphics/@listen
(Jiri Denemark)
2. [PATCH] storage: Fix incorrect format for <disk> <auth> XML
(John Ferlan)
3. Re: [PATCH v2] qemuDomainDeviceDefPostParse: Drop useless
checks (John Ferlan)
4. Re: [PATCH RFC 4/7] libxl: implement virDomainBlockStats
(Jim Fehlig)
5. [PATCH 0/6] Fix some Coverity issues (John Ferlan)
----------------------------------------------------------------------
Message: 1
Date: Wed, 23 Sep 2015 22:48:14 +0200
From: Jiri Denemark <jdenemar(a)redhat.com>
To: libvir-list(a)redhat.com
Subject: [libvirt] [PATCH] domain: Fix migratable XML with
graphics/@listen
Message-ID:
<1e763711f268f0f5d09f6a70aab87bf13dd459f9.1443041294.git.jdenemar(a)redhat.com>
As of commit 6992994, we set graphics/@listen attribute according to the first listen child element even if that element is of type='network'.
This was done for backward compatibility with applications which only support the original listen attribute. However, by doing so we broke migration to older libvirt which tried to check that the listen attribute matches one of the listen child elements but which did not take type='network' elements into account.
We are not concerned about compatibility with old applications when formatting domain XML for migration for two reasons. The XML is consumed only by libvirtd and the IP address associated with type='network'
listen address on the source host is just useless on the destination host. Thus, we can safely avoid propagating the type='network' IP address to graphics/@listen attribute when creating migratable XML.
https://bugzilla.redhat.com/show_bug.cgi?id=1265111
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/conf/domain_conf.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c890977..033ae46 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21020,19 +21020,17 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
* <graphics>. This is done to improve backward compatibility.
*/
for (i = 0; i < def->nListens; i++) {
- virDomainGraphicsListenType listenType;
-
if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
def->listens[i].fromConfig)
continue;
- listenType = virDomainGraphicsListenGetType(def, i);
- if (listenType == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
- (listenType == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
- !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))) {
- if ((listenAddr = virDomainGraphicsListenGetAddress(def, i)))
- break;
- }
+ if (def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
+ flags & (VIR_DOMAIN_DEF_FORMAT_INACTIVE |
+ VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))
+ continue;
+
+ if ((listenAddr = virDomainGraphicsListenGetAddress(def, i)))
+ break;
}
virBufferAsprintf(buf, "<graphics type='%s'", type);
--
2.5.3
------------------------------
Message: 2
Date: Wed, 23 Sep 2015 16:54:35 -0400
From: John Ferlan <jferlan(a)redhat.com>
To: libvir-list(a)redhat.com
Subject: [libvirt] [PATCH] storage: Fix incorrect format for <disk>
<auth> XML
Message-ID: <1443041675-19738-1-git-send-email-jferlan(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1256999
When creating a copy of the 'authdef', need to take into account the
slight variation between <disk> and <pool> before blindly copying
the 'authType' field. This ensures virStorageAuthDefFormat will
properly format the <auth> XML for a <disk>.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/util/virstoragefile.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 2aa1d90..0b72cb3 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1522,7 +1522,12 @@ virStorageAuthDefCopy(const virStorageAuthDef *src)
/* Not present for storage pool, but used for disk source */
if (VIR_STRDUP(ret->secrettype, src->secrettype) < 0)
goto error;
- ret->authType = src->authType;
+ /* A <disk> uses secrettype, while a <pool> uses authType, so
+ * if we have a secrettype, then don't copy authType; otherwise,
+ * we will format the authType in <disk>
+ */
+ if (!ret->secrettype)
+ ret->authType = src->authType;
ret->secretType = src->secretType;
if (ret->secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
memcpy(ret->secret.uuid, src->secret.uuid, sizeof(ret->secret.uuid));
--
2.1.0
------------------------------
Message: 3
Date: Wed, 23 Sep 2015 18:03:47 -0400
From: John Ferlan <jferlan(a)redhat.com>
To: Michal Privoznik <mprivozn(a)redhat.com>, libvir-list(a)redhat.com
Subject: Re: [libvirt] [PATCH v2] qemuDomainDeviceDefPostParse: Drop
useless checks
Message-ID: <560321C3.1000808(a)redhat.com>
Content-Type: text/plain; charset=windows-1252
On 09/23/2015 07:19 AM, Michal Privoznik wrote:
> Now that virQEMUDriverCreateXMLConf is never called with NULL
> (after 086f37e97aab) we can safely drop useless check in
> qemuDomainDeviceDefPostParse as we are guaranteed to be always
> called with the driver initialized. Therefore checking if driver
> is NULL makes no sense. Moreover, if we mix it with direct driver
> dereference. And after that, we are sure that nor @cfg will be
> NULL, therefore we can drop checks for that too.
>
> Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
> ---
>
> diff to v1:
> - drop checks for !cfg too
>
> src/qemu/qemu_domain.c | 64 ++++++++++++++++++++------------------------------
> 1 file changed, 26 insertions(+), 38 deletions(-)
>
ACK
John
Coverity error goes away too.
------------------------------
Message: 4
Date: Wed, 23 Sep 2015 16:24:30 -0600
From: Jim Fehlig <jfehlig(a)suse.com>
To: Joao Martins <joao.m.martins(a)oracle.com>
Cc: libvir-list(a)redhat.com
Subject: Re: [libvirt] [PATCH RFC 4/7] libxl: implement
virDomainBlockStats
Message-ID: <5603269E.6090101(a)suse.com>
Content-Type: text/plain; charset=ISO-8859-1
Joao Martins wrote:
> Introduce initial support for domainBlockStats API call that
> allow us to query block device statistics. openstack nova
> uses this API call to query block statistics, alongside
> virDomainMemoryStats and virDomainInterfaceStats. Note that
> this patch only introduces it for VBD for starters. QDisk
> will come in a separate patch series.
>
> A new statistics data structure is introduced to fit common
> statistics among others specific to the underlying block
> backends. For the VBD statistics on linux these are exported
> via sysfs on the path:
>
> "/sys/bus/xen-backend/devices/vbd-<domid>-<devid>/statistics"
>
> To calculate the block devid two libxl functions were ported
> (libxlDiskPathMatches and libxlDiskPathParse) to libvirt to
> make sure the devid is calculate in the same way as libxl.
> Each backend implements its own function to extract statistics
> and let there be handled the different platforms. An alternative
> would be to reuse libvirt xen driver function.
>
> VBD stats are exposed in reqs and number of sectors from
> blkback, and it's up to us to convert it to sector sizes.
> The sector size is gathered through xenstore in the device
> backend entry "physical-sector-size". This adds up an extra
> dependency namely of xenstore for doing the xs_read.
>
> BlockStatsFlags variant is also implemented which has the
> added benefit of getting the number of flush requests.
>
> Signed-off-by: Joao Martins <joao.m.martins(a)oracle.com>
> ---
> configure.ac | 2 +-
> src/libxl/libxl_driver.c | 420 +++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 421 insertions(+), 1 deletion(-)
>
> diff --git a/configure.ac b/configure.ac
> index ef7fbdb..56fb266 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -896,7 +896,7 @@ if test "$with_libxl" != "no" ; then
> LIBS="$LIBS $LIBXL_LIBS"
> AC_CHECK_LIB([xenlight], [libxl_ctx_alloc], [
> with_libxl=yes
> - LIBXL_LIBS="$LIBXL_LIBS -lxenlight -lxenctrl"
> + LIBXL_LIBS="$LIBXL_LIBS -lxenlight -lxenctrl -lxenstore"
> ],[
> if test "$with_libxl" = "yes"; then
> fail=1
> diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
> index dc83083..fd952a3 100644
> --- a/src/libxl/libxl_driver.c
> +++ b/src/libxl/libxl_driver.c
> @@ -59,6 +59,7 @@
> #include "network/bridge_driver.h"
> #include "locking/domain_lock.h"
> #include "virstats.h"
> +#include <xenstore.h>
>
> #define VIR_FROM_THIS VIR_FROM_LIBXL
>
> @@ -75,6 +76,7 @@ VIR_LOG_INIT("libxl.libxl_driver");
> #define LIBXL_CONFIG_FORMAT_SEXPR "xen-sxpr"
>
> #define LIBXL_NB_TOTAL_CPU_STAT_PARAM 1
> +#define LIBXL_NB_TOTAL_BLK_STAT_PARAM 6
>
> #define HYPERVISOR_CAPABILITIES "/proc/xen/capabilities"
> #define HYPERVISOR_XENSTORED "/dev/xen/xenstored"
> @@ -103,6 +105,25 @@ struct _libxlOSEventHookInfo {
> int id;
> };
>
> +/* Object used to store disk statistics across multiple xen backends */
> +typedef struct _libxlBlockStats libxlBlockStats;
> +typedef libxlBlockStats *libxlBlockStatsPtr;
> +struct _libxlBlockStats {
> + long long rd_req;
> + long long rd_bytes;
> + long long wr_req;
> + long long wr_bytes;
> + long long f_req;
> +
> + char *backend;
> + union {
> + struct {
> + long long ds_req;
> + long long oo_req;
> + } vbd;
> + } u;
> +};
> +
> /* Function declarations */
> static int
> libxlDomainManagedSaveLoad(virDomainObjPtr vm,
> @@ -4641,6 +4662,403 @@ libxlDomainIsUpdated(virDomainPtr dom)
> }
>
> static int
> +libxlDiskPathMatches(const char *virtpath, const char *devtype,
> + int *index_r, int max_index,
> + int *partition_r, int max_partition)
> +{
> + const char *p;
> + char *ep;
> + int tl, c;
> + long pl;
> +
> + tl = strlen(devtype);
> + if (memcmp(virtpath, devtype, tl))
> + return 0;
> +
> + /* We decode the drive letter as if it were in base 52
> + * with digits a-zA-Z, more or less */
> + *index_r = -1;
> + p = virtpath + tl;
> + for (;;) {
> + c = *p++;
> + if (c >= 'a' && c <= 'z') {
> + c -= 'a';
> + } else {
> + --p;
> + break;
> + }
> + (*index_r)++;
> + (*index_r) *= 26;
> + (*index_r) += c;
> +
> + if (*index_r > max_index)
> + return 0;
> + }
> +
> + if (!*p) {
> + *partition_r = 0;
> + return 1;
> + }
> +
> + if (*p == '0')
> + return 0; /* leading zeroes not permitted in partition number */
> +
> + if (virStrToLong_l(p, &ep, 10, &pl) < 0)
> + return 0;
> +
> + if (pl > max_partition || *ep)
> + return 0;
> +
> + *partition_r = pl;
> + return 1;
> +}
> +
> +static int
> +libxlDiskPathParse(const char *virtpath, int *pdisk, int *ppartition)
> +{
> + int disk, partition;
> + char *ep;
> + unsigned long ul;
> + int chrused;
> +
> + chrused = -1;
> + if ((sscanf(virtpath, "d%ip%i%n", &disk, &partition, &chrused) >= 2
> + && chrused == strlen(virtpath) && disk < (1<<20) && partition < 256)
> + ||
> + libxlDiskPathMatches(virtpath, "xvd",
> + &disk, (1<<20)-1,
> + &partition, 255)) {
> + if (pdisk) *pdisk = disk;
> + if (ppartition) *ppartition = partition;
> + if (disk <= 15 && partition <= 15)
> + return (202 << 8) | (disk << 4) | partition;
> + else
> + return (1 << 28) | (disk << 8) | partition;
> + }
> +
> + errno = virStrToLong_ul(virtpath, &ep, 0, &ul);
> + if (!errno && !*ep && ul <= INT_MAX) {
> + /* FIXME: should parse ul to determine these. */
> + if (pdisk || ppartition)
> + return -1;
> + return ul;
> + }
> +
> + if (libxlDiskPathMatches(virtpath, "hd",
> + &disk, 3,
> + &partition, 63)) {
> + if (pdisk) *pdisk = disk;
> + if (ppartition) *ppartition = partition;
> + return ((disk<2 ? 3 : 22) << 8) | ((disk & 1) << 6) | partition;
> + }
> + if (libxlDiskPathMatches(virtpath, "sd",
> + &disk, 15,
> + &partition, 15)) {
> + if (pdisk) *pdisk = disk;
> + if (ppartition) *ppartition = partition;
> + return (8 << 8) | (disk << 4) | partition;
> + }
> + return -1;
> +}
> +
> +#define LIBXL_VBD_SECTOR_SIZE 512
> +
> +static int
> +libxlDiskSectorSize(int domid, int devno)
> +{
> + char *path, *val;
> + struct xs_handle *handle;
> + int ret = LIBXL_VBD_SECTOR_SIZE;
> + unsigned int len;
> +
> + handle = xs_daemon_open_readonly();
> + if (!handle) {
> + virReportError(VIR_ERR_INTERNAL_ERROR,
> + "%s", _("cannot read sector size"));
> + return ret;
> + }
> +
> + if (virAsprintf(&path, "/local/domain/%d/device/vbd/%d/backend",
> + domid, devno) < 0)
>
Indentation looks off.
> + goto close;
> +
> + if ((val = xs_read(handle, XBT_NULL, path, &len)) == NULL)
> + goto cleanup;
> +
> + VIR_FREE(path);
> + if (virAsprintf(&path, "%s/physical-sector-size", val) < 0) {
> + VIR_FREE(val);
> + goto close;
> + }
> +
> + VIR_FREE(val);
> + if ((val = xs_read(handle, XBT_NULL, path, &len)) == NULL)
> + goto cleanup;
> +
> + if (sscanf(val, "%d", &ret) != 1)
> + ret = -1;
>
Should ret be set back to LIBXL_VBD_SECTOR_SIZE? '-1' wouldn't be a good
value for the calling function.
> +
> + VIR_FREE(val);
> +
> + cleanup:
> + VIR_FREE(path);
> + close:
> + xs_daemon_close(handle);
> + return ret;
> +}
> +
> +static int
> +libxlDomainBlockStatsVBD(virDomainObjPtr vm,
> + const char *dev,
> + libxlBlockStatsPtr stats)
> +{
> + int ret = -1;
> + int devno = libxlDiskPathParse(dev, NULL, NULL);
> + int size = libxlDiskSectorSize(vm->def->id, devno);
> +#ifdef __linux__
> + char *path, *name, *val;
> + unsigned long long stat;
> +
> + if (VIR_STRDUP(stats->backend, "vbd") < 0) {
> + virReportError(VIR_ERR_OPERATION_INVALID,
> + "%s", _("cannot set backend"));
>
VIR_STRDUP() already reports OOM error, which is about the only one it
can encounter.
> + return -1;
> + }
> +
> + ret = virAsprintf(&path, "/sys/bus/xen-backend/devices/vbd-%d-%d/statistics",
> + vm->def->id, devno);
>
The usual pattern is 'if (virAsprintf(...) < 0)'.
> +
> + if (!virFileExists(path)) {
> + virReportError(VIR_ERR_OPERATION_INVALID,
> + "%s", _("cannot open bus path"));
>
I think the error should be VIR_ERR_OPERATION_FAILED.
> + goto cleanup;
> + }
> +
> +#define LIBXL_SET_VBDSTAT(FIELD, VAR, MUL) \
>
Indentation is off here. Fails 'make syntax-check' with cppi installed.
> + if ((virAsprintf(&name, "%s/"FIELD, path) < 0) || \
> + (virFileReadAll(name, 256, &val) < 0) || \
> + (sscanf(val, "%llu", &stat) != 1)) { \
> + virReportError(VIR_ERR_OPERATION_INVALID, \
> + _("cannot read %s"), name); \
>
VIR_ERR_OPERATION_FAILED?
> + goto cleanup; \
> + } \
> + VAR += (stat * MUL); \
> + VIR_FREE(name); \
> + VIR_FREE(val);
> +
> + LIBXL_SET_VBDSTAT("f_req", stats->f_req, 1)
> + LIBXL_SET_VBDSTAT("wr_req", stats->wr_req, 1)
> + LIBXL_SET_VBDSTAT("rd_req", stats->rd_req, 1)
> + LIBXL_SET_VBDSTAT("wr_sect", stats->wr_bytes, size)
> + LIBXL_SET_VBDSTAT("rd_sect", stats->rd_bytes, size)
> +
> + LIBXL_SET_VBDSTAT("ds_req", stats->u.vbd.ds_req, size)
> + LIBXL_SET_VBDSTAT("oo_req", stats->u.vbd.oo_req, 1)
> + ret = 0;
> +
> + cleanup:
> + VIR_FREE(name);
> + VIR_FREE(path);
> + VIR_FREE(val);
>
This will only cleanup 'name' and 'val' from the last invocation of the
LIBXL_SET_VBDSTAT macro. 'name' and 'val' from the prior invocations
will be leaked.
> +
> +#undef LIBXL_SET_VBDSTAT
>
Another case of failing 'make syntax-check' with cppi installed.
Regards,
Jim
> +
> +#else
> + virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
> + "%s", _("platform unsupported"));
> +#endif
> + return ret;
> +}
> +
> +static int
> +libxlDomainBlockStatsGatherSingle(virDomainObjPtr vm,
> + const char *path,
> + libxlBlockStatsPtr stats)
> +{
> + virDomainDiskDefPtr disk;
> + const char *disk_drv;
> + int ret = -1, disk_fmt;
> +
> + if (!(disk = virDomainDiskByName(vm->def, path, false))) {
> + virReportError(VIR_ERR_OPERATION_INVALID,
> + _("invalid path: %s"), path);
> + return ret;
> + }
> +
> + disk_fmt = virDomainDiskGetFormat(disk);
> + if (!(disk_drv = virDomainDiskGetDriver(disk)))
> + disk_drv = "qemu";
> +
> + if (STREQ(disk_drv, "phy")) {
> + if (disk_fmt != VIR_STORAGE_FILE_RAW &&
> + disk_fmt != VIR_STORAGE_FILE_NONE) {
> + virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
> + _("unsupported format %s"),
> + virStorageFileFormatTypeToString(disk_fmt));
> + return ret;
> + }
> +
> + ret = libxlDomainBlockStatsVBD(vm, path, stats);
> + } else {
> + virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
> + _("unsupported disk driver %s"),
> + disk_drv);
> + return ret;
> + }
> + return ret;
> +}
> +
> +static int
> +libxlDomainBlockStatsGather(virDomainObjPtr vm,
> + const char *path,
> + libxlBlockStatsPtr stats)
> +{
> + int ret = -1;
> + if (*path) {
> + if (libxlDomainBlockStatsGatherSingle(vm, path, stats) < 0)
> + return ret;
> + } else {
> + size_t i;
> + for (i = 0; i < vm->def->ndisks; ++i) {
> + if (libxlDomainBlockStatsGatherSingle(vm, vm->def->disks[i]->dst,
> + stats) < 0)
> + return ret;
> + }
> + }
> + return 0;
> +}
> +
> +static int
> +libxlDomainBlockStats(virDomainPtr dom,
> + const char *path,
> + virDomainBlockStatsPtr stats)
> +{
> + libxlDriverPrivatePtr driver = dom->conn->privateData;
> + virDomainObjPtr vm;
> + libxlBlockStats blkstats;
> + int ret = -1;
> +
> + if (!(vm = libxlDomObjFromDomain(dom)))
> + goto cleanup;
> +
> + if (virDomainBlockStatsEnsureACL(dom->conn, vm->def) < 0)
> + goto cleanup;
> +
> + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
> + goto cleanup;
> +
> + if (!virDomainObjIsActive(vm)) {
> + virReportError(VIR_ERR_OPERATION_INVALID,
> + "%s", _("domain is not running"));
> + goto endjob;
> + }
> +
> + memset(&blkstats, 0, sizeof(libxlBlockStats));
> + if ((ret = libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0)
> + goto endjob;
> +
> + stats->rd_req = blkstats.rd_req;
> + stats->rd_bytes = blkstats.rd_bytes;
> + stats->wr_req = blkstats.wr_req;
> + stats->wr_bytes = blkstats.wr_bytes;
> + if (STREQ_NULLABLE(blkstats.backend, "vbd"))
> + stats->errs = blkstats.u.vbd.oo_req;
> + else
> + stats->errs = -1;
> +
> + endjob:
> + if (!libxlDomainObjEndJob(driver, vm)) {
> + virObjectUnlock(vm);
> + vm = NULL;
> + }
> +
> + cleanup:
> + if (vm)
> + virObjectUnlock(vm);
> + return ret;
> +}
> +
> +static int
> +libxlDomainBlockStatsFlags(virDomainPtr dom,
> + const char *path,
> + virTypedParameterPtr params,
> + int *nparams,
> + unsigned int flags)
> +{
> + libxlDriverPrivatePtr driver = dom->conn->privateData;
> + virDomainObjPtr vm;
> + libxlBlockStats blkstats;
> + int nstats;
> + int ret = -1;
> +
> + virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1);
> +
> + flags &= ~VIR_TYPED_PARAM_STRING_OKAY;
> +
> + if (!(vm = libxlDomObjFromDomain(dom)))
> + goto cleanup;
> +
> + if (virDomainBlockStatsFlagsEnsureACL(dom->conn, vm->def) < 0)
> + goto cleanup;
> +
> + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
> + goto cleanup;
> +
> + if (!virDomainObjIsActive(vm)) {
> + virReportError(VIR_ERR_OPERATION_INVALID,
> + "%s", _("domain is not running"));
> + goto endjob;
> + }
> +
> + /* return count of supported stats */
> + if (*nparams == 0) {
> + *nparams = LIBXL_NB_TOTAL_BLK_STAT_PARAM;
> + ret = 0;
> + goto endjob;
> + }
> +
> + memset(&blkstats, 0, sizeof(libxlBlockStats));
> + if ((ret = libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0)
> + goto endjob;
> +
> + nstats = 0;
> +
> +#define LIBXL_BLKSTAT_ASSIGN_PARAM(VAR, NAME) \
> + if (nstats < *nparams && (blkstats.VAR) != -1) { \
> + if (virTypedParameterAssign(params + nstats, NAME, \
> + VIR_TYPED_PARAM_LLONG, (blkstats.VAR)) < 0) \
> + goto endjob; \
> + nstats++; \
> + }
> +
> + LIBXL_BLKSTAT_ASSIGN_PARAM(wr_bytes, VIR_DOMAIN_BLOCK_STATS_WRITE_BYTES);
> + LIBXL_BLKSTAT_ASSIGN_PARAM(wr_req, VIR_DOMAIN_BLOCK_STATS_WRITE_REQ);
> +
> + LIBXL_BLKSTAT_ASSIGN_PARAM(rd_bytes, VIR_DOMAIN_BLOCK_STATS_READ_BYTES);
> + LIBXL_BLKSTAT_ASSIGN_PARAM(rd_req, VIR_DOMAIN_BLOCK_STATS_READ_REQ);
> +
> + LIBXL_BLKSTAT_ASSIGN_PARAM(f_req, VIR_DOMAIN_BLOCK_STATS_FLUSH_REQ);
> +
> + if (STREQ_NULLABLE(blkstats.backend, "vbd"))
> + LIBXL_BLKSTAT_ASSIGN_PARAM(u.vbd.oo_req, VIR_DOMAIN_BLOCK_STATS_ERRS);
> +
> + *nparams = nstats;
> +
> +#undef LIBXL_BLKSTAT_ASSIGN_PARAM
> +
> + endjob:
> + if (!libxlDomainObjEndJob(driver, vm)) {
> + virObjectUnlock(vm);
> + vm = NULL;
> + }
> +
> + cleanup:
> + if (vm)
> + virObjectUnlock(vm);
> + return ret;
> +}
> +
> +static int
> libxlDomainInterfaceStats(virDomainPtr dom,
> const char *path,
> virDomainInterfaceStatsPtr stats)
> @@ -5459,6 +5877,8 @@ static virHypervisorDriver libxlHypervisorDriver = {
> #endif
> .nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */
> .nodeGetCellsFreeMemory = libxlNodeGetCellsFreeMemory, /* 1.1.1 */
> + .domainBlockStats = libxlDomainBlockStats, /* 1.2.20 */
> + .domainBlockStatsFlags = libxlDomainBlockStatsFlags, /* 1.2.20 */
> .domainInterfaceStats = libxlDomainInterfaceStats, /* 1.2.20 */
> .domainMemoryStats = libxlDomainMemoryStats, /* 1.2.20 */
> .domainGetCPUStats = libxlDomainGetCPUStats, /* 1.2.20 */
>
------------------------------
Message: 5
Date: Wed, 23 Sep 2015 19:18:27 -0400
From: John Ferlan <jferlan(a)redhat.com>
To: libvir-list(a)redhat.com
Subject: [libvirt] [PATCH 0/6] Fix some Coverity issues
Message-ID: <1443050313-15412-1-git-send-email-jferlan(a)redhat.com>
Newer Coverity (7.7.0) found a couple real issues and a few more
false positives. There's still a few more to be resolved, but still
trying to figure them out...
libxlDomainMigrationPrepare - claim is args is leaked. Although
it seems to be handled in libxlMigrateReceive or libxlDoMigrateReceive.
Don't know the code well enough to do proper triage.
qemuProcessStop - claim is usage of net->ifname in the condition
(vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
is using a NULL net->ifname that would have been VIR_FREE()'d
when case VIR_DOMAIN_NET_TYPE_DIRECT a few lines above.
qemuDomainBlockRebase - claim is overwriting 'dest' after call to
qemuDomainBlockCopyCommon causes resource leak. Although reading
code says otherwise, except of course if CopyCommon goes to cleanup
rather than endjob. Even changing the location doesn't resolve
the issue.
Fix the Coverity tag for the DEADCODE... It's always a coin-flip either
dead_error_begin or dead_error_condition - I gave Jiri bad advice as
to which one to use it seems.
John Ferlan (6):
Avoid Coverity FORWARD_NULL prior to strtok_r calls
tests: Resolve Coverity RESOURCE_LEAK
tests: Resolve Coverity RESOURCE_LEAK
virsh: Resolve Coverity DEADCODE
qemu: Resolve Coverity CHECKED_RETURN
qemu: Resolve Coverity RESOURCE_LEAK
src/esx/esx_vi.c | 1 +
src/libxl/libxl_conf.c | 1 +
src/openvz/openvz_conf.c | 2 ++
src/qemu/qemu_driver.c | 24 +++++++++++-------------
src/qemu/qemu_process.c | 6 +++---
src/xenapi/xenapi_utils.c | 1 +
tests/qemucaps2xmltest.c | 1 +
tests/virnetdaemontest.c | 2 ++
tools/virsh.c | 2 +-
9 files changed, 23 insertions(+), 17 deletions(-)
--
2.1.0
------------------------------
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
End of libvir-list Digest, Vol 118, Issue 146
*********************************************
********************************************************************************************************************************
The information in this email is confidential and may be legally privileged. If you have received this email in error or are not the intended recipient, please immediately notify the sender and delete this message from your computer. Any use, distribution, or copying of this email other than by the intended recipient is strictly prohibited. All messages sent to and from us may be monitored to ensure compliance with internal policies and to protect our business.
Emails are not secure and cannot be guaranteed to be error free as they can be intercepted, amended, lost or destroyed, or contain viruses. Anyone who communicates with us by email is taken to accept these risks.
�跺���欢���娉ㄦ�锛����浠跺�淇��淇℃�锛��璇�����浠讹�璇峰�蹇���ュ���汉骞剁��ュ��伙�涓��浣跨�������澶�����浠躲�
杩����欢����版�������������浠跺��藉����������淇����涪澶便�琚��������璁$��虹�姣��涓���ㄦ��点�
********************************************************************************************************************************
9 years, 2 months
[libvirt] [PATCH v2] qemuDomainDeviceDefPostParse: Drop useless checks
by Michal Privoznik
Now that virQEMUDriverCreateXMLConf is never called with NULL
(after 086f37e97aab) we can safely drop useless check in
qemuDomainDeviceDefPostParse as we are guaranteed to be always
called with the driver initialized. Therefore checking if driver
is NULL makes no sense. Moreover, if we mix it with direct driver
dereference. And after that, we are sure that nor @cfg will be
NULL, therefore we can drop checks for that too.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
diff to v1:
- drop checks for !cfg too
src/qemu/qemu_domain.c | 64 ++++++++++++++++++++------------------------------
1 file changed, 26 insertions(+), 38 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 7d92f3a..78f305f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1233,12 +1233,9 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
{
virQEMUDriverPtr driver = opaque;
virQEMUCapsPtr qemuCaps = NULL;
- virQEMUDriverConfigPtr cfg = NULL;
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
int ret = -1;
- if (driver)
- cfg = virQEMUDriverGetConfig(driver);
-
qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator);
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
@@ -1253,37 +1250,34 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
virDomainDiskDefPtr disk = dev->data.disk;
- /* both of these require data from the driver config */
- if (cfg) {
- /* assign default storage format and driver according to config */
- if (cfg->allowDiskFormatProbing) {
- /* default disk format for drives */
- if (virDomainDiskGetFormat(disk) == VIR_STORAGE_FILE_NONE &&
- (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_FILE ||
- virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_BLOCK))
- virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_AUTO);
+ /* assign default storage format and driver according to config */
+ if (cfg->allowDiskFormatProbing) {
+ /* default disk format for drives */
+ if (virDomainDiskGetFormat(disk) == VIR_STORAGE_FILE_NONE &&
+ (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_FILE ||
+ virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_BLOCK))
+ virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_AUTO);
- /* default disk format for mirrored drive */
- if (disk->mirror &&
- disk->mirror->format == VIR_STORAGE_FILE_NONE)
- disk->mirror->format = VIR_STORAGE_FILE_AUTO;
- } else {
- /* default driver if probing is forbidden */
- if (!virDomainDiskGetDriver(disk) &&
- virDomainDiskSetDriver(disk, "qemu") < 0)
- goto cleanup;
+ /* default disk format for mirrored drive */
+ if (disk->mirror &&
+ disk->mirror->format == VIR_STORAGE_FILE_NONE)
+ disk->mirror->format = VIR_STORAGE_FILE_AUTO;
+ } else {
+ /* default driver if probing is forbidden */
+ if (!virDomainDiskGetDriver(disk) &&
+ virDomainDiskSetDriver(disk, "qemu") < 0)
+ goto cleanup;
- /* default disk format for drives */
- if (virDomainDiskGetFormat(disk) == VIR_STORAGE_FILE_NONE &&
- (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_FILE ||
- virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_BLOCK))
- virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_RAW);
+ /* default disk format for drives */
+ if (virDomainDiskGetFormat(disk) == VIR_STORAGE_FILE_NONE &&
+ (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_FILE ||
+ virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_BLOCK))
+ virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_RAW);
- /* default disk format for mirrored drive */
- if (disk->mirror &&
- disk->mirror->format == VIR_STORAGE_FILE_NONE)
- disk->mirror->format = VIR_STORAGE_FILE_RAW;
- }
+ /* default disk format for mirrored drive */
+ if (disk->mirror &&
+ disk->mirror->format == VIR_STORAGE_FILE_NONE)
+ disk->mirror->format = VIR_STORAGE_FILE_RAW;
}
}
@@ -1315,12 +1309,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
dev->data.chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
dev->data.chr->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
!dev->data.chr->source.data.nix.path) {
- if (!cfg) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("cannot generate UNIX socket path"));
- goto cleanup;
- }
-
if (virAsprintf(&dev->data.chr->source.data.nix.path,
"%s/domain-%s/%s",
cfg->channelTargetDir, def->name,
--
2.4.9
9 years, 2 months
[libvirt] [libvirt-glib] gobject: Correct docs for gvir_storage_pool_get_info()
by Zeeshan Ali (Khattak)
The returned GVirStoragePoolInfo pointer is not a GObject so it must not
be unrefed using g_object_unref(). Since gvir_storage_pool_info_free()
is private function, callers must either use g_slice_free() or
g_boxed_free().
---
Perhaps we should just make gvir_storage_pool_info_free() public instead?
libvirt-gobject/libvirt-gobject-storage-pool.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index 7f26b1b..f015efa 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -277,8 +277,8 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
* @pool: the storage_pool
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the info. The returned object should be
- * unreffed with g_object_unref() when no longer needed.
+ * Returns: (transfer full): the info. The returned pointer should be
+ * freed using either #g_slice_free() or #g_boxed_free() when no longer needed.
*/
GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool,
GError **err)
--
2.4.3
9 years, 2 months
[libvirt] [libvirt-guests] New feature ALWAYS_START
by Marek Lukács
Hi,
It will be nice feature to have configuration option
ALWAYS_START="$uri:$name $uri:name ..." in libvirt-guests
configuration file.
If ON_BOOT is "start" and if ALWAYS_START is not empty, it iterates
over the ALWAYS_START and starts guests with same conditions (delays
etc.) before it starts guests from LISTFILE.
Benefits:
- guests are started with delays
- guests are started after host failure
- guests are started in specific order (for example complex
environment, when DB should be started before other guest, etc.)
Regards,
Marek Lukács
9 years, 2 months
[libvirt] [PATCH v2] virsh: Fix job status indicator for 0 length block jobs
by Peter Krempa
Although 0 length block jobs aren't entirely useful, the output of virsh
blockjob is empty due to the condition that suppresses the output for
migration jobs that did not start. Since the only place that actually
uses the condition that suppresses the output is in migration, let's
move the check there and thus add support for 0 of 0 equaling to 100%.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1196711
---
tools/virsh-domain.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 73c476d..fb138d5 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1700,10 +1700,6 @@ virshPrintJobProgress(const char *label, unsigned long long remaining,
{
int progress;
- if (total == 0)
- /* migration has not been started */
- return;
-
if (remaining == 0) {
/* migration has completed */
progress = 100;
@@ -4401,7 +4397,7 @@ virshWatchJob(vshControl *ctl,
ret = virDomainGetJobInfo(dom, &jobinfo);
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
if (ret == 0) {
- if (verbose)
+ if (verbose && jobinfo.dataTotal > 0)
virshPrintJobProgress(label, jobinfo.dataRemaining,
jobinfo.dataTotal);
--
2.4.5
9 years, 2 months
[libvirt] [PATCH v2] qemu: Refresh memory size only on fresh starts
by Peter Krempa
Qemu unfortunately doesn't update internal state right after migration
and so the actual balloon size as returned by 'query-balloon' are
invalid for a while after the CPUs are started after migration. If we'd
refresh our internal state at this point we would report invalid current
memory size until the next balloon event would arrive.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1242940
---
Version 2:
- completely different from original posting due to unexpected qemu behavior
src/qemu/qemu_process.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 7187dc1..b961f40 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5023,7 +5023,8 @@ int qemuProcessStart(virConnectPtr conn,
/* Since CPUs were not started yet, the balloon could not return the memory
* to the host and thus cur_balloon needs to be updated so that GetXMLdesc
* and friends return the correct size in case they can't grab the job */
- if (qemuProcessRefreshBalloonState(driver, vm, asyncJob) < 0)
+ if (!migrateFrom && !snapshot &&
+ qemuProcessRefreshBalloonState(driver, vm, asyncJob) < 0)
goto cleanup;
VIR_DEBUG("Detecting actual memory size for video device");
--
2.4.5
9 years, 2 months
[libvirt] [PATCH] qemu: Align memory module sizes to 2MiB
by Peter Krempa
My original implementation was based on a qemu version that still did
not have all the checks in place. Using sizes that would align to odd
megabyte increments will produce the following error:
qemu-kvm: -device pc-dimm,node=0,memdev=memdimm0,id=dimm0: backend memory size must be multiple of 0x200000
qemu-kvm: -device pc-dimm,node=0,memdev=memdimm0,id=dimm0: Device 'pc-dimm' could not be initialized
Introduce an alignment retrieval function for memory devices and use it
to align the devices separately and modify a test case to verify it.
---
src/qemu/qemu_domain.c | 19 ++++++++++++++++++-
.../qemuxml2argv-memory-hotplug-dimm.xml | 2 +-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 7d92f3a..7680c87 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3376,6 +3376,21 @@ qemuDomainGetMemorySizeAlignment(virDomainDefPtr def)
}
+static unsigned long long
+qemuDomainGetMemoryModuleSizeAlignment(const virDomainDef *def,
+ const virDomainMemoryDef *mem ATTRIBUTE_UNUSED)
+{
+ /* PPC requires the memory sizes to be rounded to 256MiB increments, so
+ * round them to the size always. */
+ if (ARCH_IS_PPC64(def->os.arch))
+ return 256 * 1024;
+
+ /* dimm memory modules require 2MiB alignment rather than the 1MiB we are
+ * using elsewhere. */
+ return 2048;
+}
+
+
int
qemuDomainAlignMemorySizes(virDomainDefPtr def)
{
@@ -3402,8 +3417,10 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def)
def->mem.max_memory = VIR_ROUND_UP(def->mem.max_memory, align);
/* Align memory module sizes */
- for (i = 0; i < def->nmems; i++)
+ for (i = 0; i < def->nmems; i++) {
+ align = qemuDomainGetMemoryModuleSizeAlignment(def, def->mems[i]);
def->mems[i]->size = VIR_ROUND_UP(def->mems[i]->size, align);
+ }
return 0;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.xml b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.xml
index 3f468ec..fbcac84 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.xml
@@ -36,7 +36,7 @@
<memballoon model='virtio'/>
<memory model='dimm'>
<target>
- <size unit='KiB'>524287</size>
+ <size unit='KiB'>523264</size>
<node>0</node>
</target>
</memory>
--
2.4.5
9 years, 2 months
[libvirt] [PATCH 0/3] Improve keepalive timeout handling in clients
by Jiri Denemark
Jiri Denemark (3):
client rpc: Report proper error for keepalive disconnections
client rpc: Process pending data on error
virsh: Notify users about disconnects
src/rpc/virkeepalive.c | 10 +++++-----
src/rpc/virnetclient.c | 30 +++++++++++++++++++++++++-----
tools/virsh.c | 35 ++++++++++++++++++++++++++++++++---
3 files changed, 62 insertions(+), 13 deletions(-)
--
2.5.2
9 years, 2 months
[libvirt] [sandbox 00/11] Adding a virt-builder source
by Cédric Bosdonnat
Hi all,
Here are a few patches to add a virt-builder source to virt-sandbox-image. There
are also patches fixing a few issues here and there.
Cédric Bosdonnat (11):
Fix memory leak
virt-sandbox-image: fix error string formatting.
Make virt-sandbox-image executable
virt-sandbox-image: remove undefined default_disk_format
virt-sandbox-image: add a source post_run hook
virt-sandbox-image: move DockerSource _format_disk to Source
virt-sandbox-image: smarter source name computing
virt-sandbox-image: add a virt-builder source
virt-sandbox-image: automatically call download and create if needed
virt-sandbox-image: fix exception catching
virt-sandbox-image: add error handling for sources import
bin/virt-sandbox-image | 0
libvirt-sandbox.spec.in | 1 +
libvirt-sandbox/image/cli.py | 154 +++++++++++----------
libvirt-sandbox/image/sources/DockerSource.py | 32 +++--
libvirt-sandbox/image/sources/Makefile.am | 1 +
libvirt-sandbox/image/sources/Source.py | 50 +++++++
libvirt-sandbox/image/sources/VirtBuilderSource.py | 143 +++++++++++++++++++
libvirt-sandbox/image/template.py | 24 +++-
libvirt-sandbox/libvirt-sandbox-builder.c | 1 +
9 files changed, 311 insertions(+), 95 deletions(-)
mode change 100644 => 100755 bin/virt-sandbox-image
create mode 100644 libvirt-sandbox/image/sources/VirtBuilderSource.py
--
2.1.4
9 years, 2 months