Meeting the Incas in memory of Jane Morffew
C++ vector iterators, why over-use?
I understand that it can be seen as nice and orthogonal that all kinds of containers have a uniform paradigm to access them sequentially. Or something similarly sublime.
But in the specific case of vectors, in a method of a class that has a vector as a private field (and said method thus knows that it is implemented as a vector), what does one win by accessing the vector through iterators and not indexing?
I mean, using indexing is much safer.
Case in point:
Klass::Method()
{
VectorMemberType::iterator it = vectorMember::begin();
while (it != vectorMember::end()) {
VectorElement el = *it;
if (SomeTest(el))
DoSomethingToTheVectorThatMightPushBack();
++it;
}
}
Now, as it happens increasing a vector size (for instance by push_back()) does not always make iterators open on it de facto invalid with GCC, it seems, the code just silently does something slightly wrong or whatever. Apparently it does make the iterator really invalid much more easily with MSVC, leading to a crash.
Working around that while still using iterators gets pretty ugly, doesn't it? You have to restart the iteration and skip the number of elements already handled. Or change the code structure completely.
Compare to simply using indexing:
Klass::Method()
{
size_t it = 0;
while (it < vectorMember::size()) {
VectorElement el = vectorMember[it];
if (SomeTest(el))
DoSomethingToTheVectorThatMightPushBack();
++it;
}
}
No stateful iterator that might get invalidated when the vector is resized. Just a simple integer index. What is so wrong and ugly with this? That it, shock horror, looks more like C?
Persistent IUCV Network Devices
On mainframes, Inter User Communication Vehicle provides a means to exchange data between two guests in z/VM. Some time ago, this has been one of the preferred networking methods between two Users (virtual machines) on z/VM. From a linux perspective, IUCV is not a supported networking method anymore, although it actually still works quite nicely.
Setup as a pointopoint connection, IUCV needs a special machine that is run as a pointopoint partner and routes to the rest of the network if needed. With linux, it is quite easy to setup IUCV interfaces. The problems arise when you have more than one IUCV interface and must make sure that the IP configuration in /etc/sysconfig/network/ifcfg-iucv* is setup for the correct User.
In SLES11 and later, the hardware configuration of IUCV interfaces is done with udev rules. For each available connection, there is an extra file with a ruleset below /etc/udev/rules.d. By default, such a rules file looks like this:
# cat /etc/udev/rules.d/51-iucv-LINUX001.rules
ACTION=="add", SUBSYSTEM=="subsystem", KERNEL=="iucv", RUN+="/sbin/modprobe netiucv"
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="netiucv", ATTR{connection}="LINUX001"
The issue is, that during network device setup, all of the devices are simply setup as they are found. This is unfortunately not persistent and commonly results in connecting a User (virtual machine) with the IP address of a completely different machine. In the end, networking is simply broken.
For example, if you look at the netiucv0 user, the following is found:
# cat /sys/devices/iucv/netiucv0/user LINUX001
However the actual device is configured in /etc/sysconfig/network/ifcfg-iucv36. To solve this, a special iucv device below the netiucv device must be configured. This is a task for udev. The above udev rule needs an extra line at the end:
ACTION=="add", SUBSYSTEM=="subsystem", KERNEL=="iucv", RUN+="/sbin/modprobe netiucv"
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="netiucv", ATTR{connection}="LINUX001"
ACTION=="add", SUBSYSTEM=="net", KERNEL=="iucv*", SUBSYSTEMS=="iucv", ATTRS{user}=="LINUX001", NAME="iucv36"
After this, the netiucv0/user is still LINUX001. In this case, an extra iucv36 is configured like this:
# cat /sys/devices/iucv/netiucv0/net/iucv36/device/user LINUX001
and now, the iucv36 device, like it is found in /proc/net/dev is the one that is configured with ifcfg-iucv36, really uses LINUX001 as pointopoint partner. For the sake of completeness, here is the configuration as it is found in /etc/sysconfig/network/:
# cat ifcfg-iucv36 BOOTPROTO='static' BROADCAST='' ETHTOOL_OPTIONS='' IPADDR='192.168.0.127/24' MTU='' NAME='' NETWORK='' REMOTE_IPADDR='192.168.0.67' STARTMODE='auto' USERCONTROL='no'
Note, that it is possible to use the same IPADDR for all of the configured IUCV interfaces. Only the pointopoint partners that are configured with REMOTE_IPADDR must have their own unique addresses.
When configuring the partner User, IPADDR and REMOTE_IPADDR are swapped of course.
When a Raspberry has all the flavour a Pi needs
Installing Horde 4 pear packages to a custom pear location (SUSE)
When installing horde to a custom pear location, you need to run the pear of your custom location, not the system pear with the custom location’s config.
So the steps would be:
1 mkdir /srv/horde 2 pear config-create /srv/horde/ /srv/horde/pear.conf 3 pear -c /srv/horde/pear.conf install PEAR
as the install docs say but then:
4 /srv/horde/pear/pear -c /srv/horde/pear.conf channel-discover pear.horde.org 5 /srv/horde/pear/pear -c /srv/horde/pear.conf run-scripts horde/Horde_Role 6 /srv/horde/pear/pear -c /srv/horde/pear.conf install --alldeps horde/groupware
Otherwise running the Horde_Role script will fail saying
config-set (horde_dir, /srv/horde/, user) failed, channel pear.php.net
This was experienced on SLES11SP1, SLES11SP2 and openSUSE Factory.
I did not test this for any debian based products yet.
/dev/sdx is apparently in use by the system.
Greetings programs, in today’s post i will present a little issue i had with
an old box i needed to format and reuse:
root@nibelheim:~# mkfs.ext4 /dev/sdxy
mke2fs 1.41..12 (17-May-2010)
/dev/sdxy is apparently in use by the system; will not make a filesystem here!
this one might get triggered by a number of factors:
1. the drive could be mounted on the current system.
2. there are raid array data left marking the drive or partition as “in use”.
Disk /dev/md127: 10.5 GB, 10536091648 bytes
255 heads, 63 sectors/track, 1280 cylinders, total 20578304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/md127 doesn't contain a valid partition table
and here is our ‘little’ problem.
As you can see my case falls under the second “category”, there are some raid data left on the device,
now that we know what the problem is we can proceed with the solution.
root@nibelheim:~# mdadm --remove /dev/md127
root@nibelheim:~# mdadm --stop /dev/md127
mdadm: stopped /dev/md127
then it was a simple:
root@nibelheim:~# mkfs.ext4 /dev/sdxy
and the driver was ready and formated :)
Announce: Linux Desktop Testing Project (LDTP) 2.3.1 released
When Geekos with ARMs get together
Horde 5 is coming / Horde 3 support ends
The spring 2012 release of the Horde Application Suite and Framework will probably be called Horde 5. In a recent discussion the majority of developers agreed on a new major revision for some changes that some view as minor backward compatibility break. Currently planned features include:
- New standard UI for „traditional view“
- Move of Ajax code from specific apps to a common framework
- Release of a small inventory management app (sesha)
- complete configuration via UI (likely)
- Webmail: Write support for smartphone view
- Calendar: Resource calendar support for ajax view
At the same time, Horde 3 will no longer receive any support. Horde 3 has been around since 2005 and really has reached its end of life.
Since the Horde 4 release, The Horde 3 family of applications has only received critical bugfixes and security updates, the last being released this february. You should really consider updating to Horde 4 – the transition from Horde 3 to Horde 4 has been tested and done by numerous people and the transition from Horde 4 to Horde 5 should run smoothly as both releases are PEAR based.
I have already removed all things horde3 from OpenSUSE-Factory. OpenSUSE 12.2 will not ship Horde 3 any longer. Depending on packaging progress, openSUSE 12.2 will very likely ship Horde 5 or the most recent Horde 4 release. Horde 4 maintainence will continue.
Horde 3 Packages in the server:php:applications repository (see here) will be available at least until openSUSE 12.1 runs out of maintainence. I won’t give these much attention though. Please also note Eleusis Password Manager will be dropped with currently no planned replacement.
Collectd on openSUSE
collectd is a very nice metrics collection daemon for Linux, *BSD and a few other Unix variants. Essentially, what it does is run in the background, record a lot of metrics about the system and store them into RRD, from which you can then visualize time graphs.
There are around 100 plugins, going from low level things such as CPU load, memory usage to application level metrics like MySQL slow queries, Apache access log, memcached, etc..., as well as the ability of writing your own plugins in many languages using a nice, well documented and stable API.
I'm maintaining the latest version of collect for openSUSE in the server:monitoring repository.
Finally finished to upgrade to the latest, 5.0.3 -- please test and report any issues either directly to me by email, or using our bug tracker.