[libvirt] [PATCH 0/2] virsh: Further improve handling of integer options
by Andrea Bolognani
As suggested by Michal: now that we have a generic error message for
failures related to the parsing of integer options, it makes sense to
perform the corresponding check in a single spot instead of replicating
it every time vshCommandOpt*() is used.
Andrea Bolognani (2):
virsh: Pass vshControl to all vshCommandOpt*() calls.
virsh: Move error messages inside vshCommandOpt*() functions.
tests/vcpupin | 4 +-
tools/virsh-domain-monitor.c | 97 +++---
tools/virsh-domain.c | 696 +++++++++++++++++++------------------------
tools/virsh-host.c | 87 ++----
tools/virsh-interface.c | 18 +-
tools/virsh-network.c | 38 ++-
tools/virsh-nodedev.c | 6 +-
tools/virsh-pool.c | 26 +-
tools/virsh-secret.c | 8 +-
tools/virsh-snapshot.c | 88 +++---
tools/virsh-volume.c | 50 ++--
tools/virsh.c | 195 ++++++------
tools/virsh.h | 77 ++---
13 files changed, 624 insertions(+), 766 deletions(-)
--
2.1.0
9 years, 7 months
[libvirt] [PATCH libvirt] interface: don't error out if a bond has no interfaces
by Lubomir Rintel
It's not a problem at all and causes virt-manager to break down.
Note: netcf 0.2.8 generates invalid XML for a bond with no interfaces anyway,
so this error is in fact not reached as we fail earlier. Fix submitted upstream.
Signed-off-by: Lubomir Rintel <lkundrak(a)v3.sk>
---
src/conf/interface_conf.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index c2eb945..29769ac 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -553,19 +553,15 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
nbItf = virXPathNodeSet("./interface", ctxt, &interfaces);
if (nbItf < 0) {
ret = -1;
- goto error;
+ goto cleanup;
}
- if (nbItf == 0) {
- virReportError(VIR_ERR_XML_ERROR,
- "%s", _("bond has no interfaces"));
- ret = -1;
- goto error;
- }
+ if (nbItf == 0)
+ goto cleanup;
if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0) {
ret = -1;
- goto error;
+ goto cleanup;
}
def->data.bond.nbItf = nbItf;
@@ -575,12 +571,12 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
if (itf == NULL) {
ret = -1;
def->data.bond.nbItf = i;
- goto error;
+ goto cleanup;
}
def->data.bond.itf[i] = itf;
}
- error:
+ cleanup:
VIR_FREE(interfaces);
ctxt->node = bond;
return ret;
--
2.4.1
9 years, 7 months
[libvirt] [PATCHv3] util: make it more robust to calculate timeout value
by Wang Yufei
From: Zhang Bo <oscar.zhangbo(a)huawei.com>
When we change system clock to years ago, a certain CPU may use up 100% cputime.
The reason is that in function virEventPollCalculateTimeout(), we assign the
unsigned long long result to an INT variable,
*timeout = then - now; // timeout is INT, and then/now are long long
if (*timeout < 0)
*timeout = 0;
there's a chance that variable @then minus variable @now may be a very large number
that overflows INT value expression, then *timeout will be negative and be assigned to 0.
Next the 'poll' in function virEventPollRunOnce() will get into an 'endless' while loop there.
thus, the cpu that virEventPollRunOnce() thread runs on will go up to 100%.
Although as we discussed before in https://www.redhat.com/archives/libvir-list/2015-May/msg00400.html
it should be prohibited to set-time while other applications are running, but it does
seems to have no harm to make the codes more robust.
Signed-off-by: Wang Yufei <james.wangyufei(a)huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo(a)huawei.com>
---
src/util/vireventpoll.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c
index ffda206..4e4f407 100644
--- a/src/util/vireventpoll.c
+++ b/src/util/vireventpoll.c
@@ -357,9 +357,10 @@ static int virEventPollCalculateTimeout(int *timeout)
return -1;
EVENT_DEBUG("Schedule timeout then=%llu now=%llu", then, now);
- *timeout = then - now;
- if (*timeout < 0)
+ if (then <= now)
*timeout = 0;
+ else
+ *timeout = ((then-now) > INT_MAX) ? INT_MAX : (then-now);
} else {
*timeout = -1;
}
--
1.7.12.4
9 years, 7 months
[libvirt] [PATCH] storage_fs: Create directory with UID if needed
by Martin Kletzander
The code already exists there, it just modified different flags. I just
noticed this when looking at the code. This patch is better to view
with bigger context or '-W'.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/storage/storage_backend_fs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index bcbbb3ae252a..5dc712925b27 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1,7 +1,7 @@
/*
* storage_backend_fs.c: storage backend for FS and directory handling
*
- * Copyright (C) 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2007-2015 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -807,7 +807,7 @@ virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
(needs_create_as_uid || !virFileExists(pool->def->target.path)))
mode = VIR_STORAGE_DEFAULT_POOL_PERM_MODE;
if (needs_create_as_uid)
- flags |= VIR_DIR_CREATE_AS_UID;
+ dir_create_flags |= VIR_DIR_CREATE_AS_UID;
/* Now create the final dir in the path with the uid/gid/mode
* requested in the config. If the dir already exists, just set
--
2.4.1
9 years, 7 months
[libvirt] [PATCH] zfs: fix storagepoolxml2xml test
by Roman Bogorodskiy
Commit 7c2d65d dropped setting default mode.
Update zfs tests accordingly.
---
tests/storagepoolxml2xmlout/pool-zfs-sourcedev.xml | 3 ---
tests/storagepoolxml2xmlout/pool-zfs.xml | 3 ---
2 files changed, 6 deletions(-)
diff --git a/tests/storagepoolxml2xmlout/pool-zfs-sourcedev.xml b/tests/storagepoolxml2xmlout/pool-zfs-sourcedev.xml
index 89dcdbf..8d9be73 100644
--- a/tests/storagepoolxml2xmlout/pool-zfs-sourcedev.xml
+++ b/tests/storagepoolxml2xmlout/pool-zfs-sourcedev.xml
@@ -10,8 +10,5 @@
</source>
<target>
<path>/dev/zvol/testpool</path>
- <permissions>
- <mode>0755</mode>
- </permissions>
</target>
</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-zfs.xml b/tests/storagepoolxml2xmlout/pool-zfs.xml
index c9e5df9..1a8de4f 100644
--- a/tests/storagepoolxml2xmlout/pool-zfs.xml
+++ b/tests/storagepoolxml2xmlout/pool-zfs.xml
@@ -9,8 +9,5 @@
</source>
<target>
<path>/dev/zvol/testpool</path>
- <permissions>
- <mode>0755</mode>
- </permissions>
</target>
</pool>
--
2.3.5
9 years, 7 months
[libvirt] Libvirt now using Zanata for translation
by Daniel P. Berrange
As of current GIT master, libvirt is fully using Zanata for po file
translation
After some trouble with the zanata python client, I have now successfully
refreshed & pushed the current libvirt.pot file, and synchronized all
the translation po files back down to GIT master.
For ongoing refreshes of the libvirt.pot, it can be rebuild & pushed
to zanata and .po files resynchonized using
# cd po
# rm libvirt.pot
# make libvirt.pot
# zanata-cli push
# zanata-cli pull
Where 'zanata-cli' is the *JAVA* client, not the python client. I strongly
recommend against use of the python client for the libvirt project as it
doesn't handle the size of the libvirt.pot/.po files well resulting in
unexplained data loss. Even the java client has problems pushing the
.po files to the server due to poorly designed rate limiting in the
zanata server.
Fortunately this is not something we need do again, now we have imported
the existing .po file. The java client has been troublefree wrt to pushing
the .pot file and pulling .po files, which is all we need for ongoing work
now.
Currently myself & Daniel Veillard are setup as admins of the libvirt
project in Zanata & we can add further people as required.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
9 years, 7 months
[libvirt] [PATCH] util: improve the sysinfo element XML format
by Luyao Huang
When set sysinfo element without sub-elements,
libvirt will format it as:
<sysinfo type='smbios'>
</sysinfo>
After improve the format:
<sysinfo type='smbios'/>
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/util/virsysinfo.c | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 8bb17f0..f87376f 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -1041,31 +1041,42 @@ virSysinfoMemoryFormat(virBufferPtr buf, virSysinfoDefPtr def)
int
virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def)
{
+ virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
const char *type = virSysinfoTypeToString(def->type);
+ int indent = virBufferGetIndent(buf, false);
+ int ret = -1;
if (!type) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected sysinfo type model %d"),
def->type);
virBufferFreeAndReset(buf);
- return -1;
+ goto cleanup;
}
- virBufferAsprintf(buf, "<sysinfo type='%s'>\n", type);
- virBufferAdjustIndent(buf, 2);
+ virBufferAdjustIndent(&childrenBuf, indent + 2);
- virSysinfoBIOSFormat(buf, def);
- virSysinfoSystemFormat(buf, def);
- virSysinfoProcessorFormat(buf, def);
- virSysinfoMemoryFormat(buf, def);
+ virSysinfoBIOSFormat(&childrenBuf, def);
+ virSysinfoSystemFormat(&childrenBuf, def);
+ virSysinfoProcessorFormat(&childrenBuf, def);
+ virSysinfoMemoryFormat(&childrenBuf, def);
- virBufferAdjustIndent(buf, -2);
- virBufferAddLit(buf, "</sysinfo>\n");
+ virBufferAsprintf(buf, "<sysinfo type='%s'", type);
+ if (virBufferUse(&childrenBuf)) {
+ virBufferAddLit(buf, ">\n");
+ virBufferAddBuffer(buf, &childrenBuf);
+ virBufferAddLit(buf, "</sysinfo>\n");
+ } else {
+ virBufferAddLit(buf, "/>\n");
+ }
if (virBufferCheckError(buf) < 0)
- return -1;
+ goto cleanup;
- return 0;
+ ret = 0;
+ cleanup:
+ virBufferFreeAndReset(&childrenBuf);
+ return ret;
}
bool virSysinfoIsEqual(virSysinfoDefPtr src,
--
1.8.3.1
9 years, 7 months
[libvirt] [PATCH v2] qemu: Fix compilation error when enum variable size differs from 'int'
by Peter Krempa
Since commit bcd9a564b631aa virDomainNumatuneGetMode returns the value
via a pointer rather than in the return value. The change triggered
problems with platforms where the compiler decides to use a data type of
size different than integer at the point where we typecast it.
Work around the issue by using an intermediate variable of the correct
type that gets casted back by the default typecasting rules.
---
Version 2:
- removed block from the case statement
- added ignore value section to silence coverity and initialized the temp variable
src/qemu/qemu_driver.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index aa0acde..1233d8f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10524,6 +10524,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr persistentDef = NULL;
+ virDomainNumatuneMemMode tmpmode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
char *nodeset = NULL;
int ret = -1;
virCapsPtr caps = NULL;
@@ -10567,12 +10568,12 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
switch (i) {
case 0: /* fill numa mode here */
+ ignore_value(virDomainNumatuneGetMode(def->numa, -1, &tmpmode));
+
if (virTypedParameterAssign(param, VIR_DOMAIN_NUMA_MODE,
- VIR_TYPED_PARAM_INT, 0) < 0)
+ VIR_TYPED_PARAM_INT, tmpmode) < 0)
goto cleanup;
- virDomainNumatuneGetMode(def->numa, -1,
- (virDomainNumatuneMemMode *) ¶m->value.i);
break;
case 1: /* fill numa nodeset here */
--
2.4.1
9 years, 7 months
[libvirt] [PATCH] conf: improve the address check for dimm type
by Luyao Huang
When hot-plug/cold-plug a memory device, we use
memcmp() function to check if there is a memory device
have the same address with the memory device we want
hot-pluged. But qemu forbid use/hot-plug 2 memory device
with same slot *or* the same base(qemu side this elemnt
named addr).
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/conf/domain_conf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6e57425..413f839 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3089,7 +3089,10 @@ virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a,
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
- if (memcmp(&a->addr.dimm, &b->addr.dimm, sizeof(a->addr.dimm)))
+ if (a->addr.dimm.slot != b->addr.dimm.slot &&
+ (a->addr.dimm.base == 0 ||
+ b->addr.dimm.base == 0 ||
+ a->addr.dimm.base != b->addr.dimm.base))
return false;
break;
}
--
1.8.3.1
9 years, 7 months
[libvirt] [PATCH] maint: update to latest gnulib
by Eric Blake
Time to update to new gnulib before a release.
gcc 5.1 introduced a new -Wformat-signedness, and new gnulib now
turns it on by default. However, it is still rather lame at the
moment, because it warns for enums, even though there is no way
to control the signeness of an enum which does not use any members
that are negative or larger than INT_MAX, and even though such an
enum would always print the same for both %d and %u:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66249
In file included from ../../src/util/virarch.c:26:0:
../../src/util/virarch.c: In function 'virArchFromHost':
../../src/util/virarch.c:180:15: error: format '%d' expects argument of type 'int', but argument 9 has type 'unsigned int' [-Werror=format=]
VIR_DEBUG("Mapped %s to %d (%s)",
So this patch turns off the new warning as part of enabling all
other new gcc 5.1 warnings that gnulib now enables.
* .gnulib: Update to latest, in part for gcc 5.1 interaction.
* m4/virt-compile-warnings.m4: Ignore -Wformat-signedness, for now.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
It looks like DV hasn't done the freeze yet, so I'll push this under
the gnulib rule. I still have a pending gnulib patch that helps the
build under rawhide mingw (where newer gcc broke how older gnulib
was probing for whether PRIdMAX was "lld" vs. "I64d"); that may miss
the freeze, but my goal in pushing this now is that if it is the only
gnulib change post-freeze, then we are minimizing the risk on other
platforms by getting the rest picked up now.
* .gnulib 106a386...875ec93 (34):
> autoupdate
> gitlog-to-changelog: parse "Tiny-change"
> update from texinfo
> doc: document glibc posix_fallocate() issues
> gendocs.sh: document new htmlarg default
> extern-inline: no need for workaround in GCC 5.1
> update from texinfo
> eealloc, pagealign_alloc, xalloc: avoid clang warnings
> tests: pacify GCC 5.1's stricter printf checking
> fts: port to GCC 5.1 with --enable-gcc-warnings
> file-has-acl: port to CentOS 6
> file-has-acl: always return false when ACLs aren't supported
> gettext: propagate po/Makefile.in.in too
> file-has-acl: new module, split from acl
> manywarnings: add GCC 5.1 warnings
> autoupdate
> doc: update FDL template to match FDL examples.
> lstat: fix cross-compilation 'ln -s' problem
> gendocs.sh: default to a common CSS style sheet for HTML output
> gnulib-tool: output bold attribute more portably
> qacl: Simplify HP-UX acl_nontrivial check
> acl: On Linux, check for acls without libacl
> acl, qacl: split off shared functions into separate object file
> git-version-gen: revert "detect untagged revisions"
> tempname: avoid unused parameter warnings
> git-version-gen: detect untagged revisions
> fseeko: fix build failure on NetBSD >= 6
> gitlog-to-changelog: port to MS-Windows
> gendocs: new option --tex for texi2dvi options
> sync gettext .m4 files from gettext
> uniname/uniname-tests: fix failure due to alias
> hash: remove deprecated hash_insert0 function
> mountlist: remove dependency on libmount
> stddef: port to pre-C11 GCC on x86
.gnulib | 2 +-
m4/virt-compile-warnings.m4 | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/.gnulib b/.gnulib
index 106a386..875ec93 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 106a3866d01f9dd57ab4f10dbeb0d5a8db73a9f7
+Subproject commit 875ec93e1501d2d2a8bab1b64fa66b8ceb51dc67
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 8aebdb0..3dd0665 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -59,6 +59,8 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dontwarn="$dontwarn -Waggregate-return"
# gcc 4.4.6 complains this is C++ only; gcc 4.7.0 implies this from -Wall
dontwarn="$dontwarn -Wenum-compare"
+ # gcc 5.1 -Wformat-signedness mishandles enums, not ready for prime time
+ dontwarn="$dontwarn -Wformat-signedness"
# gcc 4.2 treats attribute(format) as an implicit attribute(nonnull),
# which triggers spurious warnings for our usage
--
2.1.0
9 years, 7 months