[libvirt] libvirt for rhel-5?
by Farkas Levente
hi,
is there any plan to be able to buils libvirt on rhel-5 ie. epel-5?
currently all virt and kvm releated packages can be build on epel except
libvirt since this dbus problem.
thanks in advance.
--------------------------------------
gcc -I../gnulib/lib -I../gnulib/lib -I../include -I../include -I../src
-I/usr/include/libxml2 -Wall -Wformat -Wformat-security
-Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra -Wshadow
-Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes
-Winline -Wredundant-decls -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fasynchronous-unwind-tables -DLOCAL_STATE_DIR=\"/var\"
-DSYSCONF_DIR=\"/etc\" -DQEMUD_PID_FILE=\"\"
-DREMOTE_PID_FILE=\"/var/run/libvirtd.pid\"
-DGETTEXT_PACKAGE=\"libvirt\" -D_REENTRANT -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -Wall -Wformat
-Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith
-Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return
-Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables -o
.libs/libvirtd libvirtd-event.o libvirtd-qemud.o libvirtd-remote.o
libvirtd-remote_protocol.o libvirtd-mdns.o ../gnulib/lib/.libs/libgnu.a
../src/.libs/libvirt_driver_qemu.a ../src/.libs/libvirt_driver_lxc.a
../src/.libs/libvirt_driver_uml.a ../src/.libs/libvirt_driver_storage.a
../src/.libs/libvirt_driver_network.a
../src/.libs/libvirt_driver_nodedev.a -L/lib64 -lhal -ldbus-1
../src/.libs/libvirt.so -lxml2 -lz -lm -lselinux -lgnutls -lsasl2
-lxenstore -lavahi-common -lavahi-client -lpthread
../src/.libs/libvirt_driver_nodedev.a(libvirt_driver_nodedev_la-node_device_hal.o):
In function `add_dbus_watch':
/home/robot/rpm/BUILD/libvirt-0.5.1/src/node_device_hal.c:578: undefined
reference to `dbus_watch_get_unix_fd'
collect2: ld returned 1 exit status
make[2]: *** [libvirtd] Error 1
make[2]: Leaving directory `/home/robot/rpm/BUILD/libvirt-0.5.1/qemud'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/robot/rpm/BUILD/libvirt-0.5.1'
make: *** [all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.39202 (%build)
--------------------------------------
--
Levente "Si vis pacem para bellum!"
15 years, 11 months
[libvirt] bug: libvirt hang while restore a domain
by Daniel Schwager
Hi,
i try to restore a domain without a valid disk (I deleted the diskfile
before restoring it ...). Normally, this must always produce an error.
** The first time, an error occurred - OK:
[root@xen03 srv]# virsh restore /srv/save
libvir: QEMU error : operation failed: failed to start VM
error: Failed to restore domain from /srv/save
** But the second time, the command hang:
[root@xen03 srv]# virsh restore /srv/save
^C
[root@xen03 srv]# virsh list
^C
[root@xen03 srv]#
I can't use libvirt now, until restarting the daemon....
*** The domain looks like this (/tmp/winxp100 does NOT exist)
<domain type='kvm' id='3'>
<name>winxp100</name>
<uuid>4e991a91-5db6-0584-3750-6a288ae01ee4</uuid>
<memory>256000</memory>
<currentMemory>256000</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/kvm/bin/qemu-system-x86_64</emulator>
<disk type='block' device='disk'>
<driver name='qemu'/>
<source dev='/tmp/winxp100'/>
<target dev='hda' bus='ide'/>
</disk>
<interface type='bridge'>
<mac address='52:54:00:cf:3e:66'/>
<source bridge='br0'/>
<script path='/etc/kvm/kvm-qemu-ipup.sh'/>
<target dev='vnet1'/>
<model type='e1000'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/6'/>
<target port='0'/>
</serial>
<console type='pty' tty='/dev/pts/6'>
<source path='/dev/pts/6'/>
<target port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5901' autoport='yes'/>
</devices>
</domain>
Is this a bug ?
regards
Danny
-------------------------------------------------------------------
DT Netsolution GmbH - Taläckerstr. 30 - D-70437 Stuttgart
Geschäftsführer: Daniel Schwager, Stefan Hörz - HRB Stuttgart 19870
Tel: +49-711-849910-32, Fax: -932 - Mailto:daniel.schwager@dtnet.de
15 years, 11 months
[libvirt] kvm, sync guest disk before saving ?
by Daniel Schwager
Hi,
is there a way to get a consistent disk image of a domain running qemu-kvm
before saving it ?
I used " xm sysrq <id> s" with xen-hypervisor - but what's the way with kvm ?
Or could I install drivers into the guest helping to solve this problem ?
regards
Danny
-------------------------------------------------------------------
DT Netsolution GmbH - Taläckerstr. 30 - D-70437 Stuttgart
Geschäftsführer: Daniel Schwager, Stefan Hörz - HRB Stuttgart 19870
Tel: +49-711-849910-32, Fax: -932 - Mailto:daniel.schwager@dtnet.de
15 years, 11 months
[libvirt] invoking interface.script - missing interface name of domain
by Daniel Schwager
Hi,
i would like to write a small script
- bringing up my qemu-kvm interface and
- connecting it to a bridge
using the following XML domain-syntax :
....
<interface type='ethernet'>
<script path='/etc/kvm/qemu-ifup'/>
</interface>
....
The script will invoked (from qemu-kvm I thinkg) but
I can't find any arguments like "interface name" - so
my script cannot setup the bridge correctly because of
missing information about the interface name.
At the moment, I look to the PPID (parent pid of the script) and
parse the qemu commandline (ps ef) to find out the interfacename -
but it's only a workaround.
Q: Is there a way to get informed about the interface libvirt/quemu used
for the new domain ?
regards
Danny
15 years, 11 months
[libvirt] bug: libvirt hang while restore a domain
by Daniel Schwager
Hi,
i try to restore a domain
[root@xen03 srv]# virsh restore /srv/save
libvir: QEMU error : operation failed: failed to start VM
error: Failed to restore domain from /srv/save
[root@xen03 srv]# virsh restore /srv/save
^C
[root@xen03 srv]# virsh list
^C
[root@xen03 srv]#
Viele Gruesse
Daniel Schwager
-------------------------------------------------------------------
DT Netsolution GmbH - Taläckerstr. 30 - D-70437 Stuttgart
Geschäftsführer: Daniel Schwager, Stefan Hörz - HRB Stuttgart 19870
Tel: +49-711-849910-32, Fax: -932 - Mailto:daniel.schwager@dtnet.de
15 years, 11 months
[libvirt] PATCH: Fix save/restore for new KVM
by Daniel P. Berrange
This is a repost of the patch from:
http://www.redhat.com/archives/libvir-list/2009-January/msg00583.html
updated to take account of the changes commited since I first posted it.
Daniel
diff -r 7aa9f1c885e7 src/qemu_conf.c
--- a/src/qemu_conf.c Tue Jan 27 15:42:39 2009 +0000
+++ b/src/qemu_conf.c Tue Jan 27 16:00:35 2009 +0000
@@ -412,6 +412,27 @@ int qemudExtractVersionInfo(const char *
if (kvm_version >= 74)
flags |= QEMUD_CMD_FLAG_VNET_HDR;
+ /*
+ * Handling of -incoming arg with varying features
+ * -incoming tcp (kvm >= 79)
+ * -incoming exec (kvm >= 80)
+ * -incoming stdio (all earlier kvm)
+ *
+ * NB, there was a pre-kvm-79 'tcp' support, but it
+ * was broken, because it blocked the monitor console
+ * while waiting for data, so pretend it doesn't exist
+ *
+ * XXX when next QEMU release after 0.9.1 arrives,
+ * we'll need to add MIGRATE_QEMU_TCP/EXEC here too
+ */
+ if (kvm_version >= 79) {
+ flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP;
+ if (kvm_version >= 80)
+ flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC;
+ } else if (kvm_version > 0) {
+ flags |= QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO;
+ }
+
if (retversion)
*retversion = version;
if (retflags)
@@ -694,6 +715,33 @@ int qemudBuildCommandLine(virConnectPtr
virUUIDFormat(vm->def->uuid, uuid);
+ /* Migration is very annoying due to wildly varying syntax & capabilities
+ * over time of KVM / QEMU codebases
+ */
+ if (migrateFrom) {
+ if (STRPREFIX(migrateFrom, "tcp")) {
+ if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP)) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
+ "%s", _("TCP migration is not supported with this QEMU binary"));
+ return -1;
+ }
+ } else if (STREQ(migrateFrom, "stdio")) {
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC) {
+ migrateFrom = "exec:cat";
+ } else if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO)) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
+ "%s", _("STDIO migration is not supported with this QEMU binary"));
+ return -1;
+ }
+ } else if (STRPREFIX(migrateFrom, "exec")) {
+ if (!(qemuCmdFlags & QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC)) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT,
+ "%s", _("STDIO migration is not supported with this QEMU binary"));
+ return -1;
+ }
+ }
+ }
+
/* Need to explicitly disable KQEMU if
* 1. Arch matches host arch
* 2. Guest is 'qemu'
diff -r 7aa9f1c885e7 src/qemu_conf.h
--- a/src/qemu_conf.h Tue Jan 27 15:42:39 2009 +0000
+++ b/src/qemu_conf.h Tue Jan 27 16:00:35 2009 +0000
@@ -40,15 +40,19 @@
/* Internal flags to keep track of qemu command line capabilities */
enum qemud_cmd_flags {
- QEMUD_CMD_FLAG_KQEMU = (1 << 0),
- QEMUD_CMD_FLAG_VNC_COLON = (1 << 1),
- QEMUD_CMD_FLAG_NO_REBOOT = (1 << 2),
- QEMUD_CMD_FLAG_DRIVE = (1 << 3),
- QEMUD_CMD_FLAG_DRIVE_BOOT = (1 << 4),
- QEMUD_CMD_FLAG_NAME = (1 << 5),
- QEMUD_CMD_FLAG_UUID = (1 << 6),
- QEMUD_CMD_FLAG_DOMID = (1 << 7), /* Xenner only */
- QEMUD_CMD_FLAG_VNET_HDR = (1 << 8),
+ QEMUD_CMD_FLAG_KQEMU = (1 << 0), /* Whether KQEMU is compiled in */
+ QEMUD_CMD_FLAG_VNC_COLON = (1 << 1), /* Does the VNC take just port, or address + display */
+ QEMUD_CMD_FLAG_NO_REBOOT = (1 << 2), /* Is the -no-reboot flag available */
+ QEMUD_CMD_FLAG_DRIVE = (1 << 3), /* Is the new -drive arg available */
+ QEMUD_CMD_FLAG_DRIVE_BOOT = (1 << 4), /* Does -drive support boot=on */
+ QEMUD_CMD_FLAG_NAME = (1 << 5), /* Is the -name flag available */
+ QEMUD_CMD_FLAG_UUID = (1 << 6), /* Is the -uuid flag available */
+ QEMUD_CMD_FLAG_DOMID = (1 << 7), /* Xenner only, special -domid flag available */
+ QEMUD_CMD_FLAG_VNET_HDR = (1 << 8),
+ QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO = (1 << 9), /* Original migration code from KVM. Also had tcp, but we can't use that
+ * since it had a design bug blocking the entire monitor console */
+ QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP = (1 << 10), /* New migration syntax after merge to QEMU with TCP transport */
+ QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC = (1 << 11), /* New migration syntax after merge to QEMU with EXEC transport */
};
/* Main driver state */
diff -r 7aa9f1c885e7 tests/qemuxml2argvdata/qemuxml2argv-migrate.args
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/qemuxml2argvdata/qemuxml2argv-migrate.args Tue Jan 27 16:00:35 2009 +0000
@@ -0,0 +1,1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-kvm -S -M pc -m 214 -smp 1 -nographic -monitor pty -pidfile /nowhere/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -incoming tcp:10.0.0.1:5000
diff -r 7aa9f1c885e7 tests/qemuxml2argvdata/qemuxml2argv-migrate.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/qemuxml2argvdata/qemuxml2argv-migrate.xml Tue Jan 27 16:00:35 2009 +0000
@@ -0,0 +1,22 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>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-kvm</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ </devices>
+</domain>
diff -r 7aa9f1c885e7 tests/qemuxml2argvdata/qemuxml2argv-restore-v1.args
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/qemuxml2argvdata/qemuxml2argv-restore-v1.args Tue Jan 27 16:00:35 2009 +0000
@@ -0,0 +1,1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-kvm -S -M pc -m 214 -smp 1 -nographic -monitor pty -pidfile /nowhere/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -incoming stdio
diff -r 7aa9f1c885e7 tests/qemuxml2argvdata/qemuxml2argv-restore-v1.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/qemuxml2argvdata/qemuxml2argv-restore-v1.xml Tue Jan 27 16:00:35 2009 +0000
@@ -0,0 +1,22 @@
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>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-kvm</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ </devices>
+</domain>
diff -r 7aa9f1c885e7 tests/qemuxml2argvdata/qemuxml2argv-restore-v2.args
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/qemuxml2argvdata/qemuxml2argv-restore-v2.args Tue Jan 27 16:00:35 2009 +0000
@@ -0,0 +1,1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-kvm -S -M pc -m 214 -smp 1 -nographic -monitor pty -pidfile /nowhere/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -incoming exec:cat
diff -r 7aa9f1c885e7 tests/qemuxml2argvdata/qemuxml2argv-restore-v2.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/qemuxml2argvdata/qemuxml2argv-restore-v2.xml Tue Jan 27 16:00:35 2009 +0000
@@ -0,0 +1,22 @@
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>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-kvm</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ </devices>
+</domain>
diff -r 7aa9f1c885e7 tests/qemuxml2argvtest.c
--- a/tests/qemuxml2argvtest.c Tue Jan 27 15:42:39 2009 +0000
+++ b/tests/qemuxml2argvtest.c Tue Jan 27 16:00:35 2009 +0000
@@ -24,7 +24,8 @@ static struct qemud_driver driver;
static int testCompareXMLToArgvFiles(const char *xml,
const char *cmd,
- int extraFlags) {
+ int extraFlags,
+ const char *migrateFrom) {
char argvData[MAX_FILE];
char *expectargv = &(argvData[0]);
char *actualargv = NULL;
@@ -56,7 +57,7 @@ static int testCompareXMLToArgvFiles(con
if (qemudBuildCommandLine(NULL, &driver,
&vm, flags, &argv, &qenv,
- NULL, NULL, NULL) < 0)
+ NULL, NULL, migrateFrom) < 0)
goto fail;
len = 1; /* for trailing newline */
@@ -122,6 +123,7 @@ static int testCompareXMLToArgvFiles(con
struct testInfo {
const char *name;
int extraFlags;
+ const char *migrateFrom;
};
static int testCompareXMLToArgvHelper(const void *data) {
@@ -132,7 +134,7 @@ static int testCompareXMLToArgvHelper(co
abs_srcdir, info->name);
snprintf(args, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.args",
abs_srcdir, info->name);
- return testCompareXMLToArgvFiles(xml, args, info->extraFlags);
+ return testCompareXMLToArgvFiles(xml, args, info->extraFlags, info->migrateFrom);
}
@@ -161,7 +163,15 @@ mymain(int argc, char **argv)
#define DO_TEST(name, extraFlags) \
do { \
- struct testInfo info = { name, extraFlags }; \
+ struct testInfo info = { name, extraFlags, NULL }; \
+ if (virtTestRun("QEMU XML-2-ARGV " name, \
+ 1, testCompareXMLToArgvHelper, &info) < 0) \
+ ret = -1; \
+ } while (0)
+
+#define DO_TEST_MIGRATE(name, extraFlags, migrateFrom) \
+ do { \
+ struct testInfo info = { name, extraFlags, migrateFrom }; \
if (virtTestRun("QEMU XML-2-ARGV " name, \
1, testCompareXMLToArgvHelper, &info) < 0) \
ret = -1; \
@@ -228,6 +238,11 @@ mymain(int argc, char **argv)
DO_TEST("hostdev-pci-address", 0);
+ DO_TEST_MIGRATE("restore-v1", QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO, "stdio");
+ DO_TEST_MIGRATE("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "stdio");
+ DO_TEST_MIGRATE("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "exec:cat");
+ DO_TEST_MIGRATE("migrate", QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP, "tcp:10.0.0.1:5000");
+
virCapabilitiesFree(driver.caps);
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 11 months
[libvirt] [PATCH 6/8] Makefile.maint: sync from coreutils
by Jim Meyering
You can ignore the patch numbering.
There was yet another one adjusting po/POTFILES.in
that I'm not bothering to post.
Probably not worth reviewing.
Some of it is just factorization.
Other bits reflect removal of coreutils-specific things (they're
migrating into coreutils' cfg.mk (was called Makefile.cfg).
On the other hand, a few are introduction of cu-specific bits,
but that are enabled only if certain coreutils-specific files
are present. This is to make later merges easier.
I've made sure that "make syntax-check" still works.
>From 19d1ea009c2d1235a271915e55eac9e170e3530c Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 28 Jan 2009 16:45:18 +0100
Subject: [PATCH 6/8] * Makefile.maint: sync from coreutils
---
Makefile.maint | 426 +++++++++++++++++++++++++++++++------------------------
1 files changed, 240 insertions(+), 186 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index 204370d..c50d100 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -25,9 +25,7 @@ syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
.PHONY: $(syntax-check-rules)
local-checks-available = \
- po-check copyright-check m4-check author_mark_check \
- patch-check strftime-check $(syntax-check-rules) \
- makefile_path_separator_check \
+ patch-check $(syntax-check-rules) \
makefile-check check-AUTHORS
.PHONY: $(local-checks-available)
@@ -45,6 +43,17 @@ syntax-check: $(local-check)
# exit 1; } || :
# FIXME: don't allow `#include .strings\.h' anywhere
+# There are many rules below that prohibit constructs in this package.
+# If the offending construct can be matched with a grep-E-style regexp,
+# use this macro. The shell variables "re" and "msg" must be defined.
+define _prohibit_regexp
+ dummy=; : so we do not need a semicolon before each use \
+ test "x$$re" != x || { echo '$(ME): re not defined' 1>&2; exit 1; }; \
+ test "x$$msg" != x || { echo '$(ME): msg not defined' 1>&2; exit 1; };\
+ grep -nE "$$re" $$($(VC_LIST_EXCEPT)) && \
+ { echo '$(ME): '"$$msg" 1>&2; exit 1; } || :
+endef
+
sc_avoid_if_before_free:
@$(srcdir)/build-aux/useless-if-before-free \
$(useless_free_options) \
@@ -64,40 +73,29 @@ sc_avoid_write:
fi
sc_cast_of_argument_to_free:
- @grep -nE '\<free *\( *\(' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): don'\''t cast free argument' 1>&2; \
- exit 1; } || :
+ @re='\<free *\( *\(' msg='don'\''t cast free argument' \
+ $(_prohibit_regexp)
sc_cast_of_x_alloc_return_value:
- @grep -nE '\*\) *x(m|c|re)alloc\>' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
- exit 1; } || :
+ @re='\*\) *x(m|c|re)alloc\>' \
+ msg='don'\''t cast x*alloc return value' \
+ $(_prohibit_regexp)
sc_cast_of_alloca_return_value:
- @grep -nE '\*\) *alloca\>' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): don'\''t cast alloca return value' 1>&2; \
- exit 1; } || :
+ @re='\*\) *alloca\>' msg='don'\''t cast alloca return value' \
+ $(_prohibit_regexp)
sc_space_tab:
- @grep -n '[ ] ' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
- 1>&2; exit 1; } || :
-
-cvs_keywords = \
- Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
-
-sc_prohibit_cvs_keyword:
- @grep -nE '\$$($(cvs_keywords))\$$' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): do not use CVS keyword expansion ' \
- 1>&2; exit 1; } || :
+ @re='[ ] ' msg='found SPACE-TAB sequence; remove the SPACE' \
+ $(_prohibit_regexp)
# Don't use *scanf or the old ato* functions in `real' code.
# They provide no error checking mechanism.
# Instead, use strto* functions.
sc_prohibit_atoi_atof:
- @grep -nE '\<([fs]?scanf|ato([filq]|ll))\>' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): do not use *scan''f, ato''f, ato''i, ato''l, ato''ll, ato''q, or ss''canf' \
- 1>&2; exit 1; } || :
+ @re='\<([fs]?scanf|ato([filq]|ll))\>' \
+ msg='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
+ $(_prohibit_regexp)
# Use STREQ rather than comparing strcmp == 0, or != 0.
# Similarly, use STREQLEN or STRPREFIX rather than strncmp.
@@ -110,8 +108,9 @@ sc_prohibit_strcmp:
# Use virAsprintf rather than a'sprintf since *strp is undefined on error.
sc_prohibit_asprintf:
- @grep -nE '\<[a]sprintf\>' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): use virAsprintf, not a'sprintf 1>&2; exit 1; } || :
+ @re='\<[a]sprintf\>' \
+ msg='use virAsprintf, not a'sprintf \
+ $(_prohibit_regexp)
sc_prohibit_nonreentrant:
@fail=0 ; \
@@ -227,120 +226,11 @@ sc_changelog:
{ echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
exit 1; } || :
-# Ensure that dd's definition of LONGEST_SYMBOL stays in sync
-# with the strings from the two affected variables.
-dd_c = $(srcdir)/src/dd.c
-sc_dd_max_sym_length:
-ifneq ($(wildcard $(dd_c)),)
- @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
- sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
- |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
- | wc --max-line-length); \
- max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
- |tr -d '"' | wc --max-line-length); \
- if test "$$len" = "$$max"; then :; else \
- echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
- exit 1; \
- fi
-endif
-
-# Many m4 macros names once began with `jm_'.
-# On 2004-04-13, they were all changed to start with gl_ instead.
-# Make sure that none are inadvertently reintroduced.
-sc_prohibit_jm_in_m4:
- @grep -nE 'jm_[A-Z]' \
- $$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
- { echo '$(ME): do not use jm_ in m4 macro names' \
- 1>&2; exit 1; } || :
-
-# Ensure that each root-requiring test is run via the "check-root" rule.
-sc_root_tests:
- @if test -d tests \
- && grep check-root tests/Makefile.am>/dev/null 2>&1; then \
- t1=sc-root.expected; t2=sc-root.actual; \
- grep -nl '^require_root_$$' \
- $$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1; \
- sed -n '/^root_tests =[ ]*\\$$/,/[^\]$$/p' \
- $(srcdir)/tests/Makefile.am \
- | sed 's/^ *//;/^root_tests =/d' \
- | tr -s '\012\\' ' ' | fmt -1 | sort > $$t2; \
- diff -u $$t1 $$t2 || diff=1; \
- rm -f $$t1 $$t2; \
- test "$$diff" \
- && { echo 'tests/Makefile.am: missing check-root action'>&2; \
- exit 1; } || :; \
- fi
-
-headers_with_interesting_macro_defs = \
- exit.h \
- fcntl_.h \
- fnmatch_.h \
- intprops.h \
- inttypes_.h \
- lchown.h \
- openat.h \
- stat-macros.h \
- stdint_.h
-
-# Create a list of regular expressions matching the names
-# of macros that are guaranteed by parts of gnulib to be defined.
-.re-defmac:
- @(cd $(srcdir)/lib; \
- for f in $(headers_with_interesting_macro_defs); do \
- test -f $$f && \
- sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \
- done; \
- ) | sort -u \
- | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \
- | sed 's/^/^# *define /' \
- > $@-t
- @mv $@-t $@
-
-# Don't define macros that we already get from gnulib header files.
-sc_always_defined_macros: .re-defmac
- @if test -f $(srcdir)/src/system.h; then \
- trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \
- grep -f .re-defmac $$($(VC_LIST)) \
- && { echo '$(ME): define the above via some gnulib .h file' \
- 1>&2; exit 1; } || :; \
- fi
-
-# Create a list of regular expressions matching the names
-# of files included from system.h. Exclude a couple.
-.re-list:
- @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
- | grep -Ev 'sys/(param|file)\.h' \
- | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
- > $@-t
- @mv $@-t $@
-
-# Files in src/ should not include directly any of
-# the headers already included via system.h.
-sc_system_h_headers: .re-list
- @if test -f $(srcdir)/src/system.h; then \
- trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
- grep -nE -f .re-list \
- $$($(VC_LIST) src | \
- grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
- && { echo '$(ME): the above are already included via system.h'\
- 1>&2; exit 1; } || :; \
- fi
-
-sc_sun_os_names:
- @grep -nEi \
- 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
- $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
- exit 1; } || :
-
sc_the_the:
@grep -ni '\<the ''the\>' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found use of "the ''the";' 1>&2; \
exit 1; } || :
-sc_tight_scope:
- $(MAKE) -C src $@
-
sc_trailing_blank:
@grep -n '[ ]$$' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found trailing blank(s)' \
@@ -374,7 +264,7 @@ sc_two_space_separator_in_usage:
@grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
$$($(VC_LIST_EXCEPT)) && \
{ echo "$(ME): help2man requires at least two spaces between"; \
- echo "$(ME): an option and its description"; \
+ echo "$(ME): an option and its description"; \
1>&2; exit 1; } || :
# Many of the function names below came from this filter:
@@ -460,15 +350,16 @@ sc_unmarked_diagnostics:
exit 1; } || :
sc_prohibit_virBufferAdd_with_string_literal:
- @grep -nE '\<virBufferAdd *\([^,]+, *"[^"]' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): use virBufferAddLit, not virBufferAdd,' \
- 'with a string literal' 1>&2; exit 1; } || :
+ @re='\<virBufferAdd *\([^,]+, *"[^"]' \
+ msg='use virBufferAddLit, not virBufferAdd, with a string literal' \
+ $(_prohibit_regexp)
# Not only do they fail to deal well with ipv6, but the gethostby*
# functions are also not thread-safe.
sc_prohibit_gethostby:
- @grep -nE '\<gethostby(addr|name2?) *\(' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): use getaddrinfo, not gethostby*' 1>&2; exit 1; } || :
+ @re='\<gethostby(addr|name2?) *\(' \
+ msg='use getaddrinfo, not gethostby*' \
+ $(_prohibit_regexp)
# Avoid useless parentheses like those in this example:
# #if defined (SYMBOL) || defined (SYM2)
@@ -482,6 +373,77 @@ sc_GPL_version:
@grep -n 'either ''version [^3]' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || :
+cvs_keywords = \
+ Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
+
+sc_prohibit_cvs_keyword:
+ @re='\$$($(cvs_keywords))\$$' \
+ msg='do not use CVS keyword expansion' \
+ $(_prohibit_regexp)
+
+# Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
+# This is a bit of a kludge, since it prevents use of the string
+# even in comments, but for now it does the job with no false positives.
+sc_prohibit_stat_st_blocks:
+ @re='[.>]st_blocks' msg='do not use st_blocks; use ST_NBLOCKS' \
+ $(_prohibit_regexp)
+
+# Make sure we don't define any S_IS* macros in src/*.c files.
+# They're already defined via gnulib's sys/stat.h replacement.
+sc_prohibit_S_IS_definition:
+ @re='^ *# *define *S_IS' \
+ msg='do not define S_IS* macros; include <sys/stat.h>' \
+ $(_prohibit_regexp)
+
+# Each program that uses proper_name_utf8 must link with
+# one of the ICONV libraries.
+sc_proper_name_utf8_requires_ICONV:
+ @progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
+ if test "x$$progs" != x; then \
+ fail=0; \
+ for p in $$progs; do \
+ dir=$$(dirname "$$p"); \
+ base=$$(basename "$$p" .c); \
+ grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \
+ || { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
+ done; \
+ test $$fail = 1 && \
+ { echo 1>&2 '$(ME): the above do not link with any ICONV library'; \
+ exit 1; } || :; \
+ fi
+
+# Warn about "c0nst struct Foo const foo[]",
+# but not about "char const *const foo" or "#define const const".
+sc_redundant_const:
+ @grep -E '\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
+ $$($(VC_LIST_EXCEPT)) && \
+ { echo 1>&2 '$(ME): redundant "const" in declarations'; \
+ exit 1; } || :
+
+sc_const_long_option:
+ @grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \
+ | grep -Ev 'const struct option|struct option const' && { \
+ echo 1>&2 '$(ME): add "const" to the above declarations'; \
+ exit 1; } || :
+
+NEWS_hash = \
+ $$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
+ $(srcdir)/NEWS | md5sum -)
+
+# Ensure that we don't accidentally insert an entry into an old NEWS block.
+sc_immutable_NEWS:
+ @if test -f $(srcdir)/NEWS; then \
+ test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
+ { echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
+ fi
+
+# Update the hash stored above. Do this after each release and
+# for any corrections to old entries.
+update-NEWS-hash: NEWS
+ perl -pi -e 's/^(old_NEWS_hash = ).*/$${1}'"$(NEWS_hash)/" \
+ $(srcdir)/cfg.mk
+
+epoch_date = 1970-01-01 00:00:00.000000000 +0000
# Ensure that the c99-to-c89 patch applies cleanly.
patch-check:
rm -rf src-c89 $@.1 $@.2
@@ -507,21 +469,6 @@ patch-check:
test "$$msg" = ok && rm -rf src-c89 $@.1 $@.2 || echo "$$msg" 1>&2; \
test "$$msg" = ok
-# Ensure that date's --help output stays in sync with the info
-# documentation for GNU strftime. The only exception is %N,
-# which date accepts but GNU strftime does not.
-extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
-strftime-check:
- @if test -f $(srcdir)/src/date.c; then \
- grep '^ %. ' $(srcdir)/src/date.c | sort \
- | $(extract_char) > $@-src; \
- { echo N; \
- info libc date calendar format | grep '^ `%.'\' \
- | $(extract_char); } | sort > $@-info; \
- diff -u $@-src $@-info || exit 1; \
- rm -f $@-src $@-info; \
- fi
-
check-AUTHORS:
$(MAKE) -C src $@
@@ -551,9 +498,10 @@ changelog-check:
exit 1; \
fi
-m4-check:
- @grep -n 'AC_DEFUN([^[]' $(srcdir)/m4/*.m4 \
- && { echo '$(ME): quote the first arg to AC_DEFUN' 1>&2; \
+sc_m4_quote_check:
+ @grep -nE '(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
+ $$($(VC_LIST_EXCEPT) | grep -E '(^configure\.ac|\.m4)$$') \
+ && { echo '$(ME): quote the first arg to AC_DEF*' 1>&2; \
exit 1; } || :
fix_po_file_diag = \
@@ -562,7 +510,7 @@ apply the above patch\n'
# Verify that all source files using _() are listed in po/POTFILES.in.
po_file = po/POTFILES.in
-po-check:
+sc_po_check:
@if test -f $(po_file); then \
grep -E -v '^(#|$$)' $(po_file) \
| grep -v '^src/false\.c$$' | sort > $@-1; \
@@ -587,14 +535,6 @@ po-check:
rm -f $@-1 $@-2; \
fi
-# In a definition of #define AUTHORS "... and ..." where the RHS contains
-# the English word `and', the string must be marked with `N_ (...)' so that
-# gettext recognizes it as a string requiring translation.
-author_mark_check:
- @grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
- { echo '$(ME): enclose the above strings in N_ (...)' 1>&2; \
- exit 1; } || :
-
# Sometimes it is useful to change the PATH environment variable
# in Makefiles. When doing so, it's better not to use the Unix-centric
# path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
@@ -602,7 +542,7 @@ author_mark_check:
# and there probably aren't many projects with so many Makefile.am files
# that we'd have to worry about limits on command line length.
msg = '$(ME): Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
-makefile_path_separator_check:
+sc_makefile_path_separator_check:
@grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
&& { echo $(msg) 1>&2; exit 1; } || :
@@ -623,24 +563,24 @@ sample-test = tests/sample-test
texi = doc/$(PACKAGE).texi
# Make sure that the copyright date in $(v_etc_file) is up to date.
# Do the same for the $(sample-test) and the main doc/.texi file.
-copyright-check:
- @if test -f $(v_etc_file); then \
+sc_copyright_check:
+ @if test -f $(v_etc_file); then \
grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
- >/dev/null \
+ >/dev/null \
|| { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
- exit 1; }; \
+ exit 1; }; \
fi
- @if test -f $(sample-test); then \
- grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
- >/dev/null \
+ @if test -f $(sample-test); then \
+ grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
+ >/dev/null \
|| { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
- exit 1; }; \
+ exit 1; }; \
fi
- @if test -f $(texi); then \
- grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
- >/dev/null \
- || { echo 'out of date copyright in $(texi); update it' 1>&2; \
- exit 1; }; \
+ @if test -f $(texi); then \
+ grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
+ >/dev/null \
+ || { echo 'out of date copyright in $(texi); update it' 1>&2; \
+ exit 1; }; \
fi
vc-diff-check:
@@ -659,6 +599,119 @@ maintainer-distcheck:
$(MAKE) distcheck
$(MAKE) my-distcheck
+
+# Don't make a distribution if checks fail.
+# Also, make sure the NEWS file is up-to-date.
+vc-dist: $(local-check) cvs-check maintainer-distcheck
+ $(MAKE) dist
+
+# Use this to make sure we don't run these programs when building
+# from a virgin tgz file, below.
+null_AM_MAKEFLAGS = \
+ ACLOCAL=false \
+ AUTOCONF=false \
+ AUTOMAKE=false \
+ AUTOHEADER=false \
+ MAKEINFO=false
+
+built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
+
+warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
+bin=bin-$$$$
+
+write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
+
+TMPDIR ?= /tmp
+t=$(TMPDIR)/$(PACKAGE)/test
+pfx=$(t)/i
+
+# More than once, tainted build and source directory names would
+# have caused at least one "make check" test to apply "chmod 700"
+# to all directories under $HOME. Make sure it doesn't happen again.
+tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-$$$$")
+t_prefix = $(tp)/a
+t_taint = '$(t_prefix) b'
+fake_home = $(tp)/home
+
+# Ensure that tests run from tainted build and src dir names work,
+# and don't affect anything in $HOME. Create witness files in $HOME,
+# record their attributes, and build/test. Then ensure that the
+# witnesses were not affected.
+taint-distcheck: $(DIST_ARCHIVES)
+ test -d $(t_taint) && chmod -R 700 $(t_taint) || :
+ -rm -rf $(t_taint) $(fake_home)
+ mkdir -p $(t_prefix) $(t_taint) $(fake_home)
+ GZIP=$(GZIP_ENV) $(AMTAR) -C $(t_taint) -zxf $(distdir).tar.gz
+ mkfifo $(fake_home)/fifo
+ touch $(fake_home)/f
+ mkdir -p $(fake_home)/d/e
+ ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
+ cd $(t_taint)/$(distdir) \
+ && ./configure \
+ && $(MAKE) \
+ && HOME=$(fake_home) $(MAKE) check \
+ && ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
+ && diff $(tp)/.ls-before $(tp)/.ls-after \
+ && test -d $(t_prefix)
+ rm -rf $(tp)
+
+# Verify that a twisted use of --program-transform-name=PROGRAM works.
+define install-transform-check
+ echo running install-transform-check \
+ && rm -rf $(pfx) \
+ && $(MAKE) program_transform_name='s/.*/zyx/' \
+ prefix=$(pfx) install \
+ && test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx" \
+ && test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
+endef
+
+# Install, then verify that all binaries and man pages are in place.
+# Note that neither the binary, ginstall, nor the ].1 man page is installed.
+define my-instcheck
+ $(MAKE) prefix=$(pfx) install \
+ && test ! -f $(pfx)/bin/ginstall \
+ && { fail=0; \
+ for i in $(built_programs); do \
+ test "$$i" = ginstall && i=install; \
+ for j in "$(pfx)/bin/$$i" \
+ "$(pfx)/share/man/man1/$$i.1"; do \
+ case $$j in *'[.1') continue;; esac; \
+ test -f "$$j" && : \
+ || { echo "$$j not installed"; fail=1; }; \
+ done; \
+ done; \
+ test $$fail = 1 && exit 1 || :; \
+ }
+endef
+
+define coreutils-path-check
+ { \
+ if test -f $(srcdir)/src/true.c; then \
+ fail=1; \
+ mkdir $(bin) \
+ && ($(write_loser)) > $(bin)/loser \
+ && chmod a+x $(bin)/loser \
+ && for i in $(built_programs); do \
+ case $$i in \
+ rm|expr|basename|echo|sort|ls|tr);; \
+ cat|dirname|mv|wc);; \
+ *) ln $(bin)/loser $(bin)/$$i;; \
+ esac; \
+ done \
+ && ln -sf ../src/true $(bin)/false \
+ && PATH=`pwd`/$(bin):$$PATH $(MAKE) -C tests check \
+ && { test -d gnulib-tests \
+ && $(MAKE) -C gnulib-tests check \
+ || :; } \
+ && rm -rf $(bin) \
+ && fail=0; \
+ else \
+ fail=0; \
+ fi; \
+ test $$fail = 1 && exit 1 || :; \
+ }
+endef
+
# Use -Wformat -Werror to detect format-string/arg-list mismatches.
# Also, check for shadowing problems with -Wshadow, and for pointer
# arithmetic problems with -Wpointer-arith.
@@ -671,8 +724,6 @@ maintainer-distcheck:
# the build srcdir, these always-failing programs will run.
# Otherwise, it is too easy to test the wrong programs.
# Note that "false" itself is a symlink to true, so it too will malfunction.
-TMPDIR ?= /tmp
-t=$(TMPDIR)/$(PACKAGE)/test
my-distcheck: $(DIST_ARCHIVES) $(local-check)
$(MAKE) syntax-check
$(MAKE) check
@@ -684,6 +735,9 @@ my-distcheck: $(DIST_ARCHIVES) $(local-check)
&& $(MAKE) CFLAGS='$(warn_cflags)' \
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
&& $(MAKE) dvi \
+ && $(install-transform-check) \
+ && $(my-instcheck) \
+ && $(coreutils-path-check) \
&& $(MAKE) distclean
(cd $(t) && mv $(distdir) $(distdir).old \
&& $(AMTAR) -zxf - ) < $(distdir).tar.gz
--
1.6.1.1.374.g0d9d7
>From e296a217081051c32ca5117ffc4689177763a1fb Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 28 Jan 2009 16:45:00 +0100
Subject: [PATCH 7/8] * Makefile.cfg: disable some new checks
---
Makefile.cfg | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/Makefile.cfg b/Makefile.cfg
index 8964319..44d3898 100644
--- a/Makefile.cfg
+++ b/Makefile.cfg
@@ -1,5 +1,5 @@
# Customize Makefile.maint. -*- makefile -*-
-# Copyright (C) 2003-2008 Free Software Foundation, Inc.
+# Copyright (C) 2003-2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,30 +26,36 @@ url_dir_list = \
# Tests not to run as part of "make distcheck".
local-checks-to-skip = \
- makefile_path_separator_check \
+ changelog-check \
+ check-AUTHORS \
makefile-check \
- sc_tight_scope \
+ makefile_path_separator_check \
+ patch-check \
sc_GPL_version \
sc_always_defined_macros \
sc_cast_of_alloca_return_value \
sc_dd_max_sym_length \
sc_error_exit_success \
sc_file_system \
+ sc_immutable_NEWS \
+ sc_m4_quote_check \
+ sc_makefile_path_separator_check \
sc_obsolete_symbols \
+ sc_prohibit_S_IS_definition \
sc_prohibit_atoi_atof \
sc_prohibit_jm_in_m4 \
+ sc_prohibit_nonreentrant \
sc_prohibit_quote_without_use \
sc_prohibit_quotearg_without_use \
- sc_prohibit_nonreentrant \
+ sc_prohibit_stat_st_blocks \
+ sc_redundant_const \
sc_root_tests \
sc_space_tab \
sc_sun_os_names \
sc_system_h_headers \
+ sc_tight_scope \
sc_two_space_separator_in_usage \
- sc_useless_cpp_parens \
- patch-check \
- check-AUTHORS \
- changelog-check
+ sc_useless_cpp_parens
useless_free_options = \
--name=sexpr_free \
--
1.6.1.1.374.g0d9d7
15 years, 11 months
[libvirt] [PATCH] Fix xend XML generation when CPU pinning is used
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1233203295 28800
# Node ID 9aac8028d5f266023c85338afe71ecabe26079f7
# Parent add5d46423d8cc24ac922373ba5cd1b3ea2e6f9f
Fix xend XML generation when CPU pinning is used
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -2227,11 +2227,21 @@ xenDaemonParseSxpr(virConnectPtr conn,
def->maxmem = def->memory;
if (cpus != NULL) {
+ def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
+ if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) {
+ virXendError(conn, VIR_ERR_NO_MEMORY, NULL);
+ goto error;
+ }
+
if (virDomainCpuSetParse(conn, &cpus,
0, def->cpumask,
- def->cpumasklen) < 0)
+ def->cpumasklen) < 0) {
+ virXendError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("invalid CPU mask %s"), cpus);
goto error;
- }
+ }
+ }
+
def->vcpus = sexpr_int(root, "domain/vcpus");
tmp = sexpr_node(root, "domain/on_poweroff");
15 years, 11 months
[libvirt] PATCH: Fix crash in QEMU driver with illegal machine/arch info
by Daniel P. Berrange
This bug was originally reported here
https://bugzilla.redhat.com/show_bug.cgi?id=479203
If you define an guest VM specifying a architecture which does not
actually exist in the QEMU driver's declared capabilities, then it
would dereference NULL when later attempting to start the VM.
The example from the bug, is attempting to create & start a 'x86_64'
VM on a host which is i686, and doesn't have the qemu-system-x86_64
emulator available. Or even just make up a random bad architecture.
This patch does two things
- Makes the domain_conf.c parser validate the requested architecture
against those actually available in the driver
- Safety net in qemu_conf.c just in case the former validation somehow
stopped working.
With this patch applie you now get
# virsh define demo.xml
libvir: Domain Config error : internal error os type 'hvm' & arch 'x86_64' combination is not supported
error: Failed to define domain from demo.xml
Regards,
Daniel
diff -r e4ec5a7bf9df src/capabilities.c
--- a/src/capabilities.c Thu Jan 29 11:54:55 2009 +0000
+++ b/src/capabilities.c Thu Jan 29 13:56:55 2009 +0000
@@ -433,6 +433,30 @@ virCapabilitiesSupportsGuestOSType(virCa
/**
+ * virCapabilitiesSupportsGuestOSType:
+ * @caps: capabilities to query
+ * @ostype: OS type to search for (eg 'hvm', 'xen')
+ * @arch: Architecture to search for (eg, 'i686', 'x86_64')
+ *
+ * Returns non-zero if the capabilities support the
+ * requested operating system type
+ */
+extern int
+virCapabilitiesSupportsGuestArch(virCapsPtr caps,
+ const char *ostype,
+ const char *arch)
+{
+ int i;
+ for (i = 0 ; i < caps->nguests ; i++) {
+ if (STREQ(caps->guests[i]->ostype, ostype) &&
+ STREQ(caps->guests[i]->arch.name, arch))
+ return 1;
+ }
+ return 0;
+}
+
+
+/**
* virCapabilitiesDefaultGuestArch:
* @caps: capabilities to query
* @ostype: OS type to search for
diff -r e4ec5a7bf9df src/capabilities.h
--- a/src/capabilities.h Thu Jan 29 11:54:55 2009 +0000
+++ b/src/capabilities.h Thu Jan 29 13:56:55 2009 +0000
@@ -162,6 +162,12 @@ virCapabilitiesAddGuestFeature(virCapsGu
extern int
virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
const char *ostype);
+extern int
+virCapabilitiesSupportsGuestArch(virCapsPtr caps,
+ const char *ostype,
+ const char *arch);
+
+
extern const char *
virCapabilitiesDefaultGuestArch(virCapsPtr caps,
const char *ostype);
diff -r e4ec5a7bf9df src/domain_conf.c
--- a/src/domain_conf.c Thu Jan 29 11:54:55 2009 +0000
+++ b/src/domain_conf.c Thu Jan 29 13:56:55 2009 +0000
@@ -2038,7 +2038,14 @@ static virDomainDefPtr virDomainDefParse
}
def->os.arch = virXPathString(conn, "string(./os/type[1]/@arch)", ctxt);
- if (!def->os.arch) {
+ if (def->os.arch) {
+ if (!virCapabilitiesSupportsGuestArch(caps, def->os.type, def->os.arch)) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("os type '%s' & arch '%s' combination is not supported"),
+ def->os.type, def->os.arch);
+ goto error;
+ }
+ } else {
const char *defaultArch = virCapabilitiesDefaultGuestArch(caps, def->os.type);
if (defaultArch == NULL) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
diff -r e4ec5a7bf9df src/qemu_conf.c
--- a/src/qemu_conf.c Thu Jan 29 11:54:55 2009 +0000
+++ b/src/qemu_conf.c Thu Jan 29 13:56:55 2009 +0000
@@ -843,8 +843,16 @@ int qemudBuildCommandLine(virConnectPtr
ADD_ARG_LIT(emulator);
ADD_ARG_LIT("-S");
- ADD_ARG_LIT("-M");
- ADD_ARG_LIT(vm->def->os.machine);
+
+ /* This should *never* be NULL, since we always provide
+ * a machine in the capabilities data for QEMU. So this
+ * check is just here as a safety in case the unexpected
+ * happens */
+ if (vm->def->os.machine) {
+ ADD_ARG_LIT("-M");
+ ADD_ARG_LIT(vm->def->os.machine);
+ }
+
if (disableKQEMU)
ADD_ARG_LIT("-no-kqemu");
ADD_ARG_LIT("-m");
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 11 months
[libvirt] PATCH: Support VNC password for QEMU guests
by Daniel P. Berrange
This patch adds support for using the monitor interface to set the VNC
password
(qemu) change vnc password
Password: ********
A minor tricky thing is that we can't just send the command and password
all in one go, we must wait for the 'Password' prompt before sending the
password.
When doing this I noticed that virsh dumpxml has no way to request a
secure XML dump (required to see the password element), nor did the
virsh edit command set the SECURE or INACTIVE flags when changing
the XML.
qemu_conf.c | 45 ++++++++++++-----------
qemu_driver.c | 112 ++++++++++++++++++++++++++++++++++++++++++++--------------
virsh.c | 30 ++++++++++-----
3 files changed, 131 insertions(+), 56 deletions(-)
Daniel
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -1138,37 +1138,42 @@ int qemudBuildCommandLine(virConnectPtr
if (vm->def->graphics &&
vm->def->graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
- char vncdisplay[PATH_MAX];
- int ret;
+ virBuffer opt = VIR_BUFFER_INITIALIZER;
+ char *optstr;
if (qemuCmdFlags & QEMUD_CMD_FLAG_VNC_COLON) {
- char options[PATH_MAX] = "";
+ if (vm->def->graphics->data.vnc.listenAddr)
+ virBufferAdd(&opt, vm->def->graphics->data.vnc.listenAddr, -1);
+ else if (driver->vncListen)
+ virBufferAdd(&opt, driver->vncListen, -1);
+
+ virBufferVSprintf(&opt, ":%d",
+ vm->def->graphics->data.vnc.port - 5900);
+
+ if (vm->def->graphics->data.vnc.passwd)
+ virBufferAddLit(&opt, ",password");
+
if (driver->vncTLS) {
- strcat(options, ",tls");
+ virBufferAddLit(&opt, ",tls");
if (driver->vncTLSx509verify) {
- strcat(options, ",x509verify=");
+ virBufferVSprintf(&opt, ",x509verify=%s",
+ driver->vncTLSx509certdir);
} else {
- strcat(options, ",x509=");
+ virBufferVSprintf(&opt, ",x509=%s",
+ driver->vncTLSx509certdir);
}
- strncat(options, driver->vncTLSx509certdir,
- sizeof(options) - (strlen(driver->vncTLSx509certdir)-1));
- options[sizeof(options)-1] = '\0';
}
- ret = snprintf(vncdisplay, sizeof(vncdisplay), "%s:%d%s",
- (vm->def->graphics->data.vnc.listenAddr ?
- vm->def->graphics->data.vnc.listenAddr :
- (driver->vncListen ? driver->vncListen : "")),
- vm->def->graphics->data.vnc.port - 5900,
- options);
} else {
- ret = snprintf(vncdisplay, sizeof(vncdisplay), "%d",
- vm->def->graphics->data.vnc.port - 5900);
+ virBufferVSprintf(&opt, "%d",
+ vm->def->graphics->data.vnc.port - 5900);
}
- if (ret < 0 || ret >= (int)sizeof(vncdisplay))
- goto error;
+ if (virBufferError(&opt))
+ goto no_memory;
+
+ optstr = virBufferContentAndReset(&opt);
ADD_ARG_LIT("-vnc");
- ADD_ARG_LIT(vncdisplay);
+ ADD_ARG(optstr);
if (vm->def->graphics->data.vnc.keymap) {
ADD_ARG_LIT("-k");
ADD_ARG_LIT(vm->def->graphics->data.vnc.keymap);
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -74,6 +74,10 @@
/* For storing short-lived temporary files. */
#define TEMPDIR LOCAL_STATE_DIR "/cache/libvirt"
+#define QEMU_CMD_PROMPT "\n(qemu) "
+#define QEMU_PASSWD_PROMPT "Password: "
+
+
static int qemudShutdown(void);
#define qemudLog(level, msg...) fprintf(stderr, msg)
@@ -138,9 +142,14 @@ static void qemudShutdownVMDaemon(virCon
static int qemudDomainGetMaxVcpus(virDomainPtr dom);
-static int qemudMonitorCommand (const virDomainObjPtr vm,
- const char *cmd,
- char **reply);
+static int qemudMonitorCommand(const virDomainObjPtr vm,
+ const char *cmd,
+ char **reply);
+static int qemudMonitorCommandExtra(const virDomainObjPtr vm,
+ const char *cmd,
+ const char *extra,
+ const char *extraPrompt,
+ char **reply);
static struct qemud_driver *qemu_driver = NULL;
@@ -1012,6 +1021,36 @@ qemudInitCpus(virConnectPtr conn,
}
+static int
+qemudInitPasswords(virConnectPtr conn,
+ virDomainObjPtr vm) {
+ char *info = NULL;
+
+ /*
+ * NB: Might have more passwords to set in the future. eg a qcow
+ * disk decryption password, but there's no monitor command
+ * for that yet...
+ */
+
+ if (vm->def->graphics &&
+ vm->def->graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
+ vm->def->graphics->data.vnc.passwd) {
+
+ if (qemudMonitorCommandExtra(vm, "change vnc password",
+ vm->def->graphics->data.vnc.passwd,
+ QEMU_PASSWD_PROMPT,
+ &info) < 0) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("resume operation failed"));
+ return -1;
+ }
+ VIR_FREE(info);
+ }
+
+ return 0;
+}
+
+
static int qemudNextFreeVNCPort(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
int i;
@@ -1204,7 +1243,8 @@ static int qemudStartVMDaemon(virConnect
if (ret == 0) {
if ((qemudWaitForMonitor(conn, driver, vm, pos) < 0) ||
(qemudDetectVcpuPIDs(conn, vm) < 0) ||
- (qemudInitCpus(conn, vm, migrateFrom) < 0)) {
+ (qemudInitCpus(conn, vm, migrateFrom) < 0) ||
+ (qemudInitPasswords(conn, vm) < 0)) {
qemudShutdownVMDaemon(conn, driver, vm);
return -1;
}
@@ -1314,12 +1354,15 @@ cleanup:
}
static int
-qemudMonitorCommand (const virDomainObjPtr vm,
- const char *cmd,
- char **reply) {
+qemudMonitorCommandExtra(const virDomainObjPtr vm,
+ const char *cmd,
+ const char *extra,
+ const char *extraPrompt,
+ char **reply) {
int size = 0;
char *buf = NULL;
size_t cmdlen = strlen(cmd);
+ size_t extralen = extra ? strlen(extra) : 0;
if (safewrite(vm->monitor, cmd, cmdlen) != cmdlen)
return -1;
@@ -1355,25 +1398,34 @@ qemudMonitorCommand (const virDomainObjP
}
/* Look for QEMU prompt to indicate completion */
- if (buf && ((tmp = strstr(buf, "\n(qemu) ")) != NULL)) {
- char *commptr = NULL, *nlptr = NULL;
-
- /* Preserve the newline */
- tmp[1] = '\0';
-
- /* The monitor doesn't dump clean output after we have written to
- * it. Every character we write dumps a bunch of useless stuff,
- * so the result looks like "cXcoXcomXcommXcommaXcommanXcommand"
- * Try to throw away everything before the first full command
- * occurence, and inbetween the command and the newline starting
- * the response
- */
- if ((commptr = strstr(buf, cmd)))
- memmove(buf, commptr, strlen(commptr)+1);
- if ((nlptr = strchr(buf, '\n')))
- memmove(buf+strlen(cmd), nlptr, strlen(nlptr)+1);
-
- break;
+ if (buf) {
+ if (extra) {
+ if (strstr(buf, extraPrompt) != NULL) {
+ if (safewrite(vm->monitor, extra, extralen) != extralen)
+ return -1;
+ if (safewrite(vm->monitor, "\r", 1) != 1)
+ return -1;
+ extra = NULL;
+ }
+ } else if ((tmp = strstr(buf, QEMU_CMD_PROMPT)) != NULL) {
+ char *commptr = NULL, *nlptr = NULL;
+ /* Preserve the newline */
+ tmp[1] = '\0';
+
+ /* The monitor doesn't dump clean output after we have written to
+ * it. Every character we write dumps a bunch of useless stuff,
+ * so the result looks like "cXcoXcomXcommXcommaXcommanXcommand"
+ * Try to throw away everything before the first full command
+ * occurence, and inbetween the command and the newline starting
+ * the response
+ */
+ if ((commptr = strstr(buf, cmd)))
+ memmove(buf, commptr, strlen(commptr)+1);
+ if ((nlptr = strchr(buf, '\n')))
+ memmove(buf+strlen(cmd), nlptr, strlen(nlptr)+1);
+
+ break;
+ }
}
pollagain:
/* Need to wait for more data */
@@ -1403,6 +1455,14 @@ qemudMonitorCommand (const virDomainObjP
return -1;
}
+static int
+qemudMonitorCommand(const virDomainObjPtr vm,
+ const char *cmd,
+ char **reply) {
+ return qemudMonitorCommandExtra(vm, cmd, NULL, NULL, reply);
+}
+
+
/**
* qemudProbe:
*
diff --git a/src/virsh.c b/src/virsh.c
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -2079,6 +2079,8 @@ static const vshCmdInfo info_dumpxml[] =
static const vshCmdOptDef opts_dumpxml[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
+ {"inactive", VSH_OT_BOOL, 0, gettext_noop("show inactive defined XML")},
+ {"secure", VSH_OT_BOOL, 0, gettext_noop("include security sensitive data")},
{NULL, 0, 0, NULL}
};
@@ -2088,14 +2090,22 @@ cmdDumpXML(vshControl *ctl, const vshCmd
virDomainPtr dom;
int ret = TRUE;
char *dump;
-
- if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
- return FALSE;
-
- if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- return FALSE;
-
- dump = virDomainGetXMLDesc(dom, 0);
+ int flags = 0;
+ int inactive = vshCommandOptBool(cmd, "inactive");
+ int secure = vshCommandOptBool(cmd, "secure");
+
+ if (inactive)
+ flags |= VIR_DOMAIN_XML_INACTIVE;
+ if(secure)
+ flags |= VIR_DOMAIN_XML_SECURE;
+
+ if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
+ return FALSE;
+
+ if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+ return FALSE;
+
+ dump = virDomainGetXMLDesc(dom, flags);
if (dump != NULL) {
printf("%s", dump);
free(dump);
@@ -5374,7 +5384,7 @@ cmdEdit (vshControl *ctl, const vshCmd *
goto cleanup;
/* Get the XML configuration of the domain. */
- doc = virDomainGetXMLDesc (dom, 0);
+ doc = virDomainGetXMLDesc (dom, VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE);
if (!doc)
goto cleanup;
@@ -5404,7 +5414,7 @@ cmdEdit (vshControl *ctl, const vshCmd *
* it was being edited? This also catches problems such as us
* losing a connection or the domain going away.
*/
- doc_reread = virDomainGetXMLDesc (dom, 0);
+ doc_reread = virDomainGetXMLDesc (dom, VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE);
if (!doc_reread)
goto cleanup;
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 11 months