[libvirt] [PATCH v2 0/5] Misc cleanups for internal.h & fix tests with CLang
by Daniel P. Berrange
When writing the fix for test suite mocking under CLang I found a
bunch of cruft in internal.h The first four patches thus cleanup
up internal.h. We then add the extra annotations requird to prevent
CLang optimizer breaking mock overrides.
Changed in v2:
- Fixed version check to find clang
- Use 'printf' instead of 'gnu_printf' on clang still
- Addd fix for mock functions under clang
Daniel P. Berrange (5):
Remove duplicate define of __GNUC_PREREQ
Require use of GCC 4.4 or CLang compilers
Remove network constants out of internal.h
Remove incorrectly used TODO macro
Prevent more compiler optimization of mockable functions
build-aux/mock-noinline.pl | 2 +-
config-post.h | 24 ++---
src/check-symfile.pl | 2 +-
src/internal.h | 173 ++++++++++-----------------------
src/libxl/libxl_conf.c | 1 +
src/nwfilter/nwfilter_dhcpsnoop.c | 1 +
src/nwfilter/nwfilter_gentech_driver.c | 1 +
src/qemu/qemu_capspriv.h | 2 +-
src/qemu/qemu_conf.c | 1 +
src/rpc/virnetsocket.h | 4 +-
src/util/vircommand.h | 2 +-
src/util/vircrypto.h | 2 +-
src/util/virfile.h | 2 +-
src/util/virhostcpu.h | 4 +-
src/util/virmacaddr.h | 2 +-
src/util/virnetdev.h | 8 +-
src/util/virnetdevip.h | 2 +-
src/util/virnetdevopenvswitch.h | 2 +-
src/util/virnetdevtap.h | 6 +-
src/util/virnuma.h | 16 +--
src/util/virrandom.h | 6 +-
src/util/virscsi.h | 2 +-
src/util/virscsivhost.h | 2 +-
src/util/virsocketaddr.h | 16 +++
src/util/virtpm.h | 2 +-
src/util/virutil.c | 1 +
src/util/virutil.h | 10 +-
src/util/viruuid.h | 2 +-
src/vz/vz_sdk.c | 1 +
src/xen/xen_hypervisor.c | 6 +-
src/xen/xend_internal.c | 6 +-
31 files changed, 135 insertions(+), 176 deletions(-)
--
2.9.4
7 years, 4 months
[libvirt] [PATCH] qemuDomainGetPreservedMountPath: rename @mount
by Michal Privoznik
Obviously, old gcc-s ale sad when a variable shares the name with
a function. And we do have such variable (added in 4d8a914be0):
@mount. Rename it to @mountpoint so that compiler's happy again.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under build-breaker and trivial rules.
src/qemu/qemu_domain.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e146bc88a..ae260de00 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7578,9 +7578,9 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
* qemuDomainGetPreservedMountPath:
* @cfg: driver configuration data
* @vm: domain object
- * @mount: mount point path to convert
+ * @mountpoint: mount point path to convert
*
- * For given @mount point return new path where the mount point
+ * For given @mountpoint return new path where the mount point
* should be moved temporarily whilst building the namespace.
*
* Returns: allocated string on success which the caller must free,
@@ -7589,21 +7589,21 @@ qemuDomainGetHostdevPath(virDomainDefPtr def,
static char *
qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg,
virDomainObjPtr vm,
- const char *mount)
+ const char *mountpoint)
{
char *path = NULL;
char *tmp;
- const char *suffix = mount + strlen(DEVPREFIX);
+ const char *suffix = mountpoint + strlen(DEVPREFIX);
size_t off;
- if (STREQ(mount, "/dev"))
+ if (STREQ(mountpoint, "/dev"))
suffix = "dev";
if (virAsprintf(&path, "%s/%s.%s",
cfg->stateDir, vm->def->name, suffix) < 0)
return NULL;
- /* Now consider that @mount is "/dev/blah/blah2".
+ /* Now consider that @mountpoint is "/dev/blah/blah2".
* @suffix then points to "blah/blah2". However, caller
* expects all the @paths to be the same depth. The
* caller doesn't always do `mkdir -p` but sometimes bare
--
2.13.0
7 years, 4 months
[libvirt] [PATCH] qemu: Provide non-linux stub for qemuDomainAttachDeviceMknodRecursive
by Michal Privoznik
The way we create devices under /dev is highly linux specific.
For instance we do mknod(), mount(), umount(), etc. Some
platforms are even missing some of these functions. Then again,
as declared in qemuDomainNamespaceAvailable(): namespaces are
linux only. Therefore, to avoid obfuscating the code by trying to
make it compile on weird platforms, just provide a non-linux stub
for qemuDomainAttachDeviceMknodRecursive(). At the same time,
qemuDomainAttachDeviceMknodHelper() which actually calls the
non-existent functions is moved under ifdef __linux__ block since
its only caller is in that block too.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_domain.c | 38 ++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 080ff336e..eb1a9794b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8541,6 +8541,8 @@ struct qemuDomainAttachDeviceMknodData {
};
+/* Our way of creating devices is highly linux specific */
+#if defined(__linux__)
static int
qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
void *opaque)
@@ -8638,7 +8640,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
goto cleanup;
}
-#ifdef WITH_SELINUX
+# ifdef WITH_SELINUX
if (data->tcon &&
lsetfilecon_raw(data->file, (VIR_SELINUX_CTX_CONST char *) data->tcon) < 0) {
VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
@@ -8650,7 +8652,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
goto cleanup;
}
}
-#endif
+# endif
/* Finish mount process started earlier. */
if (isReg &&
@@ -8661,9 +8663,9 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
cleanup:
if (ret < 0 && delDevice)
unlink(data->file);
-#ifdef WITH_SELINUX
+# ifdef WITH_SELINUX
freecon(data->tcon);
-#endif
+# endif
virFileFreeACLs(&data->acl);
return ret;
}
@@ -8754,14 +8756,14 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
goto cleanup;
}
-#ifdef WITH_SELINUX
+# ifdef WITH_SELINUX
if (lgetfilecon_raw(file, &data.tcon) < 0 &&
(errno != ENOTSUP && errno != ENODATA)) {
virReportSystemError(errno,
_("Unable to get SELinux label from %s"), file);
goto cleanup;
}
-#endif
+# endif
if (STRPREFIX(file, DEVPREFIX)) {
size_t i;
@@ -8798,9 +8800,9 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
ret = 0;
cleanup:
-#ifdef WITH_SELINUX
+# ifdef WITH_SELINUX
freecon(data.tcon);
-#endif
+# endif
virFileFreeACLs(&data.acl);
if (isReg && target)
umount(target);
@@ -8810,6 +8812,26 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
}
+#else /* !defined(__linux__) */
+
+
+static int
+qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+ virDomainObjPtr vm ATTRIBUTE_UNUSED,
+ const char *file ATTRIBUTE_UNUSED,
+ char * const *devMountsPath ATTRIBUTE_UNUSED,
+ size_t ndevMountsPath ATTRIBUTE_UNUSED,
+ unsigned int ttl ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Namespaces are not supported on this platform."));
+ return -1;
+}
+
+
+#endif /* !defined(__linux__) */
+
+
static int
qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver,
virDomainObjPtr vm,
--
2.13.0
7 years, 4 months
[libvirt] [PATCH 0/6] qemu: Clean up storage file access
by Peter Krempa
A collection of few cleanups and bugfixes.
Peter Krempa (6):
lib: Remove misplaced and redundant comments
tests: storage: Fully register storage driver
storage: Split out virStorageSource accessors to separate file
storage: Make virStorageFileReadHeader more universal
qemu: Use storage driver APIs in qemuDomainBlockPeek
qemu: Support only raw volumes in qemuDomainBlockPeek
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/libvirt-domain.c | 4 +-
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_driver.c | 35 +-
src/security/virt-aa-helper.c | 2 +-
src/storage/storage_backend.h | 9 +-
src/storage/storage_backend_fs.c | 20 +-
src/storage/storage_backend_gluster.c | 37 ++-
src/storage/storage_driver.c | 551 +------------------------------
src/storage/storage_driver.h | 28 --
src/storage/storage_source.c | 587 ++++++++++++++++++++++++++++++++++
src/storage/storage_source.h | 54 ++++
tests/virstoragetest.c | 6 +-
14 files changed, 709 insertions(+), 627 deletions(-)
create mode 100644 src/storage/storage_source.c
create mode 100644 src/storage/storage_source.h
--
2.12.2
7 years, 4 months
[libvirt] [PATCH] internal: don't use weak symbols for Win32 platform
by Daniel P. Berrange
The Win32 platform will fail to link if you use weak symbols
because it is incompatible with exporting symbols in a DLL:
Cannot export virRandomGenerateWWN: symbol wrong type (2 vs 3)
We only need weak symbols for our test suite to do LD_PRELOAD
and this doesn't work on Win32, so we can just drop the hack
for Win32
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
Pushed as a build fix for Win32
src/internal.h | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/internal.h b/src/internal.h
index 00edd4f..edc3587 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -128,10 +128,14 @@
*
*/
# ifndef ATTRIBUTE_MOCKABLE
-# if __GNUC_PREREQ(4, 5)
-# define ATTRIBUTE_MOCKABLE __attribute__((__noinline__, __noclone__, __weak__))
+# if defined(WIN32)
+# define ATTRIBUTE_MOCKABLE
# else
-# define ATTRIBUTE_MOCKABLE __attribute__((__noinline__, __weak__))
+# if __GNUC_PREREQ(4, 5)
+# define ATTRIBUTE_MOCKABLE __attribute__((__noinline__, __noclone__, __weak__))
+# else
+# define ATTRIBUTE_MOCKABLE __attribute__((__noinline__, __weak__))
+# endif
# endif
# endif
--
2.9.4
7 years, 4 months
[libvirt] [PATCH] qemu: handle missing bind host/service on chardev hotplug
by Ján Tomko
On domain startup, bind host or bind service can be omitted
and we will format a working command line.
Extend this to hotplug as well and specify the service to QEMU
even if the host is missing.
https://bugzilla.redhat.com/show_bug.cgi?id=1452441
---
src/qemu/qemu_monitor_json.c | 13 ++++++++++---
tests/qemumonitorjsontest.c | 11 +++++++++++
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 0837290..ca9bb14 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6429,6 +6429,8 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
virJSONValuePtr data = NULL;
virJSONValuePtr addr = NULL;
const char *backend_type = NULL;
+ const char *host;
+ const char *port;
char *tlsalias = NULL;
bool telnet;
@@ -6492,9 +6494,14 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
virJSONValueObjectAppend(data, "remote", addr) < 0)
goto error;
- if (chr->data.udp.bindHost) {
- addr = qemuMonitorJSONBuildInetSocketAddress(chr->data.udp.bindHost,
- chr->data.udp.bindService);
+ host = chr->data.udp.bindHost;
+ port = chr->data.udp.bindService;
+ if (host || port) {
+ if (!host)
+ host = "";
+ if (!port)
+ port = "";
+ addr = qemuMonitorJSONBuildInetSocketAddress(host, port);
if (!addr ||
virJSONValueObjectAppend(data, "local", addr) < 0)
goto error;
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index e9f9d47..3de901c 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -895,6 +895,17 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOptionPtr xmlopt)
"'data':{'host':'localhost',"
"'port':'4321'}}}}}");
+ chr.data.udp.bindHost = NULL;
+ chr.data.udp.bindService = (char *) "4321";
+ CHECK("udp", false,
+ "{'id':'alias',"
+ "'backend':{'type':'udp',"
+ "'data':{'remote':{'type':'inet',"
+ "'data':{'host':'example.com',"
+ "'port':'1234'}},"
+ "'local':{'type':'inet',"
+ "'data':{'host':'',"
+ "'port':'4321'}}}}}");
memset(&chr, 0, sizeof(chr));
chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;
chr.data.nix.path = (char *) "/path/to/socket";
--
2.10.2
7 years, 4 months
[libvirt] [PATCH] tests: add further XML namespace test
by Daniel P. Berrange
Validate that we can pass QEMU command line options using a default
namespace, instead of a prefixed namespace
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
.../qemuxml2argvdata/qemuxml2argv-qemu-ns-alt.args | 25 ++++++++++++++++++
.../qemuxml2argvdata/qemuxml2argv-qemu-ns-alt.xml | 30 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
3 files changed, 56 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-alt.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-alt.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-alt.args b/tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-alt.args
new file mode 100644
index 0000000..562b562
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-alt.args
@@ -0,0 +1,25 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+NS=ns \
+BAR='' \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
+-unknown parameter
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-alt.xml b/tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-alt.xml
new file mode 100644
index 0000000..491fc2d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-alt.xml
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ </devices>
+ <commandline xmlns='http://libvirt.org/schemas/domain/qemu/1.0'>
+ <arg value='-unknown'/>
+ <arg value='parameter'/>
+ <env name='NS' value='ns'/>
+ <env name='BAR'/>
+ </commandline>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 27eea70..be2a9bc 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1505,6 +1505,7 @@ mymain(void)
DO_TEST("qemu-ns", NONE);
DO_TEST("qemu-ns-no-env", NONE);
+ DO_TEST("qemu-ns-alt", NONE);
DO_TEST("smp", NONE);
--
2.9.4
7 years, 4 months
[libvirt] [PATCH] qemu: Fix qemuDomainGetBlockInfo allocation value setting
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1467826
Commit id 'b9b1aa639' was supposed to add logic to set the allocation
for sparse files when wr_highest_offset was zero; however, an unconditional
setting was done just prior. For block devices, this means allocation is
always returning 0 since 'actual-size' will be zero.
Remove the unconditional setting and add the note about it being possible
to still be zero for block devices. As soon as the guest starts writing to
the volume, the allocation value will then be obtainable from qemu via
the wr_highest_offset.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_driver.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cdb727b..66fb80a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11711,10 +11711,9 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
* Additionally, if qemu hasn't written to the file yet, then set the
* allocation to whatever qemu returned for physical (e.g. the "actual-
* size" from the json query) as that will match the expected allocation
- * value for this API. */
+ * value for this API. NB: May still be 0 for block. */
if (entry->physical == 0 || info->allocation == 0 ||
info->allocation == entry->physical) {
- info->allocation = entry->physical;
if (info->allocation == 0)
info->allocation = entry->physical;
--
2.9.4
7 years, 4 months
[libvirt] How to make gic_version=3 as defailt to qemu on arm64
by Vishnu Pajjuri
Hi
I'm running Openstack which is installed by using devstack. But it is
not launching VMs.
>From command line with gic_version=3 option it is running. But openstack
glance doesn't have any privilege to specify gic version.
On my ARM64 board gicv2 is not supported, so i want to make gicv3 as
default one to pass to qemu.
Kindly suggest any specific version of vibvirt or patch such that libvirt
should pass gicv3 as default one.
Thanks in Advance
-Vishnu.
7 years, 4 months
[libvirt] [PATCH] tests: virjson: Reuse VIR_TEST_VERBOSE in testJSONCopy
by Peter Krempa
Use VIR_TEST_VERBOSE instead of calling virTestGetVerbose and
conditionally fprintf. Additionally remove redundant setting of 'ret' to
-1.
---
Pushed as trivial.
tests/virjsontest.c | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/tests/virjsontest.c b/tests/virjsontest.c
index b3a230a02..b9c210620 100644
--- a/tests/virjsontest.c
+++ b/tests/virjsontest.c
@@ -240,40 +240,31 @@ testJSONCopy(const void *data)
json = virJSONValueFromString(info->doc);
if (!json) {
- if (virTestGetVerbose())
- fprintf(stderr, "Failed to parse %s\n", info->doc);
- ret = -1;
+ VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc);
goto cleanup;
}
jsonCopy = virJSONValueCopy(json);
if (!jsonCopy) {
- if (virTestGetVerbose())
- fprintf(stderr, "Failed to copy JSON data\n");
- ret = -1;
+ VIR_TEST_VERBOSE("Failed to copy JSON data\n");
goto cleanup;
}
result = virJSONValueToString(json, false);
if (!result) {
- if (virTestGetVerbose())
- fprintf(stderr, "Failed to format original JSON data\n");
- ret = -1;
+ VIR_TEST_VERBOSE("Failed to format original JSON data\n");
goto cleanup;
}
resultCopy = virJSONValueToString(json, false);
if (!resultCopy) {
- if (virTestGetVerbose())
- fprintf(stderr, "Failed to format copied JSON data\n");
- ret = -1;
+ VIR_TEST_VERBOSE("Failed to format copied JSON data\n");
goto cleanup;
}
if (STRNEQ(result, resultCopy)) {
if (virTestGetVerbose())
virTestDifference(stderr, result, resultCopy);
- ret = -1;
goto cleanup;
}
@@ -282,24 +273,19 @@ testJSONCopy(const void *data)
result = virJSONValueToString(json, true);
if (!result) {
- if (virTestGetVerbose())
- fprintf(stderr, "Failed to format original JSON data\n");
- ret = -1;
+ VIR_TEST_VERBOSE("Failed to format original JSON data\n");
goto cleanup;
}
resultCopy = virJSONValueToString(json, true);
if (!resultCopy) {
- if (virTestGetVerbose())
- fprintf(stderr, "Failed to format copied JSON data\n");
- ret = -1;
+ VIR_TEST_VERBOSE("Failed to format copied JSON data\n");
goto cleanup;
}
if (STRNEQ(result, resultCopy)) {
if (virTestGetVerbose())
virTestDifference(stderr, result, resultCopy);
- ret = -1;
goto cleanup;
}
--
2.12.2
7 years, 4 months