[libvirt] [PATCH] build: submodule machinery now works also when no tag is reachable
Mike Burns wrote: I hit an issue with libvirt autobuild. I am running on an F11 machine and the build stage of libvirt--devel is failing. ... I talked to danpb and he pointed out that there is a difference between .git-module-status and git submodule status: danpb1 $ cat .git-module-status danpb1 -b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib danpb1 git submodule status danpb1 b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib (v0.0-2286-gb653eda) Hi Mike, Thanks for the report, and thanks to Dan for looking into it. Here's a patch: From 3d3f1b105e4808d1c02f2132317bf815cf587604 Mon Sep 17 00:00:00 2001 From: Jim Meyering meyer...@redhat.com Date: Wed, 15 Jul 2009 09:54:26 +0200 Subject: [PATCH] build: submodule machinery now works also when no tag is reachable The code in cfg.mk to detect when the git submodule was out of date worked most of the time, but not when checked out in a certain way. * cfg.mk: Extract submodule hash from command output and file, and compare only that, since the format of the full line may vary. Reported by Mike Burns, with some diagnosis by Daniel P Berrange. --- cfg.mk | 14 +++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cfg.mk b/cfg.mk index 3b3d57f..a5514c4 100644 --- a/cfg.mk +++ b/cfg.mk @@ -233,9 +233,17 @@ prev_version_file = /dev/null ifeq (0,$(MAKELEVEL)) _curr_status = .git-module-status - _update_required := \ -$(shell t=$$(git submodule status); \ - test $$t = $$(cat $(_curr_status) 2/dev/null); echo $$?) + # The sed filter accommodates those who check out on a commit from which + # no tag is reachable. In that case, git submodule status prints a - + # in column 1 and does not print a git describe-style string after the + # submodule name. Contrast these: + # -b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib + # b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib (v0.0-2286-gb653eda) + _submodule_hash = sed 's/.//;s/ .*//' + _update_required := $(shell \ + actual=$$(git submodule status | $(_submodule_hash));\ + stamp=$$($(_submodule_hash) $(_curr_status) 2/dev/null); \ + test $$stamp = $$actual; echo $$?) ifeq (1,$(_update_required)) $(error gnulib update required; run ./autogen.sh first) endif -- 1.6.4.rc0.127.g81400 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Update links to bugzilla
* docs/bugs.html[.in]: Red Hat Enterprise Linux 5 specific tickets are under the 'Red Hat Enterprise Linux 5' product category. --- I forgot to update the RHEL 5 links in my previous patch, so here's another. docs/bugs.html|2 +- docs/bugs.html.in |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/bugs.html b/docs/bugs.html index 55bcc2c..76653bb 100644 --- a/docs/bugs.html +++ b/docs/bugs.html @@ -93,7 +93,7 @@ If you are using official binaries from strongRed Hat Enterprise Linux distribution/strong, tickets against the codeRed Hat Enterprise Linux 5/code product and the codelibvirt/code component. - ullia href=View Red Hat Enterprise Linux libvirt tickets/a/lilia href=http://bugzilla.redhat.com/bugzilla/enter_bug.cgi?product=Red%20Hat%20Enterprise%20Linux%205amp;component=libvirt;New Red Hat Enterprise Linux libvirt ticket/a/li/ul/lili + ullia href=http://bugzilla.redhat.com/buglist.cgi?component=libvirtamp;product=Red%20Hat%20Enterprise%20Linux%205;View Red Hat Enterprise Linux libvirt tickets/a/lilia href=http://bugzilla.redhat.com/bugzilla/enter_bug.cgi?product=Red%20Hat%20Enterprise%20Linux%205amp;component=libvirt;New Red Hat Enterprise Linux libvirt ticket/a/li/ul/lili If you are using official binaries from another Linux distribution first follow their own bug reporting guidelines. /li/ul diff --git a/docs/bugs.html.in b/docs/bugs.html.in index df26c15..62e3864 100644 --- a/docs/bugs.html.in +++ b/docs/bugs.html.in @@ -43,7 +43,7 @@ tickets against the codeRed Hat Enterprise Linux 5/code product and the codelibvirt/code component. ul - lia href=View Red Hat Enterprise Linux libvirt tickets/a/li + lia href=http://bugzilla.redhat.com/buglist.cgi?component=libvirtamp;product=Red%20Hat%20Enterprise%20Linux%205;View Red Hat Enterprise Linux libvirt tickets/a/li lia href=http://bugzilla.redhat.com/bugzilla/enter_bug.cgi?product=Red%20Hat%20Enterprise%20Linux%205amp;component=libvirt;New Red Hat Enterprise Linux libvirt ticket/a/li /ul /li -- 1.6.3.1 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] 1/3 add support for netcf XML import and export
Basically this implement the routines to read an netcf XML definition and build the associated internal data structures. It does the checking of the input XML up to making sure all the needed informations are availble in the right place, but does not check for extra data. It should support the full format as defined by interface.rng as of netcf version 0.1.0, both for input and output. This is rather repetitive and boring code, so I tried to factorize things following patterms similar to the one used in the grammar, the code reflects to a large extent the definition blocks there. The main data structure is virInterfaceDef, it defines the most common and shared attributes of all interfaces, the protocol definition allowed in the schemas is only ipv4 at the moment but with the expected extension to allow ipv6 in parallel I made a separate structure (currently embedded in the main one). There is a enum discriminating the specific structures needed for vlan, bride and bonding, and for the two last ones, a dynamically allocated array of bare interfaces (which can be of vlan or ethernet type, merged into a single structure). This passes valgrind, but since I'm not testing agaisnt misformed XML input I afraid of potential leaks on exit paths, otherwise this should be fine. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ diff --git a/src/interface_conf.h b/src/interface_conf.h new file mode 100644 index 000..abd139f --- /dev/null +++ b/src/interface_conf.h @@ -0,0 +1,204 @@ +/* + * interface_conf.h: interface XML handling entry points + * + * Copyright (C) 2006-2009 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Daniel Veillard veill...@redhat.com + * Laine Stump la...@redhat.com + */ + +#ifndef __INTERFACE_CONF_H__ +#define __INTERFACE_CONF_H__ + +#include libxml/parser.h +#include libxml/tree.h +#include libxml/xpath.h + +#include internal.h +#include util.h +#include threads.h + +/* There is currently 3 types of interfaces */ + +enum virInterfaceType { +VIR_INTERFACE_TYPE_ETHERNET, /* simple ethernet */ +VIR_INTERFACE_TYPE_BRIDGE,/* bridge interface */ +VIR_INTERFACE_TYPE_BOND, /* bonding interface */ +VIR_INTERFACE_TYPE_VLAN, /* vlan description */ + +VIR_INTERFACE_TYPE_LAST, +}; + +VIR_ENUM_DECL(virInterface) + +/* types of start mode */ + +enum virInterfaceStartMode { +VIR_INTERFACE_START_NONE = 0, /* not defined */ +VIR_INTERFACE_START_ONBOOT, /* startup at boot */ +VIR_INTERFACE_START_HOTPLUG, /* on hotplug */ +}; + +enum virInterfaceBondMode { +VIR_INTERFACE_BOND_NONE = 0, +VIR_INTERFACE_BOND_BALRR, /* balance-rr */ +VIR_INTERFACE_BOND_ABACKUP, /* active backup */ +VIR_INTERFACE_BOND_BALXOR,/* balance-xor */ +VIR_INTERFACE_BOND_BCAST, /* broadcast */ +VIR_INTERFACE_BOND_8023AD,/* 802.3ad */ +VIR_INTERFACE_BOND_BALTLB,/* balance-tlb */ +VIR_INTERFACE_BOND_BALALB,/* balance-alb */ +}; + +enum virInterfaceBondMonit { +VIR_INTERFACE_BOND_MONIT_NONE = 0, +VIR_INTERFACE_BOND_MONIT_MII, /* mii based monitoring */ +VIR_INTERFACE_BOND_MONIT_ARP, /* arp based monitoring */ +}; + +enum virInterfaceBondMiiCarrier { +VIR_INTERFACE_BOND_MII_NONE = 0, +VIR_INTERFACE_BOND_MII_IOCTL, /* mii/ethtool ioctl */ +VIR_INTERFACE_BOND_MII_NETIF, /* netif_carrier_ok */ +}; + +enum virInterfaceBondArpValid { +VIR_INTERFACE_BOND_ARP_NONE = 0, +VIR_INTERFACE_BOND_ARP_ACTIVE, /* validate active */ +VIR_INTERFACE_BOND_ARP_BACKUP, /* validate backup */ +VIR_INTERFACE_BOND_ARP_ALL,/* validate all */ +}; + +typedef struct _virInterfaceBareDef virInterfaceBareDef; +typedef virInterfaceBareDef *virInterfaceBareDefPtr; +struct _virInterfaceBareDef { +int type;/* should be only ethernet or vlan */ +char *name; /* the interface name */ +char *mac_or_tag;/* MAC address for ethernet, TAG for vlan */ +char *devname; /* device name for vlan */ +}; + +typedef struct _virInterfaceBridgeDef virInterfaceBridgeDef; +typedef
[libvirt] [PATCH] 2/3 Add netcf XML schemas and test data
Directly imported from netcf-0.1.0 git with the exception that example have been changed to use single quote instead of double quote, otherwise unchanged. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ diff --git a/docs/schemas/interface.rng b/docs/schemas/interface.rng new file mode 100644 index 000..bed2f0a --- /dev/null +++ b/docs/schemas/interface.rng @@ -0,0 +1,385 @@ +!-- A Relax NG schema for network interfaces -- +grammar xmlns=http://relaxng.org/ns/structure/1.0; + datatypeLibrary=http://www.w3.org/2001/XMLSchema-datatypes; + start +choice + ref name=ethernet-interface/ + ref name=bridge-interface/ + ref name=bond-interface/ + ref name=vlan-interface/ +/choice + /start + + !-- + FIXME: How do we handle VLAN's ? Should they be their own interface + or should we treat them as an option on the base interface ? For + example, for vlan eth0.42, it would make sense to make that part of + the definition of the eth0 interface. + -- + + !-- + Ethernet adapter + -- + define name=basic-ethernet-content +attribute name=type + valueethernet/value +/attribute +ref name=name-attr/ +!-- If no MAC is given when the interface is defined, it is determined + by using the device name. + FIXME: What if device name and MAC don't specify the same NIC ? -- +optional + element name=mac +attribute name=addressref name=mac-addr//attribute + /element +/optional +!-- FIXME: Allow (some) ethtool options -- + /define + + !-- Ethernet adapter without IP addressing, e.g. for a bridge -- + define name=bare-ethernet-interface +element name=interface + ref name=basic-ethernet-content/ +/element + /define + + define name=ethernet-interface +element name=interface + ref name=startmode/ + ref name=basic-ethernet-content/ + ref name=mtu/ + ref name=interface-addressing/ +/element + /define + + !-- + VLAN's + -- + define name=vlan-interface-common +attribute name=type + valuevlan/value +/attribute +!-- The name attribute is only useful for reporting back and is always + of the form DEVICE.VLAN +-- +optionalref name=name-attr//optional + /define + + define name=vlan-device +element name=vlan + attribute name=tagref name=vlan-id//attribute + element name=interface +attribute name=nameref name=device-name//attribute + /element +/element + /define + + define name=bare-vlan-interface +element name=interface + ref name=vlan-interface-common/ + ref name=vlan-device/ +/element + /define + + define name=vlan-interface +element name=interface + ref name=vlan-interface-common/ + ref name=startmode/ + ref name=mtu/ + ref name=interface-addressing/ + ref name=vlan-device/ +/element + /define + + !-- + Bridges + -- + define name=bridge-interface +element name=interface + attribute name=type +valuebridge/value + /attribute + ref name=name-attr/ + ref name=startmode/ + ref name=mtu/ + ref name=interface-addressing/ + element name=bridge +optional + attribute name=stp +ref name=on-or-off/ + /attribute +/optional +oneOrMore + choice +ref name=bare-ethernet-interface/ +ref name=bare-vlan-interface/ + /choice +/oneOrMore + /element +/element + /define + !-- Jim Fehlig would like support for other bridge attributes, in + particular hellotime, forwarddelay, and maxage + -- + + !-- + Bonds + -- + define name=bond-interface +element name=interface + attribute name=type +valuebond/value + /attribute + ref name=name-attr/ + ref name=startmode/ + ref name=mtu/ + ref name=interface-addressing/ + element name=bond +optional + attribute name=mode +choice + valuebalance-rr/value + !-- The primary interface is the first interface child + of the bond element -- + valueactive-backup/value + valuebalance-xor/value + valuebroadcast/value + value802.3ad/value + valuebalance-tlb/value + valuebalance-alb/value +/choice + /attribute +/optional + +!-- FIXME: add more attributes + + mode == 802.3ad + ad_select + lacp_rate + xmit_hash_policy + + mode == active-backup + fail_over_mac + num_grat_arp when mode == active-backup (since 3.3.0) + num_unsol_na when mode ==
[libvirt] [PATCH] 3/3 Add netcf XML validation and input and output tests
Basic stuff similar to other tests, first we verify the input tests all conform to the provided schemas, then for each test we parse and reserialize verifying the output is identical. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ diff --git a/tests/.gitignore b/tests/.gitignore index 7a4d44f..466ec13 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -14,6 +14,7 @@ qemuxml2argvtest qemuargv2xmltest qemuhelptest nodedevxml2xmltest +interfacexml2xmltest nodeinfotest statstest qparamtest diff --git a/tests/Makefile.am b/tests/Makefile.am index f8bde34..efd7c6e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -82,8 +82,11 @@ endif noinst_PROGRAMS += nodedevxml2xmltest +noinst_PROGRAMS += interfacexml2xmltest + test_scripts = \ capabilityschematest \ + interfaceschematest \ networkschematest \ storagepoolschematest \ storagevolschematest \ @@ -141,6 +144,8 @@ endif TESTS += nodedevxml2xmltest +TESTS += interfacexml2xmltest + path_add = $$abs_top_builddir/src$(PATH_SEPARATOR)$$abs_top_builddir/qemud # NB, automake 1.10 does not provide the real @@ -219,6 +224,11 @@ nodedevxml2xmltest_SOURCES = \ testutils.c testutils.h nodedevxml2xmltest_LDADD = $(LDADDS) +interfacexml2xmltest_SOURCES = \ + interfacexml2xmltest.c \ + testutils.c testutils.h +interfacexml2xmltest_LDADD = $(LDADDS) + virshtest_SOURCES = \ virshtest.c \ testutils.c testutils.h diff --git a/tests/interfaceschematest b/tests/interfaceschematest new file mode 100755 index 000..3e4105c --- /dev/null +++ b/tests/interfaceschematest @@ -0,0 +1,33 @@ +#!/bin/sh + +test -z $srcdir srcdir=`pwd` +test -z $abs_srcdir abs_srcdir=`pwd` + +DIRS=interfaceschemadata + +n=0 +f=0 +for dir in $DIRS +do + XML=`find $abs_srcdir/$dir -name '*.xml'` || exit 1 + + for xml in $XML + do +n=`expr $n + 1` +printf %4d) %.60s $n $(basename $(dirname $xml))/$(basename $xml) +result=`xmllint --relaxng $srcdir/../docs/schemas/interface.rng --noout $xml 21` +ret=$? +if test $ret = 0; then +echo OK +else +echo FAILED +echo $result +f=`expr $f + 1` +fi + done +done +echo Validated $n files, $f failed + +ret=0 +test $f != 0 ret=255 +exit $ret diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c new file mode 100644 index 000..6e6c5e8 --- /dev/null +++ b/tests/interfacexml2xmltest.c @@ -0,0 +1,97 @@ +#include config.h + +#include stdio.h +#include stdlib.h +#include unistd.h +#include string.h + +#include sys/types.h +#include fcntl.h + +#include internal.h +#include testutils.h +#include interface_conf.h +#include testutilsqemu.h + +static char *progname; +static char *abs_srcdir; + +#define MAX_FILE 4096 + + +static int testCompareXMLToXMLFiles(const char *xml) { +char xmlData[MAX_FILE]; +char *xmlPtr = (xmlData[0]); +char *actual = NULL; +int ret = -1; +virInterfaceDefPtr dev = NULL; + +if (virtTestLoadFile(xml, xmlPtr, MAX_FILE) 0) +goto fail; + +if (!(dev = virInterfaceDefParseString(NULL, xmlData))) +goto fail; + +if (!(actual = virInterfaceDefFormat(NULL, dev))) +goto fail; + +if (STRNEQ(xmlData, actual)) { +virtTestDifference(stderr, xmlData, actual); +goto fail; +} + +ret = 0; + + fail: +if (ret != 0) +fprintf(stderr, expected: ---\n%s, actual); +free(actual); +virInterfaceDefFree(dev); +return ret; +} + +static int testCompareXMLToXMLHelper(const void *data) { +char xml[PATH_MAX]; +snprintf(xml, PATH_MAX, %s/interfaceschemadata/%s.xml, + abs_srcdir, (const char*)data); +return testCompareXMLToXMLFiles(xml); +} + + +static int +mymain(int argc, char **argv) +{ +int ret = 0; +char cwd[PATH_MAX]; + +progname = argv[0]; + +if (argc 1) { +fprintf(stderr, Usage: %s\n, progname); +return (EXIT_FAILURE); +} + +abs_srcdir = getenv(abs_srcdir); +if (!abs_srcdir) +abs_srcdir = getcwd(cwd, sizeof(cwd)); + +#define DO_TEST(name) \ +if (virtTestRun(Node device XML-2-XML name, \ +1, testCompareXMLToXMLHelper, (name)) 0) \ +ret = -1 + +DO_TEST(ethernet-dhcp); +DO_TEST(ethernet-static); +DO_TEST(ethernet-static-no-prefix); +DO_TEST(bridge); +DO_TEST(bridge42); +DO_TEST(bridge-vlan); +DO_TEST(bridge-no-address); +DO_TEST(vlan); +DO_TEST(bond); +DO_TEST(bond-arp); + +return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); +} + +VIRT_TEST_MAIN(mymain) -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] storage: disk: Fix parthelper '-g' option handling.
On Fri, Jul 10, 2009 at 03:32:20PM -0400, Cole Robinson wrote: Typo was breaking 'parthelper -g', preventing disk pool definition. --- src/parthelper.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parthelper.c b/src/parthelper.c index f456ccc..5df46e8 100644 --- a/src/parthelper.c +++ b/src/parthelper.c @@ -36,7 +36,7 @@ #include stdio.h /* we don't need to include the full internal.h just for this */ -#define STRNEQ(a,b) (strcmp((a),(b)) != 0) +#define STREQ(a,b) (strcmp((a),(b)) == 0) /* Make the comparisons below fail if your parted headers are so old that they lack the definition. */ @@ -56,7 +56,7 @@ int main(int argc, char **argv) PedPartition *part; int cmd = DISK_LAYOUT; -if (argc == 3 STRNEQ(argv[2], -g)) { +if (argc == 3 STREQ(argv[2], -g)) { cmd = DISK_GEOMETRY; } else if (argc != 2) { fprintf(stderr, syntax: %s DEVICE [-g]\n, argv[0]); Oops, that's me :-\ ACK W.r.t. redefinition, well it was looking like including the full internal.h was way beyond the scope of that small check. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/4] storage: disk: Fix segfault creating volume without target path
On Fri, Jul 10, 2009 at 03:32:21PM -0400, Cole Robinson wrote: Remove unneeded target path duplication, which could carelessly dereference NULL. Make it clear where 'key' is actually filled in. Looks fine, ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/4] storage: disk: Default to 'ext2' for new volumes.
On Fri, Jul 10, 2009 at 03:32:22PM -0400, Cole Robinson wrote: Currently, if no format is specified for a new disk volume, we pass the invalid value none as the FS type to 'parted mkpart'. There doesn't seem to be a way to have parted not format the drive, so just default to using 'ext2' in this case: this shouldn't cause any harm, since we are creating a new partition in the first place. Sounds fine, ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/4] storage: disk: Use capacity, not allocation, when creating volume.
On Fri, Jul 10, 2009 at 03:32:23PM -0400, Cole Robinson wrote: There isn't any way to dictate allocation when creating disk volumes, so capacity is the only relevant value. Sounds right, ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] PATCH: Fix libvirtd autostart for test driver
On Tue, Jul 14, 2009 at 11:36:17AM +0100, Daniel P. Berrange wrote: Ensure test:/// URIs get routed to the non-privileged libvirtd * src/remote_internal.c: Ensure that all test:/// URIs are dealt with by the auto-started, per-user unprivileged libvirtd instances Makes sense, ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Try multiple times to open unix monitor socket
On Tue, Jul 14, 2009 at 06:22:42PM -0400, Cole Robinson wrote: Unlike the pty monitor (which we know exists since we scrape its path from stdout), we have no way of knowing that the unix monitor socket should exist/ be initialized. As a result, some of my KVM guests randomly fail to start on F10 host. Try to open the unix socket in a 3 second timeout loop. Ignore EACCES (path does not exist if a first time run) and ECONNREFUSED (leftover socket from a previous run hasn't been removed yet). Fixes things for me. It's always a bit annoying to end up with heuristics like this but if we don't have any other way, okay, ACK thanks, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] build: submodule machinery now works also when no tag is reachable
On Wed, Jul 15, 2009 at 09:59:33AM +0200, Jim Meyering wrote: Mike Burns wrote: I hit an issue with libvirt autobuild. I am running on an F11 machine and the build stage of libvirt--devel is failing. ... I talked to danpb and he pointed out that there is a difference between .git-module-status and git submodule status: danpb1 $ cat .git-module-status danpb1 -b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib danpb1 git submodule status danpb1 b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib (v0.0-2286-gb653eda) Hi Mike, Thanks for the report, and thanks to Dan for looking into it. Here's a patch: Hum, isn't the patch from Paolo Bonzini earlier a cleaner way to avoid the - being inserted in the first place ? Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Update links to bugzilla
On Wed, Jul 15, 2009 at 01:16:30AM -0700, Garry Dolley wrote: * docs/bugs.html[.in]: Red Hat Enterprise Linux 5 specific tickets are under the 'Red Hat Enterprise Linux 5' product category. --- I forgot to update the RHEL 5 links in my previous patch, so here's another. Okidoc, applied and commited :-) thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] build: submodule machinery now works also when no tag is reachable
Daniel Veillard wrote: On Wed, Jul 15, 2009 at 09:59:33AM +0200, Jim Meyering wrote: Mike Burns wrote: I hit an issue with libvirt autobuild. I am running on an F11 machine and the build stage of libvirt--devel is failing. ... I talked to danpb and he pointed out that there is a difference between .git-module-status and git submodule status: danpb1 $ cat .git-module-status danpb1 -b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib danpb1 git submodule status danpb1 b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib (v0.0-2286-gb653eda) Hi Mike, Thanks for the report, and thanks to Dan for looking into it. Here's a patch: Hum, isn't the patch from Paolo Bonzini earlier a cleaner way to avoid the - being inserted in the first place ? Both patches work for gnulib. Mine is slightly more general in that it would work also for a submodule with no signed tag, and with an SHA1 for which no tag is an ancestor. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Try multiple times to open unix monitor socket
On Wed, Jul 15, 2009 at 11:40:42AM +0200, Daniel Veillard wrote: On Tue, Jul 14, 2009 at 06:22:42PM -0400, Cole Robinson wrote: Unlike the pty monitor (which we know exists since we scrape its path from stdout), we have no way of knowing that the unix monitor socket should exist/ be initialized. As a result, some of my KVM guests randomly fail to start on F10 host. Try to open the unix socket in a 3 second timeout loop. Ignore EACCES (path does not exist if a first time run) and ECONNREFUSED (leftover socket from a previous run hasn't been removed yet). Fixes things for me. It's always a bit annoying to end up with heuristics like this but if we don't have any other way, okay, ACK I don't like it much either, but this is no worse than what we had todo to find the /dev/pts/XXX path where we waited ina loop for 3 seconds. ACK to this patch Long term we'll need to discuss with QEMU developers to find a better way todo this without needing a timeout. One idea is actually instead of passing a UNIX domain socket path to QEMU, actually create bind the socket in libvirt and then pass the pre-opened FD to QEMU. This would guarentee that we can instantly connect to the monitor. Of course then the job of waiting passes to the code that sends monitor commands. Daniel -- |: 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 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] 1/3 add support for netcf XML import and export
On Wed, Jul 15, 2009 at 11:15:25AM +0200, Daniel Veillard wrote: +static int +virInterfaceDefParseBasicAttrs(virConnectPtr conn, virInterfaceDefPtr def, + xmlXPathContextPtr ctxt) { +char *tmp; +unsigned long mtu; +int ret; + +tmp = virXPathString(conn, string(./@name), ctxt); +if (tmp == NULL) { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, + %s, _(interface has no name)); +return(-1); +} +def-name = tmp; + +ret = virXPathULong(conn, string(./mtu/@size), ctxt, mtu); +if ((ret == -2) || ((ret == 0) (mtu 10))) { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, + %s, _(interface mtu value is improper)); +} else if (ret == 0) { +def-mtu = (unsigned int) mtu; +} +return(0); +} I think you need to return '-1' in that second error case. +static int +virInterfaceDefParseStartMode(virConnectPtr conn, virInterfaceDefPtr def, + xmlXPathContextPtr ctxt) { +char *tmp; + +tmp = virXPathString(conn, string(./start/@mode), ctxt); +if (tmp == NULL) { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, +%s, _(interface misses the start mode attribute)); +return(-1); +} +if (STREQ(tmp, onboot)) +def-startmode = VIR_INTERFACE_START_ONBOOT; +else if (STREQ(tmp, hotplug)) +def-startmode = VIR_INTERFACE_START_HOTPLUG; +else if (STREQ(tmp, none)) +def-startmode = VIR_INTERFACE_START_NONE; It'd be nice to use VIR_ENUM_DECL/IMPL for these strings-enum conversions +else { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, +_(unknown interface startmode %s), tmp); +VIR_FREE(tmp); +return(-1); +} +VIR_FREE(tmp); +return(0); +} + +static int +virInterfaceDefParseBondMode(virConnectPtr conn, xmlXPathContextPtr ctxt) { +char *tmp; +int ret = 0; + +tmp = virXPathString(conn, string(./@mode), ctxt); +if (tmp == NULL) +return(VIR_INTERFACE_BOND_NONE); +if (STREQ(tmp, balance-rr)) +ret = VIR_INTERFACE_BOND_BALRR; +else if (STREQ(tmp, active-backup)) +ret = VIR_INTERFACE_BOND_ABACKUP; +else if (STREQ(tmp, balance-xor)) +ret = VIR_INTERFACE_BOND_BALXOR; +else if (STREQ(tmp, broadcast)) +ret = VIR_INTERFACE_BOND_BCAST; +else if (STREQ(tmp, 802.3ad)) +ret = VIR_INTERFACE_BOND_8023AD; +else if (STREQ(tmp, balance-tlb)) +ret = VIR_INTERFACE_BOND_BALTLB; +else if (STREQ(tmp, balance-alb)) +ret = VIR_INTERFACE_BOND_BALALB; Likewise this could be done with a VIR_ENUM +else { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, +_(unknown bonding mode %s), tmp); +ret = -1; +} +VIR_FREE(tmp); +return(ret); +} + +static int +virInterfaceDefParseBondMiiCarrier(virConnectPtr conn, xmlXPathContextPtr ctxt) { +char *tmp; +int ret = 0; + +tmp = virXPathString(conn, string(./miimon/@carrier), ctxt); +if (tmp == NULL) +return(VIR_INTERFACE_BOND_MII_NONE); +if (STREQ(tmp, ioctl)) +ret = VIR_INTERFACE_BOND_MII_IOCTL; +else if (STREQ(tmp, netif)) +ret = VIR_INTERFACE_BOND_MII_NETIF; +else { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, +_(unknown mii bonding carrier %s), tmp); +ret = -1; +} +VIR_FREE(tmp); +return(ret); +} + +static int +virInterfaceDefParseBondArpValid(virConnectPtr conn, xmlXPathContextPtr ctxt) { +char *tmp; +int ret = 0; + +tmp = virXPathString(conn, string(./arpmon/@validate), ctxt); +if (tmp == NULL) +return(VIR_INTERFACE_BOND_ARP_NONE); +if (STREQ(tmp, active)) +ret = VIR_INTERFACE_BOND_ARP_ACTIVE; +else if (STREQ(tmp, backup)) +ret = VIR_INTERFACE_BOND_ARP_BACKUP; +else if (STREQ(tmp, all)) +ret = VIR_INTERFACE_BOND_ARP_ALL; +else { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, +_(unknown arp bonding validate %s), tmp); +ret = -1; +} +VIR_FREE(tmp); +return(ret); +} And these two Aside from optimizing to use more VIR_ENUMs the code all looks good to me, and i didnt' spot any obvious leaks/errors. Daniel -- |: 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 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] 2/3 Add netcf XML schemas and test data
On Wed, Jul 15, 2009 at 11:17:54AM +0200, Daniel Veillard wrote: Directly imported from netcf-0.1.0 git with the exception that example have been changed to use single quote instead of double quote, otherwise unchanged. Trivial ACK then Daniel -- |: 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 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] 3/3 Add netcf XML validation and input and output tests
On Wed, Jul 15, 2009 at 11:20:00AM +0200, Daniel Veillard wrote: Basic stuff similar to other tests, first we verify the input tests all conform to the provided schemas, then for each test we parse and reserialize verifying the output is identical. ACK, good stuff. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ diff --git a/tests/.gitignore b/tests/.gitignore index 7a4d44f..466ec13 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -14,6 +14,7 @@ qemuxml2argvtest qemuargv2xmltest qemuhelptest nodedevxml2xmltest +interfacexml2xmltest nodeinfotest statstest qparamtest diff --git a/tests/Makefile.am b/tests/Makefile.am index f8bde34..efd7c6e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -82,8 +82,11 @@ endif noinst_PROGRAMS += nodedevxml2xmltest +noinst_PROGRAMS += interfacexml2xmltest + test_scripts = \ capabilityschematest \ + interfaceschematest \ networkschematest \ storagepoolschematest \ storagevolschematest \ @@ -141,6 +144,8 @@ endif TESTS += nodedevxml2xmltest +TESTS += interfacexml2xmltest + path_add = $$abs_top_builddir/src$(PATH_SEPARATOR)$$abs_top_builddir/qemud # NB, automake 1.10 does not provide the real @@ -219,6 +224,11 @@ nodedevxml2xmltest_SOURCES = \ testutils.c testutils.h nodedevxml2xmltest_LDADD = $(LDADDS) +interfacexml2xmltest_SOURCES = \ + interfacexml2xmltest.c \ + testutils.c testutils.h +interfacexml2xmltest_LDADD = $(LDADDS) + virshtest_SOURCES = \ virshtest.c \ testutils.c testutils.h diff --git a/tests/interfaceschematest b/tests/interfaceschematest new file mode 100755 index 000..3e4105c --- /dev/null +++ b/tests/interfaceschematest @@ -0,0 +1,33 @@ +#!/bin/sh + +test -z $srcdir srcdir=`pwd` +test -z $abs_srcdir abs_srcdir=`pwd` + +DIRS=interfaceschemadata + +n=0 +f=0 +for dir in $DIRS +do + XML=`find $abs_srcdir/$dir -name '*.xml'` || exit 1 + + for xml in $XML + do +n=`expr $n + 1` +printf %4d) %.60s $n $(basename $(dirname $xml))/$(basename $xml) +result=`xmllint --relaxng $srcdir/../docs/schemas/interface.rng --noout $xml 21` +ret=$? +if test $ret = 0; then +echo OK +else +echo FAILED +echo $result +f=`expr $f + 1` +fi + done +done +echo Validated $n files, $f failed + +ret=0 +test $f != 0 ret=255 +exit $ret diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c new file mode 100644 index 000..6e6c5e8 --- /dev/null +++ b/tests/interfacexml2xmltest.c @@ -0,0 +1,97 @@ +#include config.h + +#include stdio.h +#include stdlib.h +#include unistd.h +#include string.h + +#include sys/types.h +#include fcntl.h + +#include internal.h +#include testutils.h +#include interface_conf.h +#include testutilsqemu.h + +static char *progname; +static char *abs_srcdir; + +#define MAX_FILE 4096 + + +static int testCompareXMLToXMLFiles(const char *xml) { +char xmlData[MAX_FILE]; +char *xmlPtr = (xmlData[0]); +char *actual = NULL; +int ret = -1; +virInterfaceDefPtr dev = NULL; + +if (virtTestLoadFile(xml, xmlPtr, MAX_FILE) 0) +goto fail; + +if (!(dev = virInterfaceDefParseString(NULL, xmlData))) +goto fail; + +if (!(actual = virInterfaceDefFormat(NULL, dev))) +goto fail; + +if (STRNEQ(xmlData, actual)) { +virtTestDifference(stderr, xmlData, actual); +goto fail; +} + +ret = 0; + + fail: +if (ret != 0) +fprintf(stderr, expected: ---\n%s, actual); BTW, you don't need this fprintf when using virtTestDifference. If you set VIR_TEST_DEBUG=2 then it will print out the full XML being compared automatically :-) Daniel -- |: 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 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Fix svirt handling of shared/readonly disks
The patch committed here commit 547147084d03ebf30d09d242a5a721a4df664ffe Author: Mark McLoughlin mar...@redhat.com Date: Fri Jul 3 10:26:37 2009 + was not actually the latest version currently used in Fedora. It causes shared disks to be re-labelled upon VM shutdown, breaking any other guests still runing with this disk. The only safe option is to skip relabel for all readonly shared disks Daniel diff --git a/src/security_selinux.c b/src/security_selinux.c index 80c1c85..0db9f49 100644 --- a/src/security_selinux.c +++ b/src/security_selinux.c @@ -354,6 +354,17 @@ SELinuxRestoreSecurityImageLabel(virConnectPtr conn, char *newpath = NULL; const char *path = disk-src; +/* Don't restore labels on readoly/shared disks, because + * other VMs may still be accessing these + * Alternatively we could iterate over all running + * domains and try to figure out if it is in use, but + * this would not work for clustered filesystems, since + * we can't see running VMs using the file on other nodes + * Safest bet is thus to skip the restore step. + */ +if (disk-readonly || disk-shared) +return 0; + if ((err = virFileResolveLink(path, newpath)) 0) { virReportSystemError(conn, err, _(cannot resolve symlink %s), path); -- |: 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 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Try multiple times to open unix monitor socket
Daniel P. Berrange wrote: On Wed, Jul 15, 2009 at 11:40:42AM +0200, Daniel Veillard wrote: On Tue, Jul 14, 2009 at 06:22:42PM -0400, Cole Robinson wrote: Unlike the pty monitor (which we know exists since we scrape its path from stdout), we have no way of knowing that the unix monitor socket should exist/ be initialized. As a result, some of my KVM guests randomly fail to start on F10 host. Try to open the unix socket in a 3 second timeout loop. Ignore EACCES (path does not exist if a first time run) and ECONNREFUSED (leftover socket from a previous run hasn't been removed yet). Fixes things for me. It's always a bit annoying to end up with heuristics like this but if we don't have any other way, okay, ACK I don't like it much either, but this is no worse than what we had todo to find the /dev/pts/XXX path where we waited ina loop for 3 seconds. ACK to this patch Long term we'll need to discuss with QEMU developers to find a better way todo this without needing a timeout. One idea is actually instead of passing a UNIX domain socket path to QEMU, actually create bind the socket in libvirt and then pass the pre-opened FD to QEMU. This would guarentee that we can instantly connect to the monitor. Of course then the job of waiting passes to the code that sends monitor commands. What about qemu's -daemonize option: -daemonize Daemonize the QEMU process after initialization. QEMU will not detach from standard IO until it is ready to receive connections on any of its devices. This option is a useful way for external programs to launch QEMU without having to cope with initialization race conditions. It looks like it was introduced in 0.9.0. -jim -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] 1/3 add support for netcf XML import and export
On Wed, Jul 15, 2009 at 11:22:43AM +0100, Daniel P. Berrange wrote: On Wed, Jul 15, 2009 at 11:15:25AM +0200, Daniel Veillard wrote: +static int +virInterfaceDefParseBasicAttrs(virConnectPtr conn, virInterfaceDefPtr def, + xmlXPathContextPtr ctxt) { +char *tmp; +unsigned long mtu; +int ret; + +tmp = virXPathString(conn, string(./@name), ctxt); +if (tmp == NULL) { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, + %s, _(interface has no name)); +return(-1); +} +def-name = tmp; + +ret = virXPathULong(conn, string(./mtu/@size), ctxt, mtu); +if ((ret == -2) || ((ret == 0) (mtu 10))) { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, + %s, _(interface mtu value is improper)); +} else if (ret == 0) { +def-mtu = (unsigned int) mtu; +} +return(0); +} I think you need to return '-1' in that second error case. Ah, right ! Fixed. +if (STREQ(tmp, onboot)) +def-startmode = VIR_INTERFACE_START_ONBOOT; +else if (STREQ(tmp, hotplug)) +def-startmode = VIR_INTERFACE_START_HOTPLUG; +else if (STREQ(tmp, none)) +def-startmode = VIR_INTERFACE_START_NONE; It'd be nice to use VIR_ENUM_DECL/IMPL for these strings-enum conversions +return(VIR_INTERFACE_BOND_NONE); +if (STREQ(tmp, balance-rr)) +ret = VIR_INTERFACE_BOND_BALRR; +else if (STREQ(tmp, active-backup)) +ret = VIR_INTERFACE_BOND_ABACKUP; +else if (STREQ(tmp, balance-xor)) +ret = VIR_INTERFACE_BOND_BALXOR; +else if (STREQ(tmp, broadcast)) +ret = VIR_INTERFACE_BOND_BCAST; +else if (STREQ(tmp, 802.3ad)) +ret = VIR_INTERFACE_BOND_8023AD; +else if (STREQ(tmp, balance-tlb)) +ret = VIR_INTERFACE_BOND_BALTLB; +else if (STREQ(tmp, balance-alb)) +ret = VIR_INTERFACE_BOND_BALALB; Likewise this could be done with a VIR_ENUM [...] And these two Aside from optimizing to use more VIR_ENUMs the code all looks good to me, and i didnt' spot any obvious leaks/errors. Well the current macros makes it impossible unless the enum names are all suffixed by 'Type' which IMHO constraints it a bit more than it should, that's my main beef against using it more widely, I'm using it for virInterfaceType. Another problem I have with the macros is that I used the enum value _NONE mapped to 0 to express that the value wasn't defined by the user and I don't see a good way to map that to VIR_ENUM_IMPL , NULL might work but you end up doing STREQ(NULL, something) and I'm not sure strcmp(NULL, NULL) will work correctly ... well the man page doesn't say anything about NULL parameter(s) , I guess virEnumFromString() and virEnumToString() would have to be modified to handle my case. So right now VIR_ENUM doesn't really match what I'm doing, though agreed it end up with slightly longuer code. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] 3/3 Add netcf XML validation and input and output tests
On Wed, Jul 15, 2009 at 11:24:59AM +0100, Daniel P. Berrange wrote: On Wed, Jul 15, 2009 at 11:20:00AM +0200, Daniel Veillard wrote: Basic stuff similar to other tests, first we verify the input tests all conform to the provided schemas, then for each test we parse and reserialize verifying the output is identical. ACK, good stuff. + fail: +if (ret != 0) +fprintf(stderr, expected: ---\n%s, actual); BTW, you don't need this fprintf when using virtTestDifference. If you set VIR_TEST_DEBUG=2 then it will print out the full XML being compared automatically :-) Oops I knew I had forgotten a debugging output it escaped, good catch ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] 1/3 add support for netcf XML import and export
On Wed, Jul 15, 2009 at 05:40:30PM +0200, Daniel Veillard wrote: On Wed, Jul 15, 2009 at 11:22:43AM +0100, Daniel P. Berrange wrote: On Wed, Jul 15, 2009 at 11:15:25AM +0200, Daniel Veillard wrote: +static int +virInterfaceDefParseBasicAttrs(virConnectPtr conn, virInterfaceDefPtr def, + xmlXPathContextPtr ctxt) { +char *tmp; +unsigned long mtu; +int ret; + +tmp = virXPathString(conn, string(./@name), ctxt); +if (tmp == NULL) { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, + %s, _(interface has no name)); +return(-1); +} +def-name = tmp; + +ret = virXPathULong(conn, string(./mtu/@size), ctxt, mtu); +if ((ret == -2) || ((ret == 0) (mtu 10))) { +virInterfaceReportError(conn, VIR_ERR_XML_ERROR, + %s, _(interface mtu value is improper)); +} else if (ret == 0) { +def-mtu = (unsigned int) mtu; +} +return(0); +} I think you need to return '-1' in that second error case. Ah, right ! Fixed. Okay I commited the 3 patches (with some help from Jim, git can be surprizing for newbies !) , we can still change the enum handling, at least it's there to test, thanks, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] consistency: push update hook vs. make syntax-check
Currently the server side hook that runs git diff --check to prevent pushing a change that adds trailing blanks is more strict than our make syntax-check hook, since the former rejects any change that adds blank lines at the end of a file, while make syntax-check doesn't complain about that. The two should be consistent. One way is to make make syntax-check more strict. If we were to do that, we'd have to choose between cleaning existing files and exempting them from the new test. Cleaning is easy and doesn't impact tests at all, so I prefer it. Here's what would be involved: - remove 121 trailing newlines from 109 files by running this command: git ls-files -z | xargs -0 perl -pi -0777 -e 's/\n\n+$/\n/' Add a rule to cfg.mk so that make syntax-check warns about any new violations. It might run something like this: git ls-files -z \ | xargs -0 perl -ln -0777 -e '/\n(\n+)$/ and print $ARGV: .length $1' That command prints the name of each offending file with its trailing blank line count. While it takes well under a second on my system, (admittedly, with a hot cache), it's not well optimized, reading each file into memory and processing it. If it matters, we can come up with a more efficient (yet still portable) way to compare the last two bytes of each file to \n\n. I went ahead and wrote a nearly-minimal script to do that. Rather than reading/processing all 27MB of sources, this reads just the last 2 bytes of each of the 1048 files, comparing those bytes to \n\n and printing the name when there's a match: git ls-files -z \ | xargs -0 perl -le ' foreach my $f (@ARGV) { open F,,$f or (warn failed to open $f: $!\n), next; my $p = sysseek(F, -2, 2); # seek failure probably means file has 2 bytes; ignore my $two; defined $p and $p = sysread F,$two,2; close F; # ignore read failure $p $two eq \n\n and (print $f),$fail=1; } END {exit defined $fail ? 1 : 0}' However, counting minor page faults, there's little difference (2193 before, 1976 after), but maximum memory consumption is probably way down. I didn't measure that. With a hot cache, the latter takes .02elapsed, and the former takes .09 seconds. I'm leaning towards the simplicity of the former, in spite of its cost. I'll bet someone can come up with a simple *and* efficient script (probably using sed) to list files with one or more trailing blank line. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list