Re: [libvirt] [PATCH] kvm: warn if num cpus is greater than num recommended
by Eduardo Habkost
On 22/08/2013, at 12:39, Andrew Jones <drjones(a)redhat.com> wrote:
> The comment in kvm_max_vcpus() states that it's using the recommended
> procedure from the kernel API documentation to get the max number
> of vcpus that kvm supports. It is, but by always returning the
> maximum number supported. The maximum number should only be used
> for development purposes. qemu should check KVM_CAP_NR_VCPUS for
> the recommended number of vcpus. This patch adds a warning if a user
> specifies a number of cpus between the recommended and max.
>
> Signed-off-by: Andrew Jones <drjones(a)redhat.com>
CCing libvir-list. It is probably interesting for libvirt to expose or warn about the recommended VCPU limit somehow, and in this case a simple warning on stderr won't be enough.
> ---
> kvm-all.c | 45 +++++++++++++++++++++++++++------------------
> 1 file changed, 27 insertions(+), 18 deletions(-)
>
> diff --git a/kvm-all.c b/kvm-all.c
> index 716860f617455..9092e13ae60ea 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -1313,24 +1313,24 @@ static int kvm_irqchip_create(KVMState *s)
> return 0;
> }
>
> -static int kvm_max_vcpus(KVMState *s)
> +/* Find number of supported CPUs using the recommended
> + * procedure from the kernel API documentation to cope with
> + * older kernels that may be missing capabilities.
> + */
> +static int kvm_recommended_vcpus(KVMState *s)
> {
> int ret;
>
> - /* Find number of supported CPUs using the recommended
> - * procedure from the kernel API documentation to cope with
> - * older kernels that may be missing capabilities.
> - */
> - ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS);
> - if (ret) {
> - return ret;
> - }
> ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
> - if (ret) {
> - return ret;
> - }
> + return (ret) ? ret : 4;
> +}
>
> - return 4;
> +static int kvm_max_vcpus(KVMState *s)
> +{
> + int ret;
> +
> + ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS);
> + return (ret) ? ret : kvm_recommended_vcpus(s);
> }
>
> int kvm_init(void)
> @@ -1383,12 +1383,21 @@ int kvm_init(void)
> goto err;
> }
>
> - max_vcpus = kvm_max_vcpus(s);
> + max_vcpus = kvm_recommended_vcpus(s);
> if (smp_cpus > max_vcpus) {
> - ret = -EINVAL;
> - fprintf(stderr, "Number of SMP cpus requested (%d) exceeds max cpus "
> - "supported by KVM (%d)\n", smp_cpus, max_vcpus);
> - goto err;
> + fprintf(stderr,
> + "Warning: Number of SMP cpus requested (%d) exceeds "
> + "recommended cpus supported by KVM (%d)\n",
> + smp_cpus, max_vcpus);
> +
> + max_vcpus = kvm_max_vcpus(s);
> + if (smp_cpus > max_vcpus) {
> + ret = -EINVAL;
> + fprintf(stderr, "Number of SMP cpus requested (%d) exceeds "
> + "max cpus supported by KVM (%d)\n",
> + smp_cpus, max_vcpus);
> + goto err;
> + }
> }
>
> s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);
> --
> 1.8.1.4
>
--
Eduardo
11 years, 4 months
[libvirt] How to deal with LXC cgroup access control with apparmor ?
by 止语
I don't know if it “legal” to send the email here :)
================
I am playing with libvirt 1.1.1 (lxc)
when I was starting a LXC container, the process location of cgroup is pretty , just the root directory
from the process. But I could tune the cgroup in a container as an user that logged, This is not accepted...
I wonder how to restrict it with apparmor ,so one can not modify files in the cgroup fs, e.g the cpus or mem,
if i restrict it with "deny /sys/fs/cgroup/** wrklx," in apparmor ,the container woulld not start up .
"Permission denied", because that a process would mount the cgroup, it seems done by libvirt_lxc,
Any way to restrict the cgroup in the container or just not mount cgroup in the container ??
Any help would be appreciated, thanks .
------------------
止语
11 years, 4 months
[libvirt] [RFC PATCH v2 0/3] Start fixing the pvpanic mess
by Paolo Bonzini
The pvpanic mess is even bigger than anticipated. Let's fix the monitor's
behavior (patch 1), get rid of all traces that the broken pvpanic existed
(patch 2), and give it a new name so that libvirt can detect a design
that works (patch 3).
All downstreams are urged to apply patches 1+2 as soon as they are
merged in QEMU.
Still, there are still other problems to solve.
In QEMU, exposing "-device isa-pvpanic" in the ACPI tables. Quite frankly
I don't have the time to fix this. We have ~3 months though. Patch 3
should not be applied until it is fixed.
Also, libvirt needs to know under which circumstances to add "-device
isa-pvpanic", besides obviously the availability of the device.
IMHO it is just too complicated to retrofit all complications in
<on_crash>. In fact, I suspect <on_crash> would match more closely QEMU's
"internal error" state, and it would be quite useful to add that to the
QEMU driver.
Thus, libvirt could add support for an <on_panic> element with the
following values:
- default, which depends on the hypervisor and is "crash" for Xen,
"ignore" for everything else
- "crash", which is the only supported value on Xen and means "use
the value of <on_crash>"
- ignore, which is the behavior of old libvirt that don't know pvpanic
- restart, destroy, preserve, rename-restart as for <on_crash>. In
particular, preserve can still use the crashed_guest_panicked status,
thus keeping the API compatible.
- pause, to pause the VM (with a new substatus)
<on_panic> would also have a coredump='yes/no' attribute, where yes
is only valid if the element is *not* one of default/crash/ignore.
Only "default" and "ignore" would be accepted for QEMU that does not
support the isa-pvpanic device.
Ideally, the coredump attribute would be added to <on_crash> too
for simplicity (Xen would refuse coredump + rename-restart and
coredump + preserve).
Paolo
Paolo Bonzini (3):
vl: allow "cont" from panicked state
pc: get rid of builtin pvpanic
pvpanic: rename to isa-pvpanic
gdbstub.c | 3 ---
hw/i386/pc_piix.c | 8 --------
hw/i386/pc_q35.c | 6 ------
hw/misc/pvpanic.c | 16 +++-------------
include/hw/i386/pc.h | 3 ---
vl.c | 6 ++----
6 files changed, 5 insertions(+), 37 deletions(-)
--
1.8.3.1
11 years, 4 months
[libvirt] [PATCHv3 0/5] Introduce API to query IP addresses for given domain
by nehaljwani
This feature has been requested for a very long time. Since qemu guest
agent gives us reliable results, now the wait is over.
The RFC was first proposed by Michal Privoznik:
http://www.mail-archive.com/libvir-list@redhat.com/msg51857.html
A patch was submitted, using structs:
http://www.mail-archive.com/libvir-list@redhat.com/msg57141.html
Another patch was submitted, using XML:
http://www.mail-archive.com/libvir-list@redhat.com/msg57829.html
Neither of the patches were accepted, probably due to lack of extensibility
and usability. Hence, we thought of using virTypedParameters for reporting
list of interfaces along with their MAC address and IP addresses. The RFC
can be found here:
http://www.mail-archive.com/libvir-list@redhat.com/msg79793.html
The idea of extensibility was rejected and rendered out of scope of
libvirt. Hence, we were back to structs.
This API is called virDomainInterfacesAddresses which returns a dynamically
allocated array of virDomainInterface struct. The great disadvantage is
once this gets released, it's written in stone and we cannot change
or add an item into it.
The API supports two methods:
* Return information (list of all associated interfaces with MAC address
and IP addresses) of all of the domain interfaces by default (if
no interface name is provided)
* Return information for the specified interface (if an interface name
is provided)
nehaljwani (5):
domifaddr: Implement the public API
domifaddr: Implement the remote protocol
domifaddr: Implement the API for qemu
domifaddr: Add virsh support
domifaddr: Expose python binding
daemon/remote.c | 123 +++++++++++++++++++++++++++++++
examples/python/Makefile.am | 2 +-
examples/python/README | 1 +
examples/python/domipaddrs.py | 50 +++++++++++++
include/libvirt/libvirt.h.in | 33 +++++++++
python/generator.py | 3 +
python/libvirt-override-api.xml | 8 +-
python/libvirt-override.c | 114 +++++++++++++++++++++++++++++
src/driver.h | 6 ++
src/libvirt.c | 110 ++++++++++++++++++++++++++++
src/libvirt_public.syms | 6 ++
src/qemu/qemu_agent.c | 157 ++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_agent.h | 3 +
src/qemu/qemu_driver.c | 55 ++++++++++++++
src/remote/remote_driver.c | 87 ++++++++++++++++++++++
src/remote/remote_protocol.x | 41 ++++++++++-
src/remote_protocol-structs | 24 ++++++
tests/qemuagenttest.c | 90 ++++++++++++++++++++++-
tools/virsh-domain-monitor.c | 99 +++++++++++++++++++++++++
tools/virsh.pod | 10 +++
20 files changed, 1018 insertions(+), 4 deletions(-)
create mode 100755 examples/python/domipaddrs.py
--
1.7.11.7
11 years, 4 months
[libvirt] [PATCH] tests: skip schema validation tests if xmllint is missing
by Eric Blake
On IRC, someone complained that a system without xmllint installed
failed a number of tests.
* tests/schematestutils.sh: Probe for xmllint.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
tests/schematestutils.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/schematestutils.sh b/tests/schematestutils.sh
index e594f04..a0ff77e 100644
--- a/tests/schematestutils.sh
+++ b/tests/schematestutils.sh
@@ -1,5 +1,7 @@
#!/bin/sh
+(xmllint --version) >/dev/null 2>&1 || skip_test_ 'Missing xmllint'
+
check_schema () {
DIRS=$1
--
1.8.3.1
11 years, 4 months
[libvirt] [PATCH] python: simplify complicated conditional assignment
by Claudio Bley
Signed-off-by: Claudio Bley <cbley(a)av-test.de>
---
Just noticed this while reading the generated .py files.
Might save a few cycles eventually...
python/generator.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/python/generator.py b/python/generator.py
index 427cebc..10390c3 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -1455,8 +1455,7 @@ def buildWrappers(module):
elif classname in [ "virDomainSnapshot" ]:
classes.write(" self._dom = dom\n")
classes.write(" self._conn = dom.connect()\n")
- classes.write(" if _obj != None:self._o = _obj;return\n")
- classes.write(" self._o = None\n\n")
+ classes.write(" self._o = _obj\n\n")
destruct=None
if classes_destructors.has_key(classname):
classes.write(" def __del__(self):\n")
--
1.7.9.5
11 years, 4 months
[libvirt] [PATCH] qemuBuildNicDevStr: Set vectors= on Multiqueue
by Michal Privoznik
Yet another advice appeared on the Multiqueue wiki page:
http://www.linux-kvm.org/page/Multiqueue#Enable_MQ_feature
We should add vectors=N onto the qemu command line, where
N = 2 * (number of queues) + 1.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_command.c | 13 +++++++------
src/qemu/qemu_command.h | 2 +-
src/qemu/qemu_hotplug.c | 4 +---
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b5ac15a..dbfa0dc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4730,7 +4730,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
virDomainNetDefPtr net,
int vlan,
int bootindex,
- bool multiqueue,
+ int vhostfdSize,
virQEMUCapsPtr qemuCaps)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -4783,8 +4783,11 @@ qemuBuildNicDevStr(virDomainDefPtr def,
virDomainVirtioEventIdxTypeToString(net->driver.virtio.event_idx));
}
}
- if (usingVirtio && multiqueue)
- virBufferAddLit(&buf, ",mq=on");
+ if (usingVirtio && vhostfdSize > 1) {
+ /* As advised at http://www.linux-kvm.org/page/Multiqueue
+ * we should add vectors=2*N+1 where N is the vhostfdSize */
+ virBufferAsprintf(&buf, ",mq=on,vectors=%d", 2 * vhostfdSize + 1);
+ }
if (vlan == -1)
virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias);
else
@@ -7278,10 +7281,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
virCommandAddArgList(cmd, "-netdev", host, NULL);
}
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
- bool multiqueue = tapfdSize > 1 || vhostfdSize > 1;
-
if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
- multiqueue, qemuCaps)))
+ vhostfdSize, qemuCaps)))
goto cleanup;
virCommandAddArgList(cmd, "-device", nic, NULL);
} else {
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index a9854a3..4761705 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -102,7 +102,7 @@ char * qemuBuildNicDevStr(virDomainDefPtr def,
virDomainNetDefPtr net,
int vlan,
int bootindex,
- bool multiqueue,
+ int vhostfdSize,
virQEMUCapsPtr qemuCaps);
char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 9727410..3491fd6 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -859,10 +859,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
}
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
- bool multiqueue = tapfdSize > 1 || vhostfdSize > 1;
-
if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
- multiqueue, priv->qemuCaps)))
+ vhostfdSize, priv->qemuCaps)))
goto try_remove;
} else {
if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
--
1.8.1.5
11 years, 4 months
[libvirt] virsh "cpu-stats" not working !!!
by SHREE DUTH AWASTHI
>
> Hi All,
>
> Can you please guide us in solving this issue.
>
> Version used : libvirt-1.0.6
> # rpm -qa | egrep "libvirt|qemu"
> qemu-kvm-0.14.1-1_WR4.3.x86_64_XXX.x86_64
> libvirt-1.0.6-1_WR4.3.x86_64_XXX.2.x86_64
>
> Problem :
>
> # virsh cpu-stats CLA-0
> error: Failed to retrieve CPU statistics for domain 'CLA-0'
> *error: internal error error accessing cgroup cpuacct for vcpu*
>
> Related info :
>
> # cat /proc/cgroups
> #subsys_name hierarchy num_cgroups enabled
> cpuset 3 4 1
> ns 0 1 1
> cpu 1 6 1
> cpuacct 7 3 1
> memory 2 3 1
> freezer 0 1 1
> net_cls 0 1 1
> blkio 0 1 1
>
> # cat /proc/mounts | grep cpu
> cpu /dev/cgroup_cpu cgroup rw,relatime,cpu 0 0
> cpuset /dev/cgroup_cpuset cgroup rw,relatime,cpuset 0 0
> cpuacct /dev/cgroup_cpuacct cgroup rw,relatime,cpuacct 0 0
>
> # cat /proc/self/cgroup
> 7:cpuacct:/
> 3:cpuset:/
> 2:memory:/
> 1:cpu:/
>
> virsh # vcpucount CLA-0
> maximum config 3
> maximum live 3
> current config 3
> current live 3
>
> virsh # vcpuinfo CLA-0
> VCPU: 0
> CPU: 0
> State: running
> CPU time: 5.7s
> CPU Affinity: yyyyyyyy
>
> virsh # vcpupin CLA-0 --current
> VCPU: CPU Affinity
> ----------------------------------
> 0: 0-7
> 1: 0-7
> 2: 0-7
>
> # cat /dev/cgroup_cpuacct/cpuacct.usage_percpu
> 532996776861 117928641102 125174572624 167825543709 155234053284
> 97350309867 122372010702 110640812251
> # cat /dev/cgroup_cpuacct/cpuacct.usage
> 1431288376064
> # cat /dev/cgroup_cpuacct/cpuacct.stat
> user 12148
> system 81469
>
> # cat /dev/cgroup_cpuacct/*machine*/cpuacct.usage_percpu
> 0 0 0 0 0 0 0 0
> # cat /dev/cgroup_cpuacct/*machine/*cpuacct.usage
> 0
>
> # chkconfig --list | grep cg
> cgroups_mount 0:off 1:on 2:on 3:on 4:on 5:on 6:off
>
> We have also found that there is no "*cgroup*" directory created under *
> "/sys/fs/".* We have tried mounting the same manually using the below
> commands but we were not successful.
>
> mkdir -p /dev/cgroup_cpuacct
> mount -t cgroup -o cpuacct cpuacct /dev/cgroup_cpuacct
>
> (or)
>
> mkdir -p /sys/fs/cgroup
> mount -t cgroup -o cgroup cgroup /sys/fs/cgroup
>
>
> Please find the the domain info used for the creation of VM in the
> attachment. Please let us know, how to proceed futher.
>
> Your inputs would be of great help to us.
>
> Thanks and Regards,
> Shree Duth Awasthi.
>
11 years, 4 months
[libvirt] [PATCH] Test for object identity when checking for None in Python
by Claudio Bley
Consistently use "is" or "is not" to compare variables to None,
because doing so is preferrable, as per PEP 8
(http://www.python.org/dev/peps/pep-0008/#programming-recommendations):
> Comparisons to singletons like None should always be done with is or
> is not, never the equality operators.
Signed-off-by: Claudio Bley <cbley(a)av-test.de>
---
Purely mechanical change, using:
find . -name '*.py' -exec sed -i -e 's,[ \t][ \t]*!=[ \t][ \t]*None, is not None,g' '{}' \+
find . -name '*.py' -exec sed -i -e 's,[ \t][ \t]*==[ \t][ \t]*None, is None,g' '{}' \+
docs/apibuild.py | 254 ++++++++++++++++-----------------
docs/index.py | 178 +++++++++++------------
examples/python/consolecallback.py | 2 +-
examples/python/dominfo.py | 2 +-
examples/python/domrestore.py | 2 +-
examples/python/domsave.py | 2 +-
examples/python/domstart.py | 4 +-
python/generator.py | 30 ++--
python/libvirt-override-virConnect.py | 2 +-
python/libvirt-override-virStream.py | 4 +-
10 files changed, 240 insertions(+), 240 deletions(-)
diff --git a/docs/apibuild.py b/docs/apibuild.py
index 5c55d79..ab6b0b4 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -111,7 +111,7 @@ class identifier:
self.extra = extra
self.lineno = lineno
self.static = 0
- if conditionals == None or len(conditionals) == 0:
+ if conditionals is None or len(conditionals) == 0:
self.conditionals = None
else:
self.conditionals = conditionals[:]
@@ -123,13 +123,13 @@ class identifier:
r = "%s %s:" % (self.type, self.name)
if self.static:
r = r + " static"
- if self.module != None:
+ if self.module is not None:
r = r + " from %s" % (self.module)
- if self.info != None:
+ if self.info is not None:
r = r + " " + `self.info`
- if self.extra != None:
+ if self.extra is not None:
r = r + " " + `self.extra`
- if self.conditionals != None:
+ if self.conditionals is not None:
r = r + " " + `self.conditionals`
return r
@@ -149,7 +149,7 @@ class identifier:
def set_static(self, static):
self.static = static
def set_conditionals(self, conditionals):
- if conditionals == None or len(conditionals) == 0:
+ if conditionals is None or len(conditionals) == 0:
self.conditionals = None
else:
self.conditionals = conditionals[:]
@@ -178,17 +178,17 @@ class identifier:
if self.name == debugsym and not quiet:
print "=> update %s : %s" % (debugsym, (module, type, info,
extra, conditionals))
- if header != None and self.header == None:
+ if header is not None and self.header is None:
self.set_header(module)
- if module != None and (self.module == None or self.header == self.module):
+ if module is not None and (self.module is None or self.header == self.module):
self.set_module(module)
- if type != None and self.type == None:
+ if type is not None and self.type is None:
self.set_type(type)
- if info != None:
+ if info is not None:
self.set_info(info)
- if extra != None:
+ if extra is not None:
self.set_extra(extra)
- if conditionals != None:
+ if conditionals is not None:
self.set_conditionals(conditionals)
class index:
@@ -217,10 +217,10 @@ class index:
d = identifier(name, header, module, type, lineno, info, extra, conditionals)
self.identifiers[name] = d
- if d != None and static == 1:
+ if d is not None and static == 1:
d.set_static(1)
- if d != None and name != None and type != None:
+ if d is not None and name is not None and type is not None:
self.references[name] = d
if name == debugsym and not quiet:
@@ -239,10 +239,10 @@ class index:
d = identifier(name, header, module, type, lineno, info, extra, conditionals)
self.identifiers[name] = d
- if d != None and static == 1:
+ if d is not None and static == 1:
d.set_static(1)
- if d != None and name != None and type != None:
+ if d is not None and name is not None and type is not None:
if type == "function":
self.functions[name] = d
elif type == "functype":
@@ -432,7 +432,7 @@ class CLexer:
else:
line = self.line
self.line = ""
- if line == None:
+ if line is None:
return None
if line[0] == '#':
@@ -461,7 +461,7 @@ class CLexer:
tok = tok + line
if found == 0:
line = self.getline()
- if line == None:
+ if line is None:
return None
self.last = ('string', tok)
return self.last
@@ -486,7 +486,7 @@ class CLexer:
tok = tok + line
if found == 0:
line = self.getline()
- if line == None:
+ if line is None:
return None
self.last = ('comment', tok)
return self.last
@@ -598,7 +598,7 @@ class CParser:
self.is_header = 0
self.input = open(filename)
self.lexer = CLexer(self.input)
- if idx == None:
+ if idx is None:
self.index = index()
else:
self.index = idx
@@ -707,7 +707,7 @@ class CParser:
com = token[1]
if self.top_comment == "":
self.top_comment = com
- if self.comment == None or com[0] == '*':
+ if self.comment is None or com[0] == '*':
self.comment = com
else:
self.comment = self.comment + com
@@ -731,7 +731,7 @@ class CParser:
args = []
desc = ""
- if self.comment == None:
+ if self.comment is None:
if not quiet:
self.warning("Missing comment for type %s" % (name))
return((args, desc))
@@ -780,7 +780,7 @@ class CParser:
args = []
desc = ""
- if self.comment == None:
+ if self.comment is None:
if not quiet:
self.warning("Missing comment for macro %s" % (name))
return((args, desc))
@@ -860,7 +860,7 @@ class CParser:
desc = ""
retdesc = ""
- if self.comment == None:
+ if self.comment is None:
if not quiet:
self.warning("Missing comment for function %s" % (name))
return(((ret[0], retdesc), args, desc))
@@ -958,7 +958,7 @@ class CParser:
#
i = 0
while i < nbargs:
- if args[i][2] == None and args[i][0] != "void" and args[i][1] != None:
+ if args[i][2] is None and args[i][0] != "void" and args[i][1] is not None:
self.warning("Function comment for %s lacks description of arg %s" % (name, args[i][1]))
i = i + 1
if retdesc == "" and ret[0] != "void":
@@ -975,7 +975,7 @@ class CParser:
name = token[1]
if name == "#include":
token = self.lexer.token()
- if token == None:
+ if token is None:
return None
if token[0] == 'preproc':
self.index_add(token[1], self.filename, not self.is_header,
@@ -984,14 +984,14 @@ class CParser:
return token
if name == "#define":
token = self.lexer.token()
- if token == None:
+ if token is None:
return None
if token[0] == 'preproc':
# TODO macros with arguments
name = token[1]
lst = []
token = self.lexer.token()
- while token != None and token[0] == 'preproc' and \
+ while token is not None and token[0] == 'preproc' and \
token[1][0] != '#':
lst.append(token[1])
token = self.lexer.token()
@@ -1059,7 +1059,7 @@ class CParser:
self.conditionals = self.conditionals[:-1]
self.defines = self.defines[:-1]
token = self.lexer.token()
- while token != None and token[0] == 'preproc' and \
+ while token is not None and token[0] == 'preproc' and \
token[1][0] != '#':
token = self.lexer.token()
return token
@@ -1076,7 +1076,7 @@ class CParser:
global ignored_words
token = self.lexer.token()
- while token != None:
+ while token is not None:
if token[0] == 'comment':
token = self.parseComment(token)
continue
@@ -1088,7 +1088,7 @@ class CParser:
return token
elif token[0] == "name" and token[1] == "__attribute":
token = self.lexer.token()
- while token != None and token[1] != ";":
+ while token is not None and token[1] != ";":
token = self.lexer.token()
return token
elif token[0] == "name" and ignored_words.has_key(token[1]):
@@ -1109,20 +1109,20 @@ class CParser:
# Parse a typedef, it records the type and its name.
#
def parseTypedef(self, token):
- if token == None:
+ if token is None:
return None
token = self.parseType(token)
- if token == None:
+ if token is None:
self.error("parsing typedef")
return None
base_type = self.type
type = base_type
#self.debug("end typedef type", token)
- while token != None:
+ while token is not None:
if token[0] == "name":
name = token[1]
signature = self.signature
- if signature != None:
+ if signature is not None:
type = string.split(type, '(')[0]
d = self.mergeFunctionComment(name,
((type, None), signature), 1)
@@ -1143,15 +1143,15 @@ class CParser:
self.error("parsing typedef: expecting a name")
return token
#self.debug("end typedef", token)
- if token != None and token[0] == 'sep' and token[1] == ',':
+ if token is not None and token[0] == 'sep' and token[1] == ',':
type = base_type
token = self.token()
- while token != None and token[0] == "op":
+ while token is not None and token[0] == "op":
type = type + token[1]
token = self.token()
- elif token != None and token[0] == 'sep' and token[1] == ';':
+ elif token is not None and token[0] == 'sep' and token[1] == ';':
break
- elif token != None and token[0] == 'name':
+ elif token is not None and token[0] == 'name':
type = base_type
continue
else:
@@ -1165,7 +1165,7 @@ class CParser:
# the balancing } included
#
def parseBlock(self, token):
- while token != None:
+ while token is not None:
if token[0] == "sep" and token[1] == "{":
token = self.token()
token = self.parseBlock(token)
@@ -1205,7 +1205,7 @@ class CParser:
def parseStruct(self, token):
fields = []
#self.debug("start parseStruct", token)
- while token != None:
+ while token is not None:
if token[0] == "sep" and token[1] == "{":
token = self.token()
token = self.parseTypeBlock(token)
@@ -1220,7 +1220,7 @@ class CParser:
#self.debug("before parseType", token)
token = self.parseType(token)
#self.debug("after parseType", token)
- if token != None and token[0] == "name":
+ if token is not None and token[0] == "name":
fname = token[1]
token = self.token()
if token[0] == "sep" and token[1] == ";":
@@ -1236,12 +1236,12 @@ class CParser:
self.comment = None
else:
self.error("parseStruct: expecting ;", token)
- elif token != None and token[0] == "sep" and token[1] == "{":
+ elif token is not None and token[0] == "sep" and token[1] == "{":
token = self.token()
token = self.parseTypeBlock(token)
- if token != None and token[0] == "name":
+ if token is not None and token[0] == "name":
token = self.token()
- if token != None and token[0] == "sep" and token[1] == ";":
+ if token is not None and token[0] == "sep" and token[1] == ";":
token = self.token()
else:
self.error("parseStruct: expecting ;", token)
@@ -1260,7 +1260,7 @@ class CParser:
def parseUnion(self, token):
fields = []
# self.debug("start parseUnion", token)
- while token != None:
+ while token is not None:
if token[0] == "sep" and token[1] == "{":
token = self.token()
token = self.parseTypeBlock(token)
@@ -1275,7 +1275,7 @@ class CParser:
# self.debug("before parseType", token)
token = self.parseType(token)
# self.debug("after parseType", token)
- if token != None and token[0] == "name":
+ if token is not None and token[0] == "name":
fname = token[1]
token = self.token()
if token[0] == "sep" and token[1] == ";":
@@ -1286,12 +1286,12 @@ class CParser:
self.comment = None
else:
self.error("parseUnion: expecting ;", token)
- elif token != None and token[0] == "sep" and token[1] == "{":
+ elif token is not None and token[0] == "sep" and token[1] == "{":
token = self.token()
token = self.parseTypeBlock(token)
- if token != None and token[0] == "name":
+ if token is not None and token[0] == "name":
token = self.token()
- if token != None and token[0] == "sep" and token[1] == ";":
+ if token is not None and token[0] == "sep" and token[1] == ";":
token = self.token()
else:
self.error("parseUnion: expecting ;", token)
@@ -1313,14 +1313,14 @@ class CParser:
self.comment = None
comment = ""
value = "0"
- while token != None:
+ while token is not None:
if token[0] == "sep" and token[1] == "{":
token = self.token()
token = self.parseTypeBlock(token)
elif token[0] == "sep" and token[1] == "}":
- if name != None:
+ if name is not None:
self.cleanupComment()
- if self.comment != None:
+ if self.comment is not None:
comment = self.comment
self.comment = None
self.enums.append((name, value, comment))
@@ -1328,8 +1328,8 @@ class CParser:
return token
elif token[0] == "name":
self.cleanupComment()
- if name != None:
- if self.comment != None:
+ if name is not None:
+ if self.comment is not None:
comment = string.strip(self.comment)
self.comment = None
self.enums.append((name, value, comment))
@@ -1451,7 +1451,7 @@ class CParser:
# the balancing }
#
def parseTypeBlock(self, token):
- while token != None:
+ while token is not None:
if token[0] == "sep" and token[1] == "{":
token = self.token()
token = self.parseTypeBlock(token)
@@ -1472,7 +1472,7 @@ class CParser:
self.struct_fields = []
self.union_fields = []
self.signature = None
- if token == None:
+ if token is None:
return token
while token[0] == "name" and (
@@ -1524,13 +1524,13 @@ class CParser:
if token[0] == "name":
nametok = token
token = self.token()
- if token != None and token[0] == "sep" and token[1] == "{":
+ if token is not None and token[0] == "sep" and token[1] == "{":
token = self.token()
token = self.parseStruct(token)
- elif token != None and token[0] == "op" and token[1] == "*":
+ elif token is not None and token[0] == "op" and token[1] == "*":
self.type = self.type + " " + nametok[1] + " *"
token = self.token()
- while token != None and token[0] == "op" and token[1] == "*":
+ while token is not None and token[0] == "op" and token[1] == "*":
self.type = self.type + " *"
token = self.token()
if token[0] == "name":
@@ -1539,11 +1539,11 @@ class CParser:
else:
self.error("struct : expecting name", token)
return token
- elif token != None and token[0] == "name" and nametok != None:
+ elif token is not None and token[0] == "name" and nametok is not None:
self.type = self.type + " " + nametok[1]
return token
- if nametok != None:
+ if nametok is not None:
self.lexer.push(token)
token = nametok
return token
@@ -1558,14 +1558,14 @@ class CParser:
if token[0] == "name":
nametok = token
token = self.token()
- if token != None and token[0] == "sep" and token[1] == "{":
+ if token is not None and token[0] == "sep" and token[1] == "{":
token = self.token()
token = self.parseUnion(token)
- elif token != None and token[0] == "name" and nametok != None:
+ elif token is not None and token[0] == "name" and nametok is not None:
self.type = self.type + " " + nametok[1]
return token
- if nametok != None:
+ if nametok is not None:
self.lexer.push(token)
token = nametok
return token
@@ -1577,13 +1577,13 @@ class CParser:
self.type = self.type + " " + token[1]
self.enums = []
token = self.token()
- if token != None and token[0] == "sep" and token[1] == "{":
+ if token is not None and token[0] == "sep" and token[1] == "{":
token = self.token()
token = self.parseEnumBlock(token)
else:
self.error("parsing enum: expecting '{'", token)
enum_type = None
- if token != None and token[0] != "name":
+ if token is not None and token[0] != "name":
self.lexer.push(token)
token = ("name", "enum")
else:
@@ -1595,24 +1595,24 @@ class CParser:
return token
elif token[0] == "name" and token[1] == "VIR_ENUM_DECL":
token = self.token()
- if token != None and token[0] == "sep" and token[1] == "(":
+ if token is not None and token[0] == "sep" and token[1] == "(":
token = self.token()
token = self.parseVirEnumDecl(token)
else:
self.error("parsing VIR_ENUM_DECL: expecting '('", token)
- if token != None:
+ if token is not None:
self.lexer.push(token)
token = ("name", "virenumdecl")
return token
elif token[0] == "name" and token[1] == "VIR_ENUM_IMPL":
token = self.token()
- if token != None and token[0] == "sep" and token[1] == "(":
+ if token is not None and token[0] == "sep" and token[1] == "(":
token = self.token()
token = self.parseVirEnumImpl(token)
else:
self.error("parsing VIR_ENUM_IMPL: expecting '('", token)
- if token != None:
+ if token is not None:
self.lexer.push(token)
token = ("name", "virenumimpl")
return token
@@ -1627,7 +1627,7 @@ class CParser:
token)
return token
token = self.token()
- while token != None and (token[0] == "op" or
+ while token is not None and (token[0] == "op" or
token[0] == "name" and token[1] == "const"):
self.type = self.type + " " + token[1]
token = self.token()
@@ -1635,22 +1635,22 @@ class CParser:
#
# if there is a parenthesis here, this means a function type
#
- if token != None and token[0] == "sep" and token[1] == '(':
+ if token is not None and token[0] == "sep" and token[1] == '(':
self.type = self.type + token[1]
token = self.token()
- while token != None and token[0] == "op" and token[1] == '*':
+ while token is not None and token[0] == "op" and token[1] == '*':
self.type = self.type + token[1]
token = self.token()
- if token == None or token[0] != "name" :
+ if token is None or token[0] != "name" :
self.error("parsing function type, name expected", token)
return token
self.type = self.type + token[1]
nametok = token
token = self.token()
- if token != None and token[0] == "sep" and token[1] == ')':
+ if token is not None and token[0] == "sep" and token[1] == ')':
self.type = self.type + token[1]
token = self.token()
- if token != None and token[0] == "sep" and token[1] == '(':
+ if token is not None and token[0] == "sep" and token[1] == '(':
token = self.token()
type = self.type
token = self.parseSignature(token)
@@ -1668,25 +1668,25 @@ class CParser:
#
# do some lookahead for arrays
#
- if token != None and token[0] == "name":
+ if token is not None and token[0] == "name":
nametok = token
token = self.token()
- if token != None and token[0] == "sep" and token[1] == '[':
+ if token is not None and token[0] == "sep" and token[1] == '[':
self.type = self.type + " " + nametok[1]
- while token != None and token[0] == "sep" and token[1] == '[':
+ while token is not None and token[0] == "sep" and token[1] == '[':
self.type = self.type + token[1]
token = self.token()
- while token != None and token[0] != 'sep' and \
+ while token is not None and token[0] != 'sep' and \
token[1] != ']' and token[1] != ';':
self.type = self.type + token[1]
token = self.token()
- if token != None and token[0] == 'sep' and token[1] == ']':
+ if token is not None and token[0] == 'sep' and token[1] == ']':
self.type = self.type + token[1]
token = self.token()
else:
self.error("parsing array type, ']' expected", token)
return token
- elif token != None and token[0] == "sep" and token[1] == ':':
+ elif token is not None and token[0] == "sep" and token[1] == ':':
# remove :12 in case it's a limited int size
token = self.token()
token = self.token()
@@ -1700,25 +1700,25 @@ class CParser:
# up to the ')' included
def parseSignature(self, token):
signature = []
- if token != None and token[0] == "sep" and token[1] == ')':
+ if token is not None and token[0] == "sep" and token[1] == ')':
self.signature = []
token = self.token()
return token
- while token != None:
+ while token is not None:
token = self.parseType(token)
- if token != None and token[0] == "name":
+ if token is not None and token[0] == "name":
signature.append((self.type, token[1], None))
token = self.token()
- elif token != None and token[0] == "sep" and token[1] == ',':
+ elif token is not None and token[0] == "sep" and token[1] == ',':
token = self.token()
continue
- elif token != None and token[0] == "sep" and token[1] == ')':
+ elif token is not None and token[0] == "sep" and token[1] == ')':
# only the type was provided
if self.type == "...":
signature.append((self.type, "...", None))
else:
signature.append((self.type, None, None))
- if token != None and token[0] == "sep":
+ if token is not None and token[0] == "sep":
if token[1] == ',':
token = self.token()
continue
@@ -1813,17 +1813,17 @@ class CParser:
static = 0
if token[1] == 'extern':
token = self.token()
- if token == None:
+ if token is None:
return token
if token[0] == 'string':
if token[1] == 'C':
token = self.token()
- if token == None:
+ if token is None:
return token
if token[0] == 'sep' and token[1] == "{":
token = self.token()
# print 'Entering extern "C line ', self.lineno()
- while token != None and (token[0] != 'sep' or
+ while token is not None and (token[0] != 'sep' or
token[1] != "}"):
if token[0] == 'name':
token = self.parseGlobal(token)
@@ -1840,7 +1840,7 @@ class CParser:
elif token[1] == 'static':
static = 1
token = self.token()
- if token == None or token[0] != 'name':
+ if token is None or token[0] != 'name':
return token
if token[1] == 'typedef':
@@ -1849,22 +1849,22 @@ class CParser:
else:
token = self.parseType(token)
type_orig = self.type
- if token == None or token[0] != "name":
+ if token is None or token[0] != "name":
return token
type = type_orig
self.name = token[1]
token = self.token()
- while token != None and (token[0] == "sep" or token[0] == "op"):
+ while token is not None and (token[0] == "sep" or token[0] == "op"):
if token[0] == "sep":
if token[1] == "[":
type = type + token[1]
token = self.token()
- while token != None and (token[0] != "sep" or \
+ while token is not None and (token[0] != "sep" or \
token[1] != ";"):
type = type + token[1]
token = self.token()
- if token != None and token[0] == "op" and token[1] == "=":
+ if token is not None and token[0] == "op" and token[1] == "=":
#
# Skip the initialization of the variable
#
@@ -1874,15 +1874,15 @@ class CParser:
token = self.parseBlock(token)
else:
self.comment = None
- while token != None and (token[0] != "sep" or \
+ while token is not None and (token[0] != "sep" or \
(token[1] != ';' and token[1] != ',')):
token = self.token()
self.comment = None
- if token == None or token[0] != "sep" or (token[1] != ';' and
+ if token is None or token[0] != "sep" or (token[1] != ';' and
token[1] != ','):
self.error("missing ';' or ',' after value")
- if token != None and token[0] == "sep":
+ if token is not None and token[0] == "sep":
if token[1] == ";":
self.comment = None
token = self.token()
@@ -1897,7 +1897,7 @@ class CParser:
elif token[1] == "(":
token = self.token()
token = self.parseSignature(token)
- if token == None:
+ if token is None:
return None
if token[0] == "sep" and token[1] == ";":
self.checkLongLegacyFunction(self.name, type, self.signature)
@@ -1920,10 +1920,10 @@ class CParser:
"variable", type)
type = type_orig
token = self.token()
- while token != None and token[0] == "sep":
+ while token is not None and token[0] == "sep":
type = type + token[1]
token = self.token()
- if token != None and token[0] == "name":
+ if token is not None and token[0] == "name":
self.name = token[1]
token = self.token()
else:
@@ -1935,7 +1935,7 @@ class CParser:
if not quiet:
print "Parsing %s" % (self.filename)
token = self.token()
- while token != None:
+ while token is not None:
if token[0] == 'name':
token = self.parseGlobal(token)
else:
@@ -1977,7 +1977,7 @@ class docBuilder:
print >>sys.stderr, "Error:", msg
def indexString(self, id, str):
- if str == None:
+ if str is None:
return
str = string.replace(str, "'", ' ')
str = string.replace(str, '"', ' ')
@@ -2069,17 +2069,17 @@ class docBuilder:
id = self.idx.enums[name]
output.write(" <enum name='%s' file='%s'" % (name,
self.modulename_file(id.header)))
- if id.info != None:
+ if id.info is not None:
info = id.info
- if info[0] != None and info[0] != '':
+ if info[0] is not None and info[0] != '':
try:
val = eval(info[0])
except:
val = info[0]
output.write(" value='%s'" % (val))
- if info[2] != None and info[2] != '':
+ if info[2] is not None and info[2] != '':
output.write(" type='%s'" % info[2])
- if info[1] != None and info[1] != '':
+ if info[1] is not None and info[1] != '':
output.write(" info='%s'" % escape(info[1]))
output.write("/>\n")
@@ -2087,15 +2087,15 @@ class docBuilder:
id = self.idx.macros[name]
output.write(" <macro name='%s' file='%s'>\n" % (name,
self.modulename_file(id.header)))
- if id.info != None:
+ if id.info is not None:
try:
(args, desc) = id.info
- if desc != None and desc != "":
+ if desc is not None and desc != "":
output.write(" <info><![CDATA[%s]]></info>\n" % (desc))
self.indexString(name, desc)
for arg in args:
(name, desc) = arg
- if desc != None and desc != "":
+ if desc is not None and desc != "":
output.write(" <arg name='%s' info='%s'/>\n" % (
name, escape(desc)))
self.indexString(name, desc)
@@ -2110,7 +2110,7 @@ class docBuilder:
output.write(" <union>\n")
for f in field[3]:
desc = f[2]
- if desc == None:
+ if desc is None:
desc = ''
else:
desc = escape(desc)
@@ -2133,7 +2133,7 @@ class docBuilder:
for field in self.idx.structs[name].info:
desc = field[2]
self.indexString(name, desc)
- if desc == None:
+ if desc is None:
desc = ''
else:
desc = escape(desc)
@@ -2151,7 +2151,7 @@ class docBuilder:
name, self.modulename_file(id.header), id.info))
try:
desc = id.extra
- if desc != None and desc != "":
+ if desc is not None and desc != "":
output.write(">\n <info><![CDATA[%s]]></info>\n" % (desc))
output.write(" </typedef>\n")
else:
@@ -2161,7 +2161,7 @@ class docBuilder:
def serialize_variable(self, output, name):
id = self.idx.variables[name]
- if id.info != None:
+ if id.info is not None:
output.write(" <variable name='%s' file='%s' type='%s'/>\n" % (
name, self.modulename_file(id.header), id.info))
else:
@@ -2179,7 +2179,7 @@ class docBuilder:
#
# Processing of conditionals modified by Bill 1/1/05
#
- if id.conditionals != None:
+ if id.conditionals is not None:
apstr = ""
for cond in id.conditionals:
if apstr != "":
@@ -2190,10 +2190,10 @@ class docBuilder:
(ret, params, desc) = id.info
output.write(" <info><![CDATA[%s]]></info>\n" % (desc))
self.indexString(name, desc)
- if ret[0] != None:
+ if ret[0] is not None:
if ret[0] == "void":
output.write(" <return type='void'/>\n")
- elif (ret[1] == None or ret[1] == '') and not ignored_functions.has_key(name):
+ elif (ret[1] is None or ret[1] == '') and not ignored_functions.has_key(name):
self.error("Missing documentation for return of function `%s'" % name)
else:
output.write(" <return type='%s' info='%s'/>\n" % (
@@ -2202,7 +2202,7 @@ class docBuilder:
for param in params:
if param[0] == 'void':
continue
- if (param[2] == None or param[2] == ''):
+ if (param[2] is None or param[2] == ''):
if ignored_functions.has_key(name):
output.write(" <arg name='%s' type='%s' info=''/>\n" % (param[1], param[0]))
else:
@@ -2219,7 +2219,7 @@ class docBuilder:
module = self.modulename_file(file)
output.write(" <file name='%s'>\n" % (module))
dict = self.headers[file]
- if dict.info != None:
+ if dict.info is not None:
for data in ('Summary', 'Description', 'Author'):
try:
output.write(" <%s>%s</%s>\n" % (
@@ -2352,12 +2352,12 @@ class docBuilder:
ids.sort()
for id in ids:
if id[0] != letter:
- if letter != None:
+ if letter is not None:
output.write(" </letter>\n")
letter = id[0]
output.write(" <letter name='%s'>\n" % (letter))
output.write(" <ref name='%s'/>\n" % (id))
- if letter != None:
+ if letter is not None:
output.write(" </letter>\n")
def serialize_xrefs_references(self, output):
@@ -2383,8 +2383,8 @@ class docBuilder:
if len(index[id]) > 30:
continue
if id[0] != letter:
- if letter == None or count > 200:
- if letter != None:
+ if letter is None or count > 200:
+ if letter is not None:
output.write(" </letter>\n")
output.write(" </chunk>\n")
count = 0
@@ -2392,7 +2392,7 @@ class docBuilder:
output.write(" <chunk name='chunk%s'>\n" % (chunk))
first_letter = id[0]
chunk = chunk + 1
- elif letter != None:
+ elif letter is not None:
output.write(" </letter>\n")
letter = id[0]
output.write(" <letter name='%s'>\n" % (letter))
@@ -2407,7 +2407,7 @@ class docBuilder:
output.write(" <ref name='%s'/>\n" % (token))
count = count + 1
output.write(" </word>\n")
- if letter != None:
+ if letter is not None:
output.write(" </letter>\n")
output.write(" </chunk>\n")
if count != 0:
diff --git a/docs/index.py b/docs/index.py
index ce5180f..2f0ad26 100755
--- a/docs/index.py
+++ b/docs/index.py
@@ -127,9 +127,9 @@ DB=None
def createTable(db, name):
global TABLES
- if db == None:
+ if db is None:
return -1
- if name == None:
+ if name is None:
return -1
c = db.cursor()
@@ -147,7 +147,7 @@ def createTable(db, name):
def checkTables(db, verbose = 1):
global TABLES
- if db == None:
+ if db is None:
return -1
c = db.cursor()
nbtables = c.execute("show tables")
@@ -191,7 +191,7 @@ def checkTables(db, verbose = 1):
def openMySQL(db="libvir", passwd=None, verbose = 1):
global DB
- if passwd == None:
+ if passwd is None:
try:
passwd = os.environ["MySQL_PASS"]
except:
@@ -199,7 +199,7 @@ def openMySQL(db="libvir", passwd=None, verbose = 1):
sys.exit(1)
DB = MySQLdb.connect(passwd=passwd, db=db)
- if DB == None:
+ if DB is None:
return -1
ret = checkTables(DB, verbose)
return ret
@@ -207,13 +207,13 @@ def openMySQL(db="libvir", passwd=None, verbose = 1):
def updateWord(name, symbol, relevance):
global DB
- if DB == None:
+ if DB is None:
openMySQL()
- if DB == None:
+ if DB is None:
return -1
- if name == None:
+ if name is None:
return -1
- if symbol == None:
+ if symbol is None:
return -1
c = DB.cursor()
@@ -238,15 +238,15 @@ def updateSymbol(name, module, type, desc):
global DB
updateWord(name, name, 50)
- if DB == None:
+ if DB is None:
openMySQL()
- if DB == None:
+ if DB is None:
return -1
- if name == None:
+ if name is None:
return -1
- if module == None:
+ if module is None:
return -1
- if type == None:
+ if type is None:
return -1
try:
@@ -299,11 +299,11 @@ def addFunctype(name, module, desc = ""):
def addPage(resource, title):
global DB
- if DB == None:
+ if DB is None:
openMySQL()
- if DB == None:
+ if DB is None:
return -1
- if resource == None:
+ if resource is None:
return -1
c = DB.cursor()
@@ -327,17 +327,17 @@ def addPage(resource, title):
def updateWordHTML(name, resource, desc, id, relevance):
global DB
- if DB == None:
+ if DB is None:
openMySQL()
- if DB == None:
+ if DB is None:
return -1
- if name == None:
+ if name is None:
return -1
- if resource == None:
+ if resource is None:
return -1
- if id == None:
+ if id is None:
id = ""
- if desc == None:
+ if desc is None:
desc = ""
else:
try:
@@ -367,11 +367,11 @@ def updateWordHTML(name, resource, desc, id, relevance):
def checkXMLMsgArchive(url):
global DB
- if DB == None:
+ if DB is None:
openMySQL()
- if DB == None:
+ if DB is None:
return -1
- if url == None:
+ if url is None:
return -1
c = DB.cursor()
@@ -379,7 +379,7 @@ def checkXMLMsgArchive(url):
ret = c.execute(
"""SELECT ID FROM archives WHERE resource='%s'""" % (url))
row = c.fetchone()
- if row == None:
+ if row is None:
return -1
except:
return -1
@@ -389,13 +389,13 @@ def checkXMLMsgArchive(url):
def addXMLMsgArchive(url, title):
global DB
- if DB == None:
+ if DB is None:
openMySQL()
- if DB == None:
+ if DB is None:
return -1
- if url == None:
+ if url is None:
return -1
- if title == None:
+ if title is None:
title = ""
else:
title = string.replace(title, "'", " ")
@@ -408,7 +408,7 @@ def addXMLMsgArchive(url, title):
cmd = """SELECT ID FROM archives WHERE resource='%s'""" % (url)
ret = c.execute(cmd)
row = c.fetchone()
- if row == None:
+ if row is None:
print "addXMLMsgArchive failed to get the ID: %s" % (url)
return -1
except:
@@ -420,13 +420,13 @@ def addXMLMsgArchive(url, title):
def updateWordArchive(name, id, relevance):
global DB
- if DB == None:
+ if DB is None:
openMySQL()
- if DB == None:
+ if DB is None:
return -1
- if name == None:
+ if name is None:
return -1
- if id == None:
+ if id is None:
return -1
c = DB.cursor()
@@ -533,9 +533,9 @@ def splitIdentifier(str):
def addWord(word, module, symbol, relevance):
global wordsDict
- if word == None or len(word) < 3:
+ if word is None or len(word) < 3:
return -1
- if module == None or symbol == None:
+ if module is None or symbol is None:
return -1
if dropWords.has_key(word):
return 0
@@ -544,7 +544,7 @@ def addWord(word, module, symbol, relevance):
if wordsDict.has_key(word):
d = wordsDict[word]
- if d == None:
+ if d is None:
return 0
if len(d) > 500:
wordsDict[word] = None
@@ -559,7 +559,7 @@ def addWord(word, module, symbol, relevance):
return relevance
def addString(str, module, symbol, relevance):
- if str == None or len(str) < 3:
+ if str is None or len(str) < 3:
return -1
ret = 0
str = cleanupWordsString(str)
@@ -573,9 +573,9 @@ def addString(str, module, symbol, relevance):
def addWordHTML(word, resource, id, section, relevance):
global wordsDictHTML
- if word == None or len(word) < 3:
+ if word is None or len(word) < 3:
return -1
- if resource == None or section == None:
+ if resource is None or section is None:
return -1
if dropWords.has_key(word):
return 0
@@ -586,14 +586,14 @@ def addWordHTML(word, resource, id, section, relevance):
if wordsDictHTML.has_key(word):
d = wordsDictHTML[word]
- if d == None:
+ if d is None:
print "skipped %s" % (word)
return 0
try:
(r,i,s) = d[resource]
- if i != None:
+ if i is not None:
id = i
- if s != None:
+ if s is not None:
section = s
relevance = relevance + r
except:
@@ -605,7 +605,7 @@ def addWordHTML(word, resource, id, section, relevance):
return relevance
def addStringHTML(str, resource, id, section, relevance):
- if str == None or len(str) < 3:
+ if str is None or len(str) < 3:
return -1
ret = 0
str = cleanupWordsString(str)
@@ -626,9 +626,9 @@ def addStringHTML(str, resource, id, section, relevance):
def addWordArchive(word, id, relevance):
global wordsDictArchive
- if word == None or len(word) < 3:
+ if word is None or len(word) < 3:
return -1
- if id == None or id == -1:
+ if id is None or id == -1:
return -1
if dropWords.has_key(word):
return 0
@@ -637,7 +637,7 @@ def addWordArchive(word, id, relevance):
if wordsDictArchive.has_key(word):
d = wordsDictArchive[word]
- if d == None:
+ if d is None:
print "skipped %s" % (word)
return 0
try:
@@ -652,7 +652,7 @@ def addWordArchive(word, id, relevance):
return relevance
def addStringArchive(str, id, relevance):
- if str == None or len(str) < 3:
+ if str is None or len(str) < 3:
return -1
ret = 0
str = cleanupWordsString(str)
@@ -683,9 +683,9 @@ def loadAPI(filename):
return doc
def foundExport(file, symbol):
- if file == None:
+ if file is None:
return 0
- if symbol == None:
+ if symbol is None:
return 0
addFunction(symbol, file)
l = splitIdentifier(symbol)
@@ -697,7 +697,7 @@ def analyzeAPIFile(top):
count = 0
name = top.prop("name")
cur = top.children
- while cur != None:
+ while cur is not None:
if cur.type == 'text':
cur = cur.next
continue
@@ -712,7 +712,7 @@ def analyzeAPIFiles(top):
count = 0
cur = top.children
- while cur != None:
+ while cur is not None:
if cur.type == 'text':
cur = cur.next
continue
@@ -725,10 +725,10 @@ def analyzeAPIFiles(top):
def analyzeAPIEnum(top):
file = top.prop("file")
- if file == None:
+ if file is None:
return 0
symbol = top.prop("name")
- if symbol == None:
+ if symbol is None:
return 0
addEnum(symbol, file)
@@ -740,10 +740,10 @@ def analyzeAPIEnum(top):
def analyzeAPIConst(top):
file = top.prop("file")
- if file == None:
+ if file is None:
return 0
symbol = top.prop("name")
- if symbol == None:
+ if symbol is None:
return 0
addConst(symbol, file)
@@ -755,10 +755,10 @@ def analyzeAPIConst(top):
def analyzeAPIType(top):
file = top.prop("file")
- if file == None:
+ if file is None:
return 0
symbol = top.prop("name")
- if symbol == None:
+ if symbol is None:
return 0
addType(symbol, file)
@@ -769,10 +769,10 @@ def analyzeAPIType(top):
def analyzeAPIFunctype(top):
file = top.prop("file")
- if file == None:
+ if file is None:
return 0
symbol = top.prop("name")
- if symbol == None:
+ if symbol is None:
return 0
addFunctype(symbol, file)
@@ -783,10 +783,10 @@ def analyzeAPIFunctype(top):
def analyzeAPIStruct(top):
file = top.prop("file")
- if file == None:
+ if file is None:
return 0
symbol = top.prop("name")
- if symbol == None:
+ if symbol is None:
return 0
addStruct(symbol, file)
@@ -795,7 +795,7 @@ def analyzeAPIStruct(top):
addWord(word, file, symbol, 10)
info = top.prop("info")
- if info != None:
+ if info is not None:
info = string.replace(info, "'", " ")
info = string.strip(info)
l = string.split(info)
@@ -806,17 +806,17 @@ def analyzeAPIStruct(top):
def analyzeAPIMacro(top):
file = top.prop("file")
- if file == None:
+ if file is None:
return 0
symbol = top.prop("name")
- if symbol == None:
+ if symbol is None:
return 0
symbol = string.replace(symbol, "'", " ")
symbol = string.strip(symbol)
info = None
cur = top.children
- while cur != None:
+ while cur is not None:
if cur.type == 'text':
cur = cur.next
continue
@@ -829,7 +829,7 @@ def analyzeAPIMacro(top):
for word in l:
addWord(word, file, symbol, 10)
- if info == None:
+ if info is None:
addMacro(symbol, file)
print "Macro %s description has no <info>" % (symbol)
return 0
@@ -845,17 +845,17 @@ def analyzeAPIMacro(top):
def analyzeAPIFunction(top):
file = top.prop("file")
- if file == None:
+ if file is None:
return 0
symbol = top.prop("name")
- if symbol == None:
+ if symbol is None:
return 0
symbol = string.replace(symbol, "'", " ")
symbol = string.strip(symbol)
info = None
cur = top.children
- while cur != None:
+ while cur is not None:
if cur.type == 'text':
cur = cur.next
continue
@@ -863,23 +863,23 @@ def analyzeAPIFunction(top):
info = cur.content
elif cur.name == "return":
rinfo = cur.prop("info")
- if rinfo != None:
+ if rinfo is not None:
rinfo = string.replace(rinfo, "'", " ")
rinfo = string.strip(rinfo)
addString(rinfo, file, symbol, 7)
elif cur.name == "arg":
ainfo = cur.prop("info")
- if ainfo != None:
+ if ainfo is not None:
ainfo = string.replace(ainfo, "'", " ")
ainfo = string.strip(ainfo)
addString(ainfo, file, symbol, 5)
name = cur.prop("name")
- if name != None:
+ if name is not None:
name = string.replace(name, "'", " ")
name = string.strip(name)
addWord(name, file, symbol, 7)
cur = cur.next
- if info == None:
+ if info is None:
print "Function %s description has no <info>" % (symbol)
addFunction(symbol, file, "")
else:
@@ -898,7 +898,7 @@ def analyzeAPISymbols(top):
count = 0
cur = top.children
- while cur != None:
+ while cur is not None:
if cur.type == 'text':
cur = cur.next
continue
@@ -923,14 +923,14 @@ def analyzeAPISymbols(top):
def analyzeAPI(doc):
count = 0
- if doc == None:
+ if doc is None:
return -1
root = doc.getRootElement()
if root.name != "api":
print "Unexpected root name"
return -1
cur = root.children
- while cur != None:
+ while cur is not None:
if cur.type == 'text':
cur = cur.next
continue
@@ -1056,7 +1056,7 @@ def analyzeHTMLPages():
import time
def getXMLDateArchive(t = None):
- if t == None:
+ if t is None:
t = time.time()
T = time.gmtime(t)
month = time.strftime("%B", T)
@@ -1065,7 +1065,7 @@ def getXMLDateArchive(t = None):
return url
def scanXMLMsgArchive(url, title, force = 0):
- if url == None or title == None:
+ if url is None or title is None:
return 0
ID = checkXMLMsgArchive(url)
@@ -1082,7 +1082,7 @@ def scanXMLMsgArchive(url, title, force = 0):
doc = libxml2.htmlParseFile(url, None)
except:
doc = None
- if doc == None:
+ if doc is None:
print "Failed to parse %s" % (url)
return 0
@@ -1105,7 +1105,7 @@ def scanXMLDateArchive(t = None, force = 0):
doc = libxml2.htmlParseFile(url, None)
except:
doc = None
- if doc == None:
+ if doc is None:
print "Failed to parse %s" % (url)
return -1
ctxt = doc.xpathNewContext()
@@ -1114,16 +1114,16 @@ def scanXMLDateArchive(t = None, force = 0):
newmsg = 0
for anchor in anchors:
href = anchor.prop("href")
- if href == None or href[0:3] != "msg":
+ if href is None or href[0:3] != "msg":
continue
try:
links = links + 1
msg = libxml2.buildURI(href, url)
title = anchor.content
- if title != None and title[0:4] == 'Re: ':
+ if title is not None and title[0:4] == 'Re: ':
title = title[4:]
- if title != None and title[0:6] == '[xml] ':
+ if title is not None and title[0:6] == '[xml] ':
title = title[6:]
newmsg = newmsg + scanXMLMsgArchive(msg, title, force)
@@ -1148,7 +1148,7 @@ def analyzeArchives(t = None, force = 0):
skipped = 0
for word in wordsDictArchive.keys():
refs = wordsDictArchive[word]
- if refs == None:
+ if refs is None:
skipped = skipped + 1
continue
for id in refs.keys():
@@ -1168,7 +1168,7 @@ def analyzeHTMLTop():
skipped = 0
for word in wordsDictHTML.keys():
refs = wordsDictHTML[word]
- if refs == None:
+ if refs is None:
skipped = skipped + 1
continue
for resource in refs.keys():
@@ -1197,7 +1197,7 @@ def analyzeAPITop():
skipped = 0
for word in wordsDict.keys():
refs = wordsDict[word]
- if refs == None:
+ if refs is None:
skipped = skipped + 1
continue
for (module, symbol) in refs.keys():
diff --git a/examples/python/consolecallback.py b/examples/python/consolecallback.py
index 23316ce..d8e33a9 100644
--- a/examples/python/consolecallback.py
+++ b/examples/python/consolecallback.py
@@ -29,7 +29,7 @@ class Console(object):
def check_console(console):
if (console.state[0] == libvirt.VIR_DOMAIN_RUNNING or
console.state[0] == libvirt.VIR_DOMAIN_PAUSED):
- if console.stream == None:
+ if console.stream is None:
console.stream = console.connection.newStream(libvirt.VIR_STREAM_NONBLOCK)
console.domain.openConsole(None, console.stream, 0)
console.stream.eventAddCallback(libvirt.VIR_STREAM_EVENT_READABLE, stream_callback, console)
diff --git a/examples/python/dominfo.py b/examples/python/dominfo.py
index 0d3238b..bfa3ca3 100755
--- a/examples/python/dominfo.py
+++ b/examples/python/dominfo.py
@@ -35,7 +35,7 @@ name = sys.argv[1]
# Connect to libvirt
conn = libvirt.openReadOnly(None)
-if conn == None:
+if conn is None:
print 'Failed to open connection to the hypervisor'
sys.exit(1)
diff --git a/examples/python/domrestore.py b/examples/python/domrestore.py
index ccc82f6..fffc90f 100755
--- a/examples/python/domrestore.py
+++ b/examples/python/domrestore.py
@@ -21,7 +21,7 @@ dir = sys.argv[1]
imgs = os.listdir(dir)
conn = libvirt.open(None)
-if conn == None:
+if conn is None:
print 'Failed to open connection to the hypervisor'
sys.exit(1)
diff --git a/examples/python/domsave.py b/examples/python/domsave.py
index 12ffac1..bac4536 100755
--- a/examples/python/domsave.py
+++ b/examples/python/domsave.py
@@ -19,7 +19,7 @@ if len(sys.argv) != 2:
dir = sys.argv[1]
conn = libvirt.open(None)
-if conn == None:
+if conn is None:
print 'Failed to open connection to the hypervisor'
sys.exit(1)
diff --git a/examples/python/domstart.py b/examples/python/domstart.py
index b1e89b8..b14fad1 100755
--- a/examples/python/domstart.py
+++ b/examples/python/domstart.py
@@ -33,7 +33,7 @@ if len(sys.argv) != 2:
(name, xmldesc) = read_domain(sys.argv[1])
conn = libvirt.open(None)
-if conn == None:
+if conn is None:
print 'Failed to open connection to the hypervisor'
sys.exit(1)
@@ -43,7 +43,7 @@ except libvirt.libvirtError:
print "Starting domain %s ... " % name,
sys.stdout.flush()
dom = conn.createLinux(xmldesc, 0)
- if dom == None:
+ if dom is None:
print "failed"
sys.exit(1)
else:
diff --git a/python/generator.py b/python/generator.py
index 427cebc..6c7414a 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -136,7 +136,7 @@ class docParser(xml.sax.handler.ContentHandler):
print "end %s" % tag
if tag == 'function':
# fuctions come from source files, hence 'virerror.c'
- if self.function != None:
+ if self.function is not None:
if (self.function_module == "libvirt" or
self.function_module == "virevent" or
self.function_module == "virerror"):
@@ -641,9 +641,9 @@ def print_function_wrapper(module, name, output, export, include):
(f, t, n, c) = py_types[arg[1]]
if (f == 'z') and (name in foreign_encoding_args) and (num_bufs == 0):
f = 't#'
- if f != None:
+ if f is not None:
format = format + f
- if t != None:
+ if t is not None:
format_args = format_args + ", &pyobj_%s" % (arg[0])
c_args = c_args + " PyObject *pyobj_%s;\n" % (arg[0])
c_convert = c_convert + \
@@ -686,7 +686,7 @@ def print_function_wrapper(module, name, output, export, include):
elif py_types.has_key(ret[0]):
(f, t, n, c) = py_types[ret[0]]
c_return = " %s c_retval;\n" % (ret[0])
- if file == "python_accessor" and ret[2] != None:
+ if file == "python_accessor" and ret[2] is not None:
c_call = "\n c_retval = %s->%s;\n" % (args[0][0], ret[2])
else:
c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
@@ -708,7 +708,7 @@ def print_function_wrapper(module, name, output, export, include):
unknown_types[ret[0]] = [name]
return -1
- if cond != None and cond != "":
+ if cond is not None and cond != "":
include.write("#if %s\n" % cond)
export.write("#if %s\n" % cond)
output.write("#if %s\n" % cond)
@@ -729,14 +729,14 @@ def print_function_wrapper(module, name, output, export, include):
if file == "python":
# Those have been manually generated
- if cond != None and cond != "":
+ if cond is not None and cond != "":
include.write("#endif\n")
export.write("#endif\n")
output.write("#endif\n")
return 1
if file == "python_accessor" and ret[0] != "void" and ret[2] is None:
# Those have been manually generated
- if cond != None and cond != "":
+ if cond is not None and cond != "":
include.write("#endif\n")
export.write("#endif\n")
output.write("#endif\n")
@@ -771,7 +771,7 @@ def print_function_wrapper(module, name, output, export, include):
output.write(" LIBVIRT_END_ALLOW_THREADS;\n")
output.write(ret_convert)
output.write("}\n\n")
- if cond != None and cond != "":
+ if cond is not None and cond != "":
include.write("#endif /* %s */\n" % cond)
export.write("#endif /* %s */\n" % cond)
output.write("#endif /* %s */\n" % cond)
@@ -1313,7 +1313,7 @@ def buildWrappers(module):
classes.write("#\n")
classes.write("# WARNING WARNING WARNING WARNING\n")
classes.write("#\n")
- if extra != None:
+ if extra is not None:
classes.writelines(extra.readlines())
classes.write("#\n")
classes.write("# WARNING WARNING WARNING WARNING\n")
@@ -1321,7 +1321,7 @@ def buildWrappers(module):
classes.write("# Automatically written part of python bindings for libvirt\n")
classes.write("#\n")
classes.write("# WARNING WARNING WARNING WARNING\n")
- if extra != None:
+ if extra is not None:
extra.close()
if function_classes.has_key("None"):
@@ -1460,7 +1460,7 @@ def buildWrappers(module):
destruct=None
if classes_destructors.has_key(classname):
classes.write(" def __del__(self):\n")
- classes.write(" if self._o != None:\n")
+ classes.write(" if self._o is not None:\n")
classes.write(" libvirtmod.%s(self._o)\n" %
classes_destructors[classname])
classes.write(" self._o = None\n\n")
@@ -1776,7 +1776,7 @@ def qemuBuildWrappers(module):
fd.write("#\n")
fd.write("# WARNING WARNING WARNING WARNING\n")
fd.write("#\n")
- if extra != None:
+ if extra is not None:
fd.writelines(extra.readlines())
fd.write("#\n")
fd.write("# WARNING WARNING WARNING WARNING\n")
@@ -1784,7 +1784,7 @@ def qemuBuildWrappers(module):
fd.write("# Automatically written part of python bindings for libvirt\n")
fd.write("#\n")
fd.write("# WARNING WARNING WARNING WARNING\n")
- if extra != None:
+ if extra is not None:
extra.close()
fd.write("try:\n")
@@ -1888,7 +1888,7 @@ def lxcBuildWrappers(module):
fd.write("#\n")
fd.write("# WARNING WARNING WARNING WARNING\n")
fd.write("#\n")
- if extra != None:
+ if extra is not None:
fd.writelines(extra.readlines())
fd.write("#\n")
fd.write("# WARNING WARNING WARNING WARNING\n")
@@ -1896,7 +1896,7 @@ def lxcBuildWrappers(module):
fd.write("# Automatically written part of python bindings for libvirt\n")
fd.write("#\n")
fd.write("# WARNING WARNING WARNING WARNING\n")
- if extra != None:
+ if extra is not None:
extra.close()
fd.write("try:\n")
diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
index 044faa0..4ba3d30 100644
--- a/python/libvirt-override-virConnect.py
+++ b/python/libvirt-override-virConnect.py
@@ -7,7 +7,7 @@
except AttributeError:
pass
- if self._o != None:
+ if self._o is not None:
libvirtmod.virConnectClose(self._o)
self._o = None
diff --git a/python/libvirt-override-virStream.py b/python/libvirt-override-virStream.py
index b5cec2a..53000da 100644
--- a/python/libvirt-override-virStream.py
+++ b/python/libvirt-override-virStream.py
@@ -5,7 +5,7 @@
except AttributeError:
pass
- if self._o != None:
+ if self._o is not None:
libvirtmod.virStreamFree(self._o)
self._o = None
@@ -103,7 +103,7 @@
the request would block, integer -2 is returned.
"""
ret = libvirtmod.virStreamRecv(self._o, nbytes)
- if ret == None: raise libvirtError ('virStreamRecv() failed')
+ if ret is None: raise libvirtError ('virStreamRecv() failed')
return ret
def send(self, data):
--
1.7.9.5
11 years, 4 months
[libvirt] configuring a disconnected <interface>
by Dan Kenigsberg
Hi List,
Like most of us, I've bought my actual computer with an Ethernet
interface card, that I can connect to a wall jack at will. It's quite
easy to disconnect the Ethernet cable from the wall, as well.
I would like to expose this behavior to virtual computers, too. Via
libvirt, of course. That's useful, since an admin may need to disconnect
a running VM from a network temporarily, without resorting to
hot-unplugging its nic.
How should the domxml represent this situation? An interface that is
connected to a specific LAN1 bridge is
<interface type='bridge'>
<source bridge='LAN1'>
<target dev='vnet1'/>
<model type='virtio'/>
</interface>
Would the following make sense for an interface with no bridge at the
source?
<interface type='bridge'>
<source/>
<target dev='vnet1'/>
<model type='virtio'/>
</interface>
And how about the recommended config for <interface>s, which is
type='network'? Would it make sense to predefine
<network>
<name>null-bridge-network</name>
<forward mode='bridge'>
<bridge/>
</network>
so that
<interface type='network'>
<source network='null-bridge-network'/>
</interface>
means "keep this interface dangling out there"?
Regards,
Dan.
11 years, 4 months